Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / Source / web / RotationViewportAnchor.h
blob9d512c55b08b93abdd55b730ca7705cf891a85d8
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
3 // found in the LICENSE file.
5 #ifndef RotationViewportAnchor_h
6 #define RotationViewportAnchor_h
8 #include "platform/geometry/FloatSize.h"
9 #include "platform/geometry/IntPoint.h"
10 #include "platform/geometry/IntRect.h"
11 #include "platform/geometry/LayoutRect.h"
12 #include "platform/heap/Handle.h"
13 #include "web/ViewportAnchor.h"
15 namespace blink {
17 class FrameView;
18 class Node;
19 class PageScaleConstraintsSet;
20 class VisualViewport;
22 // 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.,
24 // (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
26 // viewport anchor maintains its orientation relative to the node, and the
27 // 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
29 // logic.
30 class RotationViewportAnchor : public ViewportAnchor {
31 STACK_ALLOCATED();
32 public:
33 RotationViewportAnchor(FrameView& rootFrameView, VisualViewport&, const FloatSize& anchorInInnerViewCoords, PageScaleConstraintsSet&);
34 ~RotationViewportAnchor();
36 private:
37 void setAnchor();
38 void restoreToAnchor();
40 FloatPoint getInnerOrigin(const FloatSize& innerSize) const;
42 void computeOrigins(const FloatSize& innerSize, IntPoint& mainFrameOffset, FloatPoint& visualViewportOffset) const;
44 float m_oldPageScaleFactor;
45 float m_oldMinimumPageScaleFactor;
47 // Inner viewport origin in the reference frame of the document in CSS pixels
48 FloatPoint m_visualViewportInDocument;
50 // Inner viewport origin in the reference frame of the outer viewport
51 // normalized to the outer viewport size.
52 FloatSize m_normalizedVisualViewportOffset;
54 RefPtrWillBeMember<Node> m_anchorNode;
55 LayoutRect m_anchorNodeBounds;
57 FloatSize m_anchorInInnerViewCoords;
58 FloatSize m_anchorInNodeCoords;
60 PageScaleConstraintsSet& m_pageScaleConstraintsSet;
63 } // namespace blink
65 #endif // RotationViewportAnchor_h