WebKit Bugzilla
Attachment 349272 Details for
Bug 180378
: Update composedPath to match the latest spec
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Requests
|
Help
|
New Account
|
Log In
Remember
[x]
|
Forgot Password
Login:
[x]
[patch]
WIP
wip180378.patch (text/plain), 10.60 KB, created by
Ryosuke Niwa
on 2018-09-08 18:59:52 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Ryosuke Niwa
Created:
2018-09-08 18:59:52 PDT
Size:
10.60 KB
patch
obsolete
>Index: Source/WebCore/dom/EventContext.cpp >=================================================================== >--- Source/WebCore/dom/EventContext.cpp (revision 235827) >+++ Source/WebCore/dom/EventContext.cpp (working copy) >@@ -35,10 +35,11 @@ > > namespace WebCore { > >-EventContext::EventContext(Node* node, EventTarget* currentTarget, EventTarget* target) >- : m_node(node) >- , m_currentTarget(currentTarget) >- , m_target(target) >+EventContext::EventContext(Node* node, EventTarget* currentTarget, EventTarget* target, int closedShadowDepth) >+ : m_node { node } >+ , m_currentTarget { currentTarget } >+ , m_target { target } >+ , m_closedShadowDepth { closedShadowDepth } > { > ASSERT(!isUnreachableNode(m_target.get())); > } >@@ -66,8 +67,8 @@ > return false; > } > >-MouseOrFocusEventContext::MouseOrFocusEventContext(Node& node, EventTarget* currentTarget, EventTarget* target) >- : EventContext(&node, currentTarget, target) >+MouseOrFocusEventContext::MouseOrFocusEventContext(Node& node, EventTarget* currentTarget, EventTarget* target, int closedShadowDepth) >+ : EventContext(&node, currentTarget, target, closedShadowDepth) > { > } > >@@ -87,8 +88,8 @@ > > #if ENABLE(TOUCH_EVENTS) > >-TouchEventContext::TouchEventContext(Node& node, EventTarget* currentTarget, EventTarget* target) >- : EventContext(&node, currentTarget, target) >+TouchEventContext::TouchEventContext(Node& node, EventTarget* currentTarget, EventTarget* target, int closedShadowDepth) >+ : EventContext(&node, currentTarget, target, closedShadowDepth) > , m_touches(TouchList::create()) > , m_targetTouches(TouchList::create()) > , m_changedTouches(TouchList::create()) >Index: Source/WebCore/dom/EventContext.h >=================================================================== >--- Source/WebCore/dom/EventContext.h (revision 235827) >+++ Source/WebCore/dom/EventContext.h (working copy) >@@ -36,7 +36,7 @@ > class EventContext { > WTF_MAKE_FAST_ALLOCATED; > public: >- EventContext(Node*, EventTarget* currentTarget, EventTarget*); >+ EventContext(Node*, EventTarget* currentTarget, EventTarget*, int closedShadowDepth); > virtual ~EventContext(); > > Node* node() const { return m_node.get(); } >@@ -43,6 +43,8 @@ > EventTarget* currentTarget() const { return m_currentTarget.get(); } > EventTarget* target() const { return m_target.get(); } > >+ int closedShadowDepth() const { return m_closedShadowDepth; } >+ > virtual void handleLocalEvents(Event&) const; > > virtual bool isMouseOrFocusEventContext() const; >@@ -56,11 +58,12 @@ > RefPtr<Node> m_node; > RefPtr<EventTarget> m_currentTarget; > RefPtr<EventTarget> m_target; >+ int m_closedShadowDepth { 0 }; > }; > > class MouseOrFocusEventContext final : public EventContext { > public: >- MouseOrFocusEventContext(Node&, EventTarget* currentTarget, EventTarget*); >+ MouseOrFocusEventContext(Node&, EventTarget* currentTarget, EventTarget*, int closedShadowDepth); > virtual ~MouseOrFocusEventContext(); > > Node* relatedTarget() const { return m_relatedTarget.get(); } >@@ -77,7 +80,7 @@ > > class TouchEventContext final : public EventContext { > public: >- TouchEventContext(Node&, EventTarget* currentTarget, EventTarget*); >+ TouchEventContext(Node&, EventTarget* currentTarget, EventTarget*, int closedShadowDepth); > virtual ~TouchEventContext(); > > enum TouchListType { Touches, TargetTouches, ChangedTouches }; >Index: Source/WebCore/dom/EventPath.cpp >=================================================================== >--- Source/WebCore/dom/EventPath.cpp (revision 235827) >+++ Source/WebCore/dom/EventPath.cpp (working copy) >@@ -35,13 +35,13 @@ > > class WindowEventContext final : public EventContext { > public: >- WindowEventContext(Node&, DOMWindow&, EventTarget&); >+ WindowEventContext(Node&, DOMWindow&, EventTarget&, int closedShadowDepth); > private: > void handleLocalEvents(Event&) const final; > }; > >-inline WindowEventContext::WindowEventContext(Node& node, DOMWindow& currentTarget, EventTarget& target) >- : EventContext(&node, ¤tTarget, &target) >+inline WindowEventContext::WindowEventContext(Node& node, DOMWindow& currentTarget, EventTarget& target, int closedShadowDepth) >+ : EventContext(&node, ¤tTarget, &target, closedShadowDepth) > { > } > >@@ -111,19 +111,19 @@ > > void EventPath::buildPath(Node& originalTarget, Event& event) > { >- using MakeEventContext = std::unique_ptr<EventContext> (*)(Node&, EventTarget*, EventTarget*); >- MakeEventContext makeEventContext = [] (Node& node, EventTarget* currentTarget, EventTarget* target) { >- return std::make_unique<EventContext>(&node, currentTarget, target); >+ using MakeEventContext = std::unique_ptr<EventContext> (*)(Node&, EventTarget*, EventTarget*, unsigned closedShadowDepth); >+ MakeEventContext makeEventContext = [] (Node& node, EventTarget* currentTarget, EventTarget* target, unsigned closedShadowDepth) { >+ return std::make_unique<EventContext>(&node, currentTarget, target, closedShadowDepth); > }; > if (is<MouseEvent>(event) || event.isFocusEvent()) { >- makeEventContext = [] (Node& node, EventTarget* currentTarget, EventTarget* target) -> std::unique_ptr<EventContext> { >- return std::make_unique<MouseOrFocusEventContext>(node, currentTarget, target); >+ makeEventContext = [] (Node& node, EventTarget* currentTarget, EventTarget* target, unsigned closedShadowDepth) -> std::unique_ptr<EventContext> { >+ return std::make_unique<MouseOrFocusEventContext>(node, currentTarget, target, closedShadowDepth); > }; > } > #if ENABLE(TOUCH_EVENTS) > if (is<TouchEvent>(event)) { >- makeEventContext = [] (Node& node, EventTarget* currentTarget, EventTarget* target) -> std::unique_ptr<EventContext> { >- return std::make_unique<TouchEventContext>(node, currentTarget, target); >+ makeEventContext = [] (Node& node, EventTarget* currentTarget, EventTarget* target, unsigned closedShadowDepth) -> std::unique_ptr<EventContext> { >+ return std::make_unique<TouchEventContext>(node, currentTarget, target, closedShadowDepth); > }; > } > #endif >@@ -130,9 +130,10 @@ > > Node* node = nodeOrHostIfPseudoElement(&originalTarget); > Node* target = node ? eventTargetRespectingTargetRules(*node) : nullptr; >+ int closedShadowDepth = 0; > while (node) { > while (node) { >- m_path.append(makeEventContext(*node, eventTargetRespectingTargetRules(*node), target)); >+ m_path.append(makeEventContext(*node, eventTargetRespectingTargetRules(*node), target, closedShadowDepth)); > > if (is<ShadowRoot>(*node)) > break; >@@ -144,7 +145,7 @@ > ASSERT(target); > if (target) { > if (auto* window = downcast<Document>(*node).domWindow()) >- m_path.append(std::make_unique<WindowEventContext>(*node, *window, *target)); >+ m_path.append(std::make_unique<WindowEventContext>(*node, *window, *target, closedShadowDepth)); > } > } > return; >@@ -153,6 +154,8 @@ > auto* shadowRootOfParent = parent->shadowRoot(); > if (UNLIKELY(shadowRootOfParent)) { > if (auto* assignedSlot = shadowRootOfParent->findAssignedSlot(*node)) { >+ if (shadowRootOfParent->mode() != ShadowRootMode::Open) >+ closedShadowDepth++; > // node is assigned to a slot. Continue dispatching the event at this slot. > parent = assignedSlot; > } >@@ -165,6 +168,8 @@ > if (!shouldEventCrossShadowBoundary(event, shadowRoot, originalTarget)) > return; > node = shadowRoot.host(); >+ if (shadowRoot.mode() != ShadowRootMode::Open) >+ closedShadowDepth--; > if (exitingShadowTreeOfTarget) > target = eventTargetRespectingTargetRules(*node); > } >@@ -254,29 +259,44 @@ > Vector<EventTarget*> EventPath::computePathUnclosedToTarget(const EventTarget& target) const > { > Vector<EventTarget*> path; >- path.reserveInitialCapacity(m_path.size()); >- const Node* targetNode = nullptr; >- if (is<Node>(target)) >- targetNode = &downcast<Node>(target); >- else if (is<DOMWindow>(target)) { >- targetNode = downcast<DOMWindow>(target).document(); >- ASSERT(targetNode); >- } >- for (auto& context : m_path) { >- auto* currentTarget = context->currentTarget(); >- if (!is<Node>(currentTarget) || !targetNode || !targetNode->isClosedShadowHidden(downcast<Node>(*currentTarget))) >- path.uncheckedAppend(currentTarget); >- } >+ auto pathSize = m_path.size(); >+ path.reserveInitialCapacity(pathSize); >+ >+ auto currentTargetIndex = m_path.findMatching([&target] (auto& context) { return context->currentTarget() == ⌖ }); >+ RELEASE_ASSERT(currentTargetIndex != notFound); >+ auto currentTargetDepth = m_path[currentTargetIndex]->closedShadowDepth(); >+ >+ 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; >+ for (int i = currentTargetIndex; i >= 0; --i) >+ appendTargetWithLesserDepth(*m_path[i], currentDepthAllowed); >+ path.reverse(); >+ >+ currentDepthAllowed = currentTargetDepth; >+ for (unsigned i = currentTargetIndex + 1; i < pathSize; ++i) >+ appendTargetWithLesserDepth(*m_path[i], currentDepthAllowed); >+ > return path; > } > > EventPath::EventPath(const Vector<Element*>& targets) > { >+ // FIXME: This function seems wrong. Why are we not firing events in the closed shadow trees? > for (auto* target : targets) { > ASSERT(target); > Node* origin = *targets.begin(); > if (!target->isClosedShadowHidden(*origin)) >- m_path.append(std::make_unique<EventContext>(target, target, origin)); >+ m_path.append(std::make_unique<EventContext>(target, target, origin, 0)); > } > } > >@@ -285,7 +305,7 @@ > for (auto* target : targets) { > ASSERT(target); > ASSERT(!is<Node>(target)); >- m_path.append(std::make_unique<EventContext>(nullptr, target, *targets.begin())); >+ m_path.append(std::make_unique<EventContext>(nullptr, target, *targets.begin(), 0)); > } > } >
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 180378
:
349272
|
349533
|
349534
|
349994