WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP
bug-86064-20120511171322.patch (text/plain), 52.71 KB, created by
Hajime Morrita
on 2012-05-11 01:13:24 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Hajime Morrita
Created:
2012-05-11 01:13:24 PDT
Size:
52.71 KB
patch
obsolete
>Subversion Revision: 116733 >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 61c8843885175c4e706fce166d491ecb5975d3f1..a9980a8a19a5d7eeade770a8967f89ecec0a6e76 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -903,13 +903,13 @@ SET(WebCore_SOURCES > html/shadow/ContentSelectorQuery.cpp > html/shadow/DetailsMarkerControl.cpp > html/shadow/HTMLContentElement.cpp >- html/shadow/HTMLContentSelector.cpp > html/shadow/HTMLShadowElement.cpp > html/shadow/InsertionPoint.cpp > html/shadow/MediaControls.cpp > html/shadow/MediaControlRootElement.cpp > html/shadow/MeterShadowElement.cpp > html/shadow/ProgressShadowElement.cpp >+ html/shadow/ShadowDistributor.cpp > html/shadow/SliderThumbElement.cpp > html/shadow/TextControlInnerElements.cpp > >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 99b439866dd44740837d19c1c1b8a11e97800d0f..9ba8f291daf17b2ec30bb324fa7f6146da9ee9c7 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -2508,8 +2508,6 @@ webcore_sources += \ > Source/WebCore/html/shadow/DetailsMarkerControl.h \ > Source/WebCore/html/shadow/HTMLContentElement.cpp \ > Source/WebCore/html/shadow/HTMLContentElement.h \ >- Source/WebCore/html/shadow/HTMLContentSelector.cpp \ >- Source/WebCore/html/shadow/HTMLContentSelector.h \ > Source/WebCore/html/shadow/InsertionPoint.cpp \ > Source/WebCore/html/shadow/InsertionPoint.h \ > Source/WebCore/html/shadow/MediaControls.cpp \ >@@ -2521,7 +2519,9 @@ webcore_sources += \ > Source/WebCore/html/shadow/MeterShadowElement.cpp \ > Source/WebCore/html/shadow/MeterShadowElement.h \ > Source/WebCore/html/shadow/ProgressShadowElement.cpp \ >- Source/WebCore/html/shadow/ProgressShadowElement.h \ >+ Source/WebCore/html/shadow/ProgressShadowElement.h >+ Source/WebCore/html/shadow/ShadowDistributor.cpp \ >+ Source/WebCore/html/shadow/ShadowDistributor.h \ > Source/WebCore/html/shadow/SliderThumbElement.cpp \ > Source/WebCore/html/shadow/SliderThumbElement.h \ > Source/WebCore/html/shadow/TextControlInnerElements.cpp \ >diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index f76ae0b9f4fd2ea818a7c5f5aaefbd9f5cced1df..b48041b2b36280bae245cb0f31845275ccae2ab2 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -875,13 +875,13 @@ SOURCES += \ > html/shadow/ContentSelectorQuery.cpp \ > html/shadow/DetailsMarkerControl.cpp \ > html/shadow/HTMLContentElement.cpp \ >- html/shadow/HTMLContentSelector.cpp \ > html/shadow/HTMLShadowElement.cpp \ > html/shadow/InsertionPoint.cpp \ > html/shadow/MediaControls.cpp \ > html/shadow/MediaControlRootElement.cpp \ > html/shadow/MeterShadowElement.cpp \ > html/shadow/ProgressShadowElement.cpp \ >+ html/shadow/ShadowDistributor.cpp \ > html/shadow/SliderThumbElement.cpp \ > html/shadow/TextControlInnerElements.cpp \ > inspector/ConsoleMessage.cpp \ >@@ -1999,10 +1999,10 @@ HEADERS += \ > html/parser/XSSAuditor.h \ > html/shadow/ContentSelectorQuery.h \ > html/shadow/HTMLContentElement.h \ >- html/shadow/HTMLContentSelector.h \ > html/shadow/HTMLShadowElement.h \ > html/shadow/MediaControlElements.h \ > html/shadow/DetailsMarkerControl.h \ >+ html/shadow/ShadowDistributor.h \ > html/track/LoadableTextTrack.h \ > html/track/TextTrack.h \ > html/track/TextTrackCue.h \ >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index e7746e6471e946760d9a598f08df99b4eec02092..954b147c99357a0b5d704f728660a5b487a4b43b 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -5796,8 +5796,6 @@ > 'html/shadow/DetailsMarkerControl.h', > 'html/shadow/HTMLContentElement.cpp', > 'html/shadow/HTMLContentElement.h', >- 'html/shadow/HTMLContentSelector.cpp', >- 'html/shadow/HTMLContentSelector.h', > 'html/shadow/HTMLShadowElement.cpp', > 'html/shadow/HTMLShadowElement.h', > 'html/shadow/InsertionPoint.cpp', >@@ -5812,6 +5810,8 @@ > 'html/shadow/MeterShadowElement.h', > 'html/shadow/ProgressShadowElement.cpp', > 'html/shadow/ProgressShadowElement.h', >+ 'html/shadow/ShadowDistributor.cpp', >+ 'html/shadow/ShadowDistributor.h', > 'html/shadow/SliderThumbElement.cpp', > 'html/shadow/SliderThumbElement.h', > 'html/shadow/TextControlInnerElements.cpp', >diff --git a/Source/WebCore/WebCore.vcproj/WebCore.vcproj b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >index 3735bc8c025799f455fdb055147f3d1c6446ad23..db7342a0ba2bfa6838c37fe99ec923bad0dadfaf 100755 >--- a/Source/WebCore/WebCore.vcproj/WebCore.vcproj >+++ b/Source/WebCore/WebCore.vcproj/WebCore.vcproj >@@ -62733,14 +62733,6 @@ > > > </File> > <File >- RelativePath="..\html\shadow\HTMLContentSelector.cpp" >- > >- </File> >- <File >- RelativePath="..\html\shadow\HTMLContentSelector.h" >- > >- </File> >- <File > RelativePath="..\html\shadow\HTMLShadowElement.cpp" > > > <FileConfiguration >@@ -62849,6 +62841,14 @@ > > > </File> > <File >+ RelativePath="..\html\shadow\ShadowDistributor.cpp" >+ > >+ </File> >+ <File >+ RelativePath="..\html\shadow\ShadowDistributor.h" >+ > >+ </File> >+ <File > RelativePath="..\html\shadow\SliderThumbElement.cpp" > > > </File> >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 85c84a7079ee511e050a904423d754f50340ea49..6d7fb472b0ba444d369223b4dd34218541e1f3a6 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -1584,8 +1584,8 @@ > 5740E83D1532DE1700760628 /* TreeScopeAdjuster.h in Headers */ = {isa = PBXBuildFile; fileRef = 5740E83B1532DE1700760628 /* TreeScopeAdjuster.h */; }; > 578DA20E1520EB8C006141C1 /* InspectorFrontend.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F4F5FFC11CBD30100A186BF /* InspectorFrontend.h */; settings = {ATTRIBUTES = (Private, ); }; }; > 578DA20F1520EBA3006141C1 /* InspectorTypeBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = 573D134614CE39FF0057ABCA /* InspectorTypeBuilder.h */; settings = {ATTRIBUTES = (Private, ); }; }; >- 57B791A314C6A62900F202D1 /* HTMLContentSelector.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B7919F14C6A62900F202D1 /* HTMLContentSelector.cpp */; }; >- 57B791A414C6A62900F202D1 /* HTMLContentSelector.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A014C6A62900F202D1 /* HTMLContentSelector.h */; }; >+ 57B791A314C6A62900F202D1 /* ShadowDistributor.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B7919F14C6A62900F202D1 /* ShadowDistributor.cpp */; }; >+ 57B791A414C6A62900F202D1 /* ShadowDistributor.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A014C6A62900F202D1 /* ShadowDistributor.h */; }; > 57B791A514C6A62900F202D1 /* ContentSelectorQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */; }; > 57B791A614C6A62900F202D1 /* ContentSelectorQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */; }; > 57B791A914C6A63300F202D1 /* HTMLContentElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B791A714C6A63300F202D1 /* HTMLContentElement.cpp */; }; >@@ -8601,8 +8601,8 @@ > 573D134614CE39FF0057ABCA /* InspectorTypeBuilder.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InspectorTypeBuilder.h; sourceTree = "<group>"; }; > 5740E83A1532DE1700760628 /* TreeScopeAdjuster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TreeScopeAdjuster.cpp; sourceTree = "<group>"; }; > 5740E83B1532DE1700760628 /* TreeScopeAdjuster.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TreeScopeAdjuster.h; sourceTree = "<group>"; }; >- 57B7919F14C6A62900F202D1 /* HTMLContentSelector.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLContentSelector.cpp; sourceTree = "<group>"; }; >- 57B791A014C6A62900F202D1 /* HTMLContentSelector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = HTMLContentSelector.h; sourceTree = "<group>"; }; >+ 57B7919F14C6A62900F202D1 /* ShadowDistributor.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ShadowDistributor.cpp; sourceTree = "<group>"; }; >+ 57B791A014C6A62900F202D1 /* ShadowDistributor.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ShadowDistributor.h; sourceTree = "<group>"; }; > 57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentSelectorQuery.cpp; sourceTree = "<group>"; }; > 57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentSelectorQuery.h; sourceTree = "<group>"; }; > 57B791A714C6A63300F202D1 /* HTMLContentElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = HTMLContentElement.cpp; sourceTree = "<group>"; }; >@@ -14624,8 +14624,6 @@ > 57B791A714C6A63300F202D1 /* HTMLContentElement.cpp */, > 57B791A814C6A63300F202D1 /* HTMLContentElement.h */, > A7B7749614CF6353004044BB /* HTMLContentElement.idl */, >- 57B7919F14C6A62900F202D1 /* HTMLContentSelector.cpp */, >- 57B791A014C6A62900F202D1 /* HTMLContentSelector.h */, > 4ABDFF0714DBE312004D117D /* HTMLShadowElement.cpp */, > 4ABDFF0814DBE312004D117D /* HTMLShadowElement.h */, > 4ABDFF0914DBE312004D117D /* HTMLShadowElement.idl */, >@@ -14641,6 +14639,8 @@ > A78E526E1346BD1700AD9C31 /* MeterShadowElement.h */, > A715E650134BBBEC00D8E713 /* ProgressShadowElement.cpp */, > A715E651134BBBEC00D8E713 /* ProgressShadowElement.h */, >+ 57B7919F14C6A62900F202D1 /* ShadowDistributor.cpp */, >+ 57B791A014C6A62900F202D1 /* ShadowDistributor.h */, > 4150F9F012B6E0E70008C860 /* SliderThumbElement.cpp */, > 4150F9EF12B6E0E70008C860 /* SliderThumbElement.h */, > 142B97C713138943008BEF4B /* TextControlInnerElements.cpp */, >@@ -22939,7 +22939,6 @@ > A8DF3FD0097FA0FC0052981B /* HTMLCollection.h in Headers */, > 977B3865122883E900B81FF8 /* HTMLConstructionSite.h in Headers */, > 57B791AA14C6A63300F202D1 /* HTMLContentElement.h in Headers */, >- 57B791A414C6A62900F202D1 /* HTMLContentSelector.h in Headers */, > E1A31663134BCAE8007C9A4F /* HTMLConverter.h in Headers */, > F5C041DB0FFCA7CE00839D4A /* HTMLDataListElement.h in Headers */, > D359D78A129CA2710006E5D2 /* HTMLDetailsElement.h in Headers */, >@@ -24243,6 +24242,7 @@ > 498770E91242C535002226BA /* Shader.h in Headers */, > 0F3DD45012F5EA1B000D9190 /* ShadowBlur.h in Headers */, > BC5EB8C40E82031B00B25965 /* ShadowData.h in Headers */, >+ 57B791A414C6A62900F202D1 /* ShadowDistributor.h in Headers */, > A6D169641346B4C1000EB770 /* ShadowRoot.h in Headers */, > A80E6CE80A1989CA007FB8C5 /* ShadowValue.h in Headers */, > B2AFFC940D00A5DF0030074D /* ShapeArabic.h in Headers */, >@@ -26074,7 +26074,6 @@ > A8DF3FD1097FA0FC0052981B /* HTMLCollection.cpp in Sources */, > 977B3864122883E900B81FF8 /* HTMLConstructionSite.cpp in Sources */, > 57B791A914C6A63300F202D1 /* HTMLContentElement.cpp in Sources */, >- 57B791A314C6A62900F202D1 /* HTMLContentSelector.cpp in Sources */, > 5D4F51DF132725480016F541 /* HTMLConverter.mm in Sources */, > F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */, > D359D789129CA2710006E5D2 /* HTMLDetailsElement.cpp in Sources */, >@@ -27386,6 +27385,7 @@ > 498770E81242C535002226BA /* Shader.cpp in Sources */, > 0F3DD44F12F5EA1B000D9190 /* ShadowBlur.cpp in Sources */, > BC5EB8C30E82031B00B25965 /* ShadowData.cpp in Sources */, >+ 57B791A314C6A62900F202D1 /* ShadowDistributor.cpp in Sources */, > A6D169621346B49B000EB770 /* ShadowRoot.cpp in Sources */, > A80E6CF40A1989CA007FB8C5 /* ShadowValue.cpp in Sources */, > B2AFFC930D00A5DF0030074D /* ShapeArabic.c in Sources */, >diff --git a/Source/WebCore/dom/ComposedShadowTreeWalker.cpp b/Source/WebCore/dom/ComposedShadowTreeWalker.cpp >index d1a889e678df8a2327ff6d36fe371009b58d66ff..d0c4c132e21691d94524d7b23a97b52f54715625 100644 >--- a/Source/WebCore/dom/ComposedShadowTreeWalker.cpp >+++ b/Source/WebCore/dom/ComposedShadowTreeWalker.cpp >@@ -29,9 +29,8 @@ > > #include "Element.h" > #include "ElementShadow.h" >-#include "HTMLContentSelector.h" > #include "InsertionPoint.h" >- >+#include "ShadowDistributor.h" > > namespace WebCore { > >@@ -114,9 +113,9 @@ Node* ComposedShadowTreeWalker::traverseNode(const Node* node, TraversalDirectio > { > ASSERT(node); > if (isInsertionPoint(node)) { >- const HTMLContentSelectionList* selectionList = toInsertionPoint(node)->selections(); >- if (HTMLContentSelection* selection = (direction == TraversalDirectionForward ? selectionList->first() : selectionList->last())) >- return traverseNode(selection->node(), direction); >+ const ShadowBoundaryDistribution* distribution = toInsertionPoint(node)->distribution(); >+ if (Node* next = (direction == TraversalDirectionForward ? distribution->firstNode() : distribution->lastNode())) >+ return traverseNode(next, direction); > return traverseLightChildren(node, direction); > } > return const_cast<Node*>(node); >@@ -142,12 +141,12 @@ Node* ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint(const Node > ElementShadow* shadow = shadowOfParent(node); > if (!shadow) > return traverseSiblingInCurrentTree(node, direction); >- HTMLContentSelection* selection = shadow->selectionFor(node); >- if (!selection) >+ ShadowBoundaryDistribution::Item* item = shadow->distributionItemFor(node); >+ if (!item) > return traverseSiblingInCurrentTree(node, direction); >- if (HTMLContentSelection* nextSelection = (direction == TraversalDirectionForward ? selection->next() : selection->previous())) >- return traverseNode(nextSelection->node(), direction); >- return traverseSiblingOrBackToInsertionPoint(selection->insertionPoint(), direction); >+ if (ShadowBoundaryDistribution::Item* nextItem = (direction == TraversalDirectionForward ? item->next() : item->previous())) >+ return traverseNode(nextItem->node(), direction); >+ return traverseSiblingOrBackToInsertionPoint(item->insertionPoint(), direction); > } > > Node* ComposedShadowTreeWalker::traverseSiblingInCurrentTree(const Node* node, TraversalDirection direction) >@@ -204,8 +203,8 @@ Node* ComposedShadowTreeWalker::traverseParent(const Node* node) const > return 0; > } > if (ElementShadow* shadow = shadowOfParent(node)) { >- if (HTMLContentSelection* selection = shadow->selectionFor(node)) >- return traverseParent(selection->insertionPoint()); >+ if (InsertionPoint* insertionPoint = shadow->insertionPointFor(node)) >+ return traverseParent(insertionPoint); > } > return traverseParentInCurrentTree(node); > } >diff --git a/Source/WebCore/dom/ElementShadow.cpp b/Source/WebCore/dom/ElementShadow.cpp >index cc6c86e16525403de468aa241f72e293856fb317..a32b01919306a681a93fa1665f5c78be6b1945b4 100644 >--- a/Source/WebCore/dom/ElementShadow.cpp >+++ b/Source/WebCore/dom/ElementShadow.cpp >@@ -40,7 +40,7 @@ > namespace WebCore { > > ElementShadow::ElementShadow() >- : m_needsRecalculateContent(false) >+ : m_needsRecalcDistribution(false) > { > } > >@@ -119,16 +119,16 @@ void ElementShadow::setParentTreeScope(TreeScope* scope) > > void ElementShadow::attach() > { >- // Children of m_selector is populated lazily in >- // ensureSelector(), and here we just ensure that it is in clean state. >- ASSERT(!selector().hasPopulated()); >+ // The pool nodes are populated lazily in >+ // ensureDistributor(), and here we just ensure that it is in clean state. >+ ASSERT(!distributor().poolIsReady()); > >- selector().willSelect(); >+ distributor().willDistribute(); > for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { > if (!root->attached()) > root->attach(); > } >- selector().didSelect(); >+ distributor().didDistribute(); > } > > void ElementShadow::attachHost(Element* host) >@@ -164,15 +164,12 @@ InsertionPoint* ElementShadow::insertionPointFor(const Node* node) const > return 0; > } > >- HTMLContentSelection* found = selector().findFor(node); >- if (!found) >- return 0; >- return found->insertionPoint(); >+ return distributor().findInsertionPointFor(node); > } > >-HTMLContentSelection* ElementShadow::selectionFor(const Node* node) const >+ShadowBoundaryDistribution::Item* ElementShadow::distributionItemFor(const Node* node) const > { >- return m_selector.findFor(node); >+ return m_distributor.findFor(node); > } > > void ElementShadow::reattach() >@@ -207,7 +204,7 @@ void ElementShadow::recalcStyle(Node::StyleChange change) > if (!youngest) > return; > >- if (needsReattachHostChildrenAndShadow()) >+ if (needsRecalcDistribution()) > reattachHostChildrenAndShadow(); > else { > StyleResolver* styleResolver = youngest->document()->styleResolver(); >@@ -222,16 +219,16 @@ void ElementShadow::recalcStyle(Node::StyleChange change) > styleResolver->popParentShadowRoot(youngest); > } > >- clearNeedsReattachHostChildrenAndShadow(); >+ clearNeedsRecalcDistribution(); > for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) { > root->clearNeedsStyleRecalc(); > root->clearChildNeedsStyleRecalc(); > } > } > >-bool ElementShadow::needsReattachHostChildrenAndShadow() >+bool ElementShadow::needsRecalcDistribution() > { >- return m_needsRecalculateContent || (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint()); >+ return m_needsRecalcDistribution || (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint()); > } > > void ElementShadow::hostChildrenChanged() >@@ -242,12 +239,12 @@ void ElementShadow::hostChildrenChanged() > return; > > // This results in forced detaching/attaching of the shadow render tree. See ShadowRoot::recalcStyle(). >- setNeedsReattachHostChildrenAndShadow(); >+ setNeedsRecalcDistribution(); > } > >-void ElementShadow::setNeedsReattachHostChildrenAndShadow() >+void ElementShadow::setNeedsRecalcDistribution() > { >- m_needsRecalculateContent = true; >+ m_needsRecalcDistribution = true; > > host()->setNeedsStyleRecalc(); > } >diff --git a/Source/WebCore/dom/ElementShadow.h b/Source/WebCore/dom/ElementShadow.h >index 4c07a27e04e223a93dc736ce95018657fff7db00..b33c9ec862f8c6f5bf6b643609eb6596b81ea12c 100644 >--- a/Source/WebCore/dom/ElementShadow.h >+++ b/Source/WebCore/dom/ElementShadow.h >@@ -28,7 +28,7 @@ > #define ElementShadow_h > > #include "ExceptionCode.h" >-#include "HTMLContentSelector.h" >+#include "ShadowDistributor.h" > #include "ShadowRoot.h" > #include <wtf/DoublyLinkedList.h> > #include <wtf/Noncopyable.h> >@@ -40,9 +40,7 @@ namespace WebCore { > > class Node; > class Element; >-class InsertionPoint; > class TreeScope; >-class HTMLContentSelection; > > class ElementShadow { > public: >@@ -66,24 +64,24 @@ public: > bool childNeedsStyleRecalc(); > bool needsStyleRecalc(); > void recalcStyle(Node::StyleChange); >- void setNeedsReattachHostChildrenAndShadow(); >- void clearNeedsReattachHostChildrenAndShadow(); >- bool needsReattachHostChildrenAndShadow(); >- void reattachHostChildrenAndShadow(); >+ void setNeedsRecalcDistribution(); >+ void clearNeedsRecalcDistribution(); >+ bool needsRecalcDistribution(); > void hostChildrenChanged(); > > InsertionPoint* insertionPointFor(const Node*) const; >- HTMLContentSelection* selectionFor(const Node*) const; >+ ShadowBoundaryDistribution::Item* distributionItemFor(const Node*) const; > >- HTMLContentSelector& selector(); >- const HTMLContentSelector& selector() const; >+ ShadowDistributor& distributor(); >+ const ShadowDistributor& distributor() const; > > private: > void removeAllShadowRoots(); >+ void reattachHostChildrenAndShadow(); > > DoublyLinkedList<ShadowRoot> m_shadowRoots; >- HTMLContentSelector m_selector; >- bool m_needsRecalculateContent : 1; >+ ShadowDistributor m_distributor; >+ bool m_needsRecalcDistribution : 1; > WTF_MAKE_NONCOPYABLE(ElementShadow); > }; > >@@ -97,19 +95,19 @@ inline ShadowRoot* ElementShadow::oldestShadowRoot() const > return m_shadowRoots.tail(); > } > >-inline HTMLContentSelector& ElementShadow::selector() >+inline ShadowDistributor& ElementShadow::distributor() > { >- return m_selector; >+ return m_distributor; > } > >-inline const HTMLContentSelector& ElementShadow::selector() const >+inline const ShadowDistributor& ElementShadow::distributor() const > { >- return m_selector; >+ return m_distributor; > } > >-inline void ElementShadow::clearNeedsReattachHostChildrenAndShadow() >+inline void ElementShadow::clearNeedsRecalcDistribution() > { >- m_needsRecalculateContent = false; >+ m_needsRecalcDistribution = false; > } > > inline Element* ElementShadow::host() const >diff --git a/Source/WebCore/dom/NodeRenderingContext.cpp b/Source/WebCore/dom/NodeRenderingContext.cpp >index 5898419a6a5d43e041ff0b9efba47426618404a6..fa2c5ccefa43f0088be5391cedd18327156405a5 100644 >--- a/Source/WebCore/dom/NodeRenderingContext.cpp >+++ b/Source/WebCore/dom/NodeRenderingContext.cpp >@@ -30,7 +30,6 @@ > #include "ElementShadow.h" > #include "FlowThreadController.h" > #include "HTMLContentElement.h" >-#include "HTMLContentSelector.h" > #include "HTMLNames.h" > #include "HTMLShadowElement.h" > #include "Node.h" >@@ -38,6 +37,7 @@ > #include "RenderNamedFlowThread.h" > #include "RenderObject.h" > #include "RenderView.h" >+#include "ShadowDistributor.h" > #include "ShadowRoot.h" > > #if ENABLE(SVG) >@@ -97,7 +97,7 @@ NodeRenderingContext::NodeRenderingContext(Node* node) > return; > } > >- if (toInsertionPoint(parent)->hasSelection()) >+ if (toInsertionPoint(parent)->hasDistribution()) > m_phase = AttachingNotFallbacked; > else > m_phase = AttachingFallbacked; >@@ -142,12 +142,12 @@ PassRefPtr<RenderStyle> NodeRenderingContext::releaseStyle() > > static inline RenderObject* nextRendererOfInsertionPoint(InsertionPoint* parent, Node* current) > { >- HTMLContentSelection* currentSelection = parent->selections()->find(current); >- if (!currentSelection) >+ ShadowBoundaryDistribution::Item* currentItem = parent->distribution()->find(current); >+ if (!currentItem) > return 0; > >- for (HTMLContentSelection* selection = currentSelection->next(); selection; selection = selection->next()) { >- if (RenderObject* renderer = selection->node()->renderer()) >+ for (ShadowBoundaryDistribution::Item* item = currentItem->next(); item; item = item->next()) { >+ if (RenderObject* renderer = item->node()->renderer()) > return renderer; > } > >@@ -158,10 +158,10 @@ static inline RenderObject* previousRendererOfInsertionPoint(InsertionPoint* par > { > RenderObject* lastRenderer = 0; > >- for (HTMLContentSelection* selection = parent->selections()->first(); selection; selection = selection->next()) { >- if (selection->node() == current) >+ for (ShadowBoundaryDistribution::Item* item = parent->distribution()->first(); item; item = item->next()) { >+ if (item->node() == current) > break; >- if (RenderObject* renderer = selection->node()->renderer()) >+ if (RenderObject* renderer = item->node()->renderer()) > lastRenderer = renderer; > } > >@@ -170,9 +170,9 @@ static inline RenderObject* previousRendererOfInsertionPoint(InsertionPoint* par > > static inline RenderObject* firstRendererOfInsertionPoint(InsertionPoint* parent) > { >- if (parent->hasSelection()) { >- for (HTMLContentSelection* selection = parent->selections()->first(); selection; selection = selection->next()) { >- if (RenderObject* renderer = selection->node()->renderer()) >+ if (parent->hasDistribution()) { >+ for (ShadowBoundaryDistribution::Item* item = parent->distribution()->first(); item; item = item->next()) { >+ if (RenderObject* renderer = item->node()->renderer()) > return renderer; > } > >@@ -184,9 +184,9 @@ static inline RenderObject* firstRendererOfInsertionPoint(InsertionPoint* parent > > static inline RenderObject* lastRendererOfInsertionPoint(InsertionPoint* parent) > { >- if (parent->hasSelection()) { >- for (HTMLContentSelection* selection = parent->selections()->last(); selection; selection = selection->previous()) { >- if (RenderObject* renderer = selection->node()->renderer()) >+ if (parent->hasDistribution()) { >+ for (ShadowBoundaryDistribution::Item* item = parent->distribution()->last(); item; item = item->previous()) { >+ if (RenderObject* renderer = item->node()->renderer()) > return renderer; > } > >diff --git a/Source/WebCore/dom/ShadowRoot.cpp b/Source/WebCore/dom/ShadowRoot.cpp >index 7b246c0b12fb1872d3e9dc6cd4f897b5ed5da60e..2de59b781558de537ce8b32a53893808f6a9b229 100644 >--- a/Source/WebCore/dom/ShadowRoot.cpp >+++ b/Source/WebCore/dom/ShadowRoot.cpp >@@ -34,11 +34,11 @@ > #include "Element.h" > #include "ElementShadow.h" > #include "HTMLContentElement.h" >-#include "HTMLContentSelector.h" > #include "HTMLNames.h" > #include "InsertionPoint.h" > #include "NodeRareData.h" > #include "SVGNames.h" >+#include "ShadowDistributor.h" > #include "StyleResolver.h" > #include "markup.h" > >diff --git a/Source/WebCore/dom/ShadowRoot.h b/Source/WebCore/dom/ShadowRoot.h >index c0024c716732309970f1be8170751685ff0419e0..292f373bb8f1f9683af315aad4dbe738f6c6e609 100644 >--- a/Source/WebCore/dom/ShadowRoot.h >+++ b/Source/WebCore/dom/ShadowRoot.h >@@ -38,8 +38,6 @@ namespace WebCore { > > class Document; > class DOMSelection; >-class HTMLContentElement; >-class HTMLContentSelector; > class InsertionPoint; > class ElementShadow; > >@@ -60,9 +58,9 @@ public: > > void recalcShadowTreeStyle(StyleChange); > >- void setNeedsReattachHostChildrenAndShadow(); >- void clearNeedsReattachHostChildrenAndShadow(); >- bool needsReattachHostChildrenAndShadow(); >+ void setNeedsRecalcDistribution(); >+ void clearNeedsRecalcDistribution(); >+ bool needsRecalcDistribution(); > > InsertionPoint* insertionPointFor(Node*) const; > void hostChildrenChanged(); >diff --git a/Source/WebCore/html/shadow/HTMLContentElement.cpp b/Source/WebCore/html/shadow/HTMLContentElement.cpp >index 5436795061f939a048b2f98653c8386a9c3efa7f..e518e00a1a4ee713661a6bed6ac62662479e0bbf 100644 >--- a/Source/WebCore/html/shadow/HTMLContentElement.cpp >+++ b/Source/WebCore/html/shadow/HTMLContentElement.cpp >@@ -29,10 +29,10 @@ > > #include "ContentSelectorQuery.h" > #include "ElementShadow.h" >-#include "HTMLContentSelector.h" > #include "HTMLNames.h" > #include "QualifiedName.h" > #include "RuntimeEnabledFeatures.h" >+#include "ShadowDistributor.h" > #include "ShadowRoot.h" > #include <wtf/StdLibExtras.h> > >@@ -90,7 +90,7 @@ void HTMLContentElement::parseAttribute(Attribute* attr) > { > if (attr->name() == selectAttr) { > if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode())) >- root->owner()->setNeedsReattachHostChildrenAndShadow(); >+ root->owner()->setNeedsRecalcDistribution(); > } else > InsertionPoint::parseAttribute(attr); > } >diff --git a/Source/WebCore/html/shadow/HTMLContentSelector.cpp b/Source/WebCore/html/shadow/HTMLContentSelector.cpp >deleted file mode 100644 >index 31e4194ec5a37de0394c03f8e838e65bb45874c4..0000000000000000000000000000000000000000 >--- a/Source/WebCore/html/shadow/HTMLContentSelector.cpp >+++ /dev/null >@@ -1,172 +0,0 @@ >-/* >- * Copyright (C) 2011 Google Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions are >- * met: >- * >- * * Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * * Neither the name of Google Inc. nor the names of its >- * contributors may be used to endorse or promote products derived from >- * this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#include "config.h" >-#include "HTMLContentSelector.h" >- >-#include "ContentSelectorQuery.h" >-#include "HTMLContentElement.h" >-#include "ShadowRoot.h" >- >- >-namespace WebCore { >- >-void HTMLContentSelection::append(PassRefPtr<HTMLContentSelection> next) >-{ >- ASSERT(!m_next); >- ASSERT(!next->previous()); >- m_next = next; >- m_next->m_previous = this; >-} >- >-void HTMLContentSelection::unlink() >-{ >- ASSERT(!m_previous); // Can be called only for a head. >- RefPtr<HTMLContentSelection> item = this; >- while (item) { >- ASSERT(!item->previous()); >- RefPtr<HTMLContentSelection> nextItem = item->m_next; >- item->m_next.clear(); >- if (nextItem) >- nextItem->m_previous.clear(); >- item = nextItem; >- } >-} >- >-HTMLContentSelectionList::HTMLContentSelectionList() >-{ >-} >- >-HTMLContentSelectionList::~HTMLContentSelectionList() >-{ >- ASSERT(isEmpty()); >-} >- >-HTMLContentSelection* HTMLContentSelectionList::find(Node* node) const >-{ >- for (HTMLContentSelection* item = first(); item; item = item->next()) { >- if (node == item->node()) >- return item; >- } >- >- return 0; >-} >- >-void HTMLContentSelectionList::clear() >-{ >- if (isEmpty()) { >- ASSERT(!m_last); >- return; >- } >- >- m_first->unlink(); >- m_first.clear(); >- m_last.clear(); >-} >- >-void HTMLContentSelectionList::append(PassRefPtr<HTMLContentSelection> child) >-{ >- if (isEmpty()) { >- ASSERT(!m_last); >- m_first = m_last = child; >- return; >- } >- >- m_last->append(child); >- m_last = m_last->next(); >-} >- >-HTMLContentSelector::HTMLContentSelector() >- : m_phase(SelectionPrevented) >-{ >-} >- >-HTMLContentSelector::~HTMLContentSelector() >-{ >- ASSERT(m_candidates.isEmpty()); >-} >- >-void HTMLContentSelector::select(InsertionPoint* insertionPoint, HTMLContentSelectionList* selections) >-{ >- ASSERT(m_phase == HostChildrenPopulated); >- ASSERT(selections->isEmpty()); >- >- ContentSelectorQuery query(insertionPoint); >- >- for (size_t i = 0; i < m_candidates.size(); ++i) { >- Node* child = m_candidates[i].get(); >- if (!child) >- continue; >- if (!query.matches(child)) >- continue; >- >- RefPtr<HTMLContentSelection> selection = HTMLContentSelection::create(insertionPoint, child); >- >- selections->append(selection); >- m_selectionSet.add(selection.get()); >- m_candidates[i] = 0; >- } >-} >- >-void HTMLContentSelector::unselect(HTMLContentSelectionList* list) >-{ >- for (HTMLContentSelection* selection = list->first(); selection; selection = selection->next()) >- m_selectionSet.remove(selection); >- list->clear(); >-} >- >-HTMLContentSelection* HTMLContentSelector::findFor(const Node* key) const >-{ >- return m_selectionSet.find(key); >-} >- >-void HTMLContentSelector::willSelect() >-{ >- m_phase = SelectionStarted; >-} >- >-void HTMLContentSelector::didSelect() >-{ >- ASSERT(m_phase != SelectionPrevented); >- m_phase = SelectionPrevented; >- m_candidates.clear(); >-} >- >-void HTMLContentSelector::populateIfNecessary(Element* shadowHost) >-{ >- if (hasPopulated()) >- return; >- >- ASSERT(m_candidates.isEmpty()); >- ASSERT(shadowHost); >- ASSERT(m_phase == SelectionStarted); >- >- m_phase = HostChildrenPopulated; >- for (Node* node = shadowHost->firstChild(); node; node = node->nextSibling()) >- m_candidates.append(node); >-} >- >-} >diff --git a/Source/WebCore/html/shadow/HTMLContentSelector.h b/Source/WebCore/html/shadow/HTMLContentSelector.h >deleted file mode 100644 >index bcfbddbbd8827385a7c9afc11c24f6feca6e3629..0000000000000000000000000000000000000000 >--- a/Source/WebCore/html/shadow/HTMLContentSelector.h >+++ /dev/null >@@ -1,171 +0,0 @@ >-/* >- * Copyright (C) 2011 Google Inc. All rights reserved. >- * >- * Redistribution and use in source and binary forms, with or without >- * modification, are permitted provided that the following conditions are >- * met: >- * >- * * Redistributions of source code must retain the above copyright >- * notice, this list of conditions and the following disclaimer. >- * * Redistributions in binary form must reproduce the above >- * copyright notice, this list of conditions and the following disclaimer >- * in the documentation and/or other materials provided with the >- * distribution. >- * * Neither the name of Google Inc. nor the names of its >- * contributors may be used to endorse or promote products derived from >- * this software without specific prior written permission. >- * >- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >- * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >- * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >- * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >- * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >- * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >- * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >- * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >- */ >- >-#ifndef HTMLContentSelector_h >-#define HTMLContentSelector_h >- >-#include <wtf/Forward.h> >-#include <wtf/HashSet.h> >-#include <wtf/RefCounted.h> >-#include <wtf/Vector.h> >- >-namespace WebCore { >- >-class Element; >-class HTMLContentElement; >-class InsertionPoint; >-class Node; >-class ShadowRoot; >- >-class HTMLContentSelection : public RefCounted<HTMLContentSelection> { >-public: >- static PassRefPtr<HTMLContentSelection> create(InsertionPoint*, Node*); >- >- InsertionPoint* insertionPoint() const { return m_insertionPoint; } >- Node* node() const { return m_node.get(); } >- HTMLContentSelection* next() const { return m_next.get(); } >- HTMLContentSelection* previous() const { return m_previous.get(); } >- >- void append(PassRefPtr<HTMLContentSelection>); >- void unlink(); >- >-private: >- HTMLContentSelection(InsertionPoint*, Node*); >- >- InsertionPoint* m_insertionPoint; >- RefPtr<Node> m_node; >- RefPtr<HTMLContentSelection> m_next; >- RefPtr<HTMLContentSelection> m_previous; >-}; >- >-inline HTMLContentSelection::HTMLContentSelection(InsertionPoint* insertionPoint, Node* node) >- : m_insertionPoint(insertionPoint), m_node(node) >-{ } >- >-inline PassRefPtr<HTMLContentSelection> HTMLContentSelection::create(InsertionPoint* insertionPoint, Node* node) >-{ >- return adoptRef(new HTMLContentSelection(insertionPoint, node)); >-} >- >-class HTMLContentSelectionList { >-public: >- HTMLContentSelectionList(); >- ~HTMLContentSelectionList(); >- >- HTMLContentSelection* first() const { return m_first.get(); } >- HTMLContentSelection* last() const { return m_last.get(); } >- HTMLContentSelection* find(Node*) const; >- bool isEmpty() const { return !m_first; } >- >- void clear(); >- void append(PassRefPtr<HTMLContentSelection>); >- >-private: >- RefPtr<HTMLContentSelection> m_first; >- RefPtr<HTMLContentSelection> m_last; >-}; >- >- >-class HTMLContentSelectionSet { >-public: >- void add(HTMLContentSelection* value) { m_set.add(value); } >- void remove(HTMLContentSelection* value) { m_set.remove(value); } >- bool isEmpty() const { return m_set.isEmpty(); } >- HTMLContentSelection* find(const Node* key) const; >- >-private: >- struct Translator { >- public: >- static unsigned hash(const Node* key) { return PtrHash<const Node*>::hash(key); } >- static bool equal(const HTMLContentSelection* selection, const Node* node) { return selection->node() == node; } >- }; >- >- struct Hash { >- static unsigned hash(HTMLContentSelection* key) { return PtrHash<const Node*>::hash(key->node()); } >- static bool equal(HTMLContentSelection* a, HTMLContentSelection* b) { return a->node() == b->node(); } >- static const bool safeToCompareToEmptyOrDeleted = false; >- }; >- >- typedef HashSet<HTMLContentSelection*, Hash> PointerSet; >- >- PointerSet m_set; >-}; >- >-inline HTMLContentSelection* HTMLContentSelectionSet::find(const Node* key) const >-{ >- PointerSet::iterator found = m_set.find<const Node*, HTMLContentSelectionSet::Translator>(key); >- return found != m_set.end() ? *found : 0; >-} >- >-class HTMLContentSelector { >- WTF_MAKE_NONCOPYABLE(HTMLContentSelector); >-public: >- HTMLContentSelector(); >- ~HTMLContentSelector(); >- >- void select(InsertionPoint*, HTMLContentSelectionList*); >- void unselect(HTMLContentSelectionList*); >- HTMLContentSelection* findFor(const Node* key) const; >- >- void willSelect(); >- bool isSelecting() const; >- void didSelect(); >- >- void populateIfNecessary(Element* shadowHost); >- bool hasPopulated() const; >- >-private: >- enum SelectingPhase { >- SelectionPrevented, >- SelectionStarted, >- HostChildrenPopulated, >- }; >- >- void removeFromSet(HTMLContentSelectionList*); >- void addToSet(HTMLContentSelectionList*); >- >- Vector<RefPtr<Node> > m_candidates; >- HTMLContentSelectionSet m_selectionSet; >- SelectingPhase m_phase; >-}; >- >-inline bool HTMLContentSelector::isSelecting() const >-{ >- return m_phase != SelectionPrevented; >-} >- >-inline bool HTMLContentSelector::hasPopulated() const >-{ >- return m_phase == HostChildrenPopulated; >-} >- >-} >- >-#endif >diff --git a/Source/WebCore/html/shadow/InsertionPoint.cpp b/Source/WebCore/html/shadow/InsertionPoint.cpp >index 37e5101c37b2097e441f8a4412882eef3f529514..6c452417626548a385a91463ea4aefd1caf39b02 100644 >--- a/Source/WebCore/html/shadow/InsertionPoint.cpp >+++ b/Source/WebCore/html/shadow/InsertionPoint.cpp >@@ -38,7 +38,7 @@ namespace WebCore { > > InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document) > : HTMLElement(tagName, document) >- , m_selections() >+ , m_distribution() > { > } > >@@ -76,10 +76,10 @@ void InsertionPoint::detach() > > // When shadow element is detached, shadow tree should be recreated to re-calculate selector for > // other insertion points. >- shadow->setNeedsReattachHostChildrenAndShadow(); >+ shadow->setNeedsRecalcDistribution(); > } > >- ASSERT(m_selections.isEmpty()); >+ ASSERT(m_distribution.isEmpty()); > HTMLElement::detach(); > } > >@@ -119,41 +119,41 @@ bool InsertionPoint::rendererIsNeeded(const NodeRenderingContext& context) > > inline void InsertionPoint::distributeHostChildren(ElementShadow* shadow) > { >- if (!shadow->selector().isSelecting()) { >- // If HTMLContentSelector is not int selecting phase, it means InsertionPoint is attached from >+ if (!shadow->distributor().inDistribution()) { >+ // If ShadowDistributor is not int selecting phase, it means InsertionPoint is attached from > // non-ElementShadow node. To run distribute algorithm, we have to reattach ElementShadow. >- shadow->setNeedsReattachHostChildrenAndShadow(); >+ shadow->setNeedsRecalcDistribution(); > return; > } > >- shadow->selector().populateIfNecessary(shadow->host()); >- shadow->selector().unselect(&m_selections); >- shadow->selector().select(this, &m_selections); >+ shadow->distributor().preparePoolFor(shadow->host()); >+ shadow->distributor().clearDistribution(&m_distribution); >+ shadow->distributor().distribute(this, &m_distribution); > } > > inline void InsertionPoint::clearDistribution(ElementShadow* shadow) > { >- shadow->selector().unselect(&m_selections); >+ shadow->distributor().clearDistribution(&m_distribution); > } > > inline void InsertionPoint::attachDistributedNode() > { >- for (HTMLContentSelection* selection = m_selections.first(); selection; selection = selection->next()) >- selection->node()->attach(); >+ for (ShadowBoundaryDistribution::Item* item = m_distribution.first(); item; item = item->next()) >+ item->node()->attach(); > } > > inline void InsertionPoint::assignShadowRoot(ShadowRoot* shadowRoot) > { > shadowRoot->setAssignedTo(this); >- m_selections.clear(); >+ m_distribution.clear(); > for (Node* node = shadowRoot->firstChild(); node; node = node->nextSibling()) >- m_selections.append(HTMLContentSelection::create(this, node)); >+ m_distribution.append(this, node); > } > > inline void InsertionPoint::clearAssignment(ShadowRoot* shadowRoot) > { > shadowRoot->setAssignedTo(0); >- m_selections.clear(); >+ m_distribution.clear(); > } > > } // namespace WebCore >diff --git a/Source/WebCore/html/shadow/InsertionPoint.h b/Source/WebCore/html/shadow/InsertionPoint.h >index 840dd064790fcd936fed2c42b70283a921409fe2..d30625ed76e1d9fce844b9313c549f39d57ba3ed 100644 >--- a/Source/WebCore/html/shadow/InsertionPoint.h >+++ b/Source/WebCore/html/shadow/InsertionPoint.h >@@ -31,9 +31,9 @@ > #ifndef InsertionPoint_h > #define InsertionPoint_h > >-#include "HTMLContentSelector.h" > #include "HTMLElement.h" > #include "HTMLNames.h" >+#include "ShadowDistributor.h" > #include <wtf/Forward.h> > > namespace WebCore { >@@ -42,8 +42,8 @@ class InsertionPoint : public HTMLElement { > public: > virtual ~InsertionPoint(); > >- const HTMLContentSelectionList* selections() const { return &m_selections; } >- bool hasSelection() const { return m_selections.first(); } >+ const ShadowBoundaryDistribution* distribution() const { return &m_distribution; } >+ bool hasDistribution() const { return m_distribution.first(); } > bool isShadowBoundary() const; > bool isActive() const; > >@@ -69,7 +69,7 @@ private: > void assignShadowRoot(ShadowRoot*); > void clearAssignment(ShadowRoot*); > >- HTMLContentSelectionList m_selections; >+ ShadowBoundaryDistribution m_distribution; > }; > > inline bool isInsertionPoint(const Node* node) >diff --git a/Source/WebCore/html/shadow/ShadowDistributor.cpp b/Source/WebCore/html/shadow/ShadowDistributor.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..d46621de415eb694d42b476fb8d4dbd0b1b261d5 >--- /dev/null >+++ b/Source/WebCore/html/shadow/ShadowDistributor.cpp >@@ -0,0 +1,170 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#include "config.h" >+#include "ShadowDistributor.h" >+ >+#include "ContentSelectorQuery.h" >+#include "HTMLContentElement.h" >+#include "ShadowRoot.h" >+ >+ >+namespace WebCore { >+ >+ShadowBoundaryDistribution::ShadowBoundaryDistribution() >+{ >+} >+ >+ShadowBoundaryDistribution::~ShadowBoundaryDistribution() >+{ >+ ASSERT(isEmpty()); >+} >+ >+ShadowBoundaryDistribution::Item* ShadowBoundaryDistribution::find(Node* node) const >+{ >+ for (ShadowBoundaryDistribution::Item* item = first(); item; item = item->next()) { >+ if (node == item->node()) >+ return item; >+ } >+ >+ return 0; >+} >+ >+void ShadowBoundaryDistribution::clear() >+{ >+ if (isEmpty()) { >+ ASSERT(!m_last); >+ return; >+ } >+ >+ RefPtr<ShadowBoundaryDistribution::Item> item = m_first; >+ while (item) { >+ ASSERT(!item->previous()); >+ RefPtr<ShadowBoundaryDistribution::Item> nextItem = item->m_next; >+ item->m_next.clear(); >+ if (nextItem) >+ nextItem->m_previous.clear(); >+ item = nextItem; >+ } >+ >+ m_first.clear(); >+ m_last.clear(); >+} >+ >+void ShadowBoundaryDistribution::append(InsertionPoint* insertionPoint, Node* node) >+{ >+ RefPtr<Item> child = Item::create(insertionPoint, node); >+ >+ if (isEmpty()) { >+ ASSERT(!m_last); >+ m_first = m_last = child; >+ return; >+ } >+ >+ ASSERT(!m_last->next()); >+ ASSERT(!child->previous()); >+ m_last->m_next = child; >+ child->m_previous = m_last; >+ m_last = m_last->next(); >+} >+ >+ShadowDistributor::ShadowDistributor() >+ : m_phase(Prevented) >+{ >+} >+ >+ShadowDistributor::~ShadowDistributor() >+{ >+ ASSERT(m_pool.isEmpty()); >+} >+ >+void ShadowDistributor::distribute(InsertionPoint* insertionPoint, ShadowBoundaryDistribution* distribution) >+{ >+ ASSERT(m_phase == Prepared); >+ ASSERT(distribution->isEmpty()); >+ >+ ContentSelectorQuery query(insertionPoint); >+ >+ for (size_t i = 0; i < m_pool.size(); ++i) { >+ Node* child = m_pool[i].get(); >+ if (!child) >+ continue; >+ if (!query.matches(child)) >+ continue; >+ >+ distribution->append(insertionPoint, child); >+ m_nodeToInsertionPoint.add(distribution->last()); >+ m_pool[i] = 0; >+ } >+} >+ >+void ShadowDistributor::clearDistribution(ShadowBoundaryDistribution* list) >+{ >+ for (ShadowBoundaryDistribution::Item* item = list->first(); item; item = item->next()) >+ m_nodeToInsertionPoint.remove(item); >+ >+ list->clear(); >+} >+ >+ShadowBoundaryDistribution::Item* ShadowDistributor::findFor(const Node* key) const >+{ >+ InvertedTable::iterator found = m_nodeToInsertionPoint.find<const Node*, Translator>(key); >+ return found != m_nodeToInsertionPoint.end() ? *found : 0; >+} >+ >+InsertionPoint* ShadowDistributor::findInsertionPointFor(const Node* key) const >+{ >+ InvertedTable::iterator found = m_nodeToInsertionPoint.find<const Node*, Translator>(key); >+ return found != m_nodeToInsertionPoint.end() ? (*found)->insertionPoint() : 0; >+} >+ >+void ShadowDistributor::willDistribute() >+{ >+ m_phase = Started; >+} >+ >+void ShadowDistributor::didDistribute() >+{ >+ ASSERT(m_phase != Prevented); >+ m_phase = Prevented; >+ m_pool.clear(); >+} >+ >+void ShadowDistributor::preparePoolFor(Element* shadowHost) >+{ >+ if (poolIsReady()) >+ return; >+ >+ ASSERT(m_pool.isEmpty()); >+ ASSERT(shadowHost); >+ ASSERT(m_phase == Started); >+ >+ m_phase = Prepared; >+ for (Node* node = shadowHost->firstChild(); node; node = node->nextSibling()) >+ m_pool.append(node); >+} >+ >+} >diff --git a/Source/WebCore/html/shadow/ShadowDistributor.h b/Source/WebCore/html/shadow/ShadowDistributor.h >new file mode 100644 >index 0000000000000000000000000000000000000000..0efa85734bb3b5af6b8fa870521ccddce9d5e1e9 >--- /dev/null >+++ b/Source/WebCore/html/shadow/ShadowDistributor.h >@@ -0,0 +1,148 @@ >+/* >+ * Copyright (C) 2011 Google Inc. All rights reserved. >+ * >+ * Redistribution and use in source and binary forms, with or without >+ * modification, are permitted provided that the following conditions are >+ * met: >+ * >+ * * Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * * Redistributions in binary form must reproduce the above >+ * copyright notice, this list of conditions and the following disclaimer >+ * in the documentation and/or other materials provided with the >+ * distribution. >+ * * Neither the name of Google Inc. nor the names of its >+ * contributors may be used to endorse or promote products derived from >+ * this software without specific prior written permission. >+ * >+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS >+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT >+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR >+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT >+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, >+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT >+ * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, >+ * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY >+ * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT >+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE >+ * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. >+ */ >+ >+#ifndef ShadowDistributor_h >+#define ShadowDistributor_h >+ >+#include <wtf/Forward.h> >+#include <wtf/HashSet.h> >+#include <wtf/RefCounted.h> >+#include <wtf/Vector.h> >+ >+namespace WebCore { >+ >+class Element; >+class InsertionPoint; >+class Node; >+class ShadowRoot; >+ >+class ShadowBoundaryDistribution { >+public: >+ class Item : public RefCounted<Item> { >+ public: >+ friend class ShadowBoundaryDistribution; >+ >+ InsertionPoint* insertionPoint() const { return m_insertionPoint; } >+ Node* node() const { return m_node.get(); } >+ Item* next() const { return m_next.get(); } >+ Item* previous() const { return m_previous.get(); } >+ >+ private: >+ static PassRefPtr<Item> create(InsertionPoint* insertionPoint, Node* node) { return adoptRef(new Item(insertionPoint, node)); } >+ >+ Item(InsertionPoint* insertionPoint, Node* node) >+ : m_insertionPoint(insertionPoint) >+ , m_node(node) >+ { } >+ >+ InsertionPoint* m_insertionPoint; >+ RefPtr<Node> m_node; >+ RefPtr<Item> m_next; >+ RefPtr<Item> m_previous; >+ }; >+ >+ ShadowBoundaryDistribution(); >+ ~ShadowBoundaryDistribution(); >+ >+ Item* first() const { return m_first.get(); } >+ Item* last() const { return m_last.get(); } >+ Node* firstNode() const { return m_first ? m_first->node() : 0; } >+ Node* lastNode() const { return m_first ? m_last->node() : 0; } >+ >+ Item* find(Node*) const; >+ bool isEmpty() const { return !m_first; } >+ >+ void clear(); >+ void append(InsertionPoint*, Node*); >+ >+private: >+ >+ RefPtr<Item> m_first; >+ RefPtr<Item> m_last; >+}; >+ >+class ShadowDistributor { >+ WTF_MAKE_NONCOPYABLE(ShadowDistributor); >+public: >+ ShadowDistributor(); >+ ~ShadowDistributor(); >+ >+ void distribute(InsertionPoint*, ShadowBoundaryDistribution*); >+ void clearDistribution(ShadowBoundaryDistribution*); >+ ShadowBoundaryDistribution::Item* findFor(const Node* key) const; >+ InsertionPoint* findInsertionPointFor(const Node* key) const; >+ >+ void willDistribute(); >+ bool inDistribution() const; >+ void didDistribute(); >+ >+ void preparePoolFor(Element* shadowHost); >+ bool poolIsReady() const; >+ >+private: >+ struct Translator { >+ public: >+ static unsigned hash(const Node* key) { return PtrHash<const Node*>::hash(key); } >+ static bool equal(const ShadowBoundaryDistribution::Item* item, const Node* node) { return item->node() == node; } >+ }; >+ >+ struct Hash { >+ static unsigned hash(ShadowBoundaryDistribution::Item* key) { return PtrHash<const Node*>::hash(key->node()); } >+ static bool equal(ShadowBoundaryDistribution::Item* a, ShadowBoundaryDistribution::Item* b) { return a->node() == b->node(); } >+ static const bool safeToCompareToEmptyOrDeleted = false; >+ }; >+ >+ // Used as a table from Node to InseretionPoint >+ typedef HashSet<ShadowBoundaryDistribution::Item*, Hash> InvertedTable; >+ >+ enum DistributionPhase { >+ Prevented, >+ Started, >+ Prepared, >+ }; >+ >+ Vector<RefPtr<Node> > m_pool; >+ DistributionPhase m_phase; >+ InvertedTable m_nodeToInsertionPoint; >+}; >+ >+inline bool ShadowDistributor::inDistribution() const >+{ >+ return m_phase != Prevented; >+} >+ >+inline bool ShadowDistributor::poolIsReady() const >+{ >+ return m_phase == Prepared; >+} >+ >+} >+ >+#endif
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 86064
:
141329
|
141338
|
141348
|
141622
|
141623
|
141683