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 23 matching lines...) Expand all Loading... |
34 #include <memory> | 34 #include <memory> |
35 | 35 |
36 #include "platform/geometry/FloatPoint.h" | 36 #include "platform/geometry/FloatPoint.h" |
37 #include "platform/geometry/IntSize.h" | 37 #include "platform/geometry/IntSize.h" |
38 #include "platform/graphics/Color.h" | 38 #include "platform/graphics/Color.h" |
39 | 39 |
40 namespace blink { | 40 namespace blink { |
41 | 41 |
42 class Element; | 42 class Element; |
43 class LocalFrame; | 43 class LocalFrame; |
44 class WebViewImpl; | 44 class WebViewBase; |
45 | 45 |
46 class FullscreenController { | 46 class FullscreenController { |
47 public: | 47 public: |
48 static std::unique_ptr<FullscreenController> Create(WebViewImpl*); | 48 static std::unique_ptr<FullscreenController> Create(WebViewBase*); |
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 EnterFullscreen(LocalFrame&); | 52 void EnterFullscreen(LocalFrame&); |
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 IsFullscreenOrTransitioning() const { return state_ != State::kInitial; } | 65 bool IsFullscreenOrTransitioning() const { return state_ != State::kInitial; } |
66 | 66 |
67 void UpdateSize(); | 67 void UpdateSize(); |
68 | 68 |
69 void DidUpdateLayout(); | 69 void DidUpdateLayout(); |
70 | 70 |
71 protected: | 71 protected: |
72 explicit FullscreenController(WebViewImpl*); | 72 explicit FullscreenController(WebViewBase*); |
73 | 73 |
74 private: | 74 private: |
75 void UpdatePageScaleConstraints(bool remove_constraints); | 75 void UpdatePageScaleConstraints(bool remove_constraints); |
76 void RestoreBackgroundColorOverride(); | 76 void RestoreBackgroundColorOverride(); |
77 | 77 |
78 WebViewImpl* web_view_impl_; | 78 WebViewBase* web_view_base_; |
79 | 79 |
80 // State is used to avoid unnecessary enter/exit requests, and to restore the | 80 // State is used to avoid unnecessary enter/exit requests, and to restore the |
81 // m_initial* after the first layout upon exiting fullscreen. Typically, the | 81 // m_initial* after the first layout upon exiting fullscreen. Typically, the |
82 // state goes through every state from Initial to NeedsScrollAndScaleRestore | 82 // state goes through every state from Initial to NeedsScrollAndScaleRestore |
83 // and then back to Initial, but the are two exceptions: | 83 // and then back to Initial, but the are two exceptions: |
84 // 1. didExitFullscreen() can transition from any non-Initial state to | 84 // 1. didExitFullscreen() can transition from any non-Initial state to |
85 // NeedsScrollAndScaleRestore, in case of a browser-intiated exit. | 85 // NeedsScrollAndScaleRestore, in case of a browser-intiated exit. |
86 // 2. enterFullscreen() can transition from NeedsScrollAndScaleRestore to | 86 // 2. enterFullscreen() can transition from NeedsScrollAndScaleRestore to |
87 // EnteringFullscreen, in case of a quick exit+enter. | 87 // EnteringFullscreen, in case of a quick exit+enter. |
88 enum class State { | 88 enum class State { |
89 kInitial, | 89 kInitial, |
90 kEnteringFullscreen, | 90 kEnteringFullscreen, |
91 kFullscreen, | 91 kFullscreen, |
92 kExitingFullscreen, | 92 kExitingFullscreen, |
93 kNeedsScrollAndScaleRestore | 93 kNeedsScrollAndScaleRestore |
94 }; | 94 }; |
95 State state_ = State::kInitial; | 95 State state_ = State::kInitial; |
96 | 96 |
97 float initial_page_scale_factor_ = 0.0f; | 97 float initial_page_scale_factor_ = 0.0f; |
98 IntSize initial_scroll_offset_; | 98 IntSize initial_scroll_offset_; |
99 FloatPoint initial_visual_viewport_offset_; | 99 FloatPoint initial_visual_viewport_offset_; |
100 bool initial_background_color_override_enabled_ = false; | 100 bool initial_background_color_override_enabled_ = false; |
101 RGBA32 initial_background_color_override_ = Color::kTransparent; | 101 RGBA32 initial_background_color_override_ = Color::kTransparent; |
102 }; | 102 }; |
103 | 103 |
104 } // namespace blink | 104 } // namespace blink |
105 | 105 |
106 #endif | 106 #endif |
OLD | NEW |