Changeset 116974 in webkit
- Timestamp:
- May 14, 2012 11:54:22 AM (12 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 1 added
- 1 deleted
- 16 edited
- 1 moved
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/CMakeLists.txt
r116840 r116974 902 902 html/parser/XSSAuditor.cpp 903 903 904 html/shadow/ContentDistributor.cpp 904 905 html/shadow/ContentSelectorQuery.cpp 905 906 html/shadow/DetailsMarkerControl.cpp 906 907 html/shadow/HTMLContentElement.cpp 907 html/shadow/HTMLContentSelector.cpp908 908 html/shadow/HTMLShadowElement.cpp 909 909 html/shadow/InsertionPoint.cpp -
trunk/Source/WebCore/ChangeLog
r116970 r116974 1 2012-05-14 MORITA Hajime <morrita@google.com> 2 3 [Shadow DOM][Refactoring] HTMLContentSelector family should have better name 4 https://bugs.webkit.org/show_bug.cgi?id=86064 5 6 Reviewed by Dimitri Glazkov. 7 8 This change renames classes around shadow content distribution. 9 - Renamed HTMLContentSelector to ContentDistributor 10 - Renamed HTMLContentSelectionList to ContentDistribution 11 - Renamed HTMLContentSelection to ContentDistribution::Item 12 - Inlined HTMLContentSelectionSet into ContentDistributor 13 14 Associated rename and inlining are also happening for method names. 15 16 No new tests. No behavior change. 17 18 * CMakeLists.txt: 19 * GNUmakefile.list.am: 20 * Target.pri: 21 * WebCore.gypi: 22 * WebCore.vcproj/WebCore.vcproj: 23 * WebCore.xcodeproj/project.pbxproj: 24 * dom/ComposedShadowTreeWalker.cpp: 25 (WebCore::ComposedShadowTreeWalker::traverseNode): 26 (WebCore::ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint): 27 (WebCore::ComposedShadowTreeWalker::traverseParent): 28 * dom/ElementShadow.cpp: 29 (WebCore::ElementShadow::ElementShadow): 30 (WebCore::ElementShadow::attach): 31 (WebCore::ElementShadow::insertionPointFor): 32 (WebCore::ElementShadow::distributionItemFor): 33 (WebCore::ElementShadow::recalcStyle): 34 (WebCore::ElementShadow::needsRedistributing): 35 (WebCore::ElementShadow::hostChildrenChanged): 36 (WebCore::ElementShadow::setNeedsRedistributing): 37 * dom/ElementShadow.h: 38 (WebCore): 39 (ElementShadow): 40 (WebCore::ElementShadow::distributor): 41 (WebCore::ElementShadow::clearNeedsRedistributing): 42 * dom/NodeRenderingContext.cpp: 43 (WebCore::NodeRenderingContext::NodeRenderingContext): 44 (WebCore::nextRendererOfInsertionPoint): 45 (WebCore::previousRendererOfInsertionPoint): 46 (WebCore::firstRendererOfInsertionPoint): 47 (WebCore::lastRendererOfInsertionPoint): 48 * dom/ShadowRoot.cpp: 49 * dom/ShadowRoot.h: 50 (WebCore): 51 * html/shadow/ContentDistributor.cpp: Renamed from Source/WebCore/html/shadow/HTMLContentSelector.cpp. 52 (WebCore): 53 (WebCore::ContentDistribution::ContentDistribution): 54 (WebCore::ContentDistribution::~ContentDistribution): 55 (WebCore::ContentDistribution::find): 56 (WebCore::ContentDistribution::clear): 57 (WebCore::ContentDistribution::append): 58 (WebCore::ContentDistributor::ContentDistributor): 59 (WebCore::ContentDistributor::~ContentDistributor): 60 (WebCore::ContentDistributor::distribute): 61 (WebCore::ContentDistributor::clearDistribution): 62 (WebCore::ContentDistributor::findFor): 63 (WebCore::ContentDistributor::findInsertionPointFor): 64 (WebCore::ContentDistributor::willDistribute): 65 (WebCore::ContentDistributor::didDistribute): 66 (WebCore::ContentDistributor::preparePoolFor): 67 * html/shadow/ContentDistributor.h: Added. 68 (WebCore): 69 (ContentDistribution): 70 (Item): 71 (WebCore::ContentDistribution::Item::insertionPoint): 72 (WebCore::ContentDistribution::Item::node): 73 (WebCore::ContentDistribution::Item::next): 74 (WebCore::ContentDistribution::Item::previous): 75 (WebCore::ContentDistribution::Item::create): 76 (WebCore::ContentDistribution::Item::Item): 77 (WebCore::ContentDistribution::first): 78 (WebCore::ContentDistribution::last): 79 (WebCore::ContentDistribution::firstNode): 80 (WebCore::ContentDistribution::lastNode): 81 (WebCore::ContentDistribution::isEmpty): 82 (ContentDistributor): 83 (Translator): 84 (WebCore::ContentDistributor::Translator::hash): 85 (WebCore::ContentDistributor::Translator::equal): 86 (WebCore::ContentDistributor::Hash::hash): 87 (WebCore::ContentDistributor::Hash::equal): 88 (Hash): 89 (WebCore::ContentDistributor::inDistribution): 90 (WebCore::ContentDistributor::poolIsReady): 91 * html/shadow/HTMLContentElement.cpp: 92 (WebCore::HTMLContentElement::parseAttribute): 93 * html/shadow/HTMLContentSelector.h: Removed. 94 * html/shadow/InsertionPoint.cpp: 95 (WebCore::InsertionPoint::InsertionPoint): 96 (WebCore::InsertionPoint::detach): 97 (WebCore::InsertionPoint::distributeHostChildren): 98 (WebCore::InsertionPoint::clearDistribution): 99 (WebCore::InsertionPoint::attachDistributedNode): 100 (WebCore::InsertionPoint::assignShadowRoot): 101 (WebCore::InsertionPoint::clearAssignment): 102 * html/shadow/InsertionPoint.h: 103 (WebCore::InsertionPoint::distribution): 104 (WebCore::InsertionPoint::hasDistribution): 105 1 106 2012-05-14 Sheriff Bot <webkit.review.bot@gmail.com> 2 107 -
trunk/Source/WebCore/GNUmakefile.list.am
r116840 r116974 2503 2503 Source/WebCore/html/shadow/CalendarPickerElement.cpp \ 2504 2504 Source/WebCore/html/shadow/CalendarPickerElement.h \ 2505 Source/WebCore/html/shadow/ContentDistributor.cpp \ 2506 Source/WebCore/html/shadow/ContentDistributor.h \ 2505 2507 Source/WebCore/html/shadow/ContentSelectorQuery.cpp \ 2506 2508 Source/WebCore/html/shadow/ContentSelectorQuery.h \ … … 2509 2511 Source/WebCore/html/shadow/HTMLContentElement.cpp \ 2510 2512 Source/WebCore/html/shadow/HTMLContentElement.h \ 2511 Source/WebCore/html/shadow/HTMLContentSelector.cpp \2512 Source/WebCore/html/shadow/HTMLContentSelector.h \2513 2513 Source/WebCore/html/shadow/InsertionPoint.cpp \ 2514 2514 Source/WebCore/html/shadow/InsertionPoint.h \ -
trunk/Source/WebCore/Target.pri
r116840 r116974 873 873 html/parser/TextViewSourceParser.cpp \ 874 874 html/parser/XSSAuditor.cpp \ 875 html/shadow/ContentDistributor.cpp \ 875 876 html/shadow/ContentSelectorQuery.cpp \ 876 877 html/shadow/DetailsMarkerControl.cpp \ 877 878 html/shadow/HTMLContentElement.cpp \ 878 html/shadow/HTMLContentSelector.cpp \879 879 html/shadow/HTMLShadowElement.cpp \ 880 880 html/shadow/InsertionPoint.cpp \ … … 1999 1999 html/parser/HTMLViewSourceParser.h \ 2000 2000 html/parser/XSSAuditor.h \ 2001 html/shadow/ContentDistributor.h \ 2001 2002 html/shadow/ContentSelectorQuery.h \ 2002 2003 html/shadow/HTMLContentElement.h \ 2003 html/shadow/HTMLContentSelector.h \2004 2004 html/shadow/HTMLShadowElement.h \ 2005 2005 html/shadow/MediaControlElements.h \ -
trunk/Source/WebCore/WebCore.gypi
r116854 r116974 5793 5793 'html/shadow/CalendarPickerElement.cpp', 5794 5794 'html/shadow/CalendarPickerElement.h', 5795 'html/shadow/ContentDistributor.cpp', 5796 'html/shadow/ContentDistributor.h', 5795 5797 'html/shadow/ContentSelectorQuery.cpp', 5796 5798 'html/shadow/ContentSelectorQuery.h', … … 5799 5801 'html/shadow/HTMLContentElement.cpp', 5800 5802 'html/shadow/HTMLContentElement.h', 5801 'html/shadow/HTMLContentSelector.cpp',5802 'html/shadow/HTMLContentSelector.h',5803 5803 'html/shadow/HTMLShadowElement.cpp', 5804 5804 'html/shadow/HTMLShadowElement.h', -
trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj
r116843 r116974 62742 62742 </File> 62743 62743 <File 62744 RelativePath="..\html\shadow\HTMLContentSelector.cpp"62745 >62746 </File>62747 <File62748 RelativePath="..\html\shadow\HTMLContentSelector.h"62749 >62750 </File>62751 <File62752 62744 RelativePath="..\html\shadow\HTMLShadowElement.cpp" 62753 62745 > … … 62800 62792 /> 62801 62793 </FileConfiguration> 62794 </File> 62795 <File 62796 RelativePath="..\html\shadow\ContentDistributor.cpp" 62797 > 62798 </File> 62799 <File 62800 RelativePath="..\html\shadow\ContentDistributor.h" 62801 > 62802 62802 </File> 62803 62803 <File -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r116840 r116974 1585 1585 578DA20E1520EB8C006141C1 /* InspectorFrontend.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F4F5FFC11CBD30100A186BF /* InspectorFrontend.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1586 1586 578DA20F1520EBA3006141C1 /* InspectorTypeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 573D134614CE39FF0057ABCA /* InspectorTypeBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; }; 1587 57B791A314C6A62900F202D1 /* HTMLContentSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B7919F14C6A62900F202D1 /* HTMLContentSelector.cpp */; };1588 57B791A414C6A62900F202D1 /* HTMLContentSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A014C6A62900F202D1 /* HTMLContentSelector.h */; };1587 57B791A314C6A62900F202D1 /* ContentDistributor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */; }; 1588 57B791A414C6A62900F202D1 /* ContentDistributor.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A014C6A62900F202D1 /* ContentDistributor.h */; }; 1589 1589 57B791A514C6A62900F202D1 /* ContentSelectorQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */; }; 1590 1590 57B791A614C6A62900F202D1 /* ContentSelectorQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */; }; … … 8602 8602 5740E83A1532DE1700760628 /* TreeScopeAdjuster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TreeScopeAdjuster.cpp; sourceTree = "<group>"; }; 8603 8603 5740E83B1532DE1700760628 /* TreeScopeAdjuster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeScopeAdjuster.h; sourceTree = "<group>"; }; 8604 57B7919F14C6A62900F202D1 /* HTMLContentSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLContentSelector.cpp; sourceTree = "<group>"; };8605 57B791A014C6A62900F202D1 /* HTMLContentSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLContentSelector.h; sourceTree = "<group>"; };8604 57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentDistributor.cpp; sourceTree = "<group>"; }; 8605 57B791A014C6A62900F202D1 /* ContentDistributor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentDistributor.h; sourceTree = "<group>"; }; 8606 8606 57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentSelectorQuery.cpp; sourceTree = "<group>"; }; 8607 8607 57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentSelectorQuery.h; sourceTree = "<group>"; }; … … 14618 14618 isa = PBXGroup; 14619 14619 children = ( 14620 57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */, 14621 57B791A014C6A62900F202D1 /* ContentDistributor.h */, 14620 14622 57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */, 14621 14623 57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */, … … 14625 14627 57B791A814C6A63300F202D1 /* HTMLContentElement.h */, 14626 14628 A7B7749614CF6353004044BB /* HTMLContentElement.idl */, 14627 57B7919F14C6A62900F202D1 /* HTMLContentSelector.cpp */,14628 57B791A014C6A62900F202D1 /* HTMLContentSelector.h */,14629 14629 4ABDFF0714DBE312004D117D /* HTMLShadowElement.cpp */, 14630 14630 4ABDFF0814DBE312004D117D /* HTMLShadowElement.h */, … … 21901 21901 E1A1470811102B1500EEC0F3 /* ContainerNodeAlgorithms.h in Headers */, 21902 21902 BC5EB9810E82072500B25965 /* ContentData.h in Headers */, 21903 57B791A414C6A62900F202D1 /* ContentDistributor.h in Headers */, 21903 21904 59102FBC14327D3B003C9D04 /* ContentSearchUtils.h in Headers */, 21904 21905 97C471DC12F925BD0086354B /* ContentSecurityPolicy.h in Headers */, … … 22942 22943 977B3865122883E900B81FF8 /* HTMLConstructionSite.h in Headers */, 22943 22944 57B791AA14C6A63300F202D1 /* HTMLContentElement.h in Headers */, 22944 57B791A414C6A62900F202D1 /* HTMLContentSelector.h in Headers */,22945 22945 E1A31663134BCAE8007C9A4F /* HTMLConverter.h in Headers */, 22946 22946 F5C041DB0FFCA7CE00839D4A /* HTMLDataListElement.h in Headers */, … … 25408 25408 A7A78CD51532BA62006C21E4 /* ContainerNodeAlgorithms.cpp in Sources */, 25409 25409 BC5EB9800E82072500B25965 /* ContentData.cpp in Sources */, 25410 57B791A314C6A62900F202D1 /* ContentDistributor.cpp in Sources */, 25410 25411 59102FBB14327D3B003C9D04 /* ContentSearchUtils.cpp in Sources */, 25411 25412 97C471DB12F925BD0086354B /* ContentSecurityPolicy.cpp in Sources */, … … 26078 26079 977B3864122883E900B81FF8 /* HTMLConstructionSite.cpp in Sources */, 26079 26080 57B791A914C6A63300F202D1 /* HTMLContentElement.cpp in Sources */, 26080 57B791A314C6A62900F202D1 /* HTMLContentSelector.cpp in Sources */,26081 26081 5D4F51DF132725480016F541 /* HTMLConverter.mm in Sources */, 26082 26082 F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */, -
trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp
r116730 r116974 28 28 #include "ComposedShadowTreeWalker.h" 29 29 30 #include "ContentDistributor.h" 30 31 #include "Element.h" 31 32 #include "ElementShadow.h" 32 #include "HTMLContentSelector.h"33 33 #include "InsertionPoint.h" 34 35 34 36 35 namespace WebCore { … … 115 114 ASSERT(node); 116 115 if (isInsertionPoint(node)) { 117 const HTMLContentSelectionList* selectionList = toInsertionPoint(node)->selections();118 if ( HTMLContentSelection* selection = (direction == TraversalDirectionForward ? selectionList->first() : selectionList->last()))119 return traverseNode( selection->node(), direction);116 const ContentDistribution* distribution = toInsertionPoint(node)->distribution(); 117 if (Node* next = (direction == TraversalDirectionForward ? distribution->firstNode() : distribution->lastNode())) 118 return traverseNode(next, direction); 120 119 return traverseLightChildren(node, direction); 121 120 } … … 143 142 if (!shadow) 144 143 return traverseSiblingInCurrentTree(node, direction); 145 HTMLContentSelection* selection = shadow->selectionFor(node);146 if (! selection)144 ContentDistribution::Item* item = shadow->distributionItemFor(node); 145 if (!item) 147 146 return traverseSiblingInCurrentTree(node, direction); 148 if ( HTMLContentSelection* nextSelection = (direction == TraversalDirectionForward ? selection->next() : selection->previous()))149 return traverseNode(next Selection->node(), direction);150 return traverseSiblingOrBackToInsertionPoint( selection->insertionPoint(), direction);147 if (ContentDistribution::Item* nextItem = (direction == TraversalDirectionForward ? item->next() : item->previous())) 148 return traverseNode(nextItem->node(), direction); 149 return traverseSiblingOrBackToInsertionPoint(item->insertionPoint(), direction); 151 150 } 152 151 … … 205 204 } 206 205 if (ElementShadow* shadow = shadowOfParent(node)) { 207 if ( HTMLContentSelection* selection = shadow->selectionFor(node))208 return traverseParent( selection->insertionPoint());206 if (InsertionPoint* insertionPoint = shadow->insertionPointFor(node)) 207 return traverseParent(insertionPoint); 209 208 } 210 209 return traverseParentInCurrentTree(node); -
trunk/Source/WebCore/dom/ElementShadow.cpp
r116730 r116974 41 41 42 42 ElementShadow::ElementShadow() 43 : m_needsRe calculateContent(false)43 : m_needsRedistributing(false) 44 44 { 45 45 } … … 120 120 void ElementShadow::attach() 121 121 { 122 // Children of m_selector ispopulated lazily in123 // ensure Selector(), and here we just ensure that it is in clean state.124 ASSERT(! selector().hasPopulated());125 126 selector().willSelect();122 // The pool nodes are populated lazily in 123 // ensureDistributor(), and here we just ensure that it is in clean state. 124 ASSERT(!distributor().poolIsReady()); 125 126 distributor().willDistribute(); 127 127 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { 128 128 if (!root->attached()) 129 129 root->attach(); 130 130 } 131 selector().didSelect();131 distributor().didDistribute(); 132 132 } 133 133 … … 165 165 } 166 166 167 HTMLContentSelection* found = selector().findFor(node); 168 if (!found) 169 return 0; 170 return found->insertionPoint(); 171 } 172 173 HTMLContentSelection* ElementShadow::selectionFor(const Node* node) const 174 { 175 return m_selector.findFor(node); 167 return distributor().findInsertionPointFor(node); 168 } 169 170 ContentDistribution::Item* ElementShadow::distributionItemFor(const Node* node) const 171 { 172 return m_distributor.findFor(node); 176 173 } 177 174 … … 208 205 return; 209 206 210 if (needsRe attachHostChildrenAndShadow())207 if (needsRedistributing()) 211 208 reattachHostChildrenAndShadow(); 212 209 else { … … 223 220 } 224 221 225 clearNeedsRe attachHostChildrenAndShadow();222 clearNeedsRedistributing(); 226 223 for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { 227 224 root->clearNeedsStyleRecalc(); … … 230 227 } 231 228 232 bool ElementShadow::needsRe attachHostChildrenAndShadow()233 { 234 return m_needsRe calculateContent|| (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint());229 bool ElementShadow::needsRedistributing() 230 { 231 return m_needsRedistributing || (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint()); 235 232 } 236 233 … … 243 240 244 241 // This results in forced detaching/attaching of the shadow render tree. See ShadowRoot::recalcStyle(). 245 setNeedsRe attachHostChildrenAndShadow();246 } 247 248 void ElementShadow::setNeedsRe attachHostChildrenAndShadow()249 { 250 m_needsRe calculateContent= true;242 setNeedsRedistributing(); 243 } 244 245 void ElementShadow::setNeedsRedistributing() 246 { 247 m_needsRedistributing = true; 251 248 252 249 host()->setNeedsStyleRecalc(); -
trunk/Source/WebCore/dom/ElementShadow.h
r116730 r116974 28 28 #define ElementShadow_h 29 29 30 #include "ContentDistributor.h" 30 31 #include "ExceptionCode.h" 31 #include "HTMLContentSelector.h"32 32 #include "ShadowRoot.h" 33 33 #include <wtf/DoublyLinkedList.h> … … 41 41 class Node; 42 42 class Element; 43 class InsertionPoint;44 43 class TreeScope; 45 class HTMLContentSelection;46 44 47 45 class ElementShadow { … … 67 65 bool needsStyleRecalc(); 68 66 void recalcStyle(Node::StyleChange); 69 void setNeedsReattachHostChildrenAndShadow(); 70 void clearNeedsReattachHostChildrenAndShadow(); 71 bool needsReattachHostChildrenAndShadow(); 72 void reattachHostChildrenAndShadow(); 67 void setNeedsRedistributing(); 68 void clearNeedsRedistributing(); 69 bool needsRedistributing(); 73 70 void hostChildrenChanged(); 74 71 75 72 InsertionPoint* insertionPointFor(const Node*) const; 76 HTMLContentSelection* selectionFor(const Node*) const;73 ContentDistribution::Item* distributionItemFor(const Node*) const; 77 74 78 HTMLContentSelector& selector();79 const HTMLContentSelector& selector() const;75 ContentDistributor& distributor(); 76 const ContentDistributor& distributor() const; 80 77 81 78 private: 82 79 void removeAllShadowRoots(); 80 void reattachHostChildrenAndShadow(); 83 81 84 82 DoublyLinkedList<ShadowRoot> m_shadowRoots; 85 HTMLContentSelector m_selector;86 bool m_needsRe calculateContent: 1;83 ContentDistributor m_distributor; 84 bool m_needsRedistributing : 1; 87 85 WTF_MAKE_NONCOPYABLE(ElementShadow); 88 86 }; … … 98 96 } 99 97 100 inline HTMLContentSelector& ElementShadow::selector()98 inline ContentDistributor& ElementShadow::distributor() 101 99 { 102 return m_ selector;100 return m_distributor; 103 101 } 104 102 105 inline const HTMLContentSelector& ElementShadow::selector() const103 inline const ContentDistributor& ElementShadow::distributor() const 106 104 { 107 return m_ selector;105 return m_distributor; 108 106 } 109 107 110 inline void ElementShadow::clearNeedsRe attachHostChildrenAndShadow()108 inline void ElementShadow::clearNeedsRedistributing() 111 109 { 112 m_needsRe calculateContent= false;110 m_needsRedistributing = false; 113 111 } 114 112 -
trunk/Source/WebCore/dom/NodeRenderingContext.cpp
r116730 r116974 28 28 29 29 #include "ContainerNode.h" 30 #include "ContentDistributor.h" 30 31 #include "ElementShadow.h" 31 32 #include "FlowThreadController.h" 32 33 #include "HTMLContentElement.h" 33 #include "HTMLContentSelector.h"34 34 #include "HTMLNames.h" 35 35 #include "HTMLShadowElement.h" … … 98 98 } 99 99 100 if (toInsertionPoint(parent)->has Selection())100 if (toInsertionPoint(parent)->hasDistribution()) 101 101 m_phase = AttachingNotFallbacked; 102 102 else … … 143 143 static inline RenderObject* nextRendererOfInsertionPoint(InsertionPoint* parent, Node* current) 144 144 { 145 HTMLContentSelection* currentSelection = parent->selections()->find(current);146 if (!current Selection)147 return 0; 148 149 for ( HTMLContentSelection* selection = currentSelection->next(); selection; selection = selection->next()) {150 if (RenderObject* renderer = selection->node()->renderer())145 ContentDistribution::Item* currentItem = parent->distribution()->find(current); 146 if (!currentItem) 147 return 0; 148 149 for (ContentDistribution::Item* item = currentItem->next(); item; item = item->next()) { 150 if (RenderObject* renderer = item->node()->renderer()) 151 151 return renderer; 152 152 } … … 159 159 RenderObject* lastRenderer = 0; 160 160 161 for ( HTMLContentSelection* selection = parent->selections()->first(); selection; selection = selection->next()) {162 if ( selection->node() == current)161 for (ContentDistribution::Item* item = parent->distribution()->first(); item; item = item->next()) { 162 if (item->node() == current) 163 163 break; 164 if (RenderObject* renderer = selection->node()->renderer())164 if (RenderObject* renderer = item->node()->renderer()) 165 165 lastRenderer = renderer; 166 166 } … … 171 171 static inline RenderObject* firstRendererOfInsertionPoint(InsertionPoint* parent) 172 172 { 173 if (parent->has Selection()) {174 for ( HTMLContentSelection* selection = parent->selections()->first(); selection; selection = selection->next()) {175 if (RenderObject* renderer = selection->node()->renderer())173 if (parent->hasDistribution()) { 174 for (ContentDistribution::Item* item = parent->distribution()->first(); item; item = item->next()) { 175 if (RenderObject* renderer = item->node()->renderer()) 176 176 return renderer; 177 177 } … … 185 185 static inline RenderObject* lastRendererOfInsertionPoint(InsertionPoint* parent) 186 186 { 187 if (parent->has Selection()) {188 for ( HTMLContentSelection* selection = parent->selections()->last(); selection; selection = selection->previous()) {189 if (RenderObject* renderer = selection->node()->renderer())187 if (parent->hasDistribution()) { 188 for (ContentDistribution::Item* item = parent->distribution()->last(); item; item = item->previous()) { 189 if (RenderObject* renderer = item->node()->renderer()) 190 190 return renderer; 191 191 } -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r116746 r116974 28 28 #include "ShadowRoot.h" 29 29 30 #include "ContentDistributor.h" 30 31 #include "DOMSelection.h" 31 32 #include "DOMWindow.h" … … 35 36 #include "ElementShadow.h" 36 37 #include "HTMLContentElement.h" 37 #include "HTMLContentSelector.h"38 38 #include "HTMLNames.h" 39 39 #include "InsertionPoint.h" -
trunk/Source/WebCore/dom/ShadowRoot.h
r116521 r116974 39 39 class Document; 40 40 class DOMSelection; 41 class HTMLContentElement;42 class HTMLContentSelector;43 41 class InsertionPoint; 44 42 class ElementShadow; … … 61 59 void recalcShadowTreeStyle(StyleChange); 62 60 63 void setNeedsRe attachHostChildrenAndShadow();64 void clearNeedsRe attachHostChildrenAndShadow();65 bool needsRe attachHostChildrenAndShadow();61 void setNeedsRedistributing(); 62 void clearNeedsRedistributing(); 63 bool needsRedistributing(); 66 64 67 65 InsertionPoint* insertionPointFor(Node*) const; -
trunk/Source/WebCore/html/shadow/ContentDistributor.cpp
r116973 r116974 26 26 27 27 #include "config.h" 28 #include " HTMLContentSelector.h"28 #include "ContentDistributor.h" 29 29 30 30 #include "ContentSelectorQuery.h" … … 35 35 namespace WebCore { 36 36 37 void HTMLContentSelection::append(PassRefPtr<HTMLContentSelection> next) 38 { 39 ASSERT(!m_next); 40 ASSERT(!next->previous()); 41 m_next = next; 42 m_next->m_previous = this; 43 } 44 45 void HTMLContentSelection::unlink() 46 { 47 ASSERT(!m_previous); // Can be called only for a head. 48 RefPtr<HTMLContentSelection> item = this; 49 while (item) { 50 ASSERT(!item->previous()); 51 RefPtr<HTMLContentSelection> nextItem = item->m_next; 52 item->m_next.clear(); 53 if (nextItem) 54 nextItem->m_previous.clear(); 55 item = nextItem; 56 } 57 } 58 59 HTMLContentSelectionList::HTMLContentSelectionList() 37 ContentDistribution::ContentDistribution() 60 38 { 61 39 } 62 40 63 HTMLContentSelectionList::~HTMLContentSelectionList()41 ContentDistribution::~ContentDistribution() 64 42 { 65 43 ASSERT(isEmpty()); 66 44 } 67 45 68 HTMLContentSelection* HTMLContentSelectionList::find(Node* node) const46 ContentDistribution::Item* ContentDistribution::find(Node* node) const 69 47 { 70 for ( HTMLContentSelection* item = first(); item; item = item->next()) {48 for (ContentDistribution::Item* item = first(); item; item = item->next()) { 71 49 if (node == item->node()) 72 50 return item; … … 76 54 } 77 55 78 void HTMLContentSelectionList::clear()56 void ContentDistribution::clear() 79 57 { 80 58 if (isEmpty()) { … … 83 61 } 84 62 85 m_first->unlink(); 63 RefPtr<ContentDistribution::Item> item = m_first; 64 while (item) { 65 ASSERT(!item->previous()); 66 RefPtr<ContentDistribution::Item> nextItem = item->m_next; 67 item->m_next.clear(); 68 if (nextItem) 69 nextItem->m_previous.clear(); 70 item = nextItem; 71 } 72 86 73 m_first.clear(); 87 74 m_last.clear(); 88 75 } 89 76 90 void HTMLContentSelectionList::append(PassRefPtr<HTMLContentSelection> child)77 void ContentDistribution::append(InsertionPoint* insertionPoint, Node* node) 91 78 { 79 RefPtr<Item> child = Item::create(insertionPoint, node); 80 92 81 if (isEmpty()) { 93 82 ASSERT(!m_last); … … 96 85 } 97 86 98 m_last->append(child); 87 ASSERT(!m_last->next()); 88 ASSERT(!child->previous()); 89 m_last->m_next = child; 90 child->m_previous = m_last; 99 91 m_last = m_last->next(); 100 92 } 101 93 102 HTMLContentSelector::HTMLContentSelector()103 : m_phase( SelectionPrevented)94 ContentDistributor::ContentDistributor() 95 : m_phase(Prevented) 104 96 { 105 97 } 106 98 107 HTMLContentSelector::~HTMLContentSelector()99 ContentDistributor::~ContentDistributor() 108 100 { 109 ASSERT(m_ candidates.isEmpty());101 ASSERT(m_pool.isEmpty()); 110 102 } 111 103 112 void HTMLContentSelector::select(InsertionPoint* insertionPoint, HTMLContentSelectionList* selections)104 void ContentDistributor::distribute(InsertionPoint* insertionPoint, ContentDistribution* distribution) 113 105 { 114 ASSERT(m_phase == HostChildrenPopulated);115 ASSERT( selections->isEmpty());106 ASSERT(m_phase == Prepared); 107 ASSERT(distribution->isEmpty()); 116 108 117 109 ContentSelectorQuery query(insertionPoint); 118 110 119 for (size_t i = 0; i < m_ candidates.size(); ++i) {120 Node* child = m_ candidates[i].get();111 for (size_t i = 0; i < m_pool.size(); ++i) { 112 Node* child = m_pool[i].get(); 121 113 if (!child) 122 114 continue; … … 124 116 continue; 125 117 126 RefPtr<HTMLContentSelection> selection = HTMLContentSelection::create(insertionPoint, child); 127 128 selections->append(selection); 129 m_selectionSet.add(selection.get()); 130 m_candidates[i] = 0; 118 distribution->append(insertionPoint, child); 119 m_nodeToInsertionPoint.add(distribution->last()); 120 m_pool[i] = 0; 131 121 } 132 122 } 133 123 134 void HTMLContentSelector::unselect(HTMLContentSelectionList* list)124 void ContentDistributor::clearDistribution(ContentDistribution* list) 135 125 { 136 for (HTMLContentSelection* selection = list->first(); selection; selection = selection->next()) 137 m_selectionSet.remove(selection); 126 for (ContentDistribution::Item* item = list->first(); item; item = item->next()) 127 m_nodeToInsertionPoint.remove(item); 128 138 129 list->clear(); 139 130 } 140 131 141 HTMLContentSelection* HTMLContentSelector::findFor(const Node* key) const132 ContentDistribution::Item* ContentDistributor::findFor(const Node* key) const 142 133 { 143 return m_selectionSet.find(key); 134 InvertedTable::iterator found = m_nodeToInsertionPoint.find<const Node*, Translator>(key); 135 return found != m_nodeToInsertionPoint.end() ? *found : 0; 144 136 } 145 137 146 void HTMLContentSelector::willSelect() 138 InsertionPoint* ContentDistributor::findInsertionPointFor(const Node* key) const 147 139 { 148 m_phase = SelectionStarted; 140 InvertedTable::iterator found = m_nodeToInsertionPoint.find<const Node*, Translator>(key); 141 return found != m_nodeToInsertionPoint.end() ? (*found)->insertionPoint() : 0; 149 142 } 150 143 151 void HTMLContentSelector::didSelect()144 void ContentDistributor::willDistribute() 152 145 { 153 ASSERT(m_phase != SelectionPrevented); 154 m_phase = SelectionPrevented; 155 m_candidates.clear(); 146 m_phase = Started; 156 147 } 157 148 158 void HTMLContentSelector::populateIfNecessary(Element* shadowHost)149 void ContentDistributor::didDistribute() 159 150 { 160 if (hasPopulated()) 151 ASSERT(m_phase != Prevented); 152 m_phase = Prevented; 153 m_pool.clear(); 154 } 155 156 void ContentDistributor::preparePoolFor(Element* shadowHost) 157 { 158 if (poolIsReady()) 161 159 return; 162 160 163 ASSERT(m_ candidates.isEmpty());161 ASSERT(m_pool.isEmpty()); 164 162 ASSERT(shadowHost); 165 ASSERT(m_phase == S electionStarted);163 ASSERT(m_phase == Started); 166 164 167 m_phase = HostChildrenPopulated;165 m_phase = Prepared; 168 166 for (Node* node = shadowHost->firstChild(); node; node = node->nextSibling()) 169 m_ candidates.append(node);167 m_pool.append(node); 170 168 } 171 169 -
trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp
r116277 r116974 28 28 #include "HTMLContentElement.h" 29 29 30 #include "ContentDistributor.h" 30 31 #include "ContentSelectorQuery.h" 31 32 #include "ElementShadow.h" 32 #include "HTMLContentSelector.h"33 33 #include "HTMLNames.h" 34 34 #include "QualifiedName.h" … … 91 91 if (attr->name() == selectAttr) { 92 92 if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) 93 root->owner()->setNeedsRe attachHostChildrenAndShadow();93 root->owner()->setNeedsRedistributing(); 94 94 } else 95 95 InsertionPoint::parseAttribute(attr); -
trunk/Source/WebCore/html/shadow/InsertionPoint.cpp
r116277 r116974 39 39 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document) 40 40 : HTMLElement(tagName, document) 41 , m_ selections()41 , m_distribution() 42 42 { 43 43 } … … 77 77 // When shadow element is detached, shadow tree should be recreated to re-calculate selector for 78 78 // other insertion points. 79 shadow->setNeedsRe attachHostChildrenAndShadow();79 shadow->setNeedsRedistributing(); 80 80 } 81 81 82 ASSERT(m_ selections.isEmpty());82 ASSERT(m_distribution.isEmpty()); 83 83 HTMLElement::detach(); 84 84 } … … 120 120 inline void InsertionPoint::distributeHostChildren(ElementShadow* shadow) 121 121 { 122 if (!shadow-> selector().isSelecting()) {123 // If HTMLContentSelector is not int selecting phase, it means InsertionPoint is attached from122 if (!shadow->distributor().inDistribution()) { 123 // If ContentDistributor is not int selecting phase, it means InsertionPoint is attached from 124 124 // non-ElementShadow node. To run distribute algorithm, we have to reattach ElementShadow. 125 shadow->setNeedsRe attachHostChildrenAndShadow();125 shadow->setNeedsRedistributing(); 126 126 return; 127 127 } 128 128 129 shadow-> selector().populateIfNecessary(shadow->host());130 shadow-> selector().unselect(&m_selections);131 shadow-> selector().select(this, &m_selections);129 shadow->distributor().preparePoolFor(shadow->host()); 130 shadow->distributor().clearDistribution(&m_distribution); 131 shadow->distributor().distribute(this, &m_distribution); 132 132 } 133 133 134 134 inline void InsertionPoint::clearDistribution(ElementShadow* shadow) 135 135 { 136 shadow-> selector().unselect(&m_selections);136 shadow->distributor().clearDistribution(&m_distribution); 137 137 } 138 138 139 139 inline void InsertionPoint::attachDistributedNode() 140 140 { 141 for ( HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next())142 selection->node()->attach();141 for (ContentDistribution::Item* item = m_distribution.first(); item; item = item->next()) 142 item->node()->attach(); 143 143 } 144 144 … … 146 146 { 147 147 shadowRoot->setAssignedTo(this); 148 m_ selections.clear();148 m_distribution.clear(); 149 149 for (Node* node = shadowRoot->firstChild(); node; node = node->nextSibling()) 150 m_ selections.append(HTMLContentSelection::create(this, node));150 m_distribution.append(this, node); 151 151 } 152 152 … … 154 154 { 155 155 shadowRoot->setAssignedTo(0); 156 m_ selections.clear();156 m_distribution.clear(); 157 157 } 158 158 -
trunk/Source/WebCore/html/shadow/InsertionPoint.h
r116277 r116974 32 32 #define InsertionPoint_h 33 33 34 #include " HTMLContentSelector.h"34 #include "ContentDistributor.h" 35 35 #include "HTMLElement.h" 36 36 #include "HTMLNames.h" … … 43 43 virtual ~InsertionPoint(); 44 44 45 const HTMLContentSelectionList* selections() const { return &m_selections; }46 bool has Selection() const { return m_selections.first(); }45 const ContentDistribution* distribution() const { return &m_distribution; } 46 bool hasDistribution() const { return m_distribution.first(); } 47 47 bool isShadowBoundary() const; 48 48 bool isActive() const; … … 70 70 void clearAssignment(ShadowRoot*); 71 71 72 HTMLContentSelectionList m_selections;72 ContentDistribution m_distribution; 73 73 }; 74 74
Note: See TracChangeset
for help on using the changeset viewer.