Changeset 229368 in webkit
- Timestamp:
- Mar 7, 2018 10:27:55 AM (6 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r229363 r229368 1 2018-03-07 Antti Koivisto <antti@apple.com> 2 3 checkForSiblingStyleChanges should use internal versions of the invalidation functions 4 https://bugs.webkit.org/show_bug.cgi?id=183405 5 <rdar://problem/38218310> 6 7 Reviewed by Zalan Bujtas. 8 9 Non-internal invalidateStyleForElement/Subtree() implement sibling combinator invalidation. Checking this 10 is only needed if the element in question changed somehow. In checkForSiblingStyleChanges we know that 11 another element changed and we really just want to invalidate. 12 13 * css/SelectorChecker.cpp: 14 (WebCore::isFirstOfType): 15 (WebCore::SelectorChecker::checkOne const): 16 17 Also make :first-of-type use ChildrenAffectedByForwardPositionalRules for invalidation similar to :last-of-type 18 for more correct invalidation. 19 20 * dom/Element.cpp: 21 (WebCore::checkForSiblingStyleChanges): 22 1 23 2018-03-07 Yusuke Suzuki <utatane.tea@gmail.com> 2 24 -
trunk/Source/WebCore/css/SelectorChecker.cpp
r229307 r229368 104 104 } 105 105 106 static inline bool isFirstOfType( SelectorChecker::CheckingContext& checkingContext,const Element& element, const QualifiedName& type)106 static inline bool isFirstOfType(const Element& element, const QualifiedName& type) 107 107 { 108 108 for (const Element* sibling = ElementTraversal::previousSibling(element); sibling; sibling = ElementTraversal::previousSibling(*sibling)) { 109 addStyleRelation(checkingContext, *sibling, Style::Relation::AffectsNextSibling);110 111 109 if (sibling->hasTagName(type)) 112 110 return false; … … 746 744 case CSSSelector::PseudoClassFirstOfType: 747 745 // first-of-type matches the first element of its type 748 if ( element.parentElement()) {749 addStyleRelation(checkingContext, element, Style::Relation::AffectedByPreviousSibling);750 return isFirstOfType( checkingContext,element, element.tagQName());746 if (auto* parentElement = element.parentElement()) { 747 addStyleRelation(checkingContext, *parentElement, Style::Relation::ChildrenAffectedByForwardPositionalRules); 748 return isFirstOfType(element, element.tagQName()); 751 749 } 752 750 break; … … 786 784 // FIXME: This selector is very slow. 787 785 if (Element* parentElement = element.parentElement()) { 788 addStyleRelation(checkingContext, element, Style::Relation::AffectedByPreviousSibling);786 addStyleRelation(checkingContext, *parentElement, Style::Relation::ChildrenAffectedByForwardPositionalRules); 789 787 addStyleRelation(checkingContext, *parentElement, Style::Relation::ChildrenAffectedByBackwardPositionalRules); 790 788 if (!parentElement->isFinishedParsingChildren()) 791 789 return false; 792 return isFirstOfType( checkingContext,element, element.tagQName()) && isLastOfType(element, element.tagQName());790 return isFirstOfType(element, element.tagQName()) && isLastOfType(element, element.tagQName()); 793 791 } 794 792 break; -
trunk/Source/WebCore/dom/Element.cpp
r229307 r229368 1481 1481 } 1482 1482 1483 static void invalidateSiblingsIfNeeded(Element& element) 1484 { 1485 if (!element.affectsNextSiblingElementStyle()) 1486 return; 1487 auto* parent = element.parentElement(); 1488 if (parent && parent->styleValidity() >= Style::Validity::SubtreeInvalid) 1489 return; 1490 1491 for (auto* sibling = element.nextElementSibling(); sibling; sibling = sibling->nextElementSibling()) { 1483 static void invalidateForSiblingCombinators(Element* sibling) 1484 { 1485 for (; sibling; sibling = sibling->nextElementSibling()) { 1492 1486 if (sibling->styleIsAffectedByPreviousSibling()) 1493 1487 sibling->invalidateStyleForSubtreeInternal(); … … 1495 1489 return; 1496 1490 } 1491 } 1492 1493 static void invalidateSiblingsIfNeeded(Element& element) 1494 { 1495 if (!element.affectsNextSiblingElementStyle()) 1496 return; 1497 auto* parent = element.parentElement(); 1498 if (parent && parent->styleValidity() >= Style::Validity::SubtreeInvalid) 1499 return; 1500 1501 invalidateForSiblingCombinators(element.nextElementSibling()); 1497 1502 } 1498 1503 … … 2028 2033 auto* style = elementAfterChange->renderStyle(); 2029 2034 if (!style || style->firstChildState()) 2030 elementAfterChange->invalidateStyleForSubtree ();2035 elementAfterChange->invalidateStyleForSubtreeInternal(); 2031 2036 } 2032 2037 … … 2035 2040 auto* style = newFirstElement->renderStyle(); 2036 2041 if (!style || !style->firstChildState()) 2037 newFirstElement->invalidateStyleForSubtree ();2042 newFirstElement->invalidateStyleForSubtreeInternal(); 2038 2043 } 2039 2044 } … … 2048 2053 auto* style = elementBeforeChange->renderStyle(); 2049 2054 if (!style || style->lastChildState()) 2050 elementBeforeChange->invalidateStyleForSubtree ();2055 elementBeforeChange->invalidateStyleForSubtreeInternal(); 2051 2056 } 2052 2057 … … 2056 2061 auto* style = newLastElement->renderStyle(); 2057 2062 if (!style || !style->lastChildState()) 2058 newLastElement->invalidateStyleForSubtree ();2063 newLastElement->invalidateStyleForSubtreeInternal(); 2059 2064 } 2060 2065 } 2061 2066 2062 if (elementAfterChange) { 2063 if (elementAfterChange->styleIsAffectedByPreviousSibling()) 2064 elementAfterChange->invalidateStyleForSubtree(); 2065 else if (elementAfterChange->affectsNextSiblingElementStyle()) { 2066 Element* elementToInvalidate = elementAfterChange; 2067 do { 2068 elementToInvalidate = elementToInvalidate->nextElementSibling(); 2069 } while (elementToInvalidate && !elementToInvalidate->styleIsAffectedByPreviousSibling()); 2070 2071 if (elementToInvalidate) 2072 elementToInvalidate->invalidateStyleForSubtree(); 2073 } 2074 } 2067 invalidateForSiblingCombinators(elementAfterChange); 2075 2068 2076 2069 // We have to invalidate everything following the insertion point in the forward case, and everything before the insertion point in the … … 2078 2071 if (parent.childrenAffectedByForwardPositionalRules()) { 2079 2072 for (auto* next = elementAfterChange; next; next = next->nextElementSibling()) 2080 next->invalidateStyleForSubtree ();2073 next->invalidateStyleForSubtreeInternal(); 2081 2074 } 2082 2075 // Backward positional selectors include nth-last-child, nth-last-of-type, last-of-type and only-of-type. 2083 2076 if (parent.childrenAffectedByBackwardPositionalRules()) { 2084 2077 for (auto* previous = elementBeforeChange; previous; previous = previous->previousElementSibling()) 2085 previous->invalidateStyleForSubtree ();2078 previous->invalidateStyleForSubtreeInternal(); 2086 2079 } 2087 2080 }
Note: See TracChangeset
for help on using the changeset viewer.