Changeset 228729 in webkit
- Timestamp:
- Feb 19, 2018 10:09:13 PM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r228724 r228729 1 2018-02-19 Antti Koivisto <antti@apple.com> 2 3 Use selector filter when invalidating descendants 4 https://bugs.webkit.org/show_bug.cgi?id=182839 5 <rdar://problem/37581072> 6 7 Reviewed by Zalan Bujtas. 8 9 We can make descendant invalidation faster by enabling filtering. 10 11 * css/SelectorFilter.cpp: 12 (WebCore::SelectorFilter::initializeParentStack): 13 14 Traverse and reverse the ancestor chain, and push it. 15 16 (WebCore::SelectorFilter::pushParent): 17 (WebCore::SelectorFilter::pushParentInitializingIfNeeded): 18 19 Add a version of pushParent that can initialize the stack. 20 21 (WebCore::SelectorFilter::popParent): 22 (WebCore::SelectorFilter::popParentsUntil): 23 24 Pop until a given parent element. 25 26 (WebCore::SelectorFilter::pushParentStackFrame): Deleted. 27 (WebCore::SelectorFilter::popParentStackFrame): Deleted. 28 29 These were the same as push/popParent. 30 31 * css/SelectorFilter.h: 32 (WebCore::SelectorFilter::popParent): Deleted. 33 * style/StyleInvalidator.cpp: 34 (WebCore::Style::Invalidator::invalidateStyleForDescendants): 35 36 Use pushParentInitializingIfNeeded. 37 38 (WebCore::Style::Invalidator::invalidateStyleWithMatchElement): 39 40 Use selector filter when doing descendant tree invalidation. 41 Make sure to pop it until the parent when reusing. 42 1 43 2018-02-19 Fujii Hironori <Hironori.Fujii@sony.com> 2 44 -
trunk/Source/WebCore/css/SelectorFilter.cpp
r225596 r228729 64 64 } 65 65 66 void SelectorFilter::pushParentStackFrame(Element* parent) 66 void SelectorFilter::initializeParentStack(Element& parent) 67 { 68 Vector<Element*, 20> ancestors; 69 for (auto* ancestor = &parent; ancestor; ancestor = ancestor->parentElement()) 70 ancestors.append(ancestor); 71 for (unsigned i = ancestors.size(); i--;) 72 pushParent(ancestors[i]); 73 } 74 75 void SelectorFilter::pushParent(Element* parent) 67 76 { 68 77 ASSERT(m_parentStack.isEmpty() || m_parentStack.last().element == parent->parentElement()); … … 78 87 } 79 88 80 void SelectorFilter::popParentStackFrame() 89 void SelectorFilter::pushParentInitializingIfNeeded(Element& parent) 90 { 91 if (UNLIKELY(m_parentStack.isEmpty())) { 92 initializeParentStack(parent); 93 return; 94 } 95 pushParent(&parent); 96 } 97 98 void SelectorFilter::popParent() 81 99 { 82 100 ASSERT(!m_parentStack.isEmpty()); … … 92 110 } 93 111 94 void SelectorFilter::pushParent(Element* parent) 95 { 96 pushParentStackFrame(parent); 112 void SelectorFilter::popParentsUntil(Element* parent) 113 { 114 while (!m_parentStack.isEmpty()) { 115 if (parent && m_parentStack.last().element == parent) 116 return; 117 popParent(); 118 } 97 119 } 98 120 -
trunk/Source/WebCore/css/SelectorFilter.h
r225596 r228729 40 40 class SelectorFilter { 41 41 public: 42 void pushParentStackFrame(Element* parent);43 void popParentStackFrame();44 45 42 void pushParent(Element* parent); 46 void popParent() { popParentStackFrame(); } 43 void pushParentInitializingIfNeeded(Element& parent); 44 void popParent(); 45 void popParentsUntil(Element* parent); 47 46 bool parentStackIsEmpty() const { return m_parentStack.isEmpty(); } 48 47 bool parentStackIsConsistent(const ContainerNode* parentNode) const; … … 53 52 54 53 private: 54 void initializeParentStack(Element& parent); 55 55 56 struct ParentStackFrame { 56 57 ParentStackFrame() : element(0) { } -
trunk/Source/WebCore/style/StyleInvalidator.cpp
r228497 r228729 159 159 parentStack.append(parent); 160 160 if (filter) 161 filter->pushParent (parent);161 filter->pushParentInitializingIfNeeded(*parent); 162 162 } else { 163 163 while (parentStack.last() != parent) { … … 224 224 } 225 225 case MatchElement::Ancestor: { 226 invalidateStyleForDescendants(element, nullptr); 226 SelectorFilter filter; 227 invalidateStyleForDescendants(element, &filter); 227 228 break; 228 229 } … … 248 249 } 249 250 break; 250 case MatchElement::AncestorSibling: 251 for (auto* sibling = element.nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) 252 invalidateStyleForDescendants(*sibling, nullptr); 253 break; 251 case MatchElement::AncestorSibling: { 252 SelectorFilter filter; 253 for (auto* sibling = element.nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) { 254 filter.popParentsUntil(element.parentElement()); 255 invalidateStyleForDescendants(*sibling, &filter); 256 } 257 break; 258 } 254 259 case MatchElement::Host: 255 260 // FIXME: Handle this here as well.
Note: See TracChangeset
for help on using the changeset viewer.