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 <memory> |
37 #include "wtf/RefPtr.h" | |
38 | 37 |
39 namespace blink { | 38 namespace blink { |
40 | 39 |
41 class Element; | 40 class Element; |
42 class LocalFrame; | 41 class LocalFrame; |
43 class WebViewImpl; | 42 class WebViewImpl; |
44 | 43 |
45 class FullscreenController final | 44 class FullscreenController { |
46 : public GarbageCollected<FullscreenController> { | |
47 public: | 45 public: |
48 static FullscreenController* create(WebViewImpl*); | 46 static std::unique_ptr<FullscreenController> create(WebViewImpl*); |
49 | 47 |
50 // Called by Fullscreen (via ChromeClient) to request entering or exiting | 48 // Called by Fullscreen (via ChromeClient) to request entering or exiting |
51 // fullscreen. | 49 // fullscreen. |
52 void enterFullscreenForElement(Element*); | 50 void enterFullscreen(LocalFrame&); |
53 void exitFullscreen(LocalFrame*); | 51 void exitFullscreen(LocalFrame&); |
54 | 52 |
55 // Called by content::RenderWidget (via WebWidget) to notify that we've | 53 // 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 | 54 // entered or exited fullscreen. This can be because we requested it, or it |
57 // can be initiated by the browser directly. | 55 // can be initiated by the browser directly. |
58 void didEnterFullscreen(); | 56 void didEnterFullscreen(); |
59 void didExitFullscreen(); | 57 void didExitFullscreen(); |
60 | 58 |
61 // Called by Fullscreen (via ChromeClient) to notify that the fullscreen | 59 // Called by Fullscreen (via ChromeClient) to notify that the fullscreen |
62 // element has changed. | 60 // element has changed. |
63 void fullscreenElementChanged(Element*, Element*); | 61 void fullscreenElementChanged(Element*, Element*); |
64 | 62 |
65 bool isFullscreen() { return m_fullscreenFrame; } | 63 bool isFullscreen() { return m_state == State::Fullscreen; } |
66 | 64 |
67 void updateSize(); | 65 void updateSize(); |
68 | 66 |
69 void didUpdateLayout(); | 67 void didUpdateLayout(); |
70 | 68 |
71 DECLARE_TRACE(); | |
72 | |
73 protected: | 69 protected: |
74 explicit FullscreenController(WebViewImpl*); | 70 explicit FullscreenController(WebViewImpl*); |
75 | 71 |
76 private: | 72 private: |
77 void updatePageScaleConstraints(bool removeConstraints); | 73 void updatePageScaleConstraints(bool removeConstraints); |
78 | 74 |
79 WebViewImpl* m_webViewImpl; | 75 WebViewImpl* m_webViewImpl; |
80 | 76 |
81 bool m_haveEnteredFullscreen; | 77 // State is used to avoid unnecessary enter/exit requests, and to restore the |
82 float m_exitFullscreenPageScaleFactor; | 78 // m_initial* after the first layout upon exiting fullscreen. Typically, the |
83 IntSize m_exitFullscreenScrollOffset; | 79 // state goes through every state from Initial to NeedsScrollAndScaleRestore |
84 FloatPoint m_exitFullscreenVisualViewportOffset; | 80 // and then back to Initial, but the are two exceptions: |
85 bool m_needsScrollAndScaleRestore; | 81 // 1. didExitFullscreen() can transition from any non-Initial state to |
82 // NeedsScrollAndScaleRestore, in case of a browser-intiated exit. | |
83 // 2. enterFullscreen() can transition from NeedsScrollAndScaleRestore to | |
84 // EnteringFullscreen, in case of a quick exit+enter. | |
mlamouri (slow - plz ping)
2016/12/06 12:15:47
Thanks :)
| |
85 enum class State { | |
86 Initial, | |
87 EnteringFullscreen, | |
88 Fullscreen, | |
89 ExitingFullscreen, | |
90 NeedsScrollAndScaleRestore | |
91 }; | |
92 State m_state = State::Initial; | |
86 | 93 |
87 // If set, the WebView is transitioning to fullscreen for this element. | 94 float m_initialPageScaleFactor = 0.0f; |
88 Member<Element> m_provisionalFullscreenElement; | 95 IntSize m_initialScrollOffset; |
89 | 96 FloatPoint m_initialVisualViewportOffset; |
90 // If set, the WebView is in fullscreen mode for an element in this frame. | |
91 Member<LocalFrame> m_fullscreenFrame; | |
92 | |
93 bool m_isCancelingFullscreen; | |
94 }; | 97 }; |
95 | 98 |
96 } // namespace blink | 99 } // namespace blink |
97 | 100 |
98 #endif | 101 #endif |
OLD | NEW |