⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 150480 in webkit


Ignore:
Timestamp:
May 21, 2013, 2:38:13 PM (13 years ago)
Author:
Antti Koivisto
Message:

Remove ScopeContentDistribution
https://bugs.webkit.org/show_bug.cgi?id=116576

Reviewed by Andreas Kling.

With maximum one ShadowRoot per Element this can be smashed into ContentDistributor.

  • dom/ShadowRoot.cpp:

(WebCore):

  • dom/ShadowRoot.h:

(WebCore):

  • html/shadow/ContentDistributor.cpp:

(WebCore::ContentDistributor::ContentDistributor):
(WebCore):
(WebCore::ContentDistributor::~ContentDistributor):
(WebCore::ContentDistributor::invalidateInsertionPointList):
(WebCore::ContentDistributor::ensureInsertionPointList):
(WebCore::ContentDistributor::distribute):
(WebCore::ContentDistributor::invalidate):

  • html/shadow/ContentDistributor.h:

(WebCore):
(ContentDistributor):

  • html/shadow/InsertionPoint.cpp:

(WebCore::InsertionPoint::InsertionPoint):
(WebCore::InsertionPoint::insertedInto):
(WebCore::InsertionPoint::removedFrom):

Simplify insertion point list invalidation.

  • html/shadow/InsertionPoint.h:
Location:
trunk/Source/WebCore
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r150478 r150480  
     12013-05-21  Antti Koivisto  <antti@apple.com>
     2
     3        Remove ScopeContentDistribution
     4        https://bugs.webkit.org/show_bug.cgi?id=116576
     5
     6        Reviewed by Andreas Kling.
     7
     8        With maximum one ShadowRoot per Element this can be smashed into ContentDistributor.
     9
     10        * dom/ShadowRoot.cpp:
     11        (WebCore):
     12        * dom/ShadowRoot.h:
     13        (WebCore):
     14        * html/shadow/ContentDistributor.cpp:
     15        (WebCore::ContentDistributor::ContentDistributor):
     16        (WebCore):
     17        (WebCore::ContentDistributor::~ContentDistributor):
     18        (WebCore::ContentDistributor::invalidateInsertionPointList):
     19        (WebCore::ContentDistributor::ensureInsertionPointList):
     20        (WebCore::ContentDistributor::distribute):
     21        (WebCore::ContentDistributor::invalidate):
     22        * html/shadow/ContentDistributor.h:
     23        (WebCore):
     24        (ContentDistributor):
     25        * html/shadow/InsertionPoint.cpp:
     26        (WebCore::InsertionPoint::InsertionPoint):
     27        (WebCore::InsertionPoint::insertedInto):
     28        (WebCore::InsertionPoint::removedFrom):
     29       
     30            Simplify insertion point list invalidation.
     31
     32        * html/shadow/InsertionPoint.h:
     33
    1342013-05-21  Zoltan Horvath  <zoltan@webkit.org>
    235
  • trunk/Source/WebCore/dom/ShadowRoot.cpp

    r150010 r150480  
    4040
    4141struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope {
    42     void* pointers[1];
    4342    unsigned countersAndFlags[1];
    4443};
     
    197196}
    198197
    199 ScopeContentDistribution* ShadowRoot::ensureScopeDistribution()
    200 {
    201     if (m_scopeDistribution)
    202         return m_scopeDistribution.get();
    203 
    204     m_scopeDistribution = adoptPtr(new ScopeContentDistribution);
    205     return m_scopeDistribution.get();
    206 }   
    207 
    208198}
  • trunk/Source/WebCore/dom/ShadowRoot.h

    r150010 r150480  
    3838
    3939class ElementShadow;
    40 class ScopeContentDistribution;
    4140
    4241class ShadowRoot FINAL : public DocumentFragment, public TreeScope {
     
    7877    virtual void unregisterScopedHTMLStyleChild() OVERRIDE;
    7978
    80     ScopeContentDistribution* scopeDistribution() { return m_scopeDistribution.get(); }
    81     const ScopeContentDistribution* scopeDistribution() const { return m_scopeDistribution.get(); }
    82     ScopeContentDistribution* ensureScopeDistribution();
    83 
    8479    ShadowRootType type() const { return static_cast<ShadowRootType>(m_type); }
    8580
     
    9994    bool isOrphan() const { return !host(); }
    10095
    101     OwnPtr<ScopeContentDistribution> m_scopeDistribution;
    10296    unsigned m_numberOfStyles : 28;
    10397    unsigned m_applyAuthorStyles : 1;
  • trunk/Source/WebCore/html/shadow/ContentDistributor.cpp

    r150464 r150480  
    3636namespace WebCore {
    3737
    38 ScopeContentDistribution::ScopeContentDistribution()
     38ContentDistributor::ContentDistributor()
    3939    : m_insertionPointListIsValid(true)
     40    , m_validity(Undetermined)
    4041{
    4142}
    4243
    43 void ScopeContentDistribution::invalidateInsertionPointList()
     44ContentDistributor::~ContentDistributor()
     45{
     46}
     47
     48void ContentDistributor::invalidateInsertionPointList()
    4449{
    4550    m_insertionPointListIsValid = false;
     
    4752}
    4853
    49 const Vector<RefPtr<InsertionPoint> >& ScopeContentDistribution::ensureInsertionPointList(ShadowRoot* shadowRoot)
     54const Vector<RefPtr<InsertionPoint> >& ContentDistributor::ensureInsertionPointList(ShadowRoot* shadowRoot)
    5055{
    5156    if (m_insertionPointListIsValid)
     
    6166
    6267    return m_insertionPointList;
    63 }
    64 
    65 void ScopeContentDistribution::registerInsertionPoint(InsertionPoint*)
    66 {
    67     invalidateInsertionPointList();
    68 }
    69 
    70 void ScopeContentDistribution::unregisterInsertionPoint(InsertionPoint*)
    71 {
    72     invalidateInsertionPointList();
    73 }
    74 
    75 ContentDistributor::ContentDistributor()
    76     : m_validity(Undetermined)
    77 {
    78 }
    79 
    80 ContentDistributor::~ContentDistributor()
    81 {
    8268}
    8369
     
    9682
    9783    if (ShadowRoot* root = host->shadowRoot()) {
    98         if (ScopeContentDistribution* scope = root->scopeDistribution()) {
    99             const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
    100             for (size_t i = 0; i < insertionPoints.size(); ++i) {
    101                 InsertionPoint* point = insertionPoints[i].get();
    102                 if (!point->isActive())
    103                     continue;
     84        const Vector<RefPtr<InsertionPoint> >& insertionPoints = ensureInsertionPointList(root);
     85        for (size_t i = 0; i < insertionPoints.size(); ++i) {
     86            InsertionPoint* point = insertionPoints[i].get();
     87            if (!point->isActive())
     88                continue;
    10489
    105                 distributeSelectionsTo(point, host);
    106             }
     90            distributeSelectionsTo(point, host);
    10791        }
    10892    }
     
    11599
    116100    if (ShadowRoot* root = host->shadowRoot()) {
    117         if (ScopeContentDistribution* scope = root->scopeDistribution()) {
    118             const Vector<RefPtr<InsertionPoint> >& insertionPoints = scope->ensureInsertionPointList(root);
    119             for (size_t i = 0; i < insertionPoints.size(); ++i) {
    120                 needsReattach = needsReattach || true;
    121                 insertionPoints[i]->clearDistribution();
    122             }
     101        const Vector<RefPtr<InsertionPoint> >& insertionPoints = ensureInsertionPointList(root);
     102        for (size_t i = 0; i < insertionPoints.size(); ++i) {
     103            needsReattach = true;
     104            insertionPoints[i]->clearDistribution();
    123105        }
    124106    }
  • trunk/Source/WebCore/html/shadow/ContentDistributor.h

    r150464 r150480  
    4545class ShadowRoot;
    4646
    47 class ScopeContentDistribution {
    48 public:
    49     ScopeContentDistribution();
    50 
    51     void registerInsertionPoint(InsertionPoint*);
    52     void unregisterInsertionPoint(InsertionPoint*);
    53 
    54     void invalidateInsertionPointList();
    55     const Vector<RefPtr<InsertionPoint> >& ensureInsertionPointList(ShadowRoot*);
    56 
    57 private:
    58     bool m_insertionPointListIsValid;
    59     Vector<RefPtr<InsertionPoint> > m_insertionPointList;
    60 };
    61 
    6247class ContentDistributor {
    6348    WTF_MAKE_NONCOPYABLE(ContentDistributor);
     
    7358    ~ContentDistributor();
    7459
     60    void invalidateInsertionPointList();
     61   
    7562    InsertionPoint* findInsertionPointFor(const Node* key) const;
    7663
     
    8370
    8471private:
     72    const Vector<RefPtr<InsertionPoint> >& ensureInsertionPointList(ShadowRoot*);
     73
    8574    void distribute(Element* host);
    8675    bool invalidate(Element* host);
     
    9180    bool needsInvalidation() const { return m_validity != Invalidated; }
    9281
     82    Vector<RefPtr<InsertionPoint> > m_insertionPointList;
    9383    HashMap<const Node*, RefPtr<InsertionPoint> > m_nodeToInsertionPoint;
     84    bool m_insertionPointListIsValid;
    9485    unsigned m_validity : 2;
    9586};
  • trunk/Source/WebCore/html/shadow/InsertionPoint.cpp

    r150464 r150480  
    4444InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document)
    4545    : HTMLElement(tagName, document, CreateInsertionPoint)
    46     , m_registeredWithShadowRoot(false)
    4746    , m_hasDistribution(false)
    4847{
     
    120119        if (ElementShadow* rootOwner = root->owner()) {
    121120            rootOwner->distributor().didShadowBoundaryChange(root->host());
    122             if (isActive() && !m_registeredWithShadowRoot && insertionPoint->treeScope()->rootNode() == root) {
    123                 m_registeredWithShadowRoot = true;
    124                 root->ensureScopeDistribution()->registerInsertionPoint(this);
    125             }
     121            rootOwner->distributor().invalidateInsertionPointList();
    126122        }
    127123    }
     
    138134    // host can be null when removedFrom() is called from ElementShadow destructor.
    139135    ElementShadow* rootOwner = root ? root->owner() : 0;
    140     if (rootOwner)
     136    if (rootOwner) {
    141137        rootOwner->invalidateDistribution();
     138        rootOwner->distributor().invalidateInsertionPointList();
     139    }
    142140
    143141    // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up.
    144142    clearDistribution();
    145 
    146     if (m_registeredWithShadowRoot && insertionPoint->treeScope()->rootNode() == root) {
    147         ASSERT(root);
    148         m_registeredWithShadowRoot = false;
    149         root->ensureScopeDistribution()->unregisterInsertionPoint(this);
    150     }
    151143
    152144    HTMLElement::removedFrom(insertionPoint);
  • trunk/Source/WebCore/html/shadow/InsertionPoint.h

    r150464 r150480  
    9191private:
    9292
    93     bool m_registeredWithShadowRoot;
    9493    bool m_hasDistribution;
    9594};
Note: See TracChangeset for help on using the changeset viewer.