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

Unified Diff: third_party/WebKit/Source/core/layout/ScrollAnchor.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/ScrollAnchor.cpp
diff --git a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
index 0b3212850f6eb4a78d7d6013a92dcba244a55370..3242c0d94d87e53a6851496dfa2c6488d5e56e30 100644
--- a/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
+++ b/third_party/WebKit/Source/core/layout/ScrollAnchor.cpp
@@ -4,6 +4,7 @@
#include "core/layout/ScrollAnchor.h"
+#include "core/layout/LayoutObject.h"
#include "platform/scroll/ScrollableArea.h"
#include "wtf/Assertions.h"
@@ -35,11 +36,13 @@ static DoublePoint computeRelativeOffset(const ScrollableArea* scroller, const L
void ScrollAnchor::save()
{
- if (!m_anchorObject)
+ if (!m_anchorObject) {
m_anchorObject = findAnchor(m_scroller);
-
- if (m_anchorObject)
- m_savedRelativeOffset = computeRelativeOffset(m_scroller, m_anchorObject);
+ if (!m_anchorObject)
+ return;
+ m_anchorObject->setIsScrollAnchorObject();
+ }
+ m_savedRelativeOffset = computeRelativeOffset(m_scroller, m_anchorObject);
ojan 2016/02/05 11:01:52 I think this could be inside the if clause above a
skobes 2016/02/05 17:52:31 In theory, yes, but that seems brittle to me. Sup
ojan 2016/02/06 00:09:27 I can't think of any scenario in which it would ma
}
void ScrollAnchor::restore()
@@ -52,4 +55,13 @@ void ScrollAnchor::restore()
m_scroller->setScrollPosition(m_scroller->scrollPositionDouble() + adjustment, AnchoringScroll);
}
+void ScrollAnchor::clear()
+{
+ LayoutObject* anchorObject = m_anchorObject;
+ m_anchorObject = nullptr;
+
+ if (anchorObject)
+ anchorObject->maybeClearIsScrollAnchorObject();
+}
+
} // namespace blink
« no previous file with comments | « third_party/WebKit/Source/core/layout/ScrollAnchor.h ('k') | third_party/WebKit/Source/core/paint/PaintLayerScrollableArea.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698