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

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: 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 e83ac35b2caf958aad3234cdc702f2e3b7e17e5f..0c0c87a7a3fce66a23f174c00b682e36279f3263 100644
--- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp
+++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp
@@ -2661,6 +2661,32 @@ void LayoutObject::willBeRemovedFromTree()
// Update cached boundaries in SVG layoutObjects if a child is removed.
if (parent()->isSVG())
parent()->setNeedsBoundariesUpdate();
+
+ clearScrollAnchorIfNeeded();
+}
+
+void LayoutObject::clearScrollAnchorIfNeeded() const
+{
+ if (!scrollAnchoringEnabled())
+ return;
+
+ PaintLayer* layer = parent()->enclosingLayer();
+
+ // Walk up the layer tree to clear any scroll anchors that reference us.
+ // TODO(skobes): Should this be a hash lookup or a data member instead?
+ while (layer) {
+ if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) {
+ ScrollAnchor& anchor = scrollableArea->scrollAnchor();
+ if (anchor.layoutObject() == this)
+ anchor.clear();
+ }
+ layer = layer->parent();
ojan 2016/02/02 06:51:01 I think this is O(n^2) in the depth of the layer t
skobes 2016/02/02 22:39:10 Yes my first thought was to add a back pointer to
+ }
+ if (FrameView* view = frameView()) {
+ ScrollAnchor& anchor = view->scrollAnchor();
+ if (anchor.layoutObject() == this)
+ anchor.clear();
+ }
}
void LayoutObject::removeFromLayoutFlowThread()
@@ -3527,6 +3553,13 @@ void LayoutObject::clearObjectPaintProperties()
objectPaintPropertiesMap().remove(this);
}
+bool LayoutObject::scrollAnchoringEnabled() const
+{
+ if (Settings* settings = document().settings())
+ return settings->scrollAnchoringEnabled();
+ return false;
+}
+
} // namespace blink
#ifndef NDEBUG

Powered by Google App Engine
This is Rietveld 408576698