Changeset 150480 in webkit
- Timestamp:
- May 21, 2013, 2:38:13 PM (13 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 7 edited
-
ChangeLog (modified) (1 diff)
-
dom/ShadowRoot.cpp (modified) (2 diffs)
-
dom/ShadowRoot.h (modified) (3 diffs)
-
html/shadow/ContentDistributor.cpp (modified) (5 diffs)
-
html/shadow/ContentDistributor.h (modified) (4 diffs)
-
html/shadow/InsertionPoint.cpp (modified) (3 diffs)
-
html/shadow/InsertionPoint.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r150478 r150480 1 2013-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 1 34 2013-05-21 Zoltan Horvath <zoltan@webkit.org> 2 35 -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r150010 r150480 40 40 41 41 struct SameSizeAsShadowRoot : public DocumentFragment, public TreeScope { 42 void* pointers[1];43 42 unsigned countersAndFlags[1]; 44 43 }; … … 197 196 } 198 197 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 208 198 } -
trunk/Source/WebCore/dom/ShadowRoot.h
r150010 r150480 38 38 39 39 class ElementShadow; 40 class ScopeContentDistribution;41 40 42 41 class ShadowRoot FINAL : public DocumentFragment, public TreeScope { … … 78 77 virtual void unregisterScopedHTMLStyleChild() OVERRIDE; 79 78 80 ScopeContentDistribution* scopeDistribution() { return m_scopeDistribution.get(); }81 const ScopeContentDistribution* scopeDistribution() const { return m_scopeDistribution.get(); }82 ScopeContentDistribution* ensureScopeDistribution();83 84 79 ShadowRootType type() const { return static_cast<ShadowRootType>(m_type); } 85 80 … … 99 94 bool isOrphan() const { return !host(); } 100 95 101 OwnPtr<ScopeContentDistribution> m_scopeDistribution;102 96 unsigned m_numberOfStyles : 28; 103 97 unsigned m_applyAuthorStyles : 1; -
trunk/Source/WebCore/html/shadow/ContentDistributor.cpp
r150464 r150480 36 36 namespace WebCore { 37 37 38 ScopeContentDistribution::ScopeContentDistribution()38 ContentDistributor::ContentDistributor() 39 39 : m_insertionPointListIsValid(true) 40 , m_validity(Undetermined) 40 41 { 41 42 } 42 43 43 void ScopeContentDistribution::invalidateInsertionPointList() 44 ContentDistributor::~ContentDistributor() 45 { 46 } 47 48 void ContentDistributor::invalidateInsertionPointList() 44 49 { 45 50 m_insertionPointListIsValid = false; … … 47 52 } 48 53 49 const Vector<RefPtr<InsertionPoint> >& ScopeContentDistribution::ensureInsertionPointList(ShadowRoot* shadowRoot)54 const Vector<RefPtr<InsertionPoint> >& ContentDistributor::ensureInsertionPointList(ShadowRoot* shadowRoot) 50 55 { 51 56 if (m_insertionPointListIsValid) … … 61 66 62 67 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 {82 68 } 83 69 … … 96 82 97 83 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; 104 89 105 distributeSelectionsTo(point, host); 106 } 90 distributeSelectionsTo(point, host); 107 91 } 108 92 } … … 115 99 116 100 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(); 123 105 } 124 106 } -
trunk/Source/WebCore/html/shadow/ContentDistributor.h
r150464 r150480 45 45 class ShadowRoot; 46 46 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 62 47 class ContentDistributor { 63 48 WTF_MAKE_NONCOPYABLE(ContentDistributor); … … 73 58 ~ContentDistributor(); 74 59 60 void invalidateInsertionPointList(); 61 75 62 InsertionPoint* findInsertionPointFor(const Node* key) const; 76 63 … … 83 70 84 71 private: 72 const Vector<RefPtr<InsertionPoint> >& ensureInsertionPointList(ShadowRoot*); 73 85 74 void distribute(Element* host); 86 75 bool invalidate(Element* host); … … 91 80 bool needsInvalidation() const { return m_validity != Invalidated; } 92 81 82 Vector<RefPtr<InsertionPoint> > m_insertionPointList; 93 83 HashMap<const Node*, RefPtr<InsertionPoint> > m_nodeToInsertionPoint; 84 bool m_insertionPointListIsValid; 94 85 unsigned m_validity : 2; 95 86 }; -
trunk/Source/WebCore/html/shadow/InsertionPoint.cpp
r150464 r150480 44 44 InsertionPoint::InsertionPoint(const QualifiedName& tagName, Document* document) 45 45 : HTMLElement(tagName, document, CreateInsertionPoint) 46 , m_registeredWithShadowRoot(false)47 46 , m_hasDistribution(false) 48 47 { … … 120 119 if (ElementShadow* rootOwner = root->owner()) { 121 120 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(); 126 122 } 127 123 } … … 138 134 // host can be null when removedFrom() is called from ElementShadow destructor. 139 135 ElementShadow* rootOwner = root ? root->owner() : 0; 140 if (rootOwner) 136 if (rootOwner) { 141 137 rootOwner->invalidateDistribution(); 138 rootOwner->distributor().invalidateInsertionPointList(); 139 } 142 140 143 141 // Since this insertion point is no longer visible from the shadow subtree, it need to clean itself up. 144 142 clearDistribution(); 145 146 if (m_registeredWithShadowRoot && insertionPoint->treeScope()->rootNode() == root) {147 ASSERT(root);148 m_registeredWithShadowRoot = false;149 root->ensureScopeDistribution()->unregisterInsertionPoint(this);150 }151 143 152 144 HTMLElement::removedFrom(insertionPoint); -
trunk/Source/WebCore/html/shadow/InsertionPoint.h
r150464 r150480 91 91 private: 92 92 93 bool m_registeredWithShadowRoot;94 93 bool m_hasDistribution; 95 94 };
Note:
See TracChangeset
for help on using the changeset viewer.