Changeset 118890 in webkit
- Timestamp:
- May 29, 2012, 9:20:02 PM (14 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 5 edited
-
ChangeLog (modified) (1 diff)
-
dom/ComposedShadowTreeWalker.cpp (modified) (3 diffs)
-
dom/ComposedShadowTreeWalker.h (modified) (4 diffs)
-
dom/EventDispatcher.cpp (modified) (2 diffs)
-
page/EventHandler.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r118889 r118890 1 2012-05-29 Hayato Ito <hayato@chromium.org> 2 3 Introduces ComposedShadowTreeParentWalker, extracted from ComposedShadowTreeWalker. 4 https://bugs.webkit.org/show_bug.cgi?id=87004 5 6 Reviewed by Dimitri Glazkov. 7 8 Introduces a ComposedShadowTreeParentWalker, which is only used 9 for traversing a parent node (including shadow roots and insertion 10 points) and get rid of an equivalent function from 11 ComposedShadowTreeWalker. 12 13 Before this patch, there is an inconsistency inside of 14 ComposedShadowTreeWalker. The Walker uses 'Policy' to decide 15 whether it should visit shadow roots or not, but 16 parentIncludingInsertionPointAndShadowRoot() member function 17 ignores the policy. We can not add an assertion in its 18 constructor due to this inconsistency. To resolve it, we could 19 add yet another special policy, but that makes the implementation 20 complex and may add some overhead in runtime. So separate the 21 functionality into another class as ComposedShadowTreeParentWalker. 22 23 No new tests, no new functionality except for assertion. 24 25 * dom/ComposedShadowTreeWalker.cpp: 26 (WebCore::ComposedShadowTreeWalker::ComposedShadowTreeWalker): 27 (WebCore::ComposedShadowTreeParentWalker::ComposedShadowTreeParentWalker): 28 (WebCore): 29 (WebCore::ComposedShadowTreeParentWalker::parentIncludingInsertionPointAndShadowRoot): 30 (WebCore::ComposedShadowTreeParentWalker::traverseParentIncludingInsertionPointAndShadowRoot): 31 * dom/ComposedShadowTreeWalker.h: 32 (ComposedShadowTreeWalker): 33 (WebCore::ComposedShadowTreeWalker::assertPrecondition): 34 (WebCore): 35 (ComposedShadowTreeParentWalker): 36 (WebCore::ComposedShadowTreeParentWalker::get): 37 * dom/EventDispatcher.cpp: 38 (WebCore::EventRelatedTargetAdjuster::adjust): 39 (WebCore::EventDispatcher::ensureEventAncestors): 40 * page/EventHandler.cpp: 41 (WebCore::EventHandler::updateMouseEventTargetNode): 42 1 43 2012-05-29 Hayato Ito <hayato@chromium.org> 2 44 -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
r118125 r118890 53 53 , m_policy(policy) 54 54 { 55 // FIXME: Refactor ComposedShadowTreeWalker so that we can assert node here. 56 // https://bugs.webkit.org/show_bug.cgi?id=87004 55 #ifndef NDEBUG 56 if (m_node) 57 assertPrecondition(); 58 #endif 57 59 } 58 60 … … 199 201 } 200 202 201 void ComposedShadowTreeWalker::parentIncludingInsertionPointAndShadowRoot()202 {203 ASSERT(m_node);204 m_node = traverseParentIncludingInsertionPointAndShadowRoot(m_node);205 }206 207 Node* ComposedShadowTreeWalker::traverseParentIncludingInsertionPointAndShadowRoot(const Node* node) const208 {209 if (ElementShadow* shadow = shadowOfParent(node)) {210 if (InsertionPoint* insertionPoint = shadow->insertionPointFor(node))211 return insertionPoint;212 }213 if (!node->isShadowRoot())214 return node->parentNode();215 const ShadowRoot* shadowRoot = toShadowRoot(node);216 if (shadowRoot->isYoungest())217 return shadowRoot->host();218 InsertionPoint* assignedInsertionPoint = shadowRoot->assignedTo();219 ASSERT(assignedInsertionPoint);220 return assignedInsertionPoint;221 }222 223 203 Node* ComposedShadowTreeWalker::traverseParent(const Node* node) const 224 204 { … … 294 274 } 295 275 276 ComposedShadowTreeParentWalker::ComposedShadowTreeParentWalker(const Node* node) 277 : m_node(node) 278 { 279 } 280 281 void ComposedShadowTreeParentWalker::parentIncludingInsertionPointAndShadowRoot() 282 { 283 ASSERT(m_node); 284 m_node = traverseParentIncludingInsertionPointAndShadowRoot(m_node); 285 } 286 287 Node* ComposedShadowTreeParentWalker::traverseParentIncludingInsertionPointAndShadowRoot(const Node* node) const 288 { 289 if (ElementShadow* shadow = shadowOfParent(node)) { 290 if (InsertionPoint* insertionPoint = shadow->insertionPointFor(node)) 291 return insertionPoint; 292 } 293 if (!node->isShadowRoot()) 294 return node->parentNode(); 295 const ShadowRoot* shadowRoot = toShadowRoot(node); 296 if (shadowRoot->isYoungest()) 297 return shadowRoot->host(); 298 InsertionPoint* assignedInsertionPoint = shadowRoot->assignedTo(); 299 ASSERT(assignedInsertionPoint); 300 return assignedInsertionPoint; 301 } 302 296 303 } // namespace -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h
r117534 r118890 60 60 61 61 void parent(); 62 // This function ignores policy and always crosses an upper boundary.63 void parentIncludingInsertionPointAndShadowRoot();64 62 65 63 void next(); … … 82 80 else 83 81 ASSERT(!m_node->isShadowRoot() || toShadowRoot(m_node)->isYoungest()); 84 ASSERT(!is InsertionPoint(m_node) || !toInsertionPoint(m_node)->isActive());82 ASSERT(!isActiveInsertionPoint(m_node)); 85 83 #endif 86 84 } … … 101 99 Node* traverseChild(const Node*, TraversalDirection) const; 102 100 Node* traverseParent(const Node*) const; 103 Node* traverseParentIncludingInsertionPointAndShadowRoot(const Node*) const;104 101 105 102 static Node* traverseNextSibling(const Node*); … … 120 117 }; 121 118 119 // A special walker class which is only used for traversing a parent node, including 120 // insertion points and shadow roots. 121 class ComposedShadowTreeParentWalker { 122 public: 123 ComposedShadowTreeParentWalker(const Node*); 124 void parentIncludingInsertionPointAndShadowRoot(); 125 Node* get() const { return const_cast<Node*>(m_node); } 126 private: 127 Node* traverseParentIncludingInsertionPointAndShadowRoot(const Node*) const; 128 const Node* m_node; 129 }; 130 122 131 } // namespace 123 132 -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r118645 r118890 63 63 { 64 64 TreeScope* lastTreeScope = 0; 65 for (ComposedShadowTree Walker walker(m_relatedTarget.get()); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) {65 for (ComposedShadowTreeParentWalker walker(m_relatedTarget.get()); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) { 66 66 TreeScope* scope = walker.get()->treeScope(); 67 67 // Skips adding a node to the map if treeScope does not change. … … 204 204 bool isSVGElement = m_node->isSVGElement(); 205 205 Vector<EventTarget*> targetStack; 206 for (ComposedShadowTree Walker walker(m_node.get()); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) {206 for (ComposedShadowTreeParentWalker walker(m_node.get()); walker.get(); walker.parentIncludingInsertionPointAndShadowRoot()) { 207 207 Node* node = walker.get(); 208 208 if (isActiveInsertionPoint(node) || targetStack.isEmpty()) -
trunk/Source/WebCore/page/EventHandler.cpp
r118611 r118890 2119 2119 // If the target node is a text node, dispatch on the parent node - rdar://4196646 2120 2120 if (result && result->isTextNode()) { 2121 ComposedShadowTree Walker walker(result);2121 ComposedShadowTreeParentWalker walker(result); 2122 2122 walker.parentIncludingInsertionPointAndShadowRoot(); 2123 2123 result = walker.get();
Note:
See TracChangeset
for help on using the changeset viewer.