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

Side by Side Diff: third_party/WebKit/Source/web/RotationViewportAnchor.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, 4 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 unified diff | Download patch
OLDNEW
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef RotationViewportAnchor_h 5 #ifndef RotationViewportAnchor_h
6 #define RotationViewportAnchor_h 6 #define RotationViewportAnchor_h
7 7
8 #include "platform/geometry/FloatSize.h" 8 #include "platform/geometry/FloatSize.h"
9 #include "platform/geometry/IntPoint.h" 9 #include "platform/geometry/IntPoint.h"
10 #include "platform/geometry/IntRect.h" 10 #include "platform/geometry/IntRect.h"
11 #include "platform/geometry/LayoutRect.h" 11 #include "platform/geometry/LayoutRect.h"
12 #include "platform/heap/Handle.h" 12 #include "platform/heap/Handle.h"
13 #include "web/ViewportAnchor.h"
14 13
15 namespace blink { 14 namespace blink {
16 15
17 class FrameView; 16 class FrameView;
18 class Node; 17 class Node;
19 class PageScaleConstraintsSet; 18 class PageScaleConstraintsSet;
20 class VisualViewport; 19 class VisualViewport;
21 20
22 // The rotation anchor provides a way to anchor a viewport origin to a DOM node. 21 // The rotation anchor provides a way to anchor a viewport origin to a DOM node.
23 // In particular, the user supplies an anchor point (in view coordinates, e.g., 22 // In particular, the user supplies an anchor point (in view coordinates, e.g.,
24 // (0, 0) == viewport origin, (0.5, 0) == viewport top center). The anchor point 23 // (0, 0) == viewport origin, (0.5, 0) == viewport top center). The anchor point
25 // tracks the underlying DOM node; as the node moves or the view is resized, the 24 // tracks the underlying DOM node; as the node moves or the view is resized, the
26 // viewport anchor maintains its orientation relative to the node, and the 25 // viewport anchor maintains its orientation relative to the node, and the
27 // viewport origin maintains its orientation relative to the anchor. If there is 26 // viewport origin maintains its orientation relative to the anchor. If there is
28 // no node or it is lost during the resize, we fall back to the resize anchor 27 // no node or it is lost during the resize, we fall back to the resize anchor
29 // logic. 28 // logic.
30 class RotationViewportAnchor : public ViewportAnchor { 29 class RotationViewportAnchor {
31 STACK_ALLOCATED(); 30 STACK_ALLOCATED();
32 public: 31 public:
33 RotationViewportAnchor(FrameView& rootFrameView, VisualViewport&, const Floa tSize& anchorInInnerViewCoords, PageScaleConstraintsSet&); 32 RotationViewportAnchor(FrameView& rootFrameView, VisualViewport&, const Floa tSize& anchorInInnerViewCoords, PageScaleConstraintsSet&);
34 ~RotationViewportAnchor(); 33 ~RotationViewportAnchor();
35 34
36 private: 35 private:
37 void setAnchor(); 36 void setAnchor();
38 void restoreToAnchor(); 37 void restoreToAnchor();
39 38
40 FloatPoint getInnerOrigin(const FloatSize& innerSize) const; 39 FloatPoint getInnerOrigin(const FloatSize& innerSize) const;
41 40
42 void computeOrigins(const FloatSize& innerSize, IntPoint& mainFrameOffset, F loatPoint& visualViewportOffset) const; 41 void computeOrigins(const FloatSize& innerSize, IntPoint& mainFrameOffset, F loatPoint& visualViewportOffset) const;
43 42
43 Member<FrameView> m_rootFrameView;
44 Member<VisualViewport> m_visualViewport;
45
44 float m_oldPageScaleFactor; 46 float m_oldPageScaleFactor;
45 float m_oldMinimumPageScaleFactor; 47 float m_oldMinimumPageScaleFactor;
46 48
47 // Inner viewport origin in the reference frame of the document in CSS pixel s 49 // Inner viewport origin in the reference frame of the document in CSS pixel s
48 FloatPoint m_visualViewportInDocument; 50 FloatPoint m_visualViewportInDocument;
49 51
50 // Inner viewport origin in the reference frame of the outer viewport 52 // Inner viewport origin in the reference frame of the outer viewport
51 // normalized to the outer viewport size. 53 // normalized to the outer viewport size.
52 FloatSize m_normalizedVisualViewportOffset; 54 FloatSize m_normalizedVisualViewportOffset;
53 55
54 Member<Node> m_anchorNode; 56 Member<Node> m_anchorNode;
55 LayoutRect m_anchorNodeBounds; 57 LayoutRect m_anchorNodeBounds;
56 58
57 FloatSize m_anchorInInnerViewCoords; 59 FloatSize m_anchorInInnerViewCoords;
58 FloatSize m_anchorInNodeCoords; 60 FloatSize m_anchorInNodeCoords;
59 61
60 PageScaleConstraintsSet& m_pageScaleConstraintsSet; 62 PageScaleConstraintsSet& m_pageScaleConstraintsSet;
61 }; 63 };
62 64
63 } // namespace blink 65 } // namespace blink
64 66
65 #endif // RotationViewportAnchor_h 67 #endif // RotationViewportAnchor_h
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/web/ResizeViewportAnchor.cpp ('k') | third_party/WebKit/Source/web/RotationViewportAnchor.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698