Chromium Code Reviews| 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 10 matching lines...) Expand all Loading... | |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef WebUserGestureToken_h | 31 #ifndef ViewportAnchor_h |
| 32 #define WebUserGestureToken_h | 32 #define ViewportAnchor_h |
| 33 | 33 |
| 34 #include "../../../Platform/chromium/public/WebPrivatePtr.h" | 34 #include "FloatSize.h" |
| 35 #include "IntPoint.h" | |
| 36 #include "IntRect.h" | |
| 37 #include "LayoutRect.h" | |
| 38 #include <wtf/RefCounted.h> | |
| 35 | 39 |
| 36 namespace WebCore { | 40 namespace WebCore { |
| 37 class UserGestureToken; | 41 class EventHandler; |
| 42 class IntSize; | |
| 43 class Node; | |
| 38 } | 44 } |
| 39 | 45 |
| 40 namespace WebKit { | 46 namespace WebKit { |
| 41 | 47 |
| 42 // A WebUserGestureToken allows for storing the user gesture state of the | 48 // ViewportAnchor provides a way to anchor a viewport origin to a DOM node. |
| 43 // currently active context and reinstantiating it later on to continue | 49 // In particular, the user supplies the current viewport (in CSS coordinates) |
| 44 // processing the user gesture in case it was not consumed meanwhile. | 50 // and an anchor point (in view coordinates, e.g., (0, 0) == viewport origin, |
| 45 class WebUserGestureToken { | 51 // (0.5, 0) == viewport top center). The anchor point tracks the underlying DOM |
| 52 // node; as the node moves or the view is resized, the viewport anchor maintains | |
| 53 // its orientation relative to the node, and the viewport origin maintains its | |
| 54 // orientation relative to the anchor. | |
| 55 #if ENABLE(VIEWPORT) | |
| 56 class ViewportAnchor { | |
|
abarth-chromium
2013/04/18 05:33:04
This object seems to deal entirely in terms of Web
jdduke (slow)
2013/04/18 16:20:07
That's hard for me to say. This was originally in
| |
| 57 WTF_MAKE_NONCOPYABLE(ViewportAnchor); | |
| 46 public: | 58 public: |
| 47 WebUserGestureToken() { } | 59 explicit ViewportAnchor(WebCore::EventHandler* eventHandler); |
| 48 WebUserGestureToken(const WebUserGestureToken& other) { assign(other); } | |
| 49 WebUserGestureToken& operator=(const WebUserGestureToken& other) | |
| 50 { | |
| 51 assign(other); | |
| 52 return *this; | |
| 53 } | |
| 54 ~WebUserGestureToken() { reset(); } | |
| 55 | 60 |
| 56 WEBKIT_EXPORT bool hasGestures() const; | 61 void setAnchor(const WebCore::IntRect& viewRect, const WebCore::FloatSize& a nchorInViewCoords); |
| 57 bool isNull() const { return m_token.isNull(); } | |
| 58 | 62 |
| 59 #if WEBKIT_IMPLEMENTATION | 63 WebCore::IntPoint computeOrigin(const WebCore::IntSize& currentViewSize) con st; |
| 60 explicit WebUserGestureToken(PassRefPtr<WebCore::UserGestureToken>); | |
| 61 operator PassRefPtr<WebCore::UserGestureToken>() const; | |
| 62 #endif | |
| 63 | 64 |
| 64 private: | 65 private: |
| 65 WEBKIT_EXPORT void assign(const WebUserGestureToken&); | 66 WebCore::EventHandler* m_eventHandler; |
| 66 WEBKIT_EXPORT void reset(); | |
| 67 | 67 |
| 68 WebPrivatePtr<WebCore::UserGestureToken> m_token; | 68 WebCore::IntRect m_viewRect; |
| 69 | |
| 70 RefPtr<WebCore::Node> m_anchorNode; | |
| 71 WebCore::LayoutRect m_anchorNodeBounds; | |
| 72 | |
| 73 WebCore::FloatSize m_anchorInViewCoords; | |
| 74 WebCore::FloatSize m_anchorInNodeCoords; | |
| 69 }; | 75 }; |
| 76 #endif // ENABLE(VIEWPORT) | |
| 70 | 77 |
| 71 } // namespace WebKit | 78 } // namespace WebKit |
| 72 | 79 |
| 73 #endif // WebUserGestureToken_h | 80 #endif |
| OLD | NEW |