| OLD | NEW |
| (Empty) |
| 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. | |
| 4 | |
| 5 #ifndef RotationViewportAnchor_h | |
| 6 #define RotationViewportAnchor_h | |
| 7 | |
| 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 | |
| 14 namespace blink { | |
| 15 | |
| 16 class FrameView; | |
| 17 class Node; | |
| 18 class PageScaleConstraintsSet; | |
| 19 class ScrollableArea; | |
| 20 class VisualViewport; | |
| 21 | |
| 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 { | |
| 31 STACK_ALLOCATED(); | |
| 32 | |
| 33 public: | |
| 34 RotationViewportAnchor(FrameView& root_frame_view, | |
| 35 VisualViewport&, | |
| 36 const FloatSize& anchor_in_inner_view_coords, | |
| 37 PageScaleConstraintsSet&); | |
| 38 ~RotationViewportAnchor(); | |
| 39 | |
| 40 private: | |
| 41 void SetAnchor(); | |
| 42 void RestoreToAnchor(); | |
| 43 | |
| 44 FloatPoint GetInnerOrigin(const FloatSize& inner_size) const; | |
| 45 | |
| 46 void ComputeOrigins(const FloatSize& inner_size, | |
| 47 IntPoint& main_frame_offset, | |
| 48 FloatPoint& visual_viewport_offset) const; | |
| 49 ScrollableArea& LayoutViewport() const; | |
| 50 | |
| 51 Member<FrameView> root_frame_view_; | |
| 52 Member<VisualViewport> visual_viewport_; | |
| 53 | |
| 54 float old_page_scale_factor_; | |
| 55 float old_minimum_page_scale_factor_; | |
| 56 | |
| 57 // Inner viewport origin in the reference frame of the document in CSS pixels | |
| 58 FloatPoint visual_viewport_in_document_; | |
| 59 | |
| 60 // Inner viewport origin in the reference frame of the outer viewport | |
| 61 // normalized to the outer viewport size. | |
| 62 FloatSize normalized_visual_viewport_offset_; | |
| 63 | |
| 64 Member<Node> anchor_node_; | |
| 65 LayoutRect anchor_node_bounds_; | |
| 66 | |
| 67 FloatSize anchor_in_inner_view_coords_; | |
| 68 FloatSize anchor_in_node_coords_; | |
| 69 | |
| 70 PageScaleConstraintsSet& page_scale_constraints_set_; | |
| 71 }; | |
| 72 | |
| 73 } // namespace blink | |
| 74 | |
| 75 #endif // RotationViewportAnchor_h | |
| OLD | NEW |