| 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 15 matching lines...) Expand all Loading... |
| 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 FullscreenController_h | 31 #ifndef FullscreenController_h |
| 32 #define FullscreenController_h | 32 #define FullscreenController_h |
| 33 | 33 |
| 34 #include "platform/geometry/FloatPoint.h" | 34 #include "platform/geometry/FloatPoint.h" |
| 35 #include "platform/geometry/IntSize.h" | 35 #include "platform/geometry/IntSize.h" |
| 36 #include "platform/heap/Handle.h" | 36 #include "wtf/Vector.h" |
| 37 #include "wtf/RefPtr.h" | 37 #include <memory> |
| 38 | 38 |
| 39 namespace blink { | 39 namespace blink { |
| 40 | 40 |
| 41 class Element; | 41 class Element; |
| 42 class FullscreenCallbacks; |
| 42 class LocalFrame; | 43 class LocalFrame; |
| 43 class WebViewImpl; | 44 class WebViewImpl; |
| 44 | 45 |
| 45 class FullscreenController final | 46 class FullscreenController { |
| 46 : public GarbageCollected<FullscreenController> { | |
| 47 public: | 47 public: |
| 48 static FullscreenController* create(WebViewImpl*); | 48 static std::unique_ptr<FullscreenController> create(WebViewImpl*); |
| 49 | 49 |
| 50 // Called by Fullscreen (via ChromeClient) to request entering or exiting | 50 // Called by Fullscreen (via ChromeClient) to request entering or exiting |
| 51 // fullscreen. | 51 // fullscreen. |
| 52 void enterFullscreenForElement(Element*); | 52 void enterFullscreen(LocalFrame&, std::unique_ptr<FullscreenCallbacks>); |
| 53 void exitFullscreen(LocalFrame*); | 53 void exitFullscreen(LocalFrame&); |
| 54 | 54 |
| 55 // Called by content::RenderWidget (via WebWidget) to notify that we've | 55 // Called by content::RenderWidget (via WebWidget) to notify that we've |
| 56 // entered or exited fullscreen. This can be because we requested it, or it | 56 // entered or exited fullscreen. This can be because we requested it, or it |
| 57 // can be initiated by the browser directly. | 57 // can be initiated by the browser directly. |
| 58 void didEnterFullscreen(); | 58 void didEnterFullscreen(); |
| 59 void didExitFullscreen(); | 59 void didExitFullscreen(); |
| 60 | 60 |
| 61 // Called by Fullscreen (via ChromeClient) to notify that the fullscreen | 61 // Called by Fullscreen (via ChromeClient) to notify that the fullscreen |
| 62 // element has changed. | 62 // element has changed. |
| 63 void fullscreenElementChanged(Element*, Element*); | 63 void fullscreenElementChanged(Element*, Element*); |
| 64 | 64 |
| 65 bool isFullscreen() { return m_fullscreenFrame; } | 65 bool isFullscreen() { return m_state == State::kFullscreen; } |
| 66 | 66 |
| 67 void updateSize(); | 67 void updateSize(); |
| 68 | 68 |
| 69 void didUpdateLayout(); | 69 void didUpdateLayout(); |
| 70 | 70 |
| 71 DECLARE_TRACE(); | |
| 72 | |
| 73 protected: | 71 protected: |
| 74 explicit FullscreenController(WebViewImpl*); | 72 explicit FullscreenController(WebViewImpl*); |
| 75 | 73 |
| 76 private: | 74 private: |
| 77 void updatePageScaleConstraints(bool removeConstraints); | 75 void updatePageScaleConstraints(bool removeConstraints); |
| 78 | 76 |
| 79 WebViewImpl* m_webViewImpl; | 77 WebViewImpl* m_webViewImpl; |
| 80 | 78 |
| 81 bool m_haveEnteredFullscreen; | 79 enum class State { |
| 82 float m_exitFullscreenPageScaleFactor; | 80 kInitial, |
| 83 IntSize m_exitFullscreenScrollOffset; | 81 kEnteringFullscreen, |
| 84 FloatPoint m_exitFullscreenVisualViewportOffset; | 82 kFullscreen, |
| 85 bool m_needsScrollAndScaleRestore; | 83 kExitingFullscreen, |
| 84 kNeedsScrollAndScaleRestore |
| 85 }; |
| 86 State m_state = State::kInitial; |
| 86 | 87 |
| 87 // If set, the WebView is transitioning to fullscreen for this element. | 88 float m_initialPageScaleFactor = 0.0f; |
| 88 Member<Element> m_provisionalFullscreenElement; | 89 IntSize m_initialScrollOffset; |
| 90 FloatPoint m_initialVisualViewportOffset; |
| 89 | 91 |
| 90 // If set, the WebView is in fullscreen mode for an element in this frame. | 92 using CallbacksList = Vector<std::unique_ptr<FullscreenCallbacks>>; |
| 91 Member<LocalFrame> m_fullscreenFrame; | 93 CallbacksList m_callbacksList; |
| 92 | |
| 93 bool m_isCancelingFullscreen; | |
| 94 }; | 94 }; |
| 95 | 95 |
| 96 } // namespace blink | 96 } // namespace blink |
| 97 | 97 |
| 98 #endif | 98 #endif |
| OLD | NEW |