2016-03-10 05:27:07 +00:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2013 Google Inc. All rights reserved.
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
* Copyright (C) 2013-2017 Apple Inc. All rights reserved.
|
2016-03-10 05:27:07 +00:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Library General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Library General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Library General Public License
|
|
|
|
* along with this library; see the file COPYING.LIB. If not, write to
|
|
|
|
* the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
|
|
|
|
* Boston, MA 02110-1301, USA.
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "config.h"
|
|
|
|
#include "EventPath.h"
|
|
|
|
|
2016-11-12 05:03:27 +00:00
|
|
|
#include "DOMWindow.h"
|
2016-03-10 05:27:07 +00:00
|
|
|
#include "Event.h"
|
|
|
|
#include "EventContext.h"
|
|
|
|
#include "EventNames.h"
|
2019-04-18 22:16:54 +00:00
|
|
|
#include "FullscreenManager.h"
|
2016-03-10 05:27:07 +00:00
|
|
|
#include "HTMLSlotElement.h"
|
2019-04-10 16:53:41 +00:00
|
|
|
#include "MouseEvent.h"
|
2016-03-10 05:27:07 +00:00
|
|
|
#include "Node.h"
|
|
|
|
#include "PseudoElement.h"
|
|
|
|
#include "ShadowRoot.h"
|
|
|
|
#include "TouchEvent.h"
|
|
|
|
|
|
|
|
namespace WebCore {
|
|
|
|
|
|
|
|
static inline bool shouldEventCrossShadowBoundary(Event& event, ShadowRoot& shadowRoot, EventTarget& target)
|
|
|
|
{
|
|
|
|
#if ENABLE(FULLSCREEN_API) && ENABLE(VIDEO)
|
|
|
|
// Video-only full screen is a mode where we use the shadow DOM as an implementation
|
|
|
|
// detail that should not be detectable by the web content.
|
2017-11-13 06:12:09 +00:00
|
|
|
if (is<Node>(target)) {
|
2019-04-18 22:16:54 +00:00
|
|
|
if (auto* element = downcast<Node>(target).document().fullscreenManager().currentFullscreenElement()) {
|
2016-03-10 05:27:07 +00:00
|
|
|
// FIXME: We assume that if the full screen element is a media element that it's
|
|
|
|
// the video-only full screen. Both here and elsewhere. But that is probably wrong.
|
|
|
|
if (element->isMediaElement() && shadowRoot.host() == element)
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2017-11-13 06:12:09 +00:00
|
|
|
bool targetIsInShadowRoot = is<Node>(target) && &downcast<Node>(target).treeScope().rootNode() == &shadowRoot;
|
Replace scoped flag in Event by composed flag
https://bugs.webkit.org/show_bug.cgi?id=158415
Reviewed by Chris Dumez.
Source/WebCore:
Replace `scoped` flag with `composed` flag and negate its meaning per the latest spec:
https://dom.spec.whatwg.org/#dom-event-composed
https://github.com/w3c/webcomponents/issues/513
In the old spec, every event was assumed to be "composed" (crosses shadow boundaries)
by default and there was `scoped` flag which prevented the event from crossing bondaries,
and there was a handful of events for which `scoped` was set true when dispatched by UA.
In the new spec, every event is assumed to be "scoped" and a handful of user-initiated
events set `composed` flag to true, which is also exposed in EventInit dictionary.
`relatedTargetScoped` flag has been removed. New behavior is identical to when this flag
was set to true.
No new tests since existing tests are updated to test the new flag and behavior.
* dom/CompositionEvent.cpp:
(WebCore::CompositionEvent::isCompositionEvent): Added.
* dom/CompositionEvent.h:
* dom/Event.cpp:
(WebCore::Event::Event): Initialize m_composed. Also re-ordered m_type and m_isInitialized
for better packing.
(WebCore::Event::composed): Renamed from Event::composed. We return true whenever composed
is set to true in EventInit, or the engine is dispatching an user-initiated event listed in:
https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937
as well as keypress, cut, paste, and, copy as discussed in:
https://github.com/w3c/webcomponents/issues/513#issuecomment-230988170
(WebCore::Event::isCompositionEvent): Added.
* dom/Event.h:
(WebCore::Event::composed): Added.
(WebCore::Event::scoped): Deleted.
(WebCore::Event::relatedTargetScoped): Deleted.
(WebCore::Event): Reordered m_type and m_isInitialized for better packing. Added m_composed
and removed m_scoped and m_relatedTargetScoped.
* dom/Event.idl:
* dom/EventPath.cpp:
(WebCore::shouldEventCrossShadowBoundary): Returns true if the event did not originate from
a shadow tree (this event entered the current shadow tree via a slot so we need to proceed with
the normal bubble path outside the shadow tree) or composed flag is set true.
(WebCore::EventPath::EventPath): m_event no longer exists, which was only used to get the value
of relatedTargetScoped which has been removed.
(WebCore::EventPath::setRelatedTarget): Behave as if relatedTargetScoped is always set true
since the flag has been removed.
* dom/EventPath.h:
* dom/FocusEvent.cpp:
(WebCore::FocusEvent::relatedTargetScoped): Deleted.
* dom/FocusEvent.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::relatedTargetScoped): Deleted.
* dom/MouseEvent.h:
LayoutTests:
Updated the tests to reflect the rename of scoped to composed and the negation of its semantics.
Now every Event is assumed to be scoped / non-composed by default, and we need to explicitly set
composed to true in order for events to cross shadow boundaries.
Also, every Event behaves as if related target is assumed to be scoped in the old terminology
althoug the flag no longer exists.
* fast/shadow-dom/Extensions-to-Event-Interface-expected.txt:
* fast/shadow-dom/Extensions-to-Event-Interface.html: Removed a test case that was testing
relatedTargetScoped to false since this flag no longer exists.
* fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html:
* fast/shadow-dom/event-inside-shadow-tree.html:
* fast/shadow-dom/event-inside-slotted-node.html:
* fast/shadow-dom/event-with-related-target.html:
* fast/shadow-dom/trusted-event-scoped-flags-expected.txt:
* fast/shadow-dom/trusted-event-scoped-flags.html:
* fast/xmlhttprequest/xmlhttprequest-get-expected.txt:
* http/tests/workers/worker-importScriptsOnError-expected.txt:
* inspector/model/remote-object-get-properties-expected.txt:
Canonical link: https://commits.webkit.org/177677@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-08 01:57:44 +00:00
|
|
|
return !targetIsInShadowRoot || event.composed();
|
2016-03-10 05:27:07 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
static Node* nodeOrHostIfPseudoElement(Node* node)
|
|
|
|
{
|
|
|
|
return is<PseudoElement>(*node) ? downcast<PseudoElement>(*node).hostElement() : node;
|
|
|
|
}
|
|
|
|
|
|
|
|
class RelatedNodeRetargeter {
|
|
|
|
public:
|
2016-05-05 18:33:17 +00:00
|
|
|
RelatedNodeRetargeter(Node& relatedNode, Node& target);
|
2016-03-10 05:27:07 +00:00
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
Node* currentNode(Node& currentTreeScope);
|
2016-03-10 05:27:07 +00:00
|
|
|
void moveToNewTreeScope(TreeScope* previousTreeScope, TreeScope& newTreeScope);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Node* nodeInLowestCommonAncestor();
|
|
|
|
void collectTreeScopes();
|
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
void checkConsistency(Node& currentTarget);
|
2016-03-10 05:27:07 +00:00
|
|
|
|
|
|
|
Node& m_relatedNode;
|
|
|
|
Node* m_retargetedRelatedNode;
|
|
|
|
Vector<TreeScope*, 8> m_ancestorTreeScopes;
|
|
|
|
unsigned m_lowestCommonAncestorIndex { 0 };
|
|
|
|
bool m_hasDifferentTreeRoot { false };
|
|
|
|
};
|
|
|
|
|
|
|
|
EventPath::EventPath(Node& originalTarget, Event& event)
|
|
|
|
{
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
buildPath(originalTarget, event);
|
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
if (auto* relatedTarget = event.relatedTarget(); is<Node>(relatedTarget) && !m_path.isEmpty())
|
|
|
|
setRelatedTarget(originalTarget, downcast<Node>(*relatedTarget));
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
|
2016-03-10 05:27:07 +00:00
|
|
|
#if ENABLE(TOUCH_EVENTS)
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
if (is<TouchEvent>(event))
|
|
|
|
retargetTouchLists(downcast<TouchEvent>(event));
|
2016-03-10 05:27:07 +00:00
|
|
|
#endif
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void EventPath::buildPath(Node& originalTarget, Event& event)
|
|
|
|
{
|
2021-02-25 08:30:59 +00:00
|
|
|
EventContext::Type contextType = [&]() {
|
|
|
|
if (is<MouseEvent>(event) || event.isFocusEvent())
|
|
|
|
return EventContext::Type::MouseOrFocus;
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
#if ENABLE(TOUCH_EVENTS)
|
2021-02-25 08:30:59 +00:00
|
|
|
if (is<TouchEvent>(event))
|
|
|
|
return EventContext::Type::Touch;
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
#endif
|
2021-02-25 08:30:59 +00:00
|
|
|
return EventContext::Type::Normal;
|
|
|
|
}();
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
|
2016-03-10 05:27:07 +00:00
|
|
|
Node* node = nodeOrHostIfPseudoElement(&originalTarget);
|
2016-06-01 21:43:09 +00:00
|
|
|
Node* target = node ? eventTargetRespectingTargetRules(*node) : nullptr;
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
int closedShadowDepth = 0;
|
|
|
|
// Depths are used to decided which nodes are excluded in event.composedPath when the tree is mutated during event dispatching.
|
|
|
|
// They could be negative for nodes outside the shadow tree of the target node.
|
2016-03-10 05:27:07 +00:00
|
|
|
while (node) {
|
2016-05-05 18:33:17 +00:00
|
|
|
while (node) {
|
2021-02-25 08:30:59 +00:00
|
|
|
m_path.append(EventContext { contextType, *node, eventTargetRespectingTargetRules(*node), target, closedShadowDepth });
|
2016-03-10 05:27:07 +00:00
|
|
|
|
|
|
|
if (is<ShadowRoot>(*node))
|
|
|
|
break;
|
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
ContainerNode* parent = node->parentNode();
|
2016-11-12 05:03:27 +00:00
|
|
|
if (UNLIKELY(!parent)) {
|
|
|
|
// https://dom.spec.whatwg.org/#interface-document
|
|
|
|
if (is<Document>(*node) && event.type() != eventNames().loadEvent) {
|
|
|
|
ASSERT(target);
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
if (target) {
|
|
|
|
if (auto* window = downcast<Document>(*node).domWindow())
|
2021-02-25 08:30:59 +00:00
|
|
|
m_path.append(EventContext { EventContext::Type::Window, node, window, target, closedShadowDepth });
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
}
|
2016-11-12 05:03:27 +00:00
|
|
|
}
|
2016-03-10 05:27:07 +00:00
|
|
|
return;
|
2016-11-12 05:03:27 +00:00
|
|
|
}
|
2016-03-10 05:27:07 +00:00
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
if (auto* shadowRootOfParent = parent->shadowRoot(); UNLIKELY(shadowRootOfParent)) {
|
2016-03-10 05:27:07 +00:00
|
|
|
if (auto* assignedSlot = shadowRootOfParent->findAssignedSlot(*node)) {
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
if (shadowRootOfParent->mode() != ShadowRootMode::Open)
|
|
|
|
closedShadowDepth++;
|
2016-03-10 05:27:07 +00:00
|
|
|
// node is assigned to a slot. Continue dispatching the event at this slot.
|
|
|
|
parent = assignedSlot;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
node = parent;
|
|
|
|
}
|
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
bool exitingShadowTreeOfTarget = &target->treeScope() == &node->treeScope();
|
2016-03-10 05:27:07 +00:00
|
|
|
ShadowRoot& shadowRoot = downcast<ShadowRoot>(*node);
|
|
|
|
if (!shouldEventCrossShadowBoundary(event, shadowRoot, originalTarget))
|
|
|
|
return;
|
|
|
|
node = shadowRoot.host();
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
if (shadowRoot.mode() != ShadowRootMode::Open)
|
|
|
|
closedShadowDepth--;
|
2016-05-05 18:33:17 +00:00
|
|
|
if (exitingShadowTreeOfTarget)
|
|
|
|
target = eventTargetRespectingTargetRules(*node);
|
2016-03-10 05:27:07 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
void EventPath::setRelatedTarget(Node& origin, Node& relatedNode)
|
2016-03-10 05:27:07 +00:00
|
|
|
{
|
2021-02-25 08:30:59 +00:00
|
|
|
RelatedNodeRetargeter retargeter(relatedNode, *m_path[0].node());
|
2016-03-10 05:27:07 +00:00
|
|
|
|
2017-11-13 06:12:09 +00:00
|
|
|
bool originIsRelatedTarget = &origin == &relatedNode;
|
2016-03-10 05:27:07 +00:00
|
|
|
Node& rootNodeInOriginTreeScope = origin.treeScope().rootNode();
|
|
|
|
TreeScope* previousTreeScope = nullptr;
|
|
|
|
size_t originalEventPathSize = m_path.size();
|
|
|
|
for (unsigned contextIndex = 0; contextIndex < originalEventPathSize; contextIndex++) {
|
2021-02-25 08:30:59 +00:00
|
|
|
auto& context = m_path[contextIndex];
|
|
|
|
if (!context.isMouseOrFocusEventContext()) {
|
|
|
|
ASSERT(context.isWindowContext());
|
2016-11-12 05:03:27 +00:00
|
|
|
continue;
|
2021-02-25 08:30:59 +00:00
|
|
|
}
|
2016-03-10 05:27:07 +00:00
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
Node& currentTarget = *context.node();
|
|
|
|
TreeScope& currentTreeScope = currentTarget.treeScope();
|
2016-03-10 05:27:07 +00:00
|
|
|
if (UNLIKELY(previousTreeScope && ¤tTreeScope != previousTreeScope))
|
|
|
|
retargeter.moveToNewTreeScope(previousTreeScope, currentTreeScope);
|
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
Node* currentRelatedNode = retargeter.currentNode(currentTarget);
|
Replace scoped flag in Event by composed flag
https://bugs.webkit.org/show_bug.cgi?id=158415
Reviewed by Chris Dumez.
Source/WebCore:
Replace `scoped` flag with `composed` flag and negate its meaning per the latest spec:
https://dom.spec.whatwg.org/#dom-event-composed
https://github.com/w3c/webcomponents/issues/513
In the old spec, every event was assumed to be "composed" (crosses shadow boundaries)
by default and there was `scoped` flag which prevented the event from crossing bondaries,
and there was a handful of events for which `scoped` was set true when dispatched by UA.
In the new spec, every event is assumed to be "scoped" and a handful of user-initiated
events set `composed` flag to true, which is also exposed in EventInit dictionary.
`relatedTargetScoped` flag has been removed. New behavior is identical to when this flag
was set to true.
No new tests since existing tests are updated to test the new flag and behavior.
* dom/CompositionEvent.cpp:
(WebCore::CompositionEvent::isCompositionEvent): Added.
* dom/CompositionEvent.h:
* dom/Event.cpp:
(WebCore::Event::Event): Initialize m_composed. Also re-ordered m_type and m_isInitialized
for better packing.
(WebCore::Event::composed): Renamed from Event::composed. We return true whenever composed
is set to true in EventInit, or the engine is dispatching an user-initiated event listed in:
https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937
as well as keypress, cut, paste, and, copy as discussed in:
https://github.com/w3c/webcomponents/issues/513#issuecomment-230988170
(WebCore::Event::isCompositionEvent): Added.
* dom/Event.h:
(WebCore::Event::composed): Added.
(WebCore::Event::scoped): Deleted.
(WebCore::Event::relatedTargetScoped): Deleted.
(WebCore::Event): Reordered m_type and m_isInitialized for better packing. Added m_composed
and removed m_scoped and m_relatedTargetScoped.
* dom/Event.idl:
* dom/EventPath.cpp:
(WebCore::shouldEventCrossShadowBoundary): Returns true if the event did not originate from
a shadow tree (this event entered the current shadow tree via a slot so we need to proceed with
the normal bubble path outside the shadow tree) or composed flag is set true.
(WebCore::EventPath::EventPath): m_event no longer exists, which was only used to get the value
of relatedTargetScoped which has been removed.
(WebCore::EventPath::setRelatedTarget): Behave as if relatedTargetScoped is always set true
since the flag has been removed.
* dom/EventPath.h:
* dom/FocusEvent.cpp:
(WebCore::FocusEvent::relatedTargetScoped): Deleted.
* dom/FocusEvent.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::relatedTargetScoped): Deleted.
* dom/MouseEvent.h:
LayoutTests:
Updated the tests to reflect the rename of scoped to composed and the negation of its semantics.
Now every Event is assumed to be scoped / non-composed by default, and we need to explicitly set
composed to true in order for events to cross shadow boundaries.
Also, every Event behaves as if related target is assumed to be scoped in the old terminology
althoug the flag no longer exists.
* fast/shadow-dom/Extensions-to-Event-Interface-expected.txt:
* fast/shadow-dom/Extensions-to-Event-Interface.html: Removed a test case that was testing
relatedTargetScoped to false since this flag no longer exists.
* fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html:
* fast/shadow-dom/event-inside-shadow-tree.html:
* fast/shadow-dom/event-inside-slotted-node.html:
* fast/shadow-dom/event-with-related-target.html:
* fast/shadow-dom/trusted-event-scoped-flags-expected.txt:
* fast/shadow-dom/trusted-event-scoped-flags.html:
* fast/xmlhttprequest/xmlhttprequest-get-expected.txt:
* http/tests/workers/worker-importScriptsOnError-expected.txt:
* inspector/model/remote-object-get-properties-expected.txt:
Canonical link: https://commits.webkit.org/177677@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-08 01:57:44 +00:00
|
|
|
if (UNLIKELY(!originIsRelatedTarget && context.target() == currentRelatedNode)) {
|
2016-03-10 05:27:07 +00:00
|
|
|
m_path.shrink(contextIndex);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
context.setRelatedTarget(currentRelatedNode);
|
|
|
|
|
Replace scoped flag in Event by composed flag
https://bugs.webkit.org/show_bug.cgi?id=158415
Reviewed by Chris Dumez.
Source/WebCore:
Replace `scoped` flag with `composed` flag and negate its meaning per the latest spec:
https://dom.spec.whatwg.org/#dom-event-composed
https://github.com/w3c/webcomponents/issues/513
In the old spec, every event was assumed to be "composed" (crosses shadow boundaries)
by default and there was `scoped` flag which prevented the event from crossing bondaries,
and there was a handful of events for which `scoped` was set true when dispatched by UA.
In the new spec, every event is assumed to be "scoped" and a handful of user-initiated
events set `composed` flag to true, which is also exposed in EventInit dictionary.
`relatedTargetScoped` flag has been removed. New behavior is identical to when this flag
was set to true.
No new tests since existing tests are updated to test the new flag and behavior.
* dom/CompositionEvent.cpp:
(WebCore::CompositionEvent::isCompositionEvent): Added.
* dom/CompositionEvent.h:
* dom/Event.cpp:
(WebCore::Event::Event): Initialize m_composed. Also re-ordered m_type and m_isInitialized
for better packing.
(WebCore::Event::composed): Renamed from Event::composed. We return true whenever composed
is set to true in EventInit, or the engine is dispatching an user-initiated event listed in:
https://github.com/w3c/webcomponents/issues/513#issuecomment-224183937
as well as keypress, cut, paste, and, copy as discussed in:
https://github.com/w3c/webcomponents/issues/513#issuecomment-230988170
(WebCore::Event::isCompositionEvent): Added.
* dom/Event.h:
(WebCore::Event::composed): Added.
(WebCore::Event::scoped): Deleted.
(WebCore::Event::relatedTargetScoped): Deleted.
(WebCore::Event): Reordered m_type and m_isInitialized for better packing. Added m_composed
and removed m_scoped and m_relatedTargetScoped.
* dom/Event.idl:
* dom/EventPath.cpp:
(WebCore::shouldEventCrossShadowBoundary): Returns true if the event did not originate from
a shadow tree (this event entered the current shadow tree via a slot so we need to proceed with
the normal bubble path outside the shadow tree) or composed flag is set true.
(WebCore::EventPath::EventPath): m_event no longer exists, which was only used to get the value
of relatedTargetScoped which has been removed.
(WebCore::EventPath::setRelatedTarget): Behave as if relatedTargetScoped is always set true
since the flag has been removed.
* dom/EventPath.h:
* dom/FocusEvent.cpp:
(WebCore::FocusEvent::relatedTargetScoped): Deleted.
* dom/FocusEvent.h:
* dom/MouseEvent.cpp:
(WebCore::MouseEvent::relatedTargetScoped): Deleted.
* dom/MouseEvent.h:
LayoutTests:
Updated the tests to reflect the rename of scoped to composed and the negation of its semantics.
Now every Event is assumed to be scoped / non-composed by default, and we need to explicitly set
composed to true in order for events to cross shadow boundaries.
Also, every Event behaves as if related target is assumed to be scoped in the old terminology
althoug the flag no longer exists.
* fast/shadow-dom/Extensions-to-Event-Interface-expected.txt:
* fast/shadow-dom/Extensions-to-Event-Interface.html: Removed a test case that was testing
relatedTargetScoped to false since this flag no longer exists.
* fast/shadow-dom/MouseEvent-prototype-offsetX-offsetY.html:
* fast/shadow-dom/event-inside-shadow-tree.html:
* fast/shadow-dom/event-inside-slotted-node.html:
* fast/shadow-dom/event-with-related-target.html:
* fast/shadow-dom/trusted-event-scoped-flags-expected.txt:
* fast/shadow-dom/trusted-event-scoped-flags.html:
* fast/xmlhttprequest/xmlhttprequest-get-expected.txt:
* http/tests/workers/worker-importScriptsOnError-expected.txt:
* inspector/model/remote-object-get-properties-expected.txt:
Canonical link: https://commits.webkit.org/177677@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@202953 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2016-07-08 01:57:44 +00:00
|
|
|
if (UNLIKELY(originIsRelatedTarget && context.node() == &rootNodeInOriginTreeScope)) {
|
2016-03-10 05:27:07 +00:00
|
|
|
m_path.shrink(contextIndex + 1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
previousTreeScope = ¤tTreeScope;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#if ENABLE(TOUCH_EVENTS)
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
void EventPath::retargetTouch(EventContext::TouchListType type, const Touch& touch)
|
2016-03-10 05:27:07 +00:00
|
|
|
{
|
2017-11-13 06:12:09 +00:00
|
|
|
auto* eventTarget = touch.target();
|
|
|
|
if (!is<Node>(eventTarget))
|
2016-03-10 05:27:07 +00:00
|
|
|
return;
|
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
RelatedNodeRetargeter retargeter(downcast<Node>(*eventTarget), *m_path[0].node());
|
2016-03-10 05:27:07 +00:00
|
|
|
TreeScope* previousTreeScope = nullptr;
|
|
|
|
for (auto& context : m_path) {
|
2021-02-25 08:30:59 +00:00
|
|
|
Node& currentTarget = *context.node();
|
2016-05-05 18:33:17 +00:00
|
|
|
TreeScope& currentTreeScope = currentTarget.treeScope();
|
2016-03-10 05:27:07 +00:00
|
|
|
if (UNLIKELY(previousTreeScope && ¤tTreeScope != previousTreeScope))
|
|
|
|
retargeter.moveToNewTreeScope(previousTreeScope, currentTreeScope);
|
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
if (context.isTouchEventContext()) {
|
2016-11-12 05:03:27 +00:00
|
|
|
Node* currentRelatedNode = retargeter.currentNode(currentTarget);
|
2021-02-25 08:30:59 +00:00
|
|
|
context.touchList(type).append(touch.cloneWithNewTarget(currentRelatedNode));
|
|
|
|
} else
|
|
|
|
ASSERT(context.isWindowContext());
|
2016-03-10 05:27:07 +00:00
|
|
|
|
|
|
|
previousTreeScope = ¤tTreeScope;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
void EventPath::retargetTouchList(EventContext::TouchListType type, const TouchList* list)
|
2016-03-10 05:27:07 +00:00
|
|
|
{
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
for (unsigned i = 0, length = list ? list->length() : 0; i < length; ++i)
|
|
|
|
retargetTouch(type, *list->item(i));
|
2016-03-10 05:27:07 +00:00
|
|
|
}
|
|
|
|
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
void EventPath::retargetTouchLists(const TouchEvent& event)
|
2016-03-10 05:27:07 +00:00
|
|
|
{
|
2021-02-25 08:30:59 +00:00
|
|
|
retargetTouchList(EventContext::TouchListType::Touches, event.touches());
|
|
|
|
retargetTouchList(EventContext::TouchListType::TargetTouches, event.targetTouches());
|
|
|
|
retargetTouchList(EventContext::TouchListType::ChangedTouches, event.changedTouches());
|
2016-03-10 05:27:07 +00:00
|
|
|
}
|
|
|
|
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
#endif
|
|
|
|
|
2016-11-12 05:03:27 +00:00
|
|
|
// https://dom.spec.whatwg.org/#dom-event-composedpath
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
// Any node whose depth computed in EventPath::buildPath is greater than the context object is excluded.
|
|
|
|
// Because we can exit out of a closed shadow tree and re-enter another closed shadow tree via a slot,
|
|
|
|
// we decrease the *allowed depth* whenever we moved to a "shallower" (closer-to-document) tree.
|
2016-05-05 18:33:17 +00:00
|
|
|
Vector<EventTarget*> EventPath::computePathUnclosedToTarget(const EventTarget& target) const
|
2016-03-12 03:11:04 +00:00
|
|
|
{
|
|
|
|
Vector<EventTarget*> path;
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
auto pathSize = m_path.size();
|
|
|
|
RELEASE_ASSERT(pathSize);
|
|
|
|
path.reserveInitialCapacity(pathSize);
|
|
|
|
|
|
|
|
auto currentTargetIndex = m_path.findMatching([&target] (auto& context) {
|
2021-02-25 08:30:59 +00:00
|
|
|
return context.currentTarget() == ⌖
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
});
|
|
|
|
RELEASE_ASSERT(currentTargetIndex != notFound);
|
2021-02-25 08:30:59 +00:00
|
|
|
auto currentTargetDepth = m_path[currentTargetIndex].closedShadowDepth();
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
|
|
|
|
auto appendTargetWithLesserDepth = [&path] (const EventContext& currentContext, int& currentDepthAllowed) {
|
|
|
|
auto depth = currentContext.closedShadowDepth();
|
|
|
|
bool contextIsInsideInnerShadowTree = depth > currentDepthAllowed;
|
|
|
|
if (contextIsInsideInnerShadowTree)
|
|
|
|
return;
|
|
|
|
bool movedOutOfShadowTree = depth < currentDepthAllowed;
|
|
|
|
if (movedOutOfShadowTree)
|
|
|
|
currentDepthAllowed = depth;
|
|
|
|
path.uncheckedAppend(currentContext.currentTarget());
|
|
|
|
};
|
|
|
|
|
|
|
|
auto currentDepthAllowed = currentTargetDepth;
|
|
|
|
auto i = currentTargetIndex;
|
|
|
|
do {
|
2021-02-25 08:30:59 +00:00
|
|
|
appendTargetWithLesserDepth(m_path[i], currentDepthAllowed);
|
Update composedPath to match the latest spec
https://bugs.webkit.org/show_bug.cgi?id=180378
<rdar://problem/42843004>
Reviewed by Darin Adler.
LayoutTests/imported/w3c:
Rebaselined the test now that all test cases pass.
* web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation-expected.txt:
Source/WebCore:
This patch makes the check for whether a given node in the event path be included in composedPath
pre-determined at the time of the event dispatching per https://github.com/whatwg/dom/issues/525.
This was a fix for the issue that if an event listener in a closed shadow tree removes a node in the
same tree in the event path, then composedPath called on its shadow host, for example, will include
the removed node since it's no longer in the closed shadow tree.
Naively, implementing this behavior would require remembering the original document or shadow root
of each node in the event path as well as its parent shadow root, or worse which node is disclosed
to every other node at the time of computing the event path.
This patch takes a more novel and efficient approach to implement the new behavior by adding a single
integer indicating the number of closed-mode shadow root ancestors of each node in the event path.
In computePathUnclosedToTarget, any node whose *depth* is greater than the context object is excluded.
Consider the following example:
div ------- ShadowRoot (closed)
+- span +- slot
If an event is dispatched on span, then the event path would be [span, slot, ShadowRoot, div]. Then
the values of integers assigned to each node would be: [0, 1, 1, 0] respectively. When composedPath
is called on span or div, slot and ShadowRoot are excluded because they have a greater *depth* value.
Unfortunately, this simplistic solution doesn't work when there are multiple shadow roots of the same
depth through which an event is dispatched as in:
section -- ShadowRoot (closed, SR2)
| +- slot (s2)
+div ------ ShadowRoot (closed, SR1)
+- span +- slot (s1)
If an event is dispatched on span, the event path would be [span, s1, SR1, div, s2, SR2, section].
The values of integers assigned are: [0, 1, 1, 0, 1, 1, 0] respectively. When composedPath is called
on SR1, the simplistic approach would include s2 and SR2, which would be wrong.
To account for this case, in computePathUnclosedToTarget, we traverse the event path upwards (i.e.
ancestors) and downwards (i.e. descendants) from the context object and decrease the *allowed depth*
of shadow trees when we traverse out of a shadow tree in either direction. When traversing upwards,
therefore, moving out of a shadow root to its host would would decrease the allowed depth. When
traversing dowards, moving from a slot element to its assigned node would decrease the allowed depth.
Note that the depths can be negative when a composed event is dispatched inside a closed shadow tree,
and it gets out of its shadow host.
Unfortunately, the latest DOM specification has a bug and doesn't match the behavior of Chrome. This
patch proposes a new algorithm which can be adopted in https://github.com/whatwg/dom/issues/684.
Test: imported/w3c/web-platform-tests/shadow-dom/event-composed-path-after-dom-mutation.html
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext):
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext):
(WebCore::TouchEventContext::TouchEventContext):
* dom/EventContext.h:
(WebCore::EventContext::closedShadowDepth const): Added.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext):
(WebCore::EventPath::buildPath): Compute the closed shadow tree's depths for each node in the path.
(WebCore::computePathUnclosedToTarget const): Implemented the aforementioned algorithm.
(WebCore::EventPath::EventPath):
Canonical link: https://commits.webkit.org/204659@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@236103 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2018-09-18 07:47:35 +00:00
|
|
|
} while (i--);
|
|
|
|
path.reverse();
|
|
|
|
|
|
|
|
currentDepthAllowed = currentTargetDepth;
|
|
|
|
for (auto i = currentTargetIndex + 1; i < pathSize; ++i)
|
2021-02-25 08:30:59 +00:00
|
|
|
appendTargetWithLesserDepth(m_path[i], currentDepthAllowed);
|
2016-03-12 03:11:04 +00:00
|
|
|
|
2021-02-25 08:30:59 +00:00
|
|
|
return path;
|
2018-02-20 19:02:25 +00:00
|
|
|
}
|
|
|
|
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
EventPath::EventPath(const Vector<EventTarget*>& targets)
|
|
|
|
{
|
|
|
|
for (auto* target : targets) {
|
|
|
|
ASSERT(target);
|
2017-11-13 06:12:09 +00:00
|
|
|
ASSERT(!is<Node>(target));
|
2021-02-25 08:30:59 +00:00
|
|
|
m_path.append(EventContext { EventContext::Type::Normal, nullptr, target, *targets.begin(), 0 });
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
static Node* moveOutOfAllShadowRoots(Node& startingNode)
|
|
|
|
{
|
|
|
|
Node* node = &startingNode;
|
|
|
|
while (node->isInShadowTree())
|
|
|
|
node = downcast<ShadowRoot>(node->treeScope().rootNode()).host();
|
|
|
|
return node;
|
|
|
|
}
|
|
|
|
|
|
|
|
RelatedNodeRetargeter::RelatedNodeRetargeter(Node& relatedNode, Node& target)
|
2016-03-10 05:27:07 +00:00
|
|
|
: m_relatedNode(relatedNode)
|
|
|
|
, m_retargetedRelatedNode(&relatedNode)
|
|
|
|
{
|
2016-05-05 18:33:17 +00:00
|
|
|
auto& targetTreeScope = target.treeScope();
|
2016-03-10 05:27:07 +00:00
|
|
|
TreeScope* currentTreeScope = &m_relatedNode.treeScope();
|
2017-02-02 21:29:15 +00:00
|
|
|
if (LIKELY(currentTreeScope == &targetTreeScope && target.isConnected() && m_relatedNode.isConnected()))
|
2016-03-10 05:27:07 +00:00
|
|
|
return;
|
|
|
|
|
|
|
|
if (¤tTreeScope->documentScope() != &targetTreeScope.documentScope()) {
|
|
|
|
m_hasDifferentTreeRoot = true;
|
|
|
|
m_retargetedRelatedNode = nullptr;
|
|
|
|
return;
|
|
|
|
}
|
2017-02-02 21:29:15 +00:00
|
|
|
if (relatedNode.isConnected() != target.isConnected()) {
|
2016-03-10 05:27:07 +00:00
|
|
|
m_hasDifferentTreeRoot = true;
|
2016-05-05 18:33:17 +00:00
|
|
|
m_retargetedRelatedNode = moveOutOfAllShadowRoots(relatedNode);
|
2016-03-10 05:27:07 +00:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
collectTreeScopes();
|
|
|
|
|
|
|
|
// FIXME: We should collect this while constructing the event path.
|
|
|
|
Vector<TreeScope*, 8> targetTreeScopeAncestors;
|
|
|
|
for (TreeScope* currentTreeScope = &targetTreeScope; currentTreeScope; currentTreeScope = currentTreeScope->parentTreeScope())
|
|
|
|
targetTreeScopeAncestors.append(currentTreeScope);
|
|
|
|
ASSERT_WITH_SECURITY_IMPLICATION(!targetTreeScopeAncestors.isEmpty());
|
|
|
|
|
|
|
|
unsigned i = m_ancestorTreeScopes.size();
|
|
|
|
unsigned j = targetTreeScopeAncestors.size();
|
|
|
|
ASSERT_WITH_SECURITY_IMPLICATION(m_ancestorTreeScopes.last() == targetTreeScopeAncestors.last());
|
|
|
|
while (m_ancestorTreeScopes[i - 1] == targetTreeScopeAncestors[j - 1]) {
|
|
|
|
i--;
|
|
|
|
j--;
|
|
|
|
if (!i || !j)
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
bool lowestCommonAncestorIsDocumentScope = i + 1 == m_ancestorTreeScopes.size();
|
2017-02-02 21:29:15 +00:00
|
|
|
if (lowestCommonAncestorIsDocumentScope && !relatedNode.isConnected() && !target.isConnected()) {
|
2016-09-27 21:04:15 +00:00
|
|
|
Node& relatedNodeAncestorInDocumentScope = i ? *downcast<ShadowRoot>(m_ancestorTreeScopes[i - 1]->rootNode()).shadowHost() : relatedNode;
|
|
|
|
Node& targetAncestorInDocumentScope = j ? *downcast<ShadowRoot>(targetTreeScopeAncestors[j - 1]->rootNode()).shadowHost() : target;
|
2016-09-23 01:54:05 +00:00
|
|
|
if (&targetAncestorInDocumentScope.rootNode() != &relatedNodeAncestorInDocumentScope.rootNode()) {
|
2016-05-05 18:33:17 +00:00
|
|
|
m_hasDifferentTreeRoot = true;
|
|
|
|
m_retargetedRelatedNode = moveOutOfAllShadowRoots(relatedNode);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2016-03-10 05:27:07 +00:00
|
|
|
m_lowestCommonAncestorIndex = i;
|
|
|
|
m_retargetedRelatedNode = nodeInLowestCommonAncestor();
|
|
|
|
}
|
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
inline Node* RelatedNodeRetargeter::currentNode(Node& currentTarget)
|
2016-03-10 05:27:07 +00:00
|
|
|
{
|
2016-05-05 18:33:17 +00:00
|
|
|
checkConsistency(currentTarget);
|
2016-03-10 05:27:07 +00:00
|
|
|
return m_retargetedRelatedNode;
|
|
|
|
}
|
|
|
|
|
|
|
|
void RelatedNodeRetargeter::moveToNewTreeScope(TreeScope* previousTreeScope, TreeScope& newTreeScope)
|
|
|
|
{
|
|
|
|
if (m_hasDifferentTreeRoot)
|
|
|
|
return;
|
|
|
|
|
|
|
|
auto& currentRelatedNodeScope = m_retargetedRelatedNode->treeScope();
|
|
|
|
if (previousTreeScope != ¤tRelatedNodeScope) {
|
|
|
|
// currentRelatedNode is still outside our shadow tree. New tree scope may contain currentRelatedNode
|
|
|
|
// but there is no need to re-target it. Moving into a slot (thereby a deeper shadow tree) doesn't matter.
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool enteredSlot = newTreeScope.parentTreeScope() == previousTreeScope;
|
|
|
|
if (enteredSlot) {
|
|
|
|
if (m_lowestCommonAncestorIndex) {
|
|
|
|
if (m_ancestorTreeScopes.isEmpty())
|
|
|
|
collectTreeScopes();
|
|
|
|
bool relatedNodeIsInSlot = m_ancestorTreeScopes[m_lowestCommonAncestorIndex - 1] == &newTreeScope;
|
|
|
|
if (relatedNodeIsInSlot) {
|
|
|
|
m_lowestCommonAncestorIndex--;
|
|
|
|
m_retargetedRelatedNode = nodeInLowestCommonAncestor();
|
|
|
|
ASSERT(&newTreeScope == &m_retargetedRelatedNode->treeScope());
|
|
|
|
}
|
|
|
|
} else
|
|
|
|
ASSERT(m_retargetedRelatedNode == &m_relatedNode);
|
|
|
|
} else {
|
|
|
|
ASSERT(previousTreeScope->parentTreeScope() == &newTreeScope);
|
|
|
|
m_lowestCommonAncestorIndex++;
|
|
|
|
ASSERT_WITH_SECURITY_IMPLICATION(m_ancestorTreeScopes.isEmpty() || m_lowestCommonAncestorIndex < m_ancestorTreeScopes.size());
|
|
|
|
m_retargetedRelatedNode = downcast<ShadowRoot>(currentRelatedNodeScope.rootNode()).host();
|
|
|
|
ASSERT(&newTreeScope == &m_retargetedRelatedNode->treeScope());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inline Node* RelatedNodeRetargeter::nodeInLowestCommonAncestor()
|
|
|
|
{
|
|
|
|
if (!m_lowestCommonAncestorIndex)
|
|
|
|
return &m_relatedNode;
|
|
|
|
auto& rootNode = m_ancestorTreeScopes[m_lowestCommonAncestorIndex - 1]->rootNode();
|
|
|
|
return downcast<ShadowRoot>(rootNode).host();
|
|
|
|
}
|
|
|
|
|
|
|
|
void RelatedNodeRetargeter::collectTreeScopes()
|
|
|
|
{
|
|
|
|
ASSERT(m_ancestorTreeScopes.isEmpty());
|
|
|
|
for (TreeScope* currentTreeScope = &m_relatedNode.treeScope(); currentTreeScope; currentTreeScope = currentTreeScope->parentTreeScope())
|
|
|
|
m_ancestorTreeScopes.append(currentTreeScope);
|
|
|
|
ASSERT_WITH_SECURITY_IMPLICATION(!m_ancestorTreeScopes.isEmpty());
|
|
|
|
}
|
|
|
|
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#if !ASSERT_ENABLED
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
|
|
|
|
inline void RelatedNodeRetargeter::checkConsistency(Node&)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#else // ASSERT_ENABLED
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
|
2016-05-05 18:33:17 +00:00
|
|
|
void RelatedNodeRetargeter::checkConsistency(Node& currentTarget)
|
2016-03-10 05:27:07 +00:00
|
|
|
{
|
2016-10-04 23:42:18 +00:00
|
|
|
if (!m_retargetedRelatedNode)
|
|
|
|
return;
|
2016-12-10 10:19:00 +00:00
|
|
|
ASSERT(!currentTarget.isClosedShadowHidden(*m_retargetedRelatedNode));
|
2020-05-01 22:16:19 +00:00
|
|
|
ASSERT(m_retargetedRelatedNode == currentTarget.treeScope().retargetToScope(m_relatedNode).ptr());
|
2016-03-10 05:27:07 +00:00
|
|
|
}
|
Simplify event dispatch code and make it a bit more consistent
https://bugs.webkit.org/show_bug.cgi?id=178991
Reviewed by Chris Dumez.
Source/WebCore:
Straighten out event dispatch code in three ways:
1) Add an Event::resetAfterDispatch function, and use it instead of the multiple
separate functions that were used before to reset after dispatching. This fixed
an extremely minor bug where we would leave some kinds of state on some event
objects in unusual cases after dispatching the events.
2) Remove IDBEventDispatcher and make its callers use EventDispatcher instead.
This leaves us with one less event dispatch code path to maintain, more shared code.
3) Remove boolean return values from functions that take event objects and
dispatch the events. The return values are redundant with various things that
can be checked by looking at the event itself. The legacy return value indicates
whether the event has its "canceled flag" set, which means that the default
behavior should be prevented. If that is what we need to check, it's easier
to read the code and see that it's correct if it calls the named function
"defaultPrevented" directly. More importantly, callers can also call whatever
other function is appropriate to ask the specific relevant question to their needs.
The general rule is that default behavior that we want to allow even with an
untrusted event can be inside a default event handler function. Default behavior
that should only happen for the browser-generated event can and should be done
after dispatching the event, in the code that dispatches it; but that requires
explicitly checking "defaultPrevented".
* Modules/indexeddb/IDBDatabase.cpp:
(WebCore::IDBDatabase::dispatchEvent): Removed boolean return value.
* Modules/indexeddb/IDBDatabase.h: Ditto.
* Modules/indexeddb/IDBEventDispatcher.cpp: Removed.
* Modules/indexeddb/IDBEventDispatcher.h: Removed.
* Modules/indexeddb/IDBOpenDBRequest.cpp:
(WebCore::IDBOpenDBRequest::dispatchEvent): Removed boolean return value.
Added protection for "this" since the function accesses it after dispatching the event.
* Modules/indexeddb/IDBOpenDBRequest.h: Ditto.
* Modules/indexeddb/IDBRequest.cpp:
(WebCore::IDBRequest::dispatchEvent): Removed boolean return value. Instead of using
IDBEventDispatcher, use EventDispatcher's new function that takes an initializer_list
with a list of event targets. Added protection for "this" since the function accesses
it after dispatching the event.
* Modules/indexeddb/IDBRequest.h: Ditto.
* Modules/indexeddb/IDBTransaction.cpp:
(WebCore::IDBTransaction::dispatchEvent): Ditto.
* Modules/indexeddb/IDBTransaction.h: Ditto.
* Modules/mediastream/RTCPeerConnection.cpp:
(WebCore::RTCPeerConnection::dispatchEvent): Removed boolean return value.
* Modules/mediastream/RTCPeerConnection.h: Ditto.
* Modules/paymentrequest/PaymentRequest.cpp:
(WebCore::PaymentRequest::shippingAddressChanged): Don't dispatch an event if
m_isUpdating is true; preserves behavior that was implemented in
PaymentRequest::dispatchEvent before. Since this is the source of the trusted
event, cleaner to implement the rule here instead of overriding dispatchEvent.
(WebCore::PaymentRequest::shippingOptionChanged): Ditto.
(WebCore::PaymentRequest::dispatchEvent): Deleted.
* Modules/paymentrequest/PaymentRequest.h: Ditto.
* Sources.txt: Removed IDBEventDispatcher.cpp.
* WebCore.xcodeproj/project.pbxproj: Removed IDBEventDispatcher.h/cpp.
* dom/Element.cpp:
(WebCore::Element::dispatchMouseEvent): Updated to call defaultPrevented
directly instead of using the return value of dispatchEvent.
(WebCore::Element::dispatchWheelEvent): Ditto.
(WebCore::Element::dispatchKeyEvent): Ditto.
(WebCore::Element::dispatchFocusInEvent): Removed assertion, since the
underlying event dispatching takes care of it.
(WebCore::Element::dispatchFocusOutEvent): Ditto.
(WebCore::Element::dispatchFocusEvent): Call dispatchEvent instead of
calling EventDispatcher::dispatchEvent. There is no good reason to use
EventDispatcher directly.
(WebCore::Element::dispatchBlurEvent): Ditto.
* dom/Event.cpp:
(WebCore::Event::eventInterface const): Deleted. Moved into header since this is
short and if called in a non-polymorphic context it's good to have it be inlined.
(WebCore::Event::isUIEvent const): Ditto.
(WebCore::Event::isMouseEvent const): Ditto.
(WebCore::Event::isFocusEvent const): Ditto.
(WebCore::Event::isKeyboardEvent const): Ditto.
(WebCore::Event::isInputEvent const): Ditto.
(WebCore::Event::isCompositionEvent const): Ditto.
(WebCore::Event::isTouchEvent const): Ditto.
(WebCore::Event::isClipboardEvent const): Ditto.
(WebCore::Event::isBeforeTextInsertedEvent const): Ditto.
(WebCore::Event::isBeforeUnloadEvent const): Ditto.
(WebCore::Event::isErrorEvent const): Ditto.
(WebCore::Event::isTextEvent const): Ditto.
(WebCore::Event::isWheelEvent const): Ditto.
(WebCore::Event::receivedTarget): Ditto.
(WebCore::Event::resetAfterDispatch): Added. Replaces functions like
clearEventPath and resetPropagationFlags, covering all the things we need to clear
after dispatching an event.
* dom/Event.h: Removed some unneeded includes and forward declarations. Moved bodies
of multi-line inline member functions out of the class definition. Changed argument
type of setEventPhase and m_eventPhase to an enum rather than just an integer, since
only the getter is for use from the bindings. Removed clearEventPath, srcElement, and
resetPropagationFlags. Sorted the isXXX functions alphabetically and removed previous
attempts to make categories out of them. Marked the constructor explicit since it has
a single argument. Moved trivially short bodies into the class definition.
* dom/Event.idl: Use ImplementedAs to implement srcElement so we don't need it in
the C++ code.
* dom/EventContext.cpp:
(WebCore::EventContext::EventContext): Removed assertion since we now handle event
contexts without nodes so we can use this to dispatch events for IDB, for example.
(WebCore::EventContext::handleLocalEvents const): Add code to handle non-node event
targets by calling fireEventListeners directly.
(WebCore::MouseOrFocusEventContext::MouseOrFocusEventContext): Take a reference
insetad of a pointer for the node.
(WebCore::TouchEventContext::TouchEventContext): Ditto.
(WebCore::TouchEventContext::handleLocalEvents const): Streamline a bit by improving
the checkReachability function to be easier to call. Also removed an unneeded assertion
just before calling downcast<>, the same assertion that downcast<> itself does.
(WebCore::TouchEventContext::checkReachability const): Chagned argument type to take
a Ref& so the caller doesn't have to call get() or ptr().
* dom/EventContext.h: Removed unneeded FIXME and currentTargetSameAsTarget function.
Changed arguemnt types to use Node& instead of Node* as appropriate. Removed unused
functions from TouchEventContext, made more private, and changed data members to Ref
instead of RefPtr. Removed unused NotTouchList value from TouchListType enumeration.
Changed touchList function to return a reference instead of a pointer.
* dom/EventDispatcher.cpp: Removed unneeded includes.
(WebCore::dispatchEventInDOM): Removed use of currentTargetSameAsTarget since it's
clearer if written out.
(WebCore::EventDispatcher::dispatchEvent): Changed no-event dispatch assertion to
use RELEASE_ASSERT_WITH_SECURITY_IMPLICATION since the style checker says so, but
it still doesn't assert anything in release builds because the check in
NoEventDispatchAssertion itself is debug-only. Moved the calls to EventPath's
setRelatedTarget and retargetTouchLists functions inside the EventPath constructor.
Removed the second no-event dispatch assertion because we only need one. Replaced
calls to clearEventPath, setCurrentTarget(nullptr), resetPropagationFlags,
and setEventPhase(NONE) and with a call to resetAfterDispatch. Moved the code that
temporarily sets the target to a different value when calling default event handlers
into the block that calls the default event handlers. Added a new overload that
takes an initializer list of event targets so we can dispatch events that are not
being sent to nodes.
* dom/EventDispatcher.h: Fixed misleading copyright dates and names since this file
just contains a couple of function declarations. Added new overload of dispatchEvent.
* dom/EventPath.cpp:
(WebCore::WindowEventContext::WindowEventContext): Take references instead of pointers.
(WebCore::EventPath::EventPath): Moved the bulk of construction into a new function
named buildPath, so it can still use "return" without skipping the additions here.
Added calls to setRelatedTarget and retargetTouchLists and now both can be private.
Also added a new overload that takes event targets that are not nodes.
(WebCore::EventPath::buildPath): Added. Contains what used to be in the constructor.
But use some references instead of pointers and refactor a bit using lambdas.
(WebCore::EventPath::retargetTouchList): Added. Makes the retargetTouchLists function
shorter and less repetetive.
(WebCore::EventPath::retargetTouchLists): Updated to call retargetTouchList.
(WebCore::EventPath::hasEventListeners const): Deleted. This was unused.
* dom/EventPath.h: Added a constructor that takes an initializer list of event targets.
Made retargetTouchEvents and setRelatedTarget private and used them in the constructor
insead of expecting clients to call them. Removed unused hasEventListeners and
lastContextIfExists functions. Moved body of the eventTargetRespectingTargetRules
function out of the class definition.
* dom/EventTarget.cpp:
(WebCore::EventTarget::dispatchEventForBindings): Updated so it does not expect
dispatchEvent to return a boolean. Instead call a function on the event after dispatching.
Decided to use legacyReturnValue instead of !defaultPrevented, because this is exactly
the return value that the returnValue property is referring to.
(WebCore::EventTarget::dispatchEvent): Removed return value. Replaced calls to
resetPropagationFlags and setEventPhase(NONE) with a call to resetAfterDispatch.
I noticed that there was a local boolean here named "defaultPrevented", which was
backwards; the value in that local was "default not prevented". Doesn't matter since
the boolean return value was removed.
(WebCore::EventTarget::fireEventListeners): Removed the boolean return value.
* dom/EventTarget.h: Added initial values to members of ListenerOptions and
AddEventListenerOptions; maybe we can get rid of the constructors some day.
Removed booelan return values from dispatchEvent and fireEventListeners.
* dom/KeyboardEvent.cpp: Removed unneeded include of EventDispatcher.h.
* dom/Node.cpp:
(WebCore::Node::dispatchEvent): Got rid of boolean return value.
Removed special case code that sometimes called dispatchTouchEvent, since that
just turns around and calls EventDispatcher::dispatchEvent just like this function.
(WebCore::Node::dispatchDOMActivateEvent): Removed boolean return value, removed
integer detail argument and moved the logic to compute the value of the detail
peroprty and to call setDefaultHandled on the underlying click event in here.
This is a private helper function used only in one place.
(WebCore::Node::dispatchTouchEvent): Deleted.
(WebCore::Node::defaultEventHandler): Updated for change to dispatchDOMActivateEvent.
* dom/Node.h: Updated for the above changes.
* dom/RejectedPromiseTracker.cpp:
(WebCore::RejectedPromiseTracker::reportUnhandledRejections): Use defaultPrevented
directly instead of the return value from dispatchEvent.
* dom/ScopedEventQueue.cpp:
(WebCore::ScopedEventQueue::enqueueEvent): Moved assertions here ...
(WebCore::ScopedEventQueue::dispatchEvent const): ... from here. Also changed this
to call Node::dispatchEvent instead of calling EventDispatcher::dispatchEvent directly.
* dom/SimulatedClick.cpp:
(WebCore::simulateMouseEvent): Call Element::dispatchEvent instead of calling
EventDispatcher::dispatchEvent directly.
* editing/Editor.cpp:
(WebCore::dispatchBeforeInputEvent): Use defaultPrevented directly instead of the
return value from dispatchEvent.
* editing/FrameSelection.cpp:
(WebCore::FrameSelection::selectAll): Ditto.
(WebCore::FrameSelection::dispatchSelectStart): Ditto.
* html/CheckboxInputType.cpp:
(WebCore::CheckboxInputType::didDispatchClick): Take a reference instead of a pointer.
* html/CheckboxInputType.h: Updated for above and to use final instead of override.
* html/HTMLFormControlElement.cpp:
(WebCore::HTMLFormControlElement::checkValidity): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* html/HTMLFormElement.cpp:
(WebCore::HTMLFormElement::prepareForSubmission): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::HTMLFormElement::reset): Ditto.
* html/HTMLInputElement.cpp:
(WebCore::HTMLInputElement::didDispatchClickEvent): Updated to pass references instead
of pointer.
* html/HTMLMediaElement.cpp:
(WebCore::HTMLMediaElement::dispatchEvent): Got rid of boolean return value.
* html/HTMLMediaElement.h: Ditto.
* html/HTMLPlugInElement.h: Use "delete" instead of just a private function for something
that should never be called.
* html/InputType.cpp:
(WebCore::InputType::didDispatchClick): Take a reference instead of a pointer.
* html/InputType.h: Ditto.
* html/RadioInputType.cpp:
(WebCore::RadioInputType::didDispatchClick): Ditto.
* html/RadioInputType.h: Updated for above and to use final instead of override.
* html/track/TextTrackCue.cpp:
(WebCore::TextTrackCue::dispatchEvent): Got rid of boolean return value.
* html/track/TextTrackCue.h: Ditto.
* inspector/InspectorInstrumentation.cpp: Removed unneeded include of EventDispatcher.h.
* page/DOMWindow.cpp:
(WebCore::DOMWindow::dispatchLoadEvent): Streamlined code a bit so we only have a single
call to dispatchEvent. Improved comments.
(WebCore::DOMWindow::dispatchEvent): Removed return value. Added comments. Replaced
calls to setCurrentTarget(null), setEventPhase(NONE), and resetPropagationFlags with
a call to resetAfterDispatch.
* page/DOMWindow.h: Updated to get rid of the boolean return value.
* page/DragController.cpp:
(WebCore::DragController::dispatchTextInputEventFor): Use defaultPrevented directly instead
of the return value from dispatchEvent.
* page/EventHandler.cpp:
(WebCore::dispatchSelectStart): Use defaultPrevented directly instead
of the return value from dispatchEvent.
(WebCore::EventHandler::accessibilityPreventsEventPropagation): Fixed spelling error in the
name of this function.
(WebCore::EventHandler::dispatchDragSrcEvent): Got rid of boolean return value.
(WebCore::EventHandler::handleTouchEvent): Call dispatchEvent instead of dispatchTouchEvent;
there was no difference between the two except that dispatchTouchEvent required downcasting
and might some day lead to us missing some behavior implemented in an override to dispatchEvent.
* page/EventHandler.h: Updated for above changes.
* platform/graphics/filters/FilterOperation.h:
(WebCore::FilterOperation::clone): Removed dead code that was causing a compiler warning.
* workers/WorkerMessagingProxy.cpp:
(WebCore::WorkerMessagingProxy::postExceptionToWorkerObject): Use defaultPrevented
directly instead of the return value from dispatchEvent.
Source/WebKit:
* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMEvent.cpp:
(webkit_dom_event_get_src_element): Call target instead of srcElement.
Source/WebKitLegacy/mac:
* DOM/DOMEvent.mm:
(-[DOMEvent srcElement]): Call target instead of srcElement.
Canonical link: https://commits.webkit.org/195384@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@224459 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2017-11-04 21:19:11 +00:00
|
|
|
|
PerformanceTests:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* JetStream2/wasm/HashSet.cpp:
* StitchMarker/wtf/Assertions.h:
* StitchMarker/wtf/DateMath.cpp:
(WTF::initializeDates):
* StitchMarker/wtf/HashTable.h:
* StitchMarker/wtf/Hasher.h:
(WTF::StringHasher::addCharacters):
* StitchMarker/wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* StitchMarker/wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* StitchMarker/wtf/ValueCheck.h:
* StitchMarker/wtf/Vector.h:
(WTF::minCapacity>::checkConsistency):
* StitchMarker/wtf/text/AtomicStringImpl.cpp:
* StitchMarker/wtf/text/AtomicStringImpl.h:
* StitchMarker/wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* StitchMarker/wtf/text/StringImpl.h:
* StitchMarker/wtf/text/SymbolImpl.h:
* StitchMarker/wtf/text/UniquedStringImpl.h:
Source/JavaScriptCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* API/tests/testapi.c:
* assembler/ARM64Assembler.h:
(JSC::ARM64Assembler::replaceWithLoad):
(JSC::ARM64Assembler::replaceWithAddressComputation):
* assembler/AssemblerBuffer.h:
(JSC::AssemblerBuffer::LocalWriter::LocalWriter):
* assembler/LinkBuffer.cpp:
(JSC::LinkBuffer::copyCompactAndLinkCode):
* assembler/ProbeStack.cpp:
(JSC::Probe::Stack::Stack):
* assembler/ProbeStack.h:
* b3/B3FoldPathConstants.cpp:
* b3/B3LowerToAir.cpp:
* b3/B3MemoryValue.cpp:
(JSC::B3::MemoryValue::MemoryValue):
* b3/B3Opcode.cpp:
* b3/B3Type.h:
* b3/B3TypeMap.h:
* b3/B3Width.h:
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.cpp:
(JSC::B3::Air::GenerateAndAllocateRegisters::prepareForGeneration):
(JSC::B3::Air::GenerateAndAllocateRegisters::generate):
* b3/air/AirAllocateRegistersAndStackAndGenerateCode.h:
* b3/air/AirAllocateRegistersByGraphColoring.cpp:
* b3/air/AirArg.cpp:
* b3/air/AirArg.h:
* b3/air/AirCode.h:
* b3/air/AirEmitShuffle.cpp:
(JSC::B3::Air::emitShuffle):
* builtins/BuiltinExecutables.cpp:
(JSC::BuiltinExecutables::createExecutable):
* bytecode/AccessCase.cpp:
* bytecode/AccessCase.h:
* bytecode/CallVariant.cpp:
(JSC::variantListWithVariant):
* bytecode/CodeBlock.cpp:
(JSC::CodeBlock::ensureCatchLivenessIsComputedForBytecodeIndex):
* bytecode/CodeBlockHash.cpp:
(JSC::CodeBlockHash::dump const):
* bytecode/StructureStubInfo.cpp:
* bytecode/StructureStubInfo.h:
* bytecompiler/NodesCodegen.cpp:
(JSC::FunctionCallResolveNode::emitBytecode):
* bytecompiler/RegisterID.h:
(JSC::RegisterID::RegisterID):
(JSC::RegisterID::setIndex):
* debugger/Debugger.cpp:
(JSC::Debugger::removeBreakpoint):
* debugger/DebuggerEvalEnabler.h:
(JSC::DebuggerEvalEnabler::DebuggerEvalEnabler):
(JSC::DebuggerEvalEnabler::~DebuggerEvalEnabler):
* dfg/DFGAbstractInterpreterInlines.h:
(JSC::DFG::AbstractInterpreter<AbstractStateType>::observeTransitions):
* dfg/DFGAbstractValue.cpp:
* dfg/DFGAbstractValue.h:
(JSC::DFG::AbstractValue::merge):
(JSC::DFG::AbstractValue::checkConsistency const):
(JSC::DFG::AbstractValue::assertIsRegistered const):
* dfg/DFGArithMode.h:
(JSC::DFG::doesOverflow):
* dfg/DFGBasicBlock.cpp:
(JSC::DFG::BasicBlock::BasicBlock):
* dfg/DFGBasicBlock.h:
(JSC::DFG::BasicBlock::didLink):
* dfg/DFGCFAPhase.cpp:
(JSC::DFG::CFAPhase::performBlockCFA):
* dfg/DFGCommon.h:
(JSC::DFG::validationEnabled):
* dfg/DFGCommonData.cpp:
(JSC::DFG::CommonData::finalizeCatchEntrypoints):
* dfg/DFGDesiredWatchpoints.h:
* dfg/DFGDoesGC.cpp:
(JSC::DFG::doesGC):
* dfg/DFGEdge.h:
(JSC::DFG::Edge::makeWord):
* dfg/DFGFixupPhase.cpp:
(JSC::DFG::FixupPhase::fixupNode):
* dfg/DFGJITCode.cpp:
(JSC::DFG::JITCode::finalizeOSREntrypoints):
* dfg/DFGObjectAllocationSinkingPhase.cpp:
* dfg/DFGSSAConversionPhase.cpp:
(JSC::DFG::SSAConversionPhase::run):
* dfg/DFGScoreBoard.h:
(JSC::DFG::ScoreBoard::assertClear):
* dfg/DFGSlowPathGenerator.h:
(JSC::DFG::SlowPathGenerator::generate):
* dfg/DFGSpeculativeJIT.cpp:
(JSC::DFG::SpeculativeJIT::compileCurrentBlock):
(JSC::DFG::SpeculativeJIT::emitBinarySwitchStringRecurse):
(JSC::DFG::SpeculativeJIT::emitAllocateButterfly):
(JSC::DFG::SpeculativeJIT::compileAllocateNewArrayWithSize):
(JSC::DFG::SpeculativeJIT::compileMakeRope):
* dfg/DFGSpeculativeJIT64.cpp:
(JSC::DFG::SpeculativeJIT::fillSpeculateCell):
* dfg/DFGStructureAbstractValue.cpp:
* dfg/DFGStructureAbstractValue.h:
(JSC::DFG::StructureAbstractValue::assertIsRegistered const):
* dfg/DFGVarargsForwardingPhase.cpp:
* dfg/DFGVirtualRegisterAllocationPhase.cpp:
(JSC::DFG::VirtualRegisterAllocationPhase::run):
* ftl/FTLLink.cpp:
(JSC::FTL::link):
* ftl/FTLLowerDFGToB3.cpp:
(JSC::FTL::DFG::LowerDFGToB3::callPreflight):
(JSC::FTL::DFG::LowerDFGToB3::callCheck):
(JSC::FTL::DFG::LowerDFGToB3::crash):
* ftl/FTLOperations.cpp:
(JSC::FTL::operationMaterializeObjectInOSR):
* heap/BlockDirectory.cpp:
(JSC::BlockDirectory::assertNoUnswept):
* heap/GCSegmentedArray.h:
(JSC::GCArraySegment::GCArraySegment):
* heap/GCSegmentedArrayInlines.h:
(JSC::GCSegmentedArray<T>::clear):
(JSC::GCSegmentedArray<T>::expand):
(JSC::GCSegmentedArray<T>::validatePrevious):
* heap/HandleSet.cpp:
* heap/HandleSet.h:
* heap/Heap.cpp:
(JSC::Heap::updateAllocationLimits):
* heap/Heap.h:
* heap/MarkedBlock.cpp:
* heap/MarkedBlock.h:
(JSC::MarkedBlock::assertValidCell const):
(JSC::MarkedBlock::assertMarksNotStale):
* heap/MarkedSpace.cpp:
(JSC::MarkedSpace::beginMarking):
(JSC::MarkedSpace::endMarking):
(JSC::MarkedSpace::assertNoUnswept):
* heap/PreciseAllocation.cpp:
* heap/PreciseAllocation.h:
(JSC::PreciseAllocation::assertValidCell const):
* heap/SlotVisitor.cpp:
(JSC::SlotVisitor::SlotVisitor):
(JSC::SlotVisitor::appendJSCellOrAuxiliary):
* heap/SlotVisitor.h:
* inspector/InspectorProtocolTypes.h:
(Inspector::Protocol::BindingTraits<JSON::ArrayOf<T>>::assertValueHasExpectedType):
* inspector/scripts/codegen/generate_cpp_protocol_types_implementation.py:
(CppProtocolTypesImplementationGenerator._generate_assertion_for_object_declaration):
(CppProtocolTypesImplementationGenerator):
(CppProtocolTypesImplementationGenerator._generate_assertion_for_enum):
* inspector/scripts/tests/generic/expected/type-requiring-runtime-casts.json-result:
* interpreter/FrameTracers.h:
(JSC::JITOperationPrologueCallFrameTracer::JITOperationPrologueCallFrameTracer):
* interpreter/Interpreter.cpp:
(JSC::Interpreter::Interpreter):
* interpreter/Interpreter.h:
* jit/AssemblyHelpers.cpp:
(JSC::AssemblyHelpers::emitStoreStructureWithTypeInfo):
* jit/AssemblyHelpers.h:
(JSC::AssemblyHelpers::prepareCallOperation):
* jit/BinarySwitch.cpp:
(JSC::BinarySwitch::BinarySwitch):
* jit/CCallHelpers.h:
(JSC::CCallHelpers::setupStubArgs):
* jit/CallFrameShuffler.cpp:
(JSC::CallFrameShuffler::emitDeltaCheck):
(JSC::CallFrameShuffler::prepareAny):
* jit/JIT.cpp:
(JSC::JIT::assertStackPointerOffset):
(JSC::JIT::compileWithoutLinking):
* jit/JITOpcodes.cpp:
(JSC::JIT::emitSlow_op_loop_hint):
* jit/JITPropertyAccess.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/JITPropertyAccess32_64.cpp:
(JSC::JIT::emit_op_get_from_scope):
* jit/Repatch.cpp:
(JSC::linkPolymorphicCall):
* jit/ThunkGenerators.cpp:
(JSC::emitPointerValidation):
* llint/LLIntData.cpp:
(JSC::LLInt::Data::performAssertions):
* llint/LLIntOfflineAsmConfig.h:
* parser/Lexer.cpp:
* parser/Lexer.h:
(JSC::isSafeBuiltinIdentifier):
(JSC::Lexer<T>::lexExpectIdentifier):
* runtime/ArgList.h:
(JSC::MarkedArgumentBuffer::setNeedsOverflowCheck):
(JSC::MarkedArgumentBuffer::clearNeedsOverflowCheck):
* runtime/Butterfly.h:
(JSC::ContiguousData::ContiguousData):
(JSC::ContiguousData::Data::Data):
* runtime/HashMapImpl.h:
(JSC::HashMapImpl::checkConsistency const):
(JSC::HashMapImpl::assertBufferIsEmpty const):
* runtime/JSCellInlines.h:
(JSC::JSCell::methodTable const):
* runtime/JSFunction.cpp:
* runtime/JSFunction.h:
(JSC::JSFunction::assertTypeInfoFlagInvariants):
* runtime/JSGlobalObject.cpp:
(JSC::JSGlobalObject::init):
* runtime/JSGlobalObject.h:
* runtime/JSObject.cpp:
(JSC::JSObject::visitChildren):
(JSC::JSFinalObject::visitChildren):
* runtime/JSObjectInlines.h:
(JSC::JSObject::validatePutOwnDataProperty):
* runtime/JSSegmentedVariableObject.h:
(JSC::JSSegmentedVariableObject::assertVariableIsInThisObject):
* runtime/LiteralParser.cpp:
(JSC::LiteralParser<CharType>::Lexer::lex):
* runtime/LiteralParser.h:
* runtime/Operations.h:
(JSC::scribbleFreeCells):
* runtime/OptionsList.h:
* runtime/VM.cpp:
(JSC::VM::computeCanUseJIT):
* runtime/VM.h:
(JSC::VM::canUseJIT):
* runtime/VarOffset.h:
(JSC::VarOffset::checkSanity const):
* runtime/WeakMapImpl.h:
(JSC::WeakMapImpl::checkConsistency const):
(JSC::WeakMapImpl::assertBufferIsEmpty const):
* wasm/WasmAirIRGenerator.cpp:
(JSC::Wasm::AirIRGenerator::validateInst):
* wasm/WasmB3IRGenerator.cpp:
(JSC::Wasm::parseAndCompile):
* wasm/WasmFunctionParser.h:
(JSC::Wasm::FunctionParser::validationFail const):
* wasm/WasmLLIntGenerator.cpp:
(JSC::Wasm::LLIntGenerator::checkConsistency):
* wasm/WasmPlan.cpp:
(JSC::Wasm::Plan::tryRemoveContextAndCancelIfLast):
* wasm/WasmSectionParser.h:
* wasm/WasmSections.h:
* wasm/WasmSignatureInlines.h:
(JSC::Wasm::SignatureInformation::get):
* wasm/WasmWorklist.cpp:
(JSC::Wasm::Worklist::enqueue):
* wasm/js/JSToWasm.cpp:
(JSC::Wasm::createJSToWasmWrapper):
* wasm/js/WebAssemblyFunction.cpp:
(JSC::WebAssemblyFunction::previousInstanceOffset const):
Source/WebCore:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Modules/fetch/FetchBodySource.cpp:
(WebCore::FetchBodySource::close):
* Modules/fetch/FetchBodySource.h:
* Modules/webdatabase/DatabaseDetails.h:
(WebCore::DatabaseDetails::DatabaseDetails):
(WebCore::DatabaseDetails::operator=):
* Modules/webdatabase/DatabaseTask.cpp:
(WebCore::DatabaseTask::performTask):
* Modules/webdatabase/DatabaseTask.h:
* Modules/webdatabase/DatabaseThread.cpp:
(WebCore::DatabaseThread::terminationRequested const):
* Modules/webgpu/WHLSL/AST/WHLSLAddressSpace.h:
(WebCore::WHLSL::AST::TypeAnnotation::TypeAnnotation):
* Modules/webgpu/WHLSL/WHLSLHighZombieFinder.cpp:
(WebCore::WHLSL::findHighZombies):
* Modules/webgpu/WHLSL/WHLSLInferTypes.cpp:
(WebCore::WHLSL::matches):
* Modules/webgpu/WHLSL/WHLSLLiteralTypeChecker.cpp:
(WebCore::WHLSL::checkLiteralTypes):
* Modules/webgpu/WHLSL/WHLSLSynthesizeConstructors.cpp:
(WebCore::WHLSL::FindAllTypes::appendNamedType):
* bindings/js/JSCallbackData.h:
* bindings/js/JSLazyEventListener.cpp:
* bindings/js/JSLazyEventListener.h:
* contentextensions/ContentExtensionCompiler.cpp:
(WebCore::ContentExtensions::compileRuleList):
* css/CSSCalculationValue.cpp:
(WebCore::CSSCalcOperationNode::primitiveType const):
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::ComputedStyleExtractor::valueForPropertyInStyle):
* css/CSSPrimitiveValue.cpp:
* css/CSSSelector.cpp:
(WebCore::CSSSelector::selectorText const):
* css/CSSStyleSheet.cpp:
* dom/ActiveDOMObject.cpp:
(WebCore::ActiveDOMObject::suspendIfNeeded):
(WebCore::ActiveDOMObject::assertSuspendIfNeededWasCalled const):
* dom/ActiveDOMObject.h:
* dom/ContainerNode.cpp:
* dom/ContainerNodeAlgorithms.cpp:
* dom/ContainerNodeAlgorithms.h:
* dom/CustomElementReactionQueue.cpp:
* dom/CustomElementReactionQueue.h:
(WebCore::CustomElementReactionDisallowedScope::CustomElementReactionDisallowedScope):
(WebCore::CustomElementReactionDisallowedScope::~CustomElementReactionDisallowedScope):
* dom/Document.cpp:
(WebCore::Document::hitTest):
* dom/Document.h:
(WebCore::Document::decrementReferencingNodeCount):
* dom/Element.cpp:
(WebCore::Element::addShadowRoot):
(WebCore::Element::getURLAttribute const):
(WebCore::Element::getNonEmptyURLAttribute const):
* dom/Element.h:
* dom/ElementAndTextDescendantIterator.h:
(WebCore::ElementAndTextDescendantIterator::ElementAndTextDescendantIterator):
(WebCore::ElementAndTextDescendantIterator::dropAssertions):
(WebCore::ElementAndTextDescendantIterator::popAncestorSiblingStack):
(WebCore::ElementAndTextDescendantIterator::traverseNextSibling):
(WebCore::ElementAndTextDescendantIterator::traversePreviousSibling):
* dom/ElementDescendantIterator.h:
(WebCore::ElementDescendantIterator::ElementDescendantIterator):
(WebCore::ElementDescendantIterator::dropAssertions):
(WebCore::ElementDescendantIterator::operator++):
(WebCore::ElementDescendantIterator::operator--):
(WebCore::ElementDescendantConstIterator::ElementDescendantConstIterator):
(WebCore::ElementDescendantConstIterator::dropAssertions):
(WebCore::ElementDescendantConstIterator::operator++):
* dom/ElementIterator.h:
(WebCore::ElementIterator<ElementType>::ElementIterator):
(WebCore::ElementIterator<ElementType>::traverseNext):
(WebCore::ElementIterator<ElementType>::traversePrevious):
(WebCore::ElementIterator<ElementType>::traverseNextSibling):
(WebCore::ElementIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementIterator<ElementType>::dropAssertions):
(WebCore::ElementIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::ElementConstIterator):
(WebCore::ElementConstIterator<ElementType>::traverseNext):
(WebCore::ElementConstIterator<ElementType>::traversePrevious):
(WebCore::ElementConstIterator<ElementType>::traverseNextSibling):
(WebCore::ElementConstIterator<ElementType>::traversePreviousSibling):
(WebCore::ElementConstIterator<ElementType>::traverseNextSkippingChildren):
(WebCore::ElementConstIterator<ElementType>::traverseAncestor):
(WebCore::ElementConstIterator<ElementType>::dropAssertions):
* dom/EventContext.cpp:
* dom/EventContext.h:
* dom/EventListener.h:
* dom/EventPath.cpp:
* dom/EventSender.h:
* dom/EventTarget.cpp:
(WebCore::EventTarget::addEventListener):
(WebCore::EventTarget::setAttributeEventListener):
(WebCore::EventTarget::innerInvokeEventListeners):
* dom/Node.cpp:
(WebCore::Node::~Node):
(WebCore::Node::moveNodeToNewDocument):
(WebCore::Node::removedLastRef):
* dom/Node.h:
(WebCore::Node::deref const):
* dom/ScriptDisallowedScope.h:
(WebCore::ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree):
* dom/ScriptExecutionContext.cpp:
(WebCore::ScriptExecutionContext::~ScriptExecutionContext):
* dom/ScriptExecutionContext.h:
* dom/SelectorQuery.cpp:
(WebCore::SelectorDataList::execute const):
* dom/SlotAssignment.cpp:
(WebCore::SlotAssignment::addSlotElementByName):
(WebCore::SlotAssignment::removeSlotElementByName):
(WebCore::SlotAssignment::resolveSlotsAfterSlotMutation):
(WebCore::SlotAssignment::findFirstSlotElement):
* dom/SlotAssignment.h:
* dom/TreeScopeOrderedMap.cpp:
(WebCore::TreeScopeOrderedMap::add):
(WebCore::TreeScopeOrderedMap::get const):
* dom/TreeScopeOrderedMap.h:
* fileapi/Blob.cpp:
* fileapi/Blob.h:
* history/BackForwardCache.cpp:
(WebCore::BackForwardCache::removeAllItemsForPage):
* history/BackForwardCache.h:
* html/CanvasBase.cpp:
(WebCore::CanvasBase::notifyObserversCanvasDestroyed):
* html/CanvasBase.h:
* html/HTMLCollection.h:
(WebCore::CollectionNamedElementCache::didPopulate):
* html/HTMLSelectElement.cpp:
(WebCore:: const):
* html/HTMLTableRowsCollection.cpp:
(WebCore::assertRowIsInTable):
* html/HTMLTextFormControlElement.cpp:
(WebCore::HTMLTextFormControlElement::indexForPosition const):
* html/canvas/CanvasRenderingContext2DBase.cpp:
(WebCore::CanvasRenderingContext2DBase::~CanvasRenderingContext2DBase):
* html/parser/HTMLParserScheduler.cpp:
(WebCore::HTMLParserScheduler::HTMLParserScheduler):
(WebCore::HTMLParserScheduler::suspend):
(WebCore::HTMLParserScheduler::resume):
* html/parser/HTMLParserScheduler.h:
* html/parser/HTMLToken.h:
(WebCore::HTMLToken::beginStartTag):
(WebCore::HTMLToken::beginEndTag):
(WebCore::HTMLToken::endAttribute):
* html/parser/HTMLTreeBuilder.cpp:
(WebCore::HTMLTreeBuilder::HTMLTreeBuilder):
(WebCore::HTMLTreeBuilder::constructTree):
* html/parser/HTMLTreeBuilder.h:
(WebCore::HTMLTreeBuilder::~HTMLTreeBuilder):
* layout/FormattingContext.cpp:
(WebCore::Layout::FormattingContext::geometryForBox const):
* layout/blockformatting/BlockFormattingContext.cpp:
(WebCore::Layout::BlockFormattingContext::computeEstimatedVerticalPosition):
* layout/blockformatting/BlockFormattingContext.h:
* layout/displaytree/DisplayBox.cpp:
(WebCore::Display::Box::Box):
* layout/displaytree/DisplayBox.h:
(WebCore::Display::Box::setTopLeft):
(WebCore::Display::Box::setTop):
(WebCore::Display::Box::setLeft):
(WebCore::Display::Box::setContentBoxHeight):
(WebCore::Display::Box::setContentBoxWidth):
(WebCore::Display::Box::setHorizontalMargin):
(WebCore::Display::Box::setVerticalMargin):
(WebCore::Display::Box::setHorizontalComputedMargin):
(WebCore::Display::Box::setBorder):
(WebCore::Display::Box::setPadding):
* layout/displaytree/DisplayInlineRect.h:
(WebCore::Display::InlineRect::InlineRect):
(WebCore::Display::InlineRect::setTopLeft):
(WebCore::Display::InlineRect::setTop):
(WebCore::Display::InlineRect::setBottom):
(WebCore::Display::InlineRect::setLeft):
(WebCore::Display::InlineRect::setWidth):
(WebCore::Display::InlineRect::setHeight):
* layout/displaytree/DisplayLineBox.h:
(WebCore::Display::LineBox::LineBox):
(WebCore::Display::LineBox::setBaselineOffsetIfGreater):
(WebCore::Display::LineBox::resetBaseline):
(WebCore::Display::LineBox::Baseline::Baseline):
(WebCore::Display::LineBox::Baseline::setAscent):
(WebCore::Display::LineBox::Baseline::setDescent):
(WebCore::Display::LineBox::Baseline::reset):
* layout/displaytree/DisplayRect.h:
(WebCore::Display::Rect::Rect):
(WebCore::Display::Rect::setTopLeft):
(WebCore::Display::Rect::setTop):
(WebCore::Display::Rect::setLeft):
(WebCore::Display::Rect::setWidth):
(WebCore::Display::Rect::setHeight):
(WebCore::Display::Rect::setSize):
(WebCore::Display::Rect::clone const):
* layout/floats/FloatingContext.cpp:
* layout/inlineformatting/InlineLineBuilder.cpp:
(WebCore::Layout::LineBuilder::CollapsibleContent::collapse):
* layout/tableformatting/TableGrid.cpp:
(WebCore::Layout::TableGrid::Column::setWidthConstraints):
(WebCore::Layout::TableGrid::Column::setLogicalWidth):
(WebCore::Layout::TableGrid::Column::setLogicalLeft):
* layout/tableformatting/TableGrid.h:
* loader/DocumentLoader.cpp:
(WebCore::DocumentLoader::continueAfterContentPolicy):
(WebCore::DocumentLoader::attachToFrame):
(WebCore::DocumentLoader::detachFromFrame):
(WebCore::DocumentLoader::addSubresourceLoader):
* loader/DocumentLoader.h:
* loader/ImageLoader.cpp:
* loader/cache/CachedResource.h:
* loader/cache/MemoryCache.cpp:
(WebCore::MemoryCache::lruListFor):
(WebCore::MemoryCache::removeFromLRUList):
* page/FrameView.cpp:
(WebCore::FrameView::updateLayoutAndStyleIfNeededRecursive):
* page/FrameViewLayoutContext.cpp:
* page/FrameViewLayoutContext.h:
* page/Page.cpp:
* page/Page.h:
* page/ViewportConfiguration.cpp:
* page/ViewportConfiguration.h:
* page/mac/EventHandlerMac.mm:
(WebCore::CurrentEventScope::CurrentEventScope):
* platform/DateComponents.cpp:
(WebCore::DateComponents::toStringForTime const):
* platform/ScrollableArea.cpp:
* platform/SharedBuffer.cpp:
(WebCore::SharedBuffer::combineIntoOneSegment const):
* platform/SharedBuffer.h:
* platform/Supplementable.h:
* platform/Timer.cpp:
(WebCore::TimerBase::checkHeapIndex const):
(WebCore::TimerBase::updateHeapIfNeeded):
* platform/graphics/BitmapImage.cpp:
* platform/graphics/BitmapImage.h:
* platform/graphics/Image.h:
* platform/graphics/ShadowBlur.cpp:
(WebCore::ScratchBuffer::ScratchBuffer):
(WebCore::ScratchBuffer::getScratchBuffer):
(WebCore::ScratchBuffer::scheduleScratchBufferPurge):
* platform/graphics/ca/win/CACFLayerTreeHost.cpp:
(WebCore::CACFLayerTreeHost::setWindow):
* platform/graphics/ca/win/CACFLayerTreeHost.h:
* platform/graphics/cg/ImageBufferDataCG.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/cocoa/FontCacheCoreText.cpp:
* platform/graphics/gstreamer/GstAllocatorFastMalloc.cpp:
(gstAllocatorFastMallocFree):
* platform/graphics/nicosia/cairo/NicosiaPaintingContextCairo.cpp:
(Nicosia::PaintingContextCairo::ForPainting::ForPainting):
* platform/graphics/nicosia/texmap/NicosiaBackingStoreTextureMapperImpl.cpp:
(Nicosia::BackingStoreTextureMapperImpl::createTile):
* platform/graphics/nicosia/texmap/NicosiaContentLayerTextureMapperImpl.cpp:
(Nicosia::ContentLayerTextureMapperImpl::~ContentLayerTextureMapperImpl):
* platform/graphics/win/GradientDirect2D.cpp:
(WebCore::Gradient::fill):
* platform/graphics/win/ImageBufferDataDirect2D.cpp:
(WebCore::ImageBufferData::putData):
* platform/graphics/win/PathDirect2D.cpp:
(WebCore::Path::appendGeometry):
(WebCore::Path::Path):
(WebCore::Path::operator=):
(WebCore::Path::strokeContains const):
(WebCore::Path::transform):
* platform/graphics/win/PlatformContextDirect2D.cpp:
(WebCore::PlatformContextDirect2D::setTags):
* platform/mediastream/MediaStreamTrackPrivate.h:
* platform/mediastream/RealtimeOutgoingAudioSource.cpp:
(WebCore::RealtimeOutgoingAudioSource::~RealtimeOutgoingAudioSource):
* platform/mediastream/RealtimeOutgoingVideoSource.cpp:
(WebCore::RealtimeOutgoingVideoSource::~RealtimeOutgoingVideoSource):
* platform/network/HTTPParsers.cpp:
(WebCore::isCrossOriginSafeHeader):
* platform/sql/SQLiteDatabase.cpp:
* platform/sql/SQLiteDatabase.h:
* platform/sql/SQLiteStatement.cpp:
(WebCore::SQLiteStatement::SQLiteStatement):
(WebCore::SQLiteStatement::prepare):
(WebCore::SQLiteStatement::finalize):
* platform/sql/SQLiteStatement.h:
* platform/win/COMPtr.h:
* rendering/ComplexLineLayout.cpp:
(WebCore::ComplexLineLayout::removeInlineBox const):
* rendering/FloatingObjects.cpp:
(WebCore::FloatingObject::FloatingObject):
(WebCore::FloatingObjects::addPlacedObject):
(WebCore::FloatingObjects::removePlacedObject):
* rendering/FloatingObjects.h:
* rendering/GridTrackSizingAlgorithm.cpp:
* rendering/GridTrackSizingAlgorithm.h:
* rendering/LayoutDisallowedScope.cpp:
* rendering/LayoutDisallowedScope.h:
* rendering/RenderBlock.cpp:
* rendering/RenderBlock.h:
* rendering/RenderBlockFlow.cpp:
(WebCore::RenderBlockFlow::layoutBlockChild):
(WebCore::RenderBlockFlow::removeFloatingObject):
(WebCore::RenderBlockFlow::ensureLineBoxes):
* rendering/RenderBoxModelObject.cpp:
* rendering/RenderDeprecatedFlexibleBox.cpp:
(WebCore::RenderDeprecatedFlexibleBox::layoutBlock):
* rendering/RenderElement.cpp:
* rendering/RenderGeometryMap.cpp:
(WebCore::RenderGeometryMap::mapToContainer const):
* rendering/RenderGrid.cpp:
(WebCore::RenderGrid::placeItemsOnGrid const):
(WebCore::RenderGrid::baselinePosition const):
* rendering/RenderInline.cpp:
(WebCore::RenderInline::willBeDestroyed):
* rendering/RenderLayer.cpp:
(WebCore::ClipRectsCache::ClipRectsCache):
(WebCore::RenderLayer::RenderLayer):
(WebCore::RenderLayer::paintList):
(WebCore::RenderLayer::hitTestLayer):
(WebCore::RenderLayer::updateClipRects):
(WebCore::RenderLayer::calculateClipRects const):
* rendering/RenderLayer.h:
* rendering/RenderLayerBacking.cpp:
(WebCore::traverseVisibleNonCompositedDescendantLayers):
* rendering/RenderLayerCompositor.cpp:
(WebCore::RenderLayerCompositor::computeCompositingRequirements):
(WebCore::RenderLayerCompositor::traverseUnchangedSubtree):
(WebCore::RenderLayerCompositor::updateBackingAndHierarchy):
(WebCore::RenderLayerCompositor::addDescendantsToOverlapMapRecursive const):
(WebCore::RenderLayerCompositor::recursiveRepaintLayer):
(WebCore::RenderLayerCompositor::layerHas3DContent const):
* rendering/RenderLayoutState.cpp:
(WebCore::RenderLayoutState::RenderLayoutState):
(WebCore::RenderLayoutState::computeOffsets):
(WebCore::RenderLayoutState::addLayoutDelta):
* rendering/RenderLayoutState.h:
(WebCore::RenderLayoutState::RenderLayoutState):
* rendering/RenderObject.cpp:
(WebCore::RenderObject::RenderObject):
(WebCore::RenderObject::~RenderObject):
(WebCore::RenderObject::clearNeedsLayout):
* rendering/RenderObject.h:
* rendering/RenderQuote.cpp:
(WebCore::quotesForLanguage):
* rendering/RenderTableCell.h:
* rendering/RenderTableSection.cpp:
(WebCore::RenderTableSection::computeOverflowFromCells):
* rendering/RenderTextLineBoxes.cpp:
(WebCore::RenderTextLineBoxes::checkConsistency const):
* rendering/RenderTextLineBoxes.h:
* rendering/line/BreakingContext.h:
(WebCore::tryHyphenating):
* rendering/style/GridArea.h:
(WebCore::GridSpan::GridSpan):
* rendering/style/RenderStyle.cpp:
(WebCore::RenderStyle::~RenderStyle):
* rendering/style/RenderStyle.h:
* rendering/updating/RenderTreeBuilderRuby.cpp:
(WebCore::RenderTreeBuilder::Ruby::detach):
* rendering/updating/RenderTreePosition.cpp:
(WebCore::RenderTreePosition::computeNextSibling):
* rendering/updating/RenderTreePosition.h:
* svg/SVGToOTFFontConversion.cpp:
(WebCore::SVGToOTFFontConverter::Placeholder::Placeholder):
(WebCore::SVGToOTFFontConverter::Placeholder::populate):
(WebCore::SVGToOTFFontConverter::appendCFFTable):
(WebCore::SVGToOTFFontConverter::firstGlyph const):
(WebCore::SVGToOTFFontConverter::appendKERNTable):
* svg/SVGTransformDistance.cpp:
(WebCore::SVGTransformDistance::SVGTransformDistance):
(WebCore::SVGTransformDistance::scaledDistance const):
(WebCore::SVGTransformDistance::addSVGTransforms):
(WebCore::SVGTransformDistance::addToSVGTransform const):
(WebCore::SVGTransformDistance::distance const):
* svg/graphics/SVGImage.cpp:
(WebCore::SVGImage::nativeImage):
* testing/InternalSettings.cpp:
* workers/service/ServiceWorkerJob.h:
* worklets/PaintWorkletGlobalScope.h:
(WebCore::PaintWorkletGlobalScope::~PaintWorkletGlobalScope):
* xml/XPathStep.cpp:
Source/WebKit:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* NetworkProcess/NetworkSession.cpp:
(WebKit::NetworkSession::invalidateAndCancel):
* NetworkProcess/NetworkSession.h:
* NetworkProcess/cache/NetworkCacheStorage.cpp:
(WebKit::NetworkCache::Storage::setCapacity):
* NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(toNSURLSessionResponseDisposition):
(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
* Platform/IPC/Connection.cpp:
(IPC::Connection::waitForMessage):
* Platform/IPC/MessageReceiver.h:
(IPC::MessageReceiver::willBeAddedToMessageReceiverMap):
(IPC::MessageReceiver::willBeRemovedFromMessageReceiverMap):
* Platform/IPC/cocoa/ConnectionCocoa.mm:
(IPC::readFromMachPort):
* Platform/mac/MachUtilities.cpp:
(setMachExceptionPort):
* Shared/API/APIClient.h:
(API::Client::Client):
* Shared/API/Cocoa/WKRemoteObjectCoder.mm:
* Shared/Cocoa/ArgumentCodersCocoa.h:
* Shared/SharedStringHashTableReadOnly.cpp:
* UIProcess/BackingStore.cpp:
(WebKit::BackingStore::incorporateUpdate):
* UIProcess/GenericCallback.h:
* UIProcess/Launcher/mac/ProcessLauncherMac.mm:
(WebKit::ProcessLauncher::launchProcess):
* UIProcess/PageLoadState.h:
(WebKit::PageLoadState::Transaction::Token::Token):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::~WebPageProxy):
* WebProcess/Network/WebResourceLoader.cpp:
(WebKit::WebResourceLoader::didReceiveResponse):
* WebProcess/Network/WebResourceLoader.h:
* WebProcess/Plugins/Netscape/NetscapePluginStream.cpp:
(WebKit::NetscapePluginStream::NetscapePluginStream):
(WebKit::NetscapePluginStream::notifyAndDestroyStream):
* WebProcess/Plugins/Netscape/NetscapePluginStream.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::WebPage::runModal):
* WebProcess/WebProcess.cpp:
(WebKit::checkDocumentsCaptureStateConsistency):
* WebProcess/cocoa/WebProcessCocoa.mm:
(WebKit::WebProcess::updateProcessName):
Source/WebKitLegacy:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* Storage/StorageAreaImpl.cpp:
(WebKit::StorageAreaImpl::StorageAreaImpl):
(WebKit::StorageAreaImpl::close):
* Storage/StorageAreaImpl.h:
Source/WebKitLegacy/mac:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* History/WebHistory.mm:
(-[WebHistoryPrivate removeItemForURLString:]):
* WebView/WebFrame.mm:
Source/WebKitLegacy/win:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
* WebKitQuartzCoreAdditions/CAD3DRenderer.cpp:
(WKQCA::CAD3DRenderer::swapChain):
(WKQCA::CAD3DRenderer::initialize):
* WebKitQuartzCoreAdditions/CAD3DRenderer.h:
* WebView.cpp:
(WebView::Release):
* WebView.h:
Source/WTF:
Convert ASSERT_DISABLED to ASSERT_ENABLED, and fix some tests of NDEBUG that should actually test for ASSERT_ENABLED.
https://bugs.webkit.org/show_bug.cgi?id=205776
Reviewed by Saam Barati.
This patch did the following changes:
1. Replaced ASSERT_DISABLED with ASSERT_ENABLED. This change does away
with the need for the double negative !ASSERT_DISABLED test that is commonly
used all over the code, thereby improving code readability.
In Assertions.h, there is also BACKTRACE_DISABLED, ASSERT_MSG_DISABLED,
ASSERT_ARG_DISABLED, FATAL_DISABLED, ERROR_DISABLED, LOG_DISABLED, and
RELEASE_LOG_DISABLED. We should replace those with ..._ENABLED equivalents
as well. We'll do that in another patch. For now, they are left as is to
minimize the size of this patch.
See https://bugs.webkit.org/show_bug.cgi?id=205780.
2. Fixed some code was guarded with "#ifndef NDEBUG" that should actually be
guarded by "#if ASSERT_ENABLED" instead.
3. In cases where the change is minimal, we move some code around so that we can
test for "#if ASSERT_ENABLED" instead of "#if !ASSERT_ENABLED".
* wtf/Assertions.h:
* wtf/AutomaticThread.cpp:
(WTF::AutomaticThread::start):
* wtf/BitVector.h:
* wtf/BlockObjCExceptions.mm:
(ReportBlockedObjCException):
* wtf/BloomFilter.h:
* wtf/CallbackAggregator.h:
(WTF::CallbackAggregator::CallbackAggregator):
* wtf/CheckedArithmetic.h:
(WTF::observesOverflow<AssertNoOverflow>):
* wtf/CheckedBoolean.h:
(CheckedBoolean::CheckedBoolean):
(CheckedBoolean::operator bool):
* wtf/CompletionHandler.h:
(WTF::CompletionHandler<Out):
* wtf/DateMath.cpp:
(WTF::initializeDates):
* wtf/Gigacage.cpp:
(Gigacage::tryAllocateZeroedVirtualPages):
* wtf/HashTable.h:
(WTF::KeyTraits>::checkKey):
(WTF::KeyTraits>::checkTableConsistencyExceptSize const):
* wtf/LoggerHelper.h:
* wtf/NaturalLoops.h:
(WTF::NaturalLoops::headerOf const):
* wtf/NeverDestroyed.h:
(WTF::LazyNeverDestroyed::construct):
* wtf/OptionSet.h:
(WTF::OptionSet::OptionSet):
* wtf/Platform.h:
* wtf/PtrTag.h:
* wtf/RefCounted.h:
(WTF::RefCountedBase::disableThreadingChecks):
(WTF::RefCountedBase::enableThreadingChecksGlobally):
(WTF::RefCountedBase::RefCountedBase):
(WTF::RefCountedBase::applyRefDerefThreadingCheck const):
* wtf/SingleRootGraph.h:
(WTF::SingleRootGraph::assertIsConsistent const):
* wtf/SizeLimits.cpp:
* wtf/StackBounds.h:
(WTF::StackBounds::checkConsistency const):
* wtf/URLParser.cpp:
(WTF::URLParser::URLParser):
(WTF::URLParser::domainToASCII):
* wtf/ValueCheck.h:
* wtf/Vector.h:
(WTF::Malloc>::checkConsistency):
* wtf/WeakHashSet.h:
* wtf/WeakPtr.h:
(WTF::WeakPtrImpl::WeakPtrImpl):
(WTF::WeakPtrFactory::WeakPtrFactory):
* wtf/text/AtomStringImpl.cpp:
* wtf/text/AtomStringImpl.h:
* wtf/text/StringBuilder.cpp:
(WTF::StringBuilder::reifyString const):
* wtf/text/StringBuilder.h:
* wtf/text/StringCommon.h:
(WTF::hasPrefixWithLettersIgnoringASCIICaseCommon):
* wtf/text/StringHasher.h:
(WTF::StringHasher::addCharacters):
* wtf/text/StringImpl.h:
* wtf/text/SymbolImpl.h:
* wtf/text/UniquedStringImpl.h:
Tools:
Remove WebsiteDataStore::setServiceWorkerRegistrationDirectory
https://bugs.webkit.org/show_bug.cgi?id=205754
Patch by Alex Christensen <achristensen@webkit.org> on 2020-01-06
Reviewed by Youenn Fablet.
* TestWebKitAPI/Tests/WebKitCocoa/ServiceWorkerBasic.mm:
* WebKitTestRunner/TestController.cpp:
(WTR::TestController::websiteDataStore):
(WTR::TestController::platformAdjustContext):
* WebKitTestRunner/cocoa/TestControllerCocoa.mm:
(WTR::initializeWebViewConfiguration):
Canonical link: https://commits.webkit.org/218957@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@254087 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-01-06 22:24:50 +00:00
|
|
|
#endif // ASSERT_ENABLED
|
2016-03-10 05:27:07 +00:00
|
|
|
|
|
|
|
}
|