Changeset 280901 in webkit
- Timestamp:
- Aug 11, 2021, 3:43:19 AM (5 years ago)
- Location:
- releases/WebKitGTK/webkit-2.32/Source/WebCore
- Files:
-
- 10 edited
-
ChangeLog (modified) (1 diff)
-
dom/Element.cpp (modified) (1 diff)
-
dom/Element.h (modified) (1 diff)
-
dom/Node.h (modified) (1 diff)
-
inspector/InspectorInstrumentation.cpp (modified) (1 diff)
-
inspector/InspectorInstrumentation.h (modified) (1 diff)
-
inspector/agents/InspectorCSSAgent.cpp (modified) (4 diffs)
-
inspector/agents/InspectorCSSAgent.h (modified) (3 diffs)
-
rendering/RenderGrid.cpp (modified) (2 diffs)
-
rendering/RenderObject.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
releases/WebKitGTK/webkit-2.32/Source/WebCore/ChangeLog
r280900 r280901 1 2021-03-22 Patrick Angle <pangle@apple.com> 2 3 REGRESSION(r272433): Inspector should not instrument inside `WebCore::Node::setRenderer` 4 https://bugs.webkit.org/show_bug.cgi?id=223559 5 6 Reviewed by Ryosuke Niwa and Devin Rousso. 7 8 Existing test coverage: 9 - inspector/css/nodeLayoutContextTypeChanged.html 10 - inspector/css/setLayoutContextTypeChangedMode.html 11 12 The previous approach to observing render changes was most likely a performance regression in a very hot code 13 path (`Node::setRenderer`). This patch resolves this by not instrumenting in this the hot path. Instead we call 14 inspector instrumentation inside the constructors/destructors of only the RenderObject subclasses we are 15 interested in observing layout changes for. 16 17 Additionally, layout change events are now added to a `Vector` of pending changes, which will be sent to the 18 front-end later in order to avoid evaluating JavaScript inside a destructor in WK1 with the new instrumentation 19 points. 20 21 * dom/Element.cpp: 22 (WebCore::Element::didChangeRenderer): Deleted. 23 * dom/Element.h: 24 * dom/Node.h: 25 (WebCore::Node::didChangeRenderer): Deleted. 26 * inspector/InspectorInstrumentation.cpp: 27 (WebCore::InspectorInstrumentation::nodeLayoutContextChangedImpl): 28 * inspector/InspectorInstrumentation.h: 29 (WebCore::InspectorInstrumentation::nodeLayoutContextChanged): 30 * inspector/agents/InspectorCSSAgent.cpp: 31 (WebCore::InspectorCSSAgent::InspectorCSSAgent): 32 (WebCore::InspectorCSSAgent::reset): 33 (WebCore::InspectorCSSAgent::nodeLayoutContextTypeChanged): 34 (WebCore::InspectorCSSAgent::layoutContextTypeChangedTimerFired): 35 - Moved layout change events behind a timer firing. 36 * inspector/agents/InspectorCSSAgent.h: 37 * rendering/RenderGrid.cpp: 38 (WebCore::RenderGrid::RenderGrid): 39 (WebCore::RenderGrid::~RenderGrid): 40 - Move instrumentation from `Node::setRenderer` to `RenderGrid`. 41 * rendering/RenderObject.h: 42 (WebCore::Node::setRenderer): 43 1 44 2021-03-22 Chris Dumez <cdumez@apple.com> 2 45 -
releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/Element.cpp
r280232 r280901 4565 4565 } 4566 4566 4567 void Element::didChangeRenderer(RenderObject* oldRenderer)4568 {4569 InspectorInstrumentation::nodeLayoutContextChanged(*this, oldRenderer);4570 }4571 4572 4567 #if ENABLE(CSS_TYPED_OM) 4573 4568 -
releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/Element.h
r272433 r280901 729 729 void attachAttributeNodeIfNeeded(Attr&); 730 730 731 void didChangeRenderer(RenderObject*) final;732 733 731 #if ASSERT_ENABLED 734 732 WEBCORE_EXPORT bool fastAttributeLookupAllowed(const QualifiedName&) const; -
releases/WebKitGTK/webkit-2.32/Source/WebCore/dom/Node.h
r280829 r280901 730 730 void moveNodeToNewDocument(Document& oldDocument, Document& newDocument); 731 731 732 virtual void didChangeRenderer(RenderObject*) { };733 734 732 struct NodeRareDataDeleter { 735 733 void operator()(NodeRareData*) const; -
releases/WebKitGTK/webkit-2.32/Source/WebCore/inspector/InspectorInstrumentation.cpp
r272433 r280901 177 177 } 178 178 179 void InspectorInstrumentation::nodeLayoutContextChangedImpl(InstrumentingAgents& instrumentingAgents, Node& node, RenderObject* oldRenderer)179 void InspectorInstrumentation::nodeLayoutContextChangedImpl(InstrumentingAgents& instrumentingAgents, Node& node, RenderObject* newRenderer) 180 180 { 181 181 if (auto* cssAgent = instrumentingAgents.enabledCSSAgent()) 182 cssAgent->nodeLayoutContextTypeChanged(node, oldRenderer);182 cssAgent->nodeLayoutContextTypeChanged(node, newRenderer); 183 183 } 184 184 -
releases/WebKitGTK/webkit-2.32/Source/WebCore/inspector/InspectorInstrumentation.h
r272433 r280901 605 605 } 606 606 607 inline void InspectorInstrumentation::nodeLayoutContextChanged(Node& node, RenderObject* oldRenderer)607 inline void InspectorInstrumentation::nodeLayoutContextChanged(Node& node, RenderObject* newRenderer) 608 608 { 609 609 FAST_RETURN_IF_NO_FRONTENDS(void()); 610 610 if (auto* agents = instrumentingAgents(node.document())) 611 nodeLayoutContextChangedImpl(*agents, node, oldRenderer);611 nodeLayoutContextChangedImpl(*agents, node, newRenderer); 612 612 } 613 613 -
releases/WebKitGTK/webkit-2.32/Source/WebCore/inspector/agents/InspectorCSSAgent.cpp
r273502 r280901 305 305 , m_frontendDispatcher(makeUnique<CSSFrontendDispatcher>(context.frontendRouter)) 306 306 , m_backendDispatcher(CSSBackendDispatcher::create(context.backendDispatcher, this)) 307 , m_layoutContextTypeChangedTimer(*this, &InspectorCSSAgent::layoutContextTypeChangedTimerFired) 307 308 { 308 309 } … … 327 328 m_documentToInspectorStyleSheet.clear(); 328 329 m_documentToKnownCSSStyleSheets.clear(); 330 m_nodesWithPendingLayoutContextTypeChanges.clear(); 331 if (m_layoutContextTypeChangedTimer.isActive()) 332 m_layoutContextTypeChangedTimer.stop(); 329 333 m_layoutContextTypeChangedMode = Protocol::CSS::LayoutContextTypeChangedMode::Observed; 330 334 resetPseudoStates(); … … 964 968 } 965 969 966 void InspectorCSSAgent::nodeLayoutContextTypeChanged(Node& node, RenderObject* oldRenderer)970 void InspectorCSSAgent::nodeLayoutContextTypeChanged(Node& node, RenderObject* newRenderer) 967 971 { 968 972 auto* domAgent = m_instrumentingAgents.persistentDOMAgent(); 969 973 if (!domAgent) 970 974 return; 971 972 auto newLayoutContextType = layoutContextTypeForRenderer(node.renderer()); 973 if (newLayoutContextType == layoutContextTypeForRenderer(oldRenderer)) 974 return; 975 975 976 976 auto nodeId = domAgent->boundNodeId(&node); 977 977 if (!nodeId && m_layoutContextTypeChangedMode == Protocol::CSS::LayoutContextTypeChangedMode::All) { … … 981 981 if (!nodeId) 982 982 return; 983 984 m_frontendDispatcher->nodeLayoutContextTypeChanged(nodeId, WTFMove(newLayoutContextType)); 983 984 m_nodesWithPendingLayoutContextTypeChanges.set(nodeId, layoutContextTypeForRenderer(newRenderer)); 985 if (!m_layoutContextTypeChangedTimer.isActive()) 986 m_layoutContextTypeChangedTimer.startOneShot(0_s); 987 } 988 989 void InspectorCSSAgent::layoutContextTypeChangedTimerFired() 990 { 991 for (auto&& [nodeId, layoutContextType] : std::exchange(m_nodesWithPendingLayoutContextTypeChanges, { })) 992 m_frontendDispatcher->nodeLayoutContextTypeChanged(nodeId, WTFMove(layoutContextType)); 985 993 } 986 994 -
releases/WebKitGTK/webkit-2.32/Source/WebCore/inspector/agents/InspectorCSSAgent.h
r272566 r280901 31 31 #include "InspectorWebAgentBase.h" 32 32 #include "SecurityContext.h" 33 #include "Timer.h" 33 34 #include <JavaScriptCore/InspectorBackendDispatchers.h> 34 35 #include <wtf/HashMap.h> … … 157 158 RefPtr<Inspector::Protocol::CSS::CSSStyle> buildObjectForAttributesStyle(StyledElement&); 158 159 160 void layoutContextTypeChangedTimerFired(); 159 161 160 162 void resetPseudoStates(); … … 173 175 int m_lastStyleSheetId { 1 }; 174 176 bool m_creatingViaInspectorStyleSheet { false }; 177 178 HashMap<Inspector::Protocol::DOM::NodeId, Optional<Inspector::Protocol::CSS::LayoutContextType>> m_nodesWithPendingLayoutContextTypeChanges; 179 Timer m_layoutContextTypeChangedTimer; 175 180 Inspector::Protocol::CSS::LayoutContextTypeChangedMode m_layoutContextTypeChangedMode { Inspector::Protocol::CSS::LayoutContextTypeChangedMode::Observed }; 176 181 }; -
releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/RenderGrid.cpp
r273492 r280901 32 32 #include "GridPositionsResolver.h" 33 33 #include "GridTrackSizingAlgorithm.h" 34 #include "InspectorInstrumentation.h" 34 35 #include "LayoutRepainter.h" 35 36 #include "RenderChildIterator.h" … … 57 58 // All of our children must be block level. 58 59 setChildrenInline(false); 59 } 60 61 RenderGrid::~RenderGrid() = default; 60 61 InspectorInstrumentation::nodeLayoutContextChanged(element, this); 62 } 63 64 RenderGrid::~RenderGrid() 65 { 66 InspectorInstrumentation::nodeLayoutContextChanged(element(), nullptr); 67 } 62 68 63 69 StyleSelfAlignmentData RenderGrid::selfAlignmentForChild(GridAxis axis, const RenderBox& child, const RenderStyle* gridStyle) const -
releases/WebKitGTK/webkit-2.32/Source/WebCore/rendering/RenderObject.h
r273290 r280901 1151 1151 inline void Node::setRenderer(RenderObject* renderer) 1152 1152 { 1153 auto oldRenderer = this->renderer();1154 1153 m_rendererWithStyleFlags.setPointer(renderer); 1155 didChangeRenderer(oldRenderer);1156 1154 } 1157 1155
Note:
See TracChangeset
for help on using the changeset viewer.