Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(290)

Unified Diff: third_party/WebKit/Source/core/layout/LayoutObject.cpp

Issue 1647793002: Use ScrollAnchor in FrameView and PaintLayerScrollableArea. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@anchor-skeleton
Patch Set: move save/restore from LayoutBlockFlow into LayoutBlock Created 4 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/LayoutObject.cpp
diff --git a/third_party/WebKit/Source/core/layout/LayoutObject.cpp b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
index 2af844ee0717fcfb7e676f32add5cf3ea26bfc18..4d1fd3ec9bec4fca453ab51cfb0d1091e8917973 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -2644,6 +2644,41 @@ void LayoutObject::insertedIntoTree()
flowThread->flowThreadDescendantWasInserted(this);
}
+enum FindReferencingScrollAnchorsBehavior {
+ DontClear,
+ Clear
+};
+
+static bool findReferencingScrollAnchors(LayoutObject* layoutObject, FindReferencingScrollAnchorsBehavior behavior)
+{
+ PaintLayer* layer = layoutObject->enclosingLayer();
+ bool found = false;
+
+ // Walk up the layer tree to clear any scroll anchors that reference us.
+ while (layer) {
+ if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) {
+ ScrollAnchor& anchor = scrollableArea->scrollAnchor();
+ if (anchor.anchorObject() == layoutObject) {
+ found = true;
+ if (behavior == Clear)
+ anchor.clear();
+ else
+ return true;
+ }
+ }
+ layer = layer->parent();
+ }
+ if (FrameView* view = layoutObject->frameView()) {
+ ScrollAnchor& anchor = view->scrollAnchor();
+ if (anchor.anchorObject() == layoutObject) {
+ found = true;
+ if (behavior == Clear)
+ anchor.clear();
+ }
+ }
+ return found;
+}
+
void LayoutObject::willBeRemovedFromTree()
{
// FIXME: We should ASSERT(isRooted()) but we have some out-of-order removals which would need to be fixed first.
@@ -2671,6 +2706,18 @@ void LayoutObject::willBeRemovedFromTree()
// Update cached boundaries in SVG layoutObjects if a child is removed.
if (parent()->isSVG())
parent()->setNeedsBoundariesUpdate();
+
+ if (RuntimeEnabledFeatures::scrollAnchoringEnabled() && m_bitfields.isScrollAnchorObject()) {
+ // Clear the bit first so that anchor.clear() doesn't recurse into findReferencingScrollAnchors.
+ m_bitfields.setIsScrollAnchorObject(false);
+ findReferencingScrollAnchors(this, Clear);
+ }
+}
+
+void LayoutObject::maybeClearIsScrollAnchorObject()
+{
+ if (m_bitfields.isScrollAnchorObject())
+ m_bitfields.setIsScrollAnchorObject(findReferencingScrollAnchors(this, DontClear));
}
void LayoutObject::removeFromLayoutFlowThread()

Powered by Google App Engine
This is Rietveld 408576698