OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 21 matching lines...) Expand all Loading... |
32 #define ViewportAnchor_h | 32 #define ViewportAnchor_h |
33 | 33 |
34 #include "platform/geometry/FloatSize.h" | 34 #include "platform/geometry/FloatSize.h" |
35 #include "platform/geometry/IntPoint.h" | 35 #include "platform/geometry/IntPoint.h" |
36 #include "platform/geometry/IntRect.h" | 36 #include "platform/geometry/IntRect.h" |
37 #include "platform/geometry/LayoutRect.h" | 37 #include "platform/geometry/LayoutRect.h" |
38 #include "platform/heap/Handle.h" | 38 #include "platform/heap/Handle.h" |
39 #include "wtf/RefCounted.h" | 39 #include "wtf/RefCounted.h" |
40 | 40 |
41 namespace blink { | 41 namespace blink { |
| 42 |
42 class EventHandler; | 43 class EventHandler; |
43 class IntSize; | 44 class IntSize; |
44 class Node; | 45 class Node; |
45 } | |
46 | |
47 namespace blink { | |
48 | 46 |
49 // ViewportAnchor provides a way to anchor a viewport origin to a DOM node. | 47 // ViewportAnchor provides a way to anchor a viewport origin to a DOM node. |
50 // In particular, the user supplies the current viewport (in CSS coordinates) | 48 // In particular, the user supplies the current viewport (in CSS coordinates) |
51 // and an anchor point (in view coordinates, e.g., (0, 0) == viewport origin, | 49 // and an anchor point (in view coordinates, e.g., (0, 0) == viewport origin, |
52 // (0.5, 0) == viewport top center). The anchor point tracks the underlying DOM | 50 // (0.5, 0) == viewport top center). The anchor point tracks the underlying DOM |
53 // node; as the node moves or the view is resized, the viewport anchor maintains | 51 // node; as the node moves or the view is resized, the viewport anchor maintains |
54 // its orientation relative to the node, and the viewport origin maintains its | 52 // its orientation relative to the node, and the viewport origin maintains its |
55 // orientation relative to the anchor. | 53 // orientation relative to the anchor. |
56 class ViewportAnchor { | 54 class ViewportAnchor { |
57 STACK_ALLOCATED(); | 55 STACK_ALLOCATED(); |
58 public: | 56 public: |
59 explicit ViewportAnchor(blink::EventHandler* eventHandler); | 57 explicit ViewportAnchor(EventHandler*); |
60 | 58 |
61 void setAnchor(const blink::IntRect& viewRect, const blink::FloatSize& ancho
rInViewCoords); | 59 void setAnchor(const IntRect& viewRect, const FloatSize& anchorInViewCoords)
; |
62 | 60 |
63 blink::IntPoint computeOrigin(const blink::IntSize& currentViewSize) const; | 61 IntPoint computeOrigin(const IntSize& currentViewSize) const; |
64 | 62 |
65 private: | 63 private: |
66 RawPtrWillBeMember<blink::EventHandler> m_eventHandler; | 64 RawPtrWillBeMember<EventHandler> m_eventHandler; |
67 | 65 |
68 blink::IntRect m_viewRect; | 66 IntRect m_viewRect; |
69 | 67 |
70 RefPtrWillBeMember<blink::Node> m_anchorNode; | 68 RefPtrWillBeMember<Node> m_anchorNode; |
71 blink::LayoutRect m_anchorNodeBounds; | 69 LayoutRect m_anchorNodeBounds; |
72 | 70 |
73 blink::FloatSize m_anchorInViewCoords; | 71 FloatSize m_anchorInViewCoords; |
74 blink::FloatSize m_anchorInNodeCoords; | 72 FloatSize m_anchorInNodeCoords; |
75 }; | 73 }; |
76 | 74 |
77 } // namespace blink | 75 } // namespace blink |
78 | 76 |
79 #endif | 77 #endif |
OLD | NEW |