Changeset 116974 in webkit


Ignore:
Timestamp:
May 14, 2012 11:54:22 AM (12 years ago)
Author:
morrita@google.com
Message:

[Shadow DOM][Refactoring] HTMLContentSelector family should have better name
https://bugs.webkit.org/show_bug.cgi?id=86064

Reviewed by Dimitri Glazkov.

This change renames classes around shadow content distribution.

  • Renamed HTMLContentSelector to ContentDistributor
  • Renamed HTMLContentSelectionList to ContentDistribution
  • Renamed HTMLContentSelection to ContentDistribution::Item
  • Inlined HTMLContentSelectionSet into ContentDistributor

Associated rename and inlining are also happening for method names.

No new tests. No behavior change.

  • CMakeLists.txt:
  • GNUmakefile.list.am:
  • Target.pri:
  • WebCore.gypi:
  • WebCore.vcproj/WebCore.vcproj:
  • WebCore.xcodeproj/project.pbxproj:
  • dom/ComposedShadowTreeWalker.cpp:

(WebCore::ComposedShadowTreeWalker::traverseNode):
(WebCore::ComposedShadowTreeWalker::traverseSiblingOrBackToInsertionPoint):
(WebCore::ComposedShadowTreeWalker::traverseParent):

  • dom/ElementShadow.cpp:

(WebCore::ElementShadow::ElementShadow):
(WebCore::ElementShadow::attach):
(WebCore::ElementShadow::insertionPointFor):
(WebCore::ElementShadow::distributionItemFor):
(WebCore::ElementShadow::recalcStyle):
(WebCore::ElementShadow::needsRedistributing):
(WebCore::ElementShadow::hostChildrenChanged):
(WebCore::ElementShadow::setNeedsRedistributing):

  • dom/ElementShadow.h:

(WebCore):
(ElementShadow):
(WebCore::ElementShadow::distributor):
(WebCore::ElementShadow::clearNeedsRedistributing):

  • dom/NodeRenderingContext.cpp:

(WebCore::NodeRenderingContext::NodeRenderingContext):
(WebCore::nextRendererOfInsertionPoint):
(WebCore::previousRendererOfInsertionPoint):
(WebCore::firstRendererOfInsertionPoint):
(WebCore::lastRendererOfInsertionPoint):

  • dom/ShadowRoot.cpp:
  • dom/ShadowRoot.h:

(WebCore):

  • html/shadow/ContentDistributor.cpp: Renamed from Source/WebCore/html/shadow/HTMLContentSelector.cpp.

(WebCore):
(WebCore::ContentDistribution::ContentDistribution):
(WebCore::ContentDistribution::~ContentDistribution):
(WebCore::ContentDistribution::find):
(WebCore::ContentDistribution::clear):
(WebCore::ContentDistribution::append):
(WebCore::ContentDistributor::ContentDistributor):
(WebCore::ContentDistributor::~ContentDistributor):
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::clearDistribution):
(WebCore::ContentDistributor::findFor):
(WebCore::ContentDistributor::findInsertionPointFor):
(WebCore::ContentDistributor::willDistribute):
(WebCore::ContentDistributor::didDistribute):
(WebCore::ContentDistributor::preparePoolFor):

  • html/shadow/ContentDistributor.h: Added.

(WebCore):
(ContentDistribution):
(Item):
(WebCore::ContentDistribution::Item::insertionPoint):
(WebCore::ContentDistribution::Item::node):
(WebCore::ContentDistribution::Item::next):
(WebCore::ContentDistribution::Item::previous):
(WebCore::ContentDistribution::Item::create):
(WebCore::ContentDistribution::Item::Item):
(WebCore::ContentDistribution::first):
(WebCore::ContentDistribution::last):
(WebCore::ContentDistribution::firstNode):
(WebCore::ContentDistribution::lastNode):
(WebCore::ContentDistribution::isEmpty):
(ContentDistributor):
(Translator):
(WebCore::ContentDistributor::Translator::hash):
(WebCore::ContentDistributor::Translator::equal):
(WebCore::ContentDistributor::Hash::hash):
(WebCore::ContentDistributor::Hash::equal):
(Hash):
(WebCore::ContentDistributor::inDistribution):
(WebCore::ContentDistributor::poolIsReady):

  • html/shadow/HTMLContentElement.cpp:

(WebCore::HTMLContentElement::parseAttribute):

  • html/shadow/HTMLContentSelector.h: Removed.
  • html/shadow/InsertionPoint.cpp:

(WebCore::InsertionPoint::InsertionPoint):
(WebCore::InsertionPoint::detach):
(WebCore::InsertionPoint::distributeHostChildren):
(WebCore::InsertionPoint::clearDistribution):
(WebCore::InsertionPoint::attachDistributedNode):
(WebCore::InsertionPoint::assignShadowRoot):
(WebCore::InsertionPoint::clearAssignment):

  • html/shadow/InsertionPoint.h:

(WebCore::InsertionPoint::distribution):
(WebCore::InsertionPoint::hasDistribution):

Location:
trunk/Source/WebCore
Files:
1 added
1 deleted
16 edited
1 moved

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/CMakeLists.txt

    r116840 r116974  
    902902    html/parser/XSSAuditor.cpp
    903903
     904    html/shadow/ContentDistributor.cpp
    904905    html/shadow/ContentSelectorQuery.cpp
    905906    html/shadow/DetailsMarkerControl.cpp
    906907    html/shadow/HTMLContentElement.cpp
    907     html/shadow/HTMLContentSelector.cpp
    908908    html/shadow/HTMLShadowElement.cpp
    909909    html/shadow/InsertionPoint.cpp
  • trunk/Source/WebCore/ChangeLog

    r116970 r116974  
     12012-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
    11062012-05-14  Sheriff Bot  <webkit.review.bot@gmail.com>
    2107
  • trunk/Source/WebCore/GNUmakefile.list.am

    r116840 r116974  
    25032503        Source/WebCore/html/shadow/CalendarPickerElement.cpp \
    25042504        Source/WebCore/html/shadow/CalendarPickerElement.h \
     2505        Source/WebCore/html/shadow/ContentDistributor.cpp \
     2506        Source/WebCore/html/shadow/ContentDistributor.h \
    25052507        Source/WebCore/html/shadow/ContentSelectorQuery.cpp \
    25062508        Source/WebCore/html/shadow/ContentSelectorQuery.h \
     
    25092511        Source/WebCore/html/shadow/HTMLContentElement.cpp \
    25102512        Source/WebCore/html/shadow/HTMLContentElement.h \
    2511         Source/WebCore/html/shadow/HTMLContentSelector.cpp \
    2512         Source/WebCore/html/shadow/HTMLContentSelector.h \
    25132513        Source/WebCore/html/shadow/InsertionPoint.cpp \
    25142514        Source/WebCore/html/shadow/InsertionPoint.h \
  • trunk/Source/WebCore/Target.pri

    r116840 r116974  
    873873    html/parser/TextViewSourceParser.cpp \
    874874    html/parser/XSSAuditor.cpp \
     875    html/shadow/ContentDistributor.cpp \
    875876    html/shadow/ContentSelectorQuery.cpp \
    876877    html/shadow/DetailsMarkerControl.cpp \
    877878    html/shadow/HTMLContentElement.cpp \
    878     html/shadow/HTMLContentSelector.cpp \
    879879    html/shadow/HTMLShadowElement.cpp \
    880880    html/shadow/InsertionPoint.cpp \
     
    19991999    html/parser/HTMLViewSourceParser.h \
    20002000    html/parser/XSSAuditor.h \
     2001    html/shadow/ContentDistributor.h \
    20012002    html/shadow/ContentSelectorQuery.h \
    20022003    html/shadow/HTMLContentElement.h \
    2003     html/shadow/HTMLContentSelector.h \
    20042004    html/shadow/HTMLShadowElement.h \
    20052005    html/shadow/MediaControlElements.h \
  • trunk/Source/WebCore/WebCore.gypi

    r116854 r116974  
    57935793            'html/shadow/CalendarPickerElement.cpp',
    57945794            'html/shadow/CalendarPickerElement.h',
     5795            'html/shadow/ContentDistributor.cpp',
     5796            'html/shadow/ContentDistributor.h',
    57955797            'html/shadow/ContentSelectorQuery.cpp',
    57965798            'html/shadow/ContentSelectorQuery.h',
     
    57995801            'html/shadow/HTMLContentElement.cpp',
    58005802            'html/shadow/HTMLContentElement.h',
    5801             'html/shadow/HTMLContentSelector.cpp',
    5802             'html/shadow/HTMLContentSelector.h',
    58035803            'html/shadow/HTMLShadowElement.cpp',
    58045804            'html/shadow/HTMLShadowElement.h',
  • trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj

    r116843 r116974  
    6274262742                                </File>
    6274362743                                <File
    62744                                         RelativePath="..\html\shadow\HTMLContentSelector.cpp"
    62745                                         >
    62746                                 </File>
    62747                                 <File
    62748                                         RelativePath="..\html\shadow\HTMLContentSelector.h"
    62749                                         >
    62750                                 </File>
    62751                                 <File
    6275262744                                        RelativePath="..\html\shadow\HTMLShadowElement.cpp"
    6275362745                                        >
     
    6280062792                                                />
    6280162793                                        </FileConfiguration>
     62794                                </File>
     62795                                <File
     62796                                        RelativePath="..\html\shadow\ContentDistributor.cpp"
     62797                                        >
     62798                                </File>
     62799                                <File
     62800                                        RelativePath="..\html\shadow\ContentDistributor.h"
     62801                                        >
    6280262802                                </File>
    6280362803                                <File
  • trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj

    r116840 r116974  
    15851585                578DA20E1520EB8C006141C1 /* InspectorFrontend.h in Headers */ = {isa = PBXBuildFile; fileRef = 4F4F5FFC11CBD30100A186BF /* InspectorFrontend.h */; settings = {ATTRIBUTES = (Private, ); }; };
    15861586                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 */; };
    15891589                57B791A514C6A62900F202D1 /* ContentSelectorQuery.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */; };
    15901590                57B791A614C6A62900F202D1 /* ContentSelectorQuery.h in Headers */ = {isa = PBXBuildFile; fileRef = 57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */; };
     
    86028602                5740E83A1532DE1700760628 /* TreeScopeAdjuster.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TreeScopeAdjuster.cpp; sourceTree = "<group>"; };
    86038603                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>"; };
    86068606                57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ContentSelectorQuery.cpp; sourceTree = "<group>"; };
    86078607                57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ContentSelectorQuery.h; sourceTree = "<group>"; };
     
    1461814618                        isa = PBXGroup;
    1461914619                        children = (
     14620                                57B7919F14C6A62900F202D1 /* ContentDistributor.cpp */,
     14621                                57B791A014C6A62900F202D1 /* ContentDistributor.h */,
    1462014622                                57B791A114C6A62900F202D1 /* ContentSelectorQuery.cpp */,
    1462114623                                57B791A214C6A62900F202D1 /* ContentSelectorQuery.h */,
     
    1462514627                                57B791A814C6A63300F202D1 /* HTMLContentElement.h */,
    1462614628                                A7B7749614CF6353004044BB /* HTMLContentElement.idl */,
    14627                                 57B7919F14C6A62900F202D1 /* HTMLContentSelector.cpp */,
    14628                                 57B791A014C6A62900F202D1 /* HTMLContentSelector.h */,
    1462914629                                4ABDFF0714DBE312004D117D /* HTMLShadowElement.cpp */,
    1463014630                                4ABDFF0814DBE312004D117D /* HTMLShadowElement.h */,
     
    2190121901                                E1A1470811102B1500EEC0F3 /* ContainerNodeAlgorithms.h in Headers */,
    2190221902                                BC5EB9810E82072500B25965 /* ContentData.h in Headers */,
     21903                                57B791A414C6A62900F202D1 /* ContentDistributor.h in Headers */,
    2190321904                                59102FBC14327D3B003C9D04 /* ContentSearchUtils.h in Headers */,
    2190421905                                97C471DC12F925BD0086354B /* ContentSecurityPolicy.h in Headers */,
     
    2294222943                                977B3865122883E900B81FF8 /* HTMLConstructionSite.h in Headers */,
    2294322944                                57B791AA14C6A63300F202D1 /* HTMLContentElement.h in Headers */,
    22944                                 57B791A414C6A62900F202D1 /* HTMLContentSelector.h in Headers */,
    2294522945                                E1A31663134BCAE8007C9A4F /* HTMLConverter.h in Headers */,
    2294622946                                F5C041DB0FFCA7CE00839D4A /* HTMLDataListElement.h in Headers */,
     
    2540825408                                A7A78CD51532BA62006C21E4 /* ContainerNodeAlgorithms.cpp in Sources */,
    2540925409                                BC5EB9800E82072500B25965 /* ContentData.cpp in Sources */,
     25410                                57B791A314C6A62900F202D1 /* ContentDistributor.cpp in Sources */,
    2541025411                                59102FBB14327D3B003C9D04 /* ContentSearchUtils.cpp in Sources */,
    2541125412                                97C471DB12F925BD0086354B /* ContentSecurityPolicy.cpp in Sources */,
     
    2607826079                                977B3864122883E900B81FF8 /* HTMLConstructionSite.cpp in Sources */,
    2607926080                                57B791A914C6A63300F202D1 /* HTMLContentElement.cpp in Sources */,
    26080                                 57B791A314C6A62900F202D1 /* HTMLContentSelector.cpp in Sources */,
    2608126081                                5D4F51DF132725480016F541 /* HTMLConverter.mm in Sources */,
    2608226082                                F5C041DA0FFCA7CE00839D4A /* HTMLDataListElement.cpp in Sources */,
  • trunk/Source/WebCore/dom/ComposedShadowTreeWalker.cpp

    r116730 r116974  
    2828#include "ComposedShadowTreeWalker.h"
    2929
     30#include "ContentDistributor.h"
    3031#include "Element.h"
    3132#include "ElementShadow.h"
    32 #include "HTMLContentSelector.h"
    3333#include "InsertionPoint.h"
    34 
    3534
    3635namespace WebCore {
     
    115114    ASSERT(node);
    116115    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);
    120119        return traverseLightChildren(node, direction);
    121120    }
     
    143142    if (!shadow)
    144143        return traverseSiblingInCurrentTree(node, direction);
    145     HTMLContentSelection* selection = shadow->selectionFor(node);
    146     if (!selection)
     144    ContentDistribution::Item* item = shadow->distributionItemFor(node);
     145    if (!item)
    147146        return traverseSiblingInCurrentTree(node, direction);
    148     if (HTMLContentSelection* nextSelection = (direction == TraversalDirectionForward ? selection->next() : selection->previous()))
    149         return traverseNode(nextSelection->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);
    151150}
    152151
     
    205204    }
    206205    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);
    209208    }
    210209    return traverseParentInCurrentTree(node);
  • trunk/Source/WebCore/dom/ElementShadow.cpp

    r116730 r116974  
    4141
    4242ElementShadow::ElementShadow()
    43     : m_needsRecalculateContent(false)
     43    : m_needsRedistributing(false)
    4444{
    4545}
     
    120120void ElementShadow::attach()
    121121{
    122     // Children of m_selector is populated lazily in
    123     // ensureSelector(), 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();
    127127    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
    128128        if (!root->attached())
    129129            root->attach();
    130130    }
    131     selector().didSelect();
     131    distributor().didDistribute();
    132132}
    133133
     
    165165    }
    166166
    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
     170ContentDistribution::Item* ElementShadow::distributionItemFor(const Node* node) const
     171{
     172    return m_distributor.findFor(node);
    176173}
    177174
     
    208205        return;
    209206
    210     if (needsReattachHostChildrenAndShadow())
     207    if (needsRedistributing())
    211208        reattachHostChildrenAndShadow();
    212209    else {
     
    223220    }
    224221
    225     clearNeedsReattachHostChildrenAndShadow();
     222    clearNeedsRedistributing();
    226223    for (ShadowRoot* root = youngestShadowRoot(); root; root = root->olderShadowRoot()) {
    227224        root->clearNeedsStyleRecalc();
     
    230227}
    231228
    232 bool ElementShadow::needsReattachHostChildrenAndShadow()
    233 {
    234     return m_needsRecalculateContent || (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint());
     229bool ElementShadow::needsRedistributing()
     230{
     231    return m_needsRedistributing || (youngestShadowRoot() && youngestShadowRoot()->hasInsertionPoint());
    235232}
    236233
     
    243240
    244241    // This results in forced detaching/attaching of the shadow render tree. See ShadowRoot::recalcStyle().
    245     setNeedsReattachHostChildrenAndShadow();
    246 }
    247 
    248 void ElementShadow::setNeedsReattachHostChildrenAndShadow()
    249 {
    250     m_needsRecalculateContent = true;
     242    setNeedsRedistributing();
     243}
     244
     245void ElementShadow::setNeedsRedistributing()
     246{
     247    m_needsRedistributing = true;
    251248
    252249    host()->setNeedsStyleRecalc();
  • trunk/Source/WebCore/dom/ElementShadow.h

    r116730 r116974  
    2828#define ElementShadow_h
    2929
     30#include "ContentDistributor.h"
    3031#include "ExceptionCode.h"
    31 #include "HTMLContentSelector.h"
    3232#include "ShadowRoot.h"
    3333#include <wtf/DoublyLinkedList.h>
     
    4141class Node;
    4242class Element;
    43 class InsertionPoint;
    4443class TreeScope;
    45 class HTMLContentSelection;
    4644
    4745class ElementShadow {
     
    6765    bool needsStyleRecalc();
    6866    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();
    7370    void hostChildrenChanged();
    7471
    7572    InsertionPoint* insertionPointFor(const Node*) const;
    76     HTMLContentSelection* selectionFor(const Node*) const;
     73    ContentDistribution::Item* distributionItemFor(const Node*) const;
    7774
    78     HTMLContentSelector& selector();
    79     const HTMLContentSelector& selector() const;
     75    ContentDistributor& distributor();
     76    const ContentDistributor& distributor() const;
    8077
    8178private:
    8279    void removeAllShadowRoots();
     80    void reattachHostChildrenAndShadow();
    8381
    8482    DoublyLinkedList<ShadowRoot> m_shadowRoots;
    85     HTMLContentSelector m_selector;
    86     bool m_needsRecalculateContent : 1;
     83    ContentDistributor m_distributor;
     84    bool m_needsRedistributing : 1;
    8785    WTF_MAKE_NONCOPYABLE(ElementShadow);
    8886};
     
    9896}
    9997
    100 inline HTMLContentSelector& ElementShadow::selector()
     98inline ContentDistributor& ElementShadow::distributor()
    10199{
    102     return m_selector;
     100    return m_distributor;
    103101}
    104102
    105 inline const HTMLContentSelector& ElementShadow::selector() const
     103inline const ContentDistributor& ElementShadow::distributor() const
    106104{
    107     return m_selector;
     105    return m_distributor;
    108106}
    109107
    110 inline void ElementShadow::clearNeedsReattachHostChildrenAndShadow()
     108inline void ElementShadow::clearNeedsRedistributing()
    111109{
    112     m_needsRecalculateContent = false;
     110    m_needsRedistributing = false;
    113111}
    114112
  • trunk/Source/WebCore/dom/NodeRenderingContext.cpp

    r116730 r116974  
    2828
    2929#include "ContainerNode.h"
     30#include "ContentDistributor.h"
    3031#include "ElementShadow.h"
    3132#include "FlowThreadController.h"
    3233#include "HTMLContentElement.h"
    33 #include "HTMLContentSelector.h"
    3434#include "HTMLNames.h"
    3535#include "HTMLShadowElement.h"
     
    9898            }
    9999
    100             if (toInsertionPoint(parent)->hasSelection())
     100            if (toInsertionPoint(parent)->hasDistribution())
    101101                m_phase = AttachingNotFallbacked;
    102102            else
     
    143143static inline RenderObject* nextRendererOfInsertionPoint(InsertionPoint* parent, Node* current)
    144144{
    145     HTMLContentSelection* currentSelection = parent->selections()->find(current);
    146     if (!currentSelection)
    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())
    151151            return renderer;
    152152    }
     
    159159    RenderObject* lastRenderer = 0;
    160160
    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)
    163163            break;
    164         if (RenderObject* renderer = selection->node()->renderer())
     164        if (RenderObject* renderer = item->node()->renderer())
    165165            lastRenderer = renderer;
    166166    }
     
    171171static inline RenderObject* firstRendererOfInsertionPoint(InsertionPoint* parent)
    172172{
    173     if (parent->hasSelection()) {
    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())
    176176                return renderer;
    177177        }
     
    185185static inline RenderObject* lastRendererOfInsertionPoint(InsertionPoint* parent)
    186186{
    187     if (parent->hasSelection()) {
    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())
    190190                return renderer;
    191191        }
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r116746 r116974  
    2828#include "ShadowRoot.h"
    2929
     30#include "ContentDistributor.h"
    3031#include "DOMSelection.h"
    3132#include "DOMWindow.h"
     
    3536#include "ElementShadow.h"
    3637#include "HTMLContentElement.h"
    37 #include "HTMLContentSelector.h"
    3838#include "HTMLNames.h"
    3939#include "InsertionPoint.h"
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r116521 r116974  
    3939class Document;
    4040class DOMSelection;
    41 class HTMLContentElement;
    42 class HTMLContentSelector;
    4341class InsertionPoint;
    4442class ElementShadow;
     
    6159    void recalcShadowTreeStyle(StyleChange);
    6260
    63     void setNeedsReattachHostChildrenAndShadow();
    64     void clearNeedsReattachHostChildrenAndShadow();
    65     bool needsReattachHostChildrenAndShadow();
     61    void setNeedsRedistributing();
     62    void clearNeedsRedistributing();
     63    bool needsRedistributing();
    6664
    6765    InsertionPoint* insertionPointFor(Node*) const;
  • trunk/Source/WebCore/html/shadow/ContentDistributor.cpp

    r116973 r116974  
    2626
    2727#include "config.h"
    28 #include "HTMLContentSelector.h"
     28#include "ContentDistributor.h"
    2929
    3030#include "ContentSelectorQuery.h"
     
    3535namespace WebCore {
    3636
    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()
     37ContentDistribution::ContentDistribution()
    6038{
    6139}
    6240
    63 HTMLContentSelectionList::~HTMLContentSelectionList()
     41ContentDistribution::~ContentDistribution()
    6442{
    6543    ASSERT(isEmpty());
    6644}
    6745
    68 HTMLContentSelection* HTMLContentSelectionList::find(Node* node) const
     46ContentDistribution::Item* ContentDistribution::find(Node* node) const
    6947{
    70     for (HTMLContentSelection* item = first(); item; item = item->next()) {
     48    for (ContentDistribution::Item* item = first(); item; item = item->next()) {
    7149        if (node == item->node())
    7250            return item;
     
    7654}
    7755
    78 void HTMLContentSelectionList::clear()
     56void ContentDistribution::clear()
    7957{
    8058    if (isEmpty()) {
     
    8361    }
    8462
    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
    8673    m_first.clear();
    8774    m_last.clear();
    8875}
    8976
    90 void HTMLContentSelectionList::append(PassRefPtr<HTMLContentSelection> child)
     77void ContentDistribution::append(InsertionPoint* insertionPoint, Node* node)
    9178{
     79    RefPtr<Item> child = Item::create(insertionPoint, node);
     80
    9281    if (isEmpty()) {
    9382        ASSERT(!m_last);
     
    9685    }
    9786
    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;
    9991    m_last = m_last->next();
    10092}
    10193
    102 HTMLContentSelector::HTMLContentSelector()
    103     : m_phase(SelectionPrevented)
     94ContentDistributor::ContentDistributor()
     95    : m_phase(Prevented)
    10496{
    10597}
    10698
    107 HTMLContentSelector::~HTMLContentSelector()
     99ContentDistributor::~ContentDistributor()
    108100{
    109     ASSERT(m_candidates.isEmpty());
     101    ASSERT(m_pool.isEmpty());
    110102}
    111103
    112 void HTMLContentSelector::select(InsertionPoint* insertionPoint, HTMLContentSelectionList* selections)
     104void ContentDistributor::distribute(InsertionPoint* insertionPoint, ContentDistribution* distribution)
    113105{
    114     ASSERT(m_phase == HostChildrenPopulated);
    115     ASSERT(selections->isEmpty());
     106    ASSERT(m_phase == Prepared);
     107    ASSERT(distribution->isEmpty());
    116108
    117109    ContentSelectorQuery query(insertionPoint);
    118110
    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();
    121113        if (!child)
    122114            continue;
     
    124116            continue;
    125117
    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;
    131121    }
    132122}
    133123
    134 void HTMLContentSelector::unselect(HTMLContentSelectionList* list)
     124void ContentDistributor::clearDistribution(ContentDistribution* list)
    135125{
    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
    138129    list->clear();
    139130}
    140131
    141 HTMLContentSelection* HTMLContentSelector::findFor(const Node* key) const
     132ContentDistribution::Item* ContentDistributor::findFor(const Node* key) const
    142133{
    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;
    144136}
    145137
    146 void HTMLContentSelector::willSelect()
     138InsertionPoint* ContentDistributor::findInsertionPointFor(const Node* key) const
    147139{
    148     m_phase = SelectionStarted;
     140    InvertedTable::iterator found = m_nodeToInsertionPoint.find<const Node*, Translator>(key);
     141    return found != m_nodeToInsertionPoint.end() ? (*found)->insertionPoint() : 0;
    149142}
    150143
    151 void HTMLContentSelector::didSelect()
     144void ContentDistributor::willDistribute()
    152145{
    153     ASSERT(m_phase != SelectionPrevented);
    154     m_phase = SelectionPrevented;
    155     m_candidates.clear();
     146    m_phase = Started;
    156147}
    157148
    158 void HTMLContentSelector::populateIfNecessary(Element* shadowHost)
     149void ContentDistributor::didDistribute()
    159150{
    160     if (hasPopulated())
     151    ASSERT(m_phase != Prevented);
     152    m_phase = Prevented;
     153    m_pool.clear();
     154}
     155
     156void ContentDistributor::preparePoolFor(Element* shadowHost)
     157{
     158    if (poolIsReady())
    161159        return;
    162160
    163     ASSERT(m_candidates.isEmpty());
     161    ASSERT(m_pool.isEmpty());
    164162    ASSERT(shadowHost);
    165     ASSERT(m_phase == SelectionStarted);
     163    ASSERT(m_phase == Started);
    166164
    167     m_phase = HostChildrenPopulated;
     165    m_phase = Prepared;
    168166    for (Node* node = shadowHost->firstChild(); node; node = node->nextSibling())
    169         m_candidates.append(node);
     167        m_pool.append(node);
    170168}
    171169
  • trunk/Source/WebCore/html/shadow/HTMLContentElement.cpp

    r116277 r116974  
    2828#include "HTMLContentElement.h"
    2929
     30#include "ContentDistributor.h"
    3031#include "ContentSelectorQuery.h"
    3132#include "ElementShadow.h"
    32 #include "HTMLContentSelector.h"
    3333#include "HTMLNames.h"
    3434#include "QualifiedName.h"
     
    9191    if (attr->name() == selectAttr) {
    9292        if (ShadowRoot* root = toShadowRoot(shadowTreeRootNode()))
    93             root->owner()->setNeedsReattachHostChildrenAndShadow();
     93            root->owner()->setNeedsRedistributing();
    9494    } else
    9595        InsertionPoint::parseAttribute(attr);
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r116277 r116974  
    3939InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document)
    4040    : HTMLElement(tagName, document)
    41     , m_selections()
     41    , m_distribution()
    4242{
    4343}
     
    7777        // When shadow element is detached, shadow tree should be recreated to re-calculate selector for
    7878        // other insertion points.
    79         shadow->setNeedsReattachHostChildrenAndShadow();
     79        shadow->setNeedsRedistributing();
    8080    }
    8181
    82     ASSERT(m_selections.isEmpty());
     82    ASSERT(m_distribution.isEmpty());
    8383    HTMLElement::detach();
    8484}
     
    120120inline void InsertionPoint::distributeHostChildren(ElementShadow* shadow)
    121121{
    122     if (!shadow->selector().isSelecting()) {
    123         // If HTMLContentSelector is not int selecting phase, it means InsertionPoint is attached from
     122    if (!shadow->distributor().inDistribution()) {
     123        // If ContentDistributor is not int selecting phase, it means InsertionPoint is attached from
    124124        // non-ElementShadow node. To run distribute algorithm, we have to reattach ElementShadow.
    125         shadow->setNeedsReattachHostChildrenAndShadow();
     125        shadow->setNeedsRedistributing();
    126126        return;
    127127    }
    128128
    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);
    132132}
    133133
    134134inline void InsertionPoint::clearDistribution(ElementShadow* shadow)
    135135{
    136     shadow->selector().unselect(&m_selections);
     136    shadow->distributor().clearDistribution(&m_distribution);
    137137}
    138138
    139139inline void InsertionPoint::attachDistributedNode()
    140140{
    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();
    143143}
    144144
     
    146146{
    147147    shadowRoot->setAssignedTo(this);
    148     m_selections.clear();
     148    m_distribution.clear();
    149149    for (Node* node = shadowRoot->firstChild(); node; node = node->nextSibling())
    150         m_selections.append(HTMLContentSelection::create(this, node));
     150        m_distribution.append(this, node);
    151151}
    152152
     
    154154{
    155155    shadowRoot->setAssignedTo(0);
    156     m_selections.clear();
     156    m_distribution.clear();
    157157}
    158158
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r116277 r116974  
    3232#define InsertionPoint_h
    3333
    34 #include "HTMLContentSelector.h"
     34#include "ContentDistributor.h"
    3535#include "HTMLElement.h"
    3636#include "HTMLNames.h"
     
    4343    virtual ~InsertionPoint();
    4444
    45     const HTMLContentSelectionList* selections() const { return &m_selections; }
    46     bool hasSelection() const { return m_selections.first(); }
     45    const ContentDistribution* distribution() const { return &m_distribution; }
     46    bool hasDistribution() const { return m_distribution.first(); }
    4747    bool isShadowBoundary() const;
    4848    bool isActive() const;
     
    7070    void clearAssignment(ShadowRoot*);
    7171
    72     HTMLContentSelectionList m_selections;
     72    ContentDistribution m_distribution;
    7373};
    7474
Note: See TracChangeset for help on using the changeset viewer.