Title: [292344] branches/safari-613-branch/Source/WebCore
- Revision
- 292344
- Author
- [email protected]
- Date
- 2022-04-04 14:56:25 -0700 (Mon, 04 Apr 2022)
Log Message
Cherry-pick r291981. rdar://91259284
Speed up Element::removedFromAncestor()
https://bugs.webkit.org/show_bug.cgi?id=238404
Reviewed by Geoffrey Garen.
Speed up Element::removedFromAncestor() by inlining some of the functions it is calling.
This is a confirmed 1.5-2% progression on Speedometer on iMac 20,1.
dom/Element.cpp:
(WebCore::Element::removedFromAncestor):
(WebCore::Element::clearBeforePseudoElementSlow):
(WebCore::Element::clearAfterPseudoElementSlow):
(WebCore::Element::setSavedLayerScrollPositionSlow):
(WebCore::Element::clearBeforePseudoElement): Deleted.
(WebCore::Element::clearAfterPseudoElement): Deleted.
(WebCore::Element::setSavedLayerScrollPosition): Deleted.
dom/Element.h:
(WebCore::Element::setSavedLayerScrollPosition):
(WebCore::Element::clearBeforePseudoElement):
(WebCore::Element::clearAfterPseudoElement):
page/PointerCaptureController.cpp:
(WebCore::PointerCaptureController::elementWasRemovedSlow):
(WebCore::PointerCaptureController::elementWasRemoved): Deleted.
page/PointerCaptureController.h:
(WebCore::PointerCaptureController::elementWasRemoved):
page/PointerLockController.cpp:
(WebCore::PointerLockController::elementWasRemovedInternal):
(WebCore::PointerLockController::elementWasRemoved): Deleted.
page/PointerLockController.h:
(WebCore::PointerLockController::elementWasRemoved):
Modified Paths
Diff
Modified: branches/safari-613-branch/Source/WebCore/dom/Element.cpp (292343 => 292344)
--- branches/safari-613-branch/Source/WebCore/dom/Element.cpp 2022-04-04 21:56:22 UTC (rev 292343)
+++ branches/safari-613-branch/Source/WebCore/dom/Element.cpp 2022-04-04 21:56:25 UTC (rev 292344)
@@ -2407,11 +2407,10 @@
if (hasPendingResources())
document().accessSVGExtensions().removeElementFromPendingResources(*this);
- RefPtr<Frame> frame = document().frame();
Styleable::fromElement(*this).elementWasRemoved();
#if ENABLE(WHEEL_EVENT_LATCHING)
- if (frame && frame->page()) {
+ if (RefPtr frame = document().frame(); frame && frame->page()) {
if (auto* scrollLatchingController = frame->page()->scrollLatchingControllerIfExists())
scrollLatchingController->removeLatchingStateForTarget(*this);
}
@@ -3733,18 +3732,16 @@
pseudoElement->clearHostElement();
}
-void Element::clearBeforePseudoElement()
+void Element::clearBeforePseudoElementSlow()
{
- if (!hasRareData())
- return;
+ ASSERT(hasRareData());
disconnectPseudoElement(elementRareData()->beforePseudoElement());
elementRareData()->setBeforePseudoElement(nullptr);
}
-void Element::clearAfterPseudoElement()
+void Element::clearAfterPseudoElementSlow()
{
- if (!hasRareData())
- return;
+ ASSERT(hasRareData());
disconnectPseudoElement(elementRareData()->afterPseudoElement());
elementRareData()->setAfterPseudoElement(nullptr);
}
@@ -4319,10 +4316,9 @@
return hasRareData() ? elementRareData()->savedLayerScrollPosition() : IntPoint();
}
-void Element::setSavedLayerScrollPosition(const IntPoint& position)
+void Element::setSavedLayerScrollPositionSlow(const IntPoint& position)
{
- if (position.isZero() && !hasRareData())
- return;
+ ASSERT(!position.isZero() || hasRareData());
ensureElementRareData().setSavedLayerScrollPosition(position);
}
Modified: branches/safari-613-branch/Source/WebCore/dom/Element.h (292343 => 292344)
--- branches/safari-613-branch/Source/WebCore/dom/Element.h 2022-04-04 21:56:22 UTC (rev 292343)
+++ branches/safari-613-branch/Source/WebCore/dom/Element.h 2022-04-04 21:56:25 UTC (rev 292344)
@@ -736,6 +736,10 @@
void addAttributeInternal(const QualifiedName&, const AtomString& value, SynchronizationOfLazyAttribute);
void removeAttributeInternal(unsigned index, SynchronizationOfLazyAttribute);
+ void setSavedLayerScrollPositionSlow(const IntPoint&);
+ void clearBeforePseudoElementSlow();
+ void clearAfterPseudoElementSlow();
+
LayoutRect absoluteEventBounds(bool& boundsIncludeAllDescendantElements, bool& includesFixedPositionElements);
LayoutRect absoluteEventBoundsOfElementAndDescendants(bool& includesFixedPositionElements);
@@ -783,6 +787,25 @@
bool m_hasDuplicateAttribute { false };
};
+inline void Element::setSavedLayerScrollPosition(const IntPoint& position)
+{
+ if (position.isZero() && !hasRareData())
+ return;
+ setSavedLayerScrollPositionSlow(position);
+}
+
+inline void Element::clearBeforePseudoElement()
+{
+ if (hasRareData())
+ clearBeforePseudoElementSlow();
+}
+
+inline void Element::clearAfterPseudoElement()
+{
+ if (hasRareData())
+ clearAfterPseudoElementSlow();
+}
+
void invalidateForSiblingCombinators(Element* sibling);
} // namespace WebCore
Modified: branches/safari-613-branch/Source/WebCore/page/PointerCaptureController.cpp (292343 => 292344)
--- branches/safari-613-branch/Source/WebCore/page/PointerCaptureController.cpp 2022-04-04 21:56:22 UTC (rev 292343)
+++ branches/safari-613-branch/Source/WebCore/page/PointerCaptureController.cpp 2022-04-04 21:56:25 UTC (rev 292344)
@@ -142,10 +142,9 @@
updateHaveAnyCapturingElement();
}
-void PointerCaptureController::elementWasRemoved(Element& element)
+void PointerCaptureController::elementWasRemovedSlow(Element& element)
{
- if (!m_haveAnyCapturingElement)
- return;
+ ASSERT(m_haveAnyCapturingElement);
for (auto [pointerId, capturingData] : m_activePointerIdsToCapturingData) {
if (capturingData->pendingTargetOverride == &element || capturingData->targetOverride == &element) {
Modified: branches/safari-613-branch/Source/WebCore/page/PointerCaptureController.h (292343 => 292344)
--- branches/safari-613-branch/Source/WebCore/page/PointerCaptureController.h 2022-04-04 21:56:22 UTC (rev 292343)
+++ branches/safari-613-branch/Source/WebCore/page/PointerCaptureController.h 2022-04-04 21:56:25 UTC (rev 292344)
@@ -110,6 +110,7 @@
void pointerEventWasDispatched(const PointerEvent&);
void updateHaveAnyCapturingElement();
+ void elementWasRemovedSlow(Element&);
Page& m_page;
// While PointerID is defined as int32_t, we use int64_t here so that we may use a value outside of the int32_t range to have safe
@@ -120,4 +121,10 @@
bool m_haveAnyCapturingElement { false };
};
+inline void PointerCaptureController::elementWasRemoved(Element& element)
+{
+ if (m_haveAnyCapturingElement)
+ elementWasRemovedSlow(element);
+}
+
} // namespace WebCore
Modified: branches/safari-613-branch/Source/WebCore/page/PointerLockController.cpp (292343 => 292344)
--- branches/safari-613-branch/Source/WebCore/page/PointerLockController.cpp 2022-04-04 21:56:22 UTC (rev 292343)
+++ branches/safari-613-branch/Source/WebCore/page/PointerLockController.cpp 2022-04-04 21:56:25 UTC (rev 292344)
@@ -103,15 +103,13 @@
m_forceCursorVisibleUponUnlock = true;
}
-void PointerLockController::elementWasRemoved(Element& element)
+void PointerLockController::elementWasRemovedInternal()
{
- if (m_element == &element) {
- m_documentOfRemovedElementWhileWaitingForUnlock = m_element->document();
- // Set element null immediately to block any future interaction with it
- // including mouse events received before the unlock completes.
- requestPointerUnlock();
- clearElement();
- }
+ m_documentOfRemovedElementWhileWaitingForUnlock = m_element->document();
+ // Set element null immediately to block any future interaction with it
+ // including mouse events received before the unlock completes.
+ requestPointerUnlock();
+ clearElement();
}
void PointerLockController::documentDetached(Document& document)
Modified: branches/safari-613-branch/Source/WebCore/page/PointerLockController.h (292343 => 292344)
--- branches/safari-613-branch/Source/WebCore/page/PointerLockController.h 2022-04-04 21:56:22 UTC (rev 292343)
+++ branches/safari-613-branch/Source/WebCore/page/PointerLockController.h 2022-04-04 21:56:25 UTC (rev 292344)
@@ -64,6 +64,8 @@
void clearElement();
void enqueueEvent(const AtomString& type, Element*);
void enqueueEvent(const AtomString& type, Document*);
+ void elementWasRemovedInternal();
+
Page& m_page;
bool m_lockPending { false };
bool m_unlockPending { false };
@@ -73,6 +75,12 @@
WeakPtr<Document> m_documentAllowedToRelockWithoutUserGesture;
};
+inline void PointerLockController::elementWasRemoved(Element& element)
+{
+ if (m_element == &element)
+ elementWasRemovedInternal();
+}
+
} // namespace WebCore
#endif // ENABLE(POINTER_LOCK)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes