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

Unified Diff: third_party/WebKit/Source/web/ResizeViewportAnchor.h

Issue 2184333002: Fix scroll anchoring during viewport resize. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: add comment on m_drift Created 4 years, 5 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/ResizeViewportAnchor.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/web/ResizeViewportAnchor.h
diff --git a/third_party/WebKit/Source/web/ResizeViewportAnchor.h b/third_party/WebKit/Source/web/ResizeViewportAnchor.h
index 49ec20eaeb1e5acf0ee31f0f57632b8a83eefb26..e3138cc1cd38163e9e6fd08162910e6c851b8b3e 100644
--- a/third_party/WebKit/Source/web/ResizeViewportAnchor.h
+++ b/third_party/WebKit/Source/web/ResizeViewportAnchor.h
@@ -5,28 +5,62 @@
#ifndef ResizeViewportAnchor_h
#define ResizeViewportAnchor_h
-#include "platform/geometry/DoublePoint.h"
+#include "core/page/Page.h"
#include "platform/heap/Handle.h"
-#include "web/ViewportAnchor.h"
namespace blink {
class FrameView;
-class VisualViewport;
-// The resize anchor saves the current scroll offset of the visual viewport and
-// restores to that scroll offset so that document location appears exactly
-// unchanged to the user.
-class ResizeViewportAnchor : public ViewportAnchor {
- STACK_ALLOCATED();
+// This class scrolls the viewports to compensate for bounds clamping caused by
+// viewport size changes.
+//
+// It is needed when the layout viewport grows (causing its own scroll position
+// to be clamped) and also when it shrinks (causing the visual viewport's scroll
+// position to be clamped).
+class ResizeViewportAnchor : public GarbageCollectedFinalized<ResizeViewportAnchor> {
+ WTF_MAKE_NONCOPYABLE(ResizeViewportAnchor);
public:
- ResizeViewportAnchor(FrameView& rootFrameView, VisualViewport&);
- ~ResizeViewportAnchor();
+ ResizeViewportAnchor(Page& page)
+ : m_page(page)
+ , m_scopeCount(0)
+ {
+ }
+
+ class ResizeScope {
+ STACK_ALLOCATED();
+ public:
+ explicit ResizeScope(ResizeViewportAnchor& anchor)
+ : m_anchor(anchor)
+ {
+ m_anchor->beginScope();
+ }
+ ~ResizeScope()
+ {
+ m_anchor->endScope();
+ }
+ private:
+ Member<ResizeViewportAnchor> m_anchor;
+ };
+
+ void resizeFrameView(IntSize);
+
+ DEFINE_INLINE_TRACE()
+ {
+ visitor->trace(m_page);
+ }
private:
- // Inner viewport origin in the reference frame of the root document, in CSS
- // pixels.
- DoublePoint m_visualViewportInDocument;
+ void beginScope() { m_scopeCount++; }
+ void endScope();
+ FrameView* rootFrameView();
+
+ // The amount of resize-induced clamping drift accumulated during the
+ // ResizeScope. Note that this should NOT include other kinds of scrolling
+ // that may occur during layout, such as from ScrollAnchor.
+ DoubleSize m_drift;
+ Member<Page> m_page;
+ int m_scopeCount;
};
} // namespace blink
« no previous file with comments | « no previous file | third_party/WebKit/Source/web/ResizeViewportAnchor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698