Chromium Code Reviews| 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..0d10b80251ba2d220b429cacc1f7ddccfdf633be 100644 |
| --- a/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| +++ b/third_party/WebKit/Source/core/layout/LayoutObject.cpp |
| @@ -2671,6 +2671,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? |
|
ojan
2016/02/03 01:23:43
I was hoping this TODO would explicitly point out
|
| + while (layer) { |
| + if (PaintLayerScrollableArea* scrollableArea = layer->scrollableArea()) { |
| + ScrollAnchor& anchor = scrollableArea->scrollAnchor(); |
| + if (anchor.anchorObject() == this) |
| + anchor.clear(); |
| + } |
| + layer = layer->parent(); |
| + } |
| + if (FrameView* view = frameView()) { |
| + ScrollAnchor& anchor = view->scrollAnchor(); |
| + if (anchor.anchorObject() == this) |
| + anchor.clear(); |
| + } |
| } |
| void LayoutObject::removeFromLayoutFlowThread() |
| @@ -3537,6 +3563,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 |