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

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

Issue 2394053004: Clear scroll anchor on all parent scrollers from ScrollAnchor::clear (Closed)
Patch Set: Created 4 years, 2 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/ScrollAnchor.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
index 4bb9943626ec9288e050239a16d38ba2be23d34b..b9db6f3ef737d280627669b9e3523e270f08afa8 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
@@ -34,7 +34,7 @@ void ScrollAnchor::setScroller(ScrollableArea* scroller) {
DCHECK(scroller->isRootFrameViewport() || scroller->isFrameView() ||
scroller->isPaintLayerScrollableArea());
m_scroller = scroller;
- clear();
+ clearForContainingScroller();
}
// TODO(pilgrim) replace all instances of scrollerLayoutBox with scrollerLayoutBoxItem
@@ -222,7 +222,7 @@ void ScrollAnchor::save() {
? VerticalScrollbar
: HorizontalScrollbar;
if (m_scroller->scrollPosition(blockLayoutAxis) == 0) {
- clear();
+ clearForContainingScroller();
return;
}
@@ -231,7 +231,7 @@ void ScrollAnchor::save() {
if (!m_anchorObject)
return;
- m_anchorObject->setIsScrollAnchorObject();
+ m_anchorObject->setIsScrollAnchorObject(true);
m_savedRelativeOffset =
computeRelativeOffset(m_anchorObject, m_scroller, m_corner);
}
@@ -278,7 +278,7 @@ void ScrollAnchor::restore() {
// Note that we only clear if the adjustment would have been non-zero.
// This minimizes redundant calls to findAnchor.
// TODO(skobes): add UMA metric for this.
- clear();
+ clearForContainingScroller();
DEFINE_STATIC_LOCAL(EnumerationHistogram, suppressedBySanaclapHistogram,
("Layout.ScrollAnchor.SuppressedBySanaclap", 2));
@@ -298,21 +298,27 @@ void ScrollAnchor::restore() {
UseCounter::ScrollAnchored);
}
-void ScrollAnchor::clear() {
- LayoutObject* anchorObject = m_anchorObject;
+void ScrollAnchor::releaseAnchor() {
m_anchorObject = nullptr;
+}
+
+void ScrollAnchor::clearForContainingScroller() {
+ LayoutObject* anchorObject = m_anchorObject;
+ releaseAnchor();
if (anchorObject)
anchorObject->maybeClearIsScrollAnchorObject();
}
-bool ScrollAnchor::refersTo(const LayoutObject* layoutObject) const {
- return m_anchorObject == layoutObject;
+void ScrollAnchor::clear() {
+ if (m_anchorObject)
+ m_anchorObject->clearScrollAnchors();
+ else
+ scrollerLayoutBox(m_scroller)->clearScrollAnchors();
}
-void ScrollAnchor::notifyRemoved(LayoutObject* layoutObject) {
- if (m_anchorObject == layoutObject)
- clear();
+bool ScrollAnchor::refersTo(const LayoutObject* layoutObject) const {
+ return m_anchorObject == layoutObject;
}
} // namespace blink

Powered by Google App Engine
This is Rietveld 408576698