Changeset 139325 in webkit
- Timestamp:
- Jan 10, 2013 9:44:05 AM (11 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 added
- 18 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r139289 r139325 1110 1110 1111 1111 dom/ActiveDOMObject.cpp 1112 dom/AncestorChainWalker.cpp 1112 1113 dom/Attr.cpp 1113 1114 dom/BeforeTextInsertedEvent.cpp -
trunk/Source/WebCore/ChangeLog
r139324 r139325 1 2013-01-10 Hajime Morrita <morrita@google.com> 2 3 ComposedShadowTreeWalker shouldn't be exposed to non-ShadowDOM classes 4 https://bugs.webkit.org/show_bug.cgi?id=106505 5 6 Reviewed by Dimitri Glazkov. 7 8 This change hides ComposedShadowTreeWalker from non-ShadowDOM classes by 9 10 - introducing thin wrapper functions on NodeRenderingTraversal and relacing 11 CSTW callsites with it, 12 - replacing ComposedShadowTreeWalker usage with AncestorChainWalker if possible and 13 - moving AncestorChainWalker to its own file and including it on files 14 which needs only AncestorChainWalker. This eliminates ComposedShadowTreeWalker.h inclusions. 15 16 No new tests. No behavior change. 17 18 * CMakeLists.txt: 19 * GNUmakefile.list.am: 20 * Target.pri: 21 * WebCore.gypi: 22 * WebCore.xcodeproj/project.pbxproj: 23 * dom/AncestorChainWalker.cpp: Added. Extracted from ComposedShadowTreeWalker.cpp 24 (WebCore): 25 (WebCore::AncestorChainWalker::AncestorChainWalker): 26 (WebCore::AncestorChainWalker::parent): 27 * dom/AncestorChainWalker.h: Added. Extracted from ComposedShadowTreeWalker.h 28 (WebCore): 29 (AncestorChainWalker): 30 (WebCore::AncestorChainWalker::get): 31 (WebCore::AncestorChainWalker::crossingInsertionPoint): 32 * dom/ComposedShadowTreeWalker.cpp: 33 * dom/ComposedShadowTreeWalker.h: 34 * dom/DOMAllInOne.cpp: 35 * dom/ElementShadow.h: 36 (WebCore::shadowOfParent): 37 (WebCore): 38 * dom/EventDispatcher.cpp: 39 * dom/Node.cpp: 40 * dom/NodeRenderingTraversal.cpp: 41 (WebCore::NodeRenderingTraversal::nextInScope): 42 (NodeRenderingTraversal): 43 (WebCore::NodeRenderingTraversal::previousInScope): Added. 44 (WebCore::NodeRenderingTraversal::parentInScope): Added. 45 (WebCore::NodeRenderingTraversal::lastChildInScope): Added. 46 * dom/NodeRenderingTraversal.h: 47 (NodeRenderingTraversal): 48 * dom/TreeScope.cpp: 49 * html/HTMLLIElement.cpp: 50 (WebCore::HTMLLIElement::attach): 51 * page/EventHandler.cpp: 52 * page/FocusController.cpp: Replacing CSTW with NRT 53 (WebCore): 54 (WebCore::FocusNavigationScope::focusNavigationScopeOf): 55 (WebCore::FocusController::findNodeWithExactTabIndex): 56 (WebCore::nextNodeWithGreaterTabIndex): 57 (WebCore::previousNodeWithLowerTabIndex): 58 (WebCore::FocusController::nextFocusableNode): 59 (WebCore::FocusController::previousFocusableNode): 60 1 61 2013-01-10 Zan Dobersek <zandobersek@gmail.com> 2 62 -
trunk/Source/WebCore/GNUmakefile.list.am
r139289 r139325 2697 2697 Source/WebCore/dom/ActiveDOMObject.cpp \ 2698 2698 Source/WebCore/dom/ActiveDOMObject.h \ 2699 Source/WebCore/dom/AncestorChainWalker.cpp \ 2700 Source/WebCore/dom/AncestorChainWalker.h \ 2699 2701 Source/WebCore/dom/Attr.cpp \ 2700 2702 Source/WebCore/dom/Attr.h \ -
trunk/Source/WebCore/Target.pri
r139289 r139325 336 336 css/WebKitCSSViewportRule.cpp \ 337 337 dom/ActiveDOMObject.cpp \ 338 dom/AncestorChainWalker.cpp \ 338 339 dom/Attr.cpp \ 339 340 dom/BeforeTextInsertedEvent.cpp \ … … 1543 1544 css/WebKitCSSViewportRule.h \ 1544 1545 dom/ActiveDOMObject.h \ 1546 dom/AncestorChainWalker.h \ 1545 1547 dom/Attr.h \ 1546 1548 dom/Attribute.h \ -
trunk/Source/WebCore/WebCore.gypi
r139289 r139325 2705 2705 'webcore_dom_files': [ 2706 2706 'dom/ActiveDOMObject.cpp', 2707 'dom/AncestorChainWalker.cpp', 2708 'dom/AncestorChainWalker.h', 2707 2709 'dom/Attr.cpp', 2708 2710 'dom/BeforeLoadEvent.h', -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r139289 r139325 3933 3933 A781C6A713828B5D0012A62A /* DocumentMarker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A781C6A613828B5D0012A62A /* DocumentMarker.cpp */; }; 3934 3934 A784941B0B5FE507001E237A /* Clipboard.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A784941A0B5FE507001E237A /* Clipboard.cpp */; }; 3935 A78CDD2E169E91A1009136F3 /* AncestorChainWalker.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A75CBE43169E913D0003A60F /* AncestorChainWalker.cpp */; }; 3936 A78CDD30169E91A4009136F3 /* AncestorChainWalker.h in Headers */ = {isa = PBXBuildFile; fileRef = A75CBE44169E913D0003A60F /* AncestorChainWalker.h */; }; 3935 3937 A78E526F1346BD1700AD9C31 /* MeterShadowElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A78E526D1346BD1700AD9C31 /* MeterShadowElement.cpp */; }; 3936 3938 A78E52701346BD1700AD9C31 /* MeterShadowElement.h in Headers */ = {isa = PBXBuildFile; fileRef = A78E526E1346BD1700AD9C31 /* MeterShadowElement.h */; }; … … 11284 11286 A73F95FD12C97BFE0031AAF9 /* RoundedRect.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = RoundedRect.h; sourceTree = "<group>"; }; 11285 11287 A74BB76A13BDA86300FF7BF0 /* ExceptionCodePlaceholder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ExceptionCodePlaceholder.h; sourceTree = "<group>"; }; 11288 A75CBE43169E913D0003A60F /* AncestorChainWalker.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = AncestorChainWalker.cpp; sourceTree = "<group>"; }; 11289 A75CBE44169E913D0003A60F /* AncestorChainWalker.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = AncestorChainWalker.h; sourceTree = "<group>"; }; 11286 11290 A75E497410752ACB00C9B896 /* SerializedScriptValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SerializedScriptValue.h; sourceTree = "<group>"; }; 11287 11291 A75E497510752ACB00C9B896 /* SerializedScriptValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SerializedScriptValue.cpp; sourceTree = "<group>"; }; … … 21991 21995 E1C4DE6D0EA75C650023CCD6 /* ActiveDOMObject.cpp */, 21992 21996 E1C4DE680EA75C1E0023CCD6 /* ActiveDOMObject.h */, 21997 A75CBE43169E913D0003A60F /* AncestorChainWalker.cpp */, 21998 A75CBE44169E913D0003A60F /* AncestorChainWalker.h */, 21993 21999 A8C4A7FC09D563270003AC8D /* Attr.cpp */, 21994 22000 A8C4A7FB09D563270003AC8D /* Attr.h */, … … 22764 22770 CE7B2DB31586ABAD0098B3FA /* AlternativeTextUIController.h in Headers */, 22765 22771 FD31603E12B0267600C1A359 /* AnalyserNode.h in Headers */, 22772 A78CDD30169E91A4009136F3 /* AncestorChainWalker.h in Headers */, 22766 22773 490707E71219C04300D90E51 /* ANGLEWebKitBridge.h in Headers */, 22767 22774 49E912AB0EFAC906009D0CAF /* Animation.h in Headers */, … … 26445 26452 CE7B2DB41586ABAD0098B3FA /* AlternativeTextUIController.mm in Sources */, 26446 26453 FD31603D12B0267600C1A359 /* AnalyserNode.cpp in Sources */, 26454 A78CDD2E169E91A1009136F3 /* AncestorChainWalker.cpp in Sources */, 26447 26455 490707E61219C04300D90E51 /* ANGLEWebKitBridge.cpp in Sources */, 26448 26456 49E912AA0EFAC906009D0CAF /* Animation.cpp in Sources */, -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
r139128 r139325 46 46 } 47 47 48 static inline ElementShadow* shadowOfParent(const Node* node)49 {50 if (!node)51 return 0;52 if (Node* parent = node->parentNode())53 if (parent->isElementNode())54 return toElement(parent)->shadow();55 return 0;56 }57 58 48 static inline bool nodeCanBeDistributed(const Node* node) 59 49 { … … 323 313 } 324 314 325 AncestorChainWalker::AncestorChainWalker(const Node* node)326 : m_node(node)327 , m_distributedNode(node)328 , m_isCrossingInsertionPoint(false)329 {330 ASSERT(node);331 }332 333 void AncestorChainWalker::parent()334 {335 ASSERT(m_node);336 ASSERT(m_distributedNode);337 if (ElementShadow* shadow = shadowOfParent(m_node)) {338 if (InsertionPoint* insertionPoint = shadow->distributor().findInsertionPointFor(m_distributedNode)) {339 m_node = insertionPoint;340 m_isCrossingInsertionPoint = true;341 return;342 }343 }344 if (!m_node->isShadowRoot()) {345 m_node = m_node->parentNode();346 if (!(m_node && m_node->isShadowRoot() && ScopeContentDistribution::assignedTo(toShadowRoot(m_node))))347 m_distributedNode = m_node;348 m_isCrossingInsertionPoint = false;349 return;350 }351 352 const ShadowRoot* shadowRoot = toShadowRoot(m_node);353 if (InsertionPoint* insertionPoint = ScopeContentDistribution::assignedTo(shadowRoot)) {354 m_node = insertionPoint;355 m_isCrossingInsertionPoint = true;356 return;357 }358 m_node = shadowRoot->host();359 m_distributedNode = m_node;360 m_isCrossingInsertionPoint = false;361 }362 363 315 } // namespace -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.h
r137715 r139325 142 142 } 143 143 144 class AncestorChainWalker {145 public:146 explicit AncestorChainWalker(const Node*);147 void parent();148 Node* get() const { return const_cast<Node*>(m_node); }149 bool crossingInsertionPoint() { return m_isCrossingInsertionPoint; }150 151 private:152 const Node* m_node;153 const Node* m_distributedNode;154 bool m_isCrossingInsertionPoint;155 };156 157 144 } // namespace 158 145 -
trunk/Source/WebCore/dom/DOMAllInOne.cpp
r138515 r139325 27 27 28 28 #include "ActiveDOMObject.cpp" 29 #include "AncestorChainWalker.cpp" 29 30 #include "Attr.cpp" 30 31 #include "BeforeTextInsertedEvent.cpp" -
trunk/Source/WebCore/dom/ElementShadow.h
r139269 r139325 131 131 }; 132 132 133 inline ElementShadow* shadowOfParent(const Node* node) 134 { 135 if (!node) 136 return 0; 137 if (Node* parent = node->parentNode()) 138 if (parent->isElementNode()) 139 return toElement(parent)->shadow(); 140 return 0; 141 } 142 143 133 144 } // namespace 134 145 -
trunk/Source/WebCore/dom/EventDispatcher.cpp
r137680 r139325 27 27 #include "EventDispatcher.h" 28 28 29 #include " ComposedShadowTreeWalker.h"29 #include "AncestorChainWalker.h" 30 30 #include "ContainerNode.h" 31 31 #include "ElementShadow.h" -
trunk/Source/WebCore/dom/Node.cpp
r139273 r139325 41 41 #include "ChildNodeList.h" 42 42 #include "ClassNodeList.h" 43 #include "ComposedShadowTreeWalker.h"44 43 #include "ContainerNodeAlgorithms.h" 45 44 #include "ContextMenuController.h" -
trunk/Source/WebCore/dom/NodeRenderingTraversal.cpp
r138909 r139325 93 93 } 94 94 95 Node* nextInScope(const Node* node) 96 { 97 // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339 98 ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary); 99 walker.next(); 100 return walker.get(); 101 } 102 103 Node* previousInScope(const Node* node) 104 { 105 // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339 106 ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary); 107 walker.previous(); 108 return walker.get(); 109 } 110 111 Node* parentInScope(const Node* node) 112 { 113 // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339 114 ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary); 115 walker.parent(); 116 return walker.get(); 117 } 118 119 Node* lastChildInScope(const Node* node) 120 { 121 // FIXME: ComposedShadowTreeWalker shouldn't be used when !ENABLE(SHADOW_DOM) https://bugs.webkit.org/show_bug.cgi?id=103339 122 ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary); 123 walker.lastChild(); 124 return walker.get(); 125 } 126 95 127 } 96 128 -
trunk/Source/WebCore/dom/NodeRenderingTraversal.h
r137715 r139325 72 72 Node* previousSiblingSlow(const Node*); 73 73 74 Node* nextInScope(const Node*); 75 Node* previousInScope(const Node*); 76 Node* parentInScope(const Node*); 77 Node* lastChildInScope(const Node*); 74 78 75 79 inline ContainerNode* parent(const Node* node, ParentDetails* details) -
trunk/Source/WebCore/dom/TreeScope.cpp
r139310 r139325 28 28 #include "TreeScope.h" 29 29 30 #include " ComposedShadowTreeWalker.h"30 #include "AncestorChainWalker.h" 31 31 #include "ContainerNode.h" 32 32 #include "DOMSelection.h" -
trunk/Source/WebCore/html/HTMLLIElement.cpp
r135069 r139325 24 24 #include "HTMLLIElement.h" 25 25 26 #include "AncestorChainWalker.h" 26 27 #include "Attribute.h" 27 28 #include "CSSPropertyNames.h" 28 29 #include "CSSValueKeywords.h" 29 #include "ComposedShadowTreeWalker.h"30 30 #include "HTMLNames.h" 31 31 #include "RenderListItem.h" … … 97 97 // Find the enclosing list node. 98 98 Node* listNode = 0; 99 ComposedShadowTreeWalker walker(this);99 AncestorChainWalker walker(this); 100 100 while (!listNode) { 101 101 walker.parent(); -
trunk/Source/WebCore/page/EventHandler.cpp
r139044 r139325 30 30 31 31 #include "AXObjectCache.h" 32 #include "AncestorChainWalker.h" 32 33 #include "AutoscrollController.h" 33 34 #include "CachedImage.h" 34 35 #include "Chrome.h" 35 36 #include "ChromeClient.h" 36 #include "ComposedShadowTreeWalker.h"37 37 #include "Cursor.h" 38 38 #include "CursorList.h" -
trunk/Source/WebCore/page/FocusController.cpp
r137406 r139325 30 30 #include "AXObjectCache.h" 31 31 #include "Chrome.h" 32 #include "ComposedShadowTreeWalker.h"33 32 #include "Document.h" 34 33 #include "Editor.h" … … 49 48 #include "HitTestResult.h" 50 49 #include "KeyboardEvent.h" 50 #include "NodeRenderingTraversal.h" 51 51 #include "NodeTraversal.h" 52 52 #include "Page.h" … … 67 67 using namespace std; 68 68 69 static inline ComposedShadowTreeWalker walkerFrom(const Node* node)70 {71 return ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);72 }73 74 static inline ComposedShadowTreeWalker walkerFromNext(const Node* node)75 {76 ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);77 walker.next();78 return walker;79 }80 81 static inline ComposedShadowTreeWalker walkerFromPrevious(const Node* node)82 {83 ComposedShadowTreeWalker walker = ComposedShadowTreeWalker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);84 walker.previous();85 return walker;86 }87 88 static inline Node* nextNode(const Node* node)89 {90 return walkerFromNext(node).get();91 }92 93 static inline Node* previousNode(const Node* node)94 {95 return walkerFromPrevious(node).get();96 }97 98 69 FocusNavigationScope::FocusNavigationScope(TreeScope* treeScope) 99 70 : m_rootTreeScope(treeScope) … … 121 92 { 122 93 ASSERT(node); 123 ComposedShadowTreeWalker walker(node, ComposedShadowTreeWalker::DoNotCrossUpperBoundary);124 94 Node* root = node; 125 while (walker.get()) { 126 root = walker.get(); 127 walker.parent(); 128 } 95 for (Node* n = node; n; n = NodeRenderingTraversal::parentInScope(n)) 96 root = n; 129 97 // The result is not always a ShadowRoot nor a DocumentNode since 130 98 // a starting node is in an orphaned tree in composed shadow tree. … … 450 418 { 451 419 // Search is inclusive of start 452 for (ComposedShadowTreeWalker walker = walkerFrom(start); walker.get(); direction == FocusDirectionForward ? walker.next() : walker.previous()) { 453 if (shouldVisit(walker.get(), event) && adjustedTabIndex(walker.get(), event) == tabIndex) 454 return walker.get(); 420 using namespace NodeRenderingTraversal; 421 for (Node* node = start; node; node = direction == FocusDirectionForward ? nextInScope(node) : previousInScope(node)) { 422 if (shouldVisit(node, event) && adjustedTabIndex(node, event) == tabIndex) 423 return node; 455 424 } 456 425 return 0; … … 462 431 int winningTabIndex = std::numeric_limits<short>::max() + 1; 463 432 Node* winner = 0; 464 for (ComposedShadowTreeWalker walker = walkerFrom(start); walker.get(); walker.next()) { 465 Node* node = walker.get(); 433 for (Node* node = start; node; node = NodeRenderingTraversal::nextInScope(node)) { 466 434 if (shouldVisit(node, event) && node->tabIndex() > tabIndex && node->tabIndex() < winningTabIndex) { 467 435 winner = node; … … 478 446 int winningTabIndex = 0; 479 447 Node* winner = 0; 480 for (ComposedShadowTreeWalker walker = walkerFrom(start); walker.get(); walker.previous()) { 481 Node* node = walker.get(); 448 for (Node* node = start; node; node = NodeRenderingTraversal::previousInScope(node)) { 482 449 int currentTabIndex = adjustedTabIndex(node, event); 483 450 if ((shouldVisit(node, event) || isNonFocusableShadowHost(node, event)) && currentTabIndex < tabIndex && currentTabIndex > winningTabIndex) { … … 491 458 Node* FocusController::nextFocusableNode(FocusNavigationScope scope, Node* start, KeyboardEvent* event) 492 459 { 460 using namespace NodeRenderingTraversal; 461 493 462 if (start) { 494 463 int tabIndex = adjustedTabIndex(start, event); 495 464 // If a node is excluded from the normal tabbing cycle, the next focusable node is determined by tree order 496 465 if (tabIndex < 0) { 497 for ( ComposedShadowTreeWalker walker = walkerFromNext(start); walker.get(); walker.next()) {498 if (shouldVisit( walker.get(), event) && adjustedTabIndex(walker.get(), event) >= 0)499 return walker.get();466 for (Node* node = nextInScope(start); node; node = nextInScope(node)) { 467 if (shouldVisit(node, event) && adjustedTabIndex(node, event) >= 0) 468 return node; 500 469 } 501 470 } 502 471 503 472 // First try to find a node with the same tabindex as start that comes after start in the scope. 504 if (Node* winner = findNodeWithExactTabIndex(next Node(start), tabIndex, event, FocusDirectionForward))473 if (Node* winner = findNodeWithExactTabIndex(nextInScope(start), tabIndex, event, FocusDirectionForward)) 505 474 return winner; 506 475 … … 523 492 Node* FocusController::previousFocusableNode(FocusNavigationScope scope, Node* start, KeyboardEvent* event) 524 493 { 494 using namespace NodeRenderingTraversal; 495 525 496 Node* last = 0; 526 for ( ComposedShadowTreeWalker walker = walkerFrom(scope.rootNode()); walker.get(); walker.lastChild())527 last = walker.get();497 for (Node* node = scope.rootNode(); node; node = lastChildInScope(node)) 498 last = node; 528 499 ASSERT(last); 529 500 … … 533 504 int startingTabIndex; 534 505 if (start) { 535 startingNode = previous Node(start);506 startingNode = previousInScope(start); 536 507 startingTabIndex = adjustedTabIndex(start, event); 537 508 } else { … … 542 513 // However, if a node is excluded from the normal tabbing cycle, the previous focusable node is determined by tree order 543 514 if (startingTabIndex < 0) { 544 for ( ComposedShadowTreeWalker walker = walkerFrom(startingNode); walker.get(); walker.previous()) {545 if (shouldVisit( walker.get(), event) && adjustedTabIndex(walker.get(), event) >= 0)546 return walker.get();515 for (Node* node = startingNode; node; node = previousInScope(node)) { 516 if (shouldVisit(node, event) && adjustedTabIndex(node, event) >= 0) 517 return node; 547 518 } 548 519 }
Note: See TracChangeset
for help on using the changeset viewer.