Changeset 286091 in webkit
- Timestamp:
- Nov 19, 2021, 10:40:27 PM (5 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 deleted
- 11 edited
-
ChangeLog (modified) (1 diff)
-
Sources.txt (modified) (1 diff)
-
WebCore.xcodeproj/project.pbxproj (modified) (4 diffs)
-
dom/CharacterData.cpp (modified) (7 diffs)
-
dom/CharacterData.h (modified) (1 diff)
-
dom/ContainerNode.cpp (modified) (15 diffs)
-
dom/ContainerNode.h (modified) (2 diffs)
-
dom/Element.cpp (modified) (5 diffs)
-
dom/Element.h (modified) (1 diff)
-
dom/ShadowRoot.cpp (modified) (1 diff)
-
style/ChildChangeInvalidation.cpp (deleted)
-
style/ChildChangeInvalidation.h (deleted)
-
style/StyleAdjuster.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r286086 r286091 1 2021-11-19 Commit Queue <commit-queue@webkit.org> 2 3 Unreviewed, reverting r286058. 4 https://bugs.webkit.org/show_bug.cgi?id=233394 5 6 Speedometer2 is crashing 7 8 Reverted changeset: 9 10 "Factor child change invalidation into class" 11 https://bugs.webkit.org/show_bug.cgi?id=233311 12 https://commits.webkit.org/r286058 13 1 14 2021-11-19 Kiet Ho <tho22@apple.com> 2 15 -
trunk/Source/WebCore/Sources.txt
r286086 r286091 2525 2525 storage/StorageQuotaManager.cpp 2526 2526 style/AttributeChangeInvalidation.cpp 2527 style/ChildChangeInvalidation.cpp2528 2527 style/ClassChangeInvalidation.cpp 2529 2528 style/ElementRuleCollector.cpp -
trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj
r286086 r286091 5343 5343 E4C279590CF9741900E97B98 /* RenderMedia.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C279570CF9741900E97B98 /* RenderMedia.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5344 5344 E4C3B1FA0F0E4161009693F6 /* LegacyTileCache.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */; settings = {ATTRIBUTES = (Private, ); }; }; 5345 E4C4C61A27452A7900A040E7 /* ChildChangeInvalidation.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C4C61827452A7900A040E7 /* ChildChangeInvalidation.h */; };5346 5345 E4C91A0E1802343100A17F6D /* TextPaintStyle.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C91A0D1802343100A17F6D /* TextPaintStyle.h */; }; 5347 5346 E4C91A16180999F100A17F6D /* RenderTextLineBoxes.h in Headers */ = {isa = PBXBuildFile; fileRef = E4C91A15180999F100A17F6D /* RenderTextLineBoxes.h */; settings = {ATTRIBUTES = (Private, ); }; }; … … 17048 17047 E4C3B1F90F0E4161009693F6 /* LegacyTileCache.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = LegacyTileCache.h; sourceTree = "<group>"; }; 17049 17048 E4C3B1FB0F0E4170009693F6 /* LegacyTileCache.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = LegacyTileCache.mm; sourceTree = "<group>"; }; 17050 E4C4C61827452A7900A040E7 /* ChildChangeInvalidation.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ChildChangeInvalidation.h; sourceTree = "<group>"; };17051 E4C4C61B27452A8A00A040E7 /* ChildChangeInvalidation.cpp */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.cpp.cpp; path = ChildChangeInvalidation.cpp; sourceTree = "<group>"; };17052 17049 E4C91A0D1802343100A17F6D /* TextPaintStyle.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextPaintStyle.h; sourceTree = "<group>"; }; 17053 17050 E4C91A0F1802343900A17F6D /* TextPaintStyle.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = TextPaintStyle.cpp; sourceTree = "<group>"; }; … … 30286 30283 E4A814D91C70E10D00BF85AC /* AttributeChangeInvalidation.h */, 30287 30284 E4ABABF42368C6EF00FA4345 /* CascadeLevel.h */, 30288 E4C4C61B27452A8A00A040E7 /* ChildChangeInvalidation.cpp */,30289 E4C4C61827452A7900A040E7 /* ChildChangeInvalidation.h */,30290 30285 E4A814D51C6DEE8D00BF85AC /* ClassChangeInvalidation.cpp */, 30291 30286 E4A814D31C6DEC4000BF85AC /* ClassChangeInvalidation.h */, … … 32743 32738 97B8FFD116AE7F960038388D /* CharacterReferenceParserInlines.h in Headers */, 32744 32739 F55B3DB21251F12D003EF269 /* CheckboxInputType.h in Headers */, 32745 E4C4C61A27452A7900A040E7 /* ChildChangeInvalidation.h in Headers */,32746 32740 D619A308144E00BE004BC302 /* ChildListMutationScope.h in Headers */, 32747 32741 A81872200977D3C0005826D9 /* ChildNodeList.h in Headers */, -
trunk/Source/WebCore/dom/CharacterData.cpp
r286058 r286091 24 24 25 25 #include "Attr.h" 26 #include "ChildChangeInvalidation.h"27 26 #include "ElementTraversal.h" 28 27 #include "EventNames.h" … … 75 74 } 76 75 77 static ContainerNode::ChildChange makeChildChange(CharacterData& characterData, ContainerNode::ChildChange::Source source)78 {79 return {80 ContainerNode::ChildChange::Type::TextChanged,81 ElementTraversal::previousSibling(characterData),82 ElementTraversal::nextSibling(characterData),83 source84 };85 }86 87 76 unsigned CharacterData::parserAppendData(const String& string, unsigned offset, unsigned lengthLimit) 88 77 { … … 107 96 return 0; 108 97 109 auto childChange = makeChildChange(*this, ContainerNode::ChildChange::Source::Parser);110 std::optional<Style::ChildChangeInvalidation> styleInvalidation;111 if (auto* parent = parentNode())112 styleInvalidation.emplace(*parent, childChange);113 114 98 String oldData = m_data; 115 99 if (string.is8Bit()) … … 122 106 downcast<Text>(*this).updateRendererAfterContentChange(oldLength, 0); 123 107 124 notifyParentAfterChange( childChange);108 notifyParentAfterChange(ContainerNode::ChildChange::Source::Parser); 125 109 126 110 auto mutationRecipients = MutationObserverInterestGroup::createForCharacterDataMutation(*this); … … 190 174 void CharacterData::setDataAndUpdate(const String& newData, unsigned offsetOfReplacedData, unsigned oldLength, unsigned newLength, UpdateLiveRanges shouldUpdateLiveRanges) 191 175 { 192 auto childChange = makeChildChange(*this, ContainerNode::ChildChange::Source::API);193 194 std::optional<Style::ChildChangeInvalidation> styleInvalidation;195 if (auto* parent = parentNode())196 styleInvalidation.emplace(*parent, childChange);197 198 176 String oldData = m_data; 199 177 m_data = newData; … … 214 192 document().frame()->selection().textWasReplaced(this, offsetOfReplacedData, oldLength, newLength); 215 193 216 notifyParentAfterChange( childChange);194 notifyParentAfterChange(ContainerNode::ChildChange::Source::API); 217 195 218 196 dispatchModifiedEvent(oldData); 219 197 } 220 198 221 void CharacterData::notifyParentAfterChange( const ContainerNode::ChildChange& childChange)199 void CharacterData::notifyParentAfterChange(ContainerNode::ChildChange::Source source) 222 200 { 223 201 document().incDOMTreeVersion(); … … 226 204 return; 227 205 228 parentNode()->childrenChanged(childChange); 206 ContainerNode::ChildChange change = { 207 ContainerNode::ChildChange::Type::TextChanged, 208 ElementTraversal::previousSibling(*this), 209 ElementTraversal::nextSibling(*this), 210 source 211 }; 212 213 parentNode()->childrenChanged(change); 229 214 } 230 215 -
trunk/Source/WebCore/dom/CharacterData.h
r286058 r286091 66 66 String nodeValue() const final; 67 67 ExceptionOr<void> setNodeValue(const String&) final; 68 void notifyParentAfterChange( const ContainerNode::ChildChange&);68 void notifyParentAfterChange(ContainerNode::ChildChange::Source); 69 69 70 70 String m_data; -
trunk/Source/WebCore/dom/ContainerNode.cpp
r286058 r286091 26 26 #include "AXObjectCache.h" 27 27 #include "AllDescendantsCollection.h" 28 #include "ChildChangeInvalidation.h"29 28 #include "ChildListMutationScope.h" 30 29 #include "ClassCollection.h" … … 113 112 disconnectSubframesIfNeeded(*this, DescendantsOnly); 114 113 115 ContainerNode::ChildChange childChange { ChildChange::Type::AllChildrenRemoved, nullptr, nullptr, source };116 117 114 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 118 115 ScriptDisallowedScope::InMainThread scriptDisallowedScope; 119 { 120 Style::ChildChangeInvalidation styleInvalidation(*this, childChange); 121 122 if (UNLIKELY(isShadowRoot() || isInShadowTree())) 123 containingShadowRoot()->willRemoveAllChildren(*this); 124 125 document().nodeChildrenWillBeRemoved(*this); 126 127 while (RefPtr<Node> child = m_firstChild) { 128 removeBetween(nullptr, child->nextSibling(), *child); 129 auto subtreeObservability = notifyChildNodeRemoved(*this, *child); 130 if (source == ChildChange::Source::API && subtreeObservability == RemovedSubtreeObservability::MaybeObservableByRefPtr) 131 willCreatePossiblyOrphanedTreeByRemoval(child.get()); 132 } 116 117 if (UNLIKELY(isShadowRoot() || isInShadowTree())) 118 containingShadowRoot()->willRemoveAllChildren(*this); 119 120 document().nodeChildrenWillBeRemoved(*this); 121 122 while (RefPtr<Node> child = m_firstChild) { 123 removeBetween(nullptr, child->nextSibling(), *child); 124 auto subtreeObservability = notifyChildNodeRemoved(*this, *child); 125 if (source == ChildChange::Source::API && subtreeObservability == RemovedSubtreeObservability::MaybeObservableByRefPtr) 126 willCreatePossiblyOrphanedTreeByRemoval(child.get()); 133 127 } 134 128 … … 136 130 137 131 if (deferChildrenChanged == DeferChildrenChanged::No) 138 childrenChanged( childChange);132 childrenChanged(ContainerNode::ChildChange { ChildChange::Type::AllChildrenRemoved, nullptr, nullptr, source }); 139 133 140 134 return children; 141 }142 143 static ContainerNode::ChildChange makeChildChangeForRemoval(Node& childToRemove, ContainerNode::ChildChange::Source source)144 {145 auto changeType = [&] {146 if (is<Element>(childToRemove))147 return ContainerNode::ChildChange::Type::ElementRemoved;148 if (is<Text>(childToRemove))149 return ContainerNode::ChildChange::Type::TextRemoved;150 return ContainerNode::ChildChange::Type::NonContentsChildRemoved;151 }();152 153 return {154 changeType,155 ElementTraversal::previousSibling(childToRemove),156 ElementTraversal::nextSibling(childToRemove),157 source158 };159 135 } 160 136 … … 187 163 return false; 188 164 189 auto childChange = makeChildChangeForRemoval(childToRemove, source); 190 165 ChildChange change; 191 166 RemovedSubtreeObservability subtreeObservability; 192 167 { 193 168 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 194 169 ScriptDisallowedScope::InMainThread scriptDisallowedScope; 195 Style::ChildChangeInvalidation styleInvalidation(*this, childChange);196 170 197 171 if (UNLIKELY(isShadowRoot() || isInShadowTree())) … … 205 179 RefPtr<Node> previousSibling = childToRemove.previousSibling(); 206 180 RefPtr<Node> nextSibling = childToRemove.nextSibling(); 207 208 181 removeBetween(previousSibling.get(), nextSibling.get(), childToRemove); 209 182 subtreeObservability = notifyChildNodeRemoved(*this, childToRemove); 183 184 change.type = is<Element>(childToRemove) ? 185 ChildChange::Type::ElementRemoved : 186 (is<Text>(childToRemove) ? 187 ChildChange::Type::TextRemoved : 188 ChildChange::Type::NonContentsChildRemoved); 189 change.previousSiblingElement = (!previousSibling || is<Element>(*previousSibling)) ? downcast<Element>(previousSibling.get()) : ElementTraversal::previousSibling(*previousSibling); 190 change.nextSiblingElement = (!nextSibling || is<Element>(*nextSibling)) ? downcast<Element>(nextSibling.get()) : ElementTraversal::nextSibling(*nextSibling); 191 change.source = source; 210 192 } 211 193 … … 216 198 217 199 // FIXME: Move childrenChanged into ScriptDisallowedScope block. 218 childrenChanged(ch ildChange);200 childrenChanged(change); 219 201 220 202 return true; … … 223 205 enum class ReplacedAllChildren { No, Yes }; 224 206 225 static ContainerNode::ChildChange makeChildChangeForInsertion(ContainerNode& containerNode, Node& child, Node* beforeChild, ContainerNode::ChildChange::Source source, ReplacedAllChildren replacedAllChildren)226 {227 if (replacedAllChildren == ReplacedAllChildren::Yes)228 return { ContainerNode::ChildChange::Type::AllChildrenReplaced, nullptr, nullptr, source };229 230 auto changeType = [&] {231 if (is<Element>(child))232 return ContainerNode::ChildChange::Type::ElementInserted;233 if (is<Text>(child))234 return ContainerNode::ChildChange::Type::TextInserted;235 return ContainerNode::ChildChange::Type::NonContentsChildInserted;236 }();237 238 return {239 changeType,240 beforeChild ? ElementTraversal::previousSibling(*beforeChild) : ElementTraversal::lastChild(containerNode),241 !beforeChild || is<Element>(*beforeChild) ? downcast<Element>(beforeChild) : ElementTraversal::nextSibling(*beforeChild),242 source243 };244 }245 246 207 template<typename DOMInsertionWork> 247 static ALWAYS_INLINE void executeNodeInsertionWithScriptAssertion(ContainerNode& containerNode, Node& child, Node* beforeChild,208 static ALWAYS_INLINE void executeNodeInsertionWithScriptAssertion(ContainerNode& containerNode, Node& child, 248 209 ContainerNode::ChildChange::Source source, ReplacedAllChildren replacedAllChildren, DOMInsertionWork doNodeInsertion) 249 210 { 250 auto childChange = makeChildChangeForInsertion(containerNode, child, beforeChild, source, replacedAllChildren);251 252 211 NodeVector postInsertionNotificationTargets; 253 212 { 254 213 WidgetHierarchyUpdatesSuspensionScope suspendWidgetHierarchyUpdates; 255 214 ScriptDisallowedScope::InMainThread scriptDisallowedScope; 256 Style::ChildChangeInvalidation styleInvalidation(containerNode, childChange);257 215 258 216 if (UNLIKELY(containerNode.isShadowRoot() || containerNode.isInShadowTree())) … … 265 223 266 224 // FIXME: Move childrenChanged into ScriptDisallowedScope block. 267 containerNode.childrenChanged(childChange); 225 if (replacedAllChildren == ReplacedAllChildren::Yes) 226 containerNode.childrenChanged(ContainerNode::ChildChange { ContainerNode::ChildChange::Type::AllChildrenReplaced, nullptr, nullptr, source }); 227 else { 228 containerNode.childrenChanged(ContainerNode::ChildChange { 229 child.isElementNode() ? 230 ContainerNode::ChildChange::Type::ElementInserted : 231 (child.isTextNode() ? 232 ContainerNode::ChildChange::Type::TextInserted : 233 ContainerNode::ChildChange::Type::NonContentsChildInserted), 234 ElementTraversal::previousSibling(child), 235 ElementTraversal::nextSibling(child), 236 source 237 }); 238 } 268 239 269 240 ASSERT(ScriptDisallowedScope::InMainThread::isEventDispatchAllowedInSubtree(child)); … … 478 449 break; 479 450 480 executeNodeInsertionWithScriptAssertion(*this, child.get(), next.ptr(),ChildChange::Source::API, ReplacedAllChildren::No, [&] {451 executeNodeInsertionWithScriptAssertion(*this, child.get(), ChildChange::Source::API, ReplacedAllChildren::No, [&] { 481 452 child->setTreeScopeRecursively(treeScope()); 482 453 insertBeforeCommon(next, child); … … 537 508 return; 538 509 539 executeNodeInsertionWithScriptAssertion(*this, newChild, &nextChild,ChildChange::Source::Parser, ReplacedAllChildren::No, [&] {510 executeNodeInsertionWithScriptAssertion(*this, newChild, ChildChange::Source::Parser, ReplacedAllChildren::No, [&] { 540 511 if (&document() != &newChild.document()) 541 512 document().adoptNode(newChild); … … 611 582 break; 612 583 613 executeNodeInsertionWithScriptAssertion(*this, child.get(), refChild.get(),ChildChange::Source::API, ReplacedAllChildren::No, [&] {584 executeNodeInsertionWithScriptAssertion(*this, child.get(), ChildChange::Source::API, ReplacedAllChildren::No, [&] { 614 585 child->setTreeScopeRecursively(treeScope()); 615 586 if (refChild) … … 712 683 removeAllChildrenWithScriptAssertion(ChildChange::Source::API, DeferChildrenChanged::Yes); 713 684 714 executeNodeInsertionWithScriptAssertion(*this, *node, nullptr,ChildChange::Source::API, ReplacedAllChildren::Yes, [&] {685 executeNodeInsertionWithScriptAssertion(*this, *node, ChildChange::Source::API, ReplacedAllChildren::Yes, [&] { 715 686 InspectorInstrumentation::willInsertDOMNode(document(), *this); 716 687 node->setTreeScopeRecursively(treeScope()); … … 793 764 794 765 // Append child to the end of the list 795 executeNodeInsertionWithScriptAssertion(*this, child.get(), nullptr,ChildChange::Source::API, ReplacedAllChildren::No, [&] {766 executeNodeInsertionWithScriptAssertion(*this, child.get(), ChildChange::Source::API, ReplacedAllChildren::No, [&] { 796 767 child->setTreeScopeRecursively(treeScope()); 797 768 appendChildCommon(child); … … 809 780 ASSERT(!hasTagName(HTMLNames::templateTag)); 810 781 811 executeNodeInsertionWithScriptAssertion(*this, newChild, nullptr,ChildChange::Source::Parser, ReplacedAllChildren::No, [&] {782 executeNodeInsertionWithScriptAssertion(*this, newChild, ChildChange::Source::Parser, ReplacedAllChildren::No, [&] { 812 783 if (&document() != &newChild.document()) 813 784 document().adoptNode(newChild); … … 842 813 case ContainerNode::ChildChange::Type::NonContentsChildRemoved: 843 814 return false; 844 case ContainerNode::ChildChange::Type::FinishedParsingChildren:845 break;846 815 } 847 816 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/dom/ContainerNode.h
r286058 r286091 75 75 76 76 struct ChildChange { 77 enum class Type : uint8_t { ElementInserted, ElementRemoved, TextInserted, TextRemoved, TextChanged, AllChildrenRemoved, NonContentsChildRemoved, NonContentsChildInserted, AllChildrenReplaced , FinishedParsingChildren};77 enum class Type : uint8_t { ElementInserted, ElementRemoved, TextInserted, TextRemoved, TextChanged, AllChildrenRemoved, NonContentsChildRemoved, NonContentsChildInserted, AllChildrenReplaced }; 78 78 enum class Source : bool { Parser, API }; 79 79 … … 97 97 case ChildChange::Type::NonContentsChildRemoved: 98 98 return false; 99 case ChildChange::Type::FinishedParsingChildren:100 break;101 99 } 102 100 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/dom/Element.cpp
r286058 r286091 31 31 #include "AttributeChangeInvalidation.h" 32 32 #include "CSSParser.h" 33 #include "ChildChangeInvalidation.h"34 33 #include "Chrome.h" 35 34 #include "ChromeClient.h" … … 2040 2039 } 2041 2040 2042 void invalidateForSiblingCombinators(Element* sibling)2041 static void invalidateForSiblingCombinators(Element* sibling) 2043 2042 { 2044 2043 for (; sibling; sibling = sibling->nextElementSibling()) { … … 2644 2643 return false; 2645 2644 } 2645 2646 static void checkForEmptyStyleChange(Element& element) 2647 { 2648 if (element.styleAffectedByEmpty()) { 2649 auto* style = element.renderStyle(); 2650 if (!style || (!style->emptyState() || element.hasChildNodes())) 2651 element.invalidateStyleForSubtree(); 2652 } 2653 } 2654 2655 2656 static void invalidateForForwardPositionalRules(Element& parent, Element* elementAfterChange) 2657 { 2658 bool childrenAffected = parent.childrenAffectedByForwardPositionalRules(); 2659 bool descendantsAffected = parent.descendantsAffectedByForwardPositionalRules(); 2660 2661 if (!childrenAffected && !descendantsAffected) 2662 return; 2663 2664 for (auto* sibling = elementAfterChange; sibling; sibling = sibling->nextElementSibling()) { 2665 if (childrenAffected) 2666 sibling->invalidateStyleInternal(); 2667 if (descendantsAffected) { 2668 for (auto* siblingChild = sibling->firstElementChild(); siblingChild; siblingChild = siblingChild->nextElementSibling()) 2669 siblingChild->invalidateStyleForSubtreeInternal(); 2670 } 2671 } 2672 } 2673 2674 static void invalidateForBackwardPositionalRules(Element& parent, Element* elementBeforeChange) 2675 { 2676 bool childrenAffected = parent.childrenAffectedByBackwardPositionalRules(); 2677 bool descendantsAffected = parent.descendantsAffectedByBackwardPositionalRules(); 2678 2679 if (!childrenAffected && !descendantsAffected) 2680 return; 2681 2682 for (auto* sibling = elementBeforeChange; sibling; sibling = sibling->previousElementSibling()) { 2683 if (childrenAffected) 2684 sibling->invalidateStyleInternal(); 2685 if (descendantsAffected) { 2686 for (auto* siblingChild = sibling->firstElementChild(); siblingChild; siblingChild = siblingChild->nextElementSibling()) 2687 siblingChild->invalidateStyleForSubtreeInternal(); 2688 } 2689 } 2690 } 2691 2692 enum SiblingCheckType { FinishedParsingChildren, SiblingElementRemoved, Other }; 2693 2694 static void checkForSiblingStyleChanges(Element& parent, SiblingCheckType checkType, Element* elementBeforeChange, Element* elementAfterChange) 2695 { 2696 // :empty selector. 2697 checkForEmptyStyleChange(parent); 2698 2699 if (parent.styleValidity() >= Style::Validity::SubtreeInvalid) 2700 return; 2701 2702 // :first-child. In the parser callback case, we don't have to check anything, since we were right the first time. 2703 // In the DOM case, we only need to do something if |afterChange| is not 0. 2704 // |afterChange| is 0 in the parser case, so it works out that we'll skip this block. 2705 if (parent.childrenAffectedByFirstChildRules() && elementAfterChange) { 2706 // Find our new first child. 2707 RefPtr<Element> newFirstElement = ElementTraversal::firstChild(parent); 2708 // Find the first element node following |afterChange| 2709 2710 // This is the insert/append case. 2711 if (newFirstElement != elementAfterChange) { 2712 auto* style = elementAfterChange->renderStyle(); 2713 if (!style || style->firstChildState()) 2714 elementAfterChange->invalidateStyleForSubtreeInternal(); 2715 } 2716 2717 // We also have to handle node removal. 2718 if (checkType == SiblingElementRemoved && newFirstElement == elementAfterChange && newFirstElement) { 2719 auto* style = newFirstElement->renderStyle(); 2720 if (!style || !style->firstChildState()) 2721 newFirstElement->invalidateStyleForSubtreeInternal(); 2722 } 2723 } 2724 2725 // :last-child. In the parser callback case, we don't have to check anything, since we were right the first time. 2726 // In the DOM case, we only need to do something if |afterChange| is not 0. 2727 if (parent.childrenAffectedByLastChildRules() && elementBeforeChange) { 2728 // Find our new last child. 2729 RefPtr<Element> newLastElement = ElementTraversal::lastChild(parent); 2730 2731 if (newLastElement != elementBeforeChange) { 2732 auto* style = elementBeforeChange->renderStyle(); 2733 if (!style || style->lastChildState()) 2734 elementBeforeChange->invalidateStyleForSubtreeInternal(); 2735 } 2736 2737 // We also have to handle node removal. The parser callback case is similar to node removal as well in that we need to change the last child 2738 // to match now. 2739 if ((checkType == SiblingElementRemoved || checkType == FinishedParsingChildren) && newLastElement == elementBeforeChange && newLastElement) { 2740 auto* style = newLastElement->renderStyle(); 2741 if (!style || !style->lastChildState()) 2742 newLastElement->invalidateStyleForSubtreeInternal(); 2743 } 2744 } 2745 2746 invalidateForSiblingCombinators(elementAfterChange); 2747 2748 invalidateForForwardPositionalRules(parent, elementAfterChange); 2749 invalidateForBackwardPositionalRules(parent, elementBeforeChange); 2750 } 2751 2646 2752 void Element::childrenChanged(const ChildChange& change) 2647 2753 { 2648 2754 ContainerNode::childrenChanged(change); 2649 2650 if (auto* shadowRoot = this->shadowRoot()) { 2755 if (change.source == ChildChange::Source::Parser) 2756 checkForEmptyStyleChange(*this); 2757 else { 2758 auto checkType = change.type == ChildChange::Type::ElementRemoved ? SiblingElementRemoved : Other; 2759 checkForSiblingStyleChanges(*this, checkType, change.previousSiblingElement, change.nextSiblingElement); 2760 } 2761 2762 if (ShadowRoot* shadowRoot = this->shadowRoot()) { 2651 2763 switch (change.type) { 2652 2764 case ChildChange::Type::ElementInserted: … … 2665 2777 case ChildChange::Type::NonContentsChildInserted: 2666 2778 case ChildChange::Type::NonContentsChildRemoved: 2667 case ChildChange::Type::FinishedParsingChildren:2668 2779 break; 2669 2780 } … … 2692 2803 ContainerNode::finishParsingChildren(); 2693 2804 setIsParsingChildrenFinished(); 2694 2695 Style::ChildChangeInvalidation styleInvalidation(*this, { 2696 ChildChange::Type::FinishedParsingChildren, 2697 ElementTraversal::lastChild(*this), 2698 nullptr, 2699 ChildChange::Source::Parser 2700 }); 2805 checkForSiblingStyleChanges(*this, FinishedParsingChildren, ElementTraversal::lastChild(*this), nullptr); 2701 2806 } 2702 2807 -
trunk/Source/WebCore/dom/Element.h
r286058 r286091 764 764 }; 765 765 766 void invalidateForSiblingCombinators(Element* sibling);767 768 766 } // namespace WebCore 769 767 -
trunk/Source/WebCore/dom/ShadowRoot.cpp
r286058 r286091 145 145 case ChildChange::Type::AllChildrenReplaced: 146 146 break; 147 case ChildChange::Type::FinishedParsingChildren:148 ASSERT_NOT_REACHED();149 break;150 147 } 151 148 } -
trunk/Source/WebCore/style/StyleAdjuster.h
r286058 r286091 27 27 28 28 #include "RenderStyleConstants.h" 29 #include "TextSizeAdjustment.h"30 29 #include <wtf/OptionSet.h> 31 30
Note:
See TracChangeset
for help on using the changeset viewer.