OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ | 5 #ifndef CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ |
6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ | 6 #define CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ |
7 | 7 |
8 #include <vector> | 8 #include <vector> |
9 | 9 |
10 #include "base/memory/ref_counted.h" | 10 #include "base/memory/ref_counted.h" |
11 #include "base/memory/scoped_ptr.h" | 11 #include "base/memory/scoped_ptr.h" |
12 #include "content/browser/renderer_host/overscroll_controller_delegate.h" | 12 #include "content/browser/renderer_host/overscroll_controller_delegate.h" |
13 #include "content/browser/renderer_host/render_view_host_delegate_view.h" | 13 #include "content/browser/renderer_host/render_view_host_delegate_view.h" |
14 #include "content/browser/web_contents/web_contents_view.h" | 14 #include "content/browser/web_contents/web_contents_view.h" |
15 #include "content/common/content_export.h" | 15 #include "content/common/content_export.h" |
16 #include "ui/aura/window_delegate.h" | 16 #include "ui/aura/window_delegate.h" |
17 #include "ui/aura/window_observer.h" | 17 #include "ui/aura/window_observer.h" |
18 #include "ui/compositor/layer_animation_observer.h" | |
19 #include "ui/wm/public/drag_drop_delegate.h" | 18 #include "ui/wm/public/drag_drop_delegate.h" |
20 | 19 |
21 namespace aura { | 20 namespace aura { |
22 class Window; | 21 class Window; |
23 } | 22 } |
24 | 23 |
25 namespace ui { | 24 namespace ui { |
26 class DropTargetEvent; | 25 class DropTargetEvent; |
27 } | 26 } |
28 | 27 |
29 namespace content { | 28 namespace content { |
30 class GestureNavSimple; | 29 class GestureNavSimple; |
31 class OverscrollNavigationOverlay; | 30 class OverscrollNavigationOverlay; |
32 class RenderWidgetHostImpl; | 31 class RenderWidgetHostImpl; |
33 class RenderWidgetHostViewAura; | 32 class RenderWidgetHostViewAura; |
34 class ShadowLayerDelegate; | 33 class ShadowLayerDelegate; |
35 class TouchEditableImplAura; | 34 class TouchEditableImplAura; |
36 class WebContentsViewDelegate; | 35 class WebContentsViewDelegate; |
37 class WebContentsImpl; | 36 class WebContentsImpl; |
38 class WebDragDestDelegate; | 37 class WebDragDestDelegate; |
39 | 38 |
40 class WebContentsViewAura | 39 class WebContentsViewAura |
41 : public WebContentsView, | 40 : public WebContentsView, |
42 public RenderViewHostDelegateView, | 41 public RenderViewHostDelegateView, |
43 public OverscrollControllerDelegate, | 42 public OverscrollControllerDelegate, |
44 public ui::ImplicitAnimationObserver, | |
45 public aura::WindowDelegate, | 43 public aura::WindowDelegate, |
46 public aura::client::DragDropDelegate, | 44 public aura::client::DragDropDelegate, |
47 public aura::WindowObserver { | 45 public aura::WindowObserver { |
48 public: | 46 public: |
49 WebContentsViewAura(WebContentsImpl* web_contents, | 47 WebContentsViewAura(WebContentsImpl* web_contents, |
50 WebContentsViewDelegate* delegate); | 48 WebContentsViewDelegate* delegate); |
51 | 49 |
52 CONTENT_EXPORT void SetTouchEditableForTest( | 50 CONTENT_EXPORT void SetTouchEditableForTest( |
53 TouchEditableImplAura* touch_editable); | 51 TouchEditableImplAura* touch_editable); |
54 | 52 |
55 private: | 53 private: |
56 class WindowObserver; | 54 class WindowObserver; |
57 | 55 |
58 ~WebContentsViewAura() override; | 56 ~WebContentsViewAura() override; |
59 | 57 |
60 void SizeChangedCommon(const gfx::Size& size); | 58 void SizeChangedCommon(const gfx::Size& size); |
61 | 59 |
62 void EndDrag(blink::WebDragOperationsMask ops); | 60 void EndDrag(blink::WebDragOperationsMask ops); |
63 | 61 |
64 void InstallOverscrollControllerDelegate(RenderWidgetHostViewAura* view); | 62 void InstallOverscrollControllerDelegate(RenderWidgetHostViewAura* view); |
65 | 63 |
66 // Creates and sets up the overlay window that will be displayed during the | |
67 // overscroll gesture. | |
68 void PrepareOverscrollWindow(); | |
69 | |
70 // Sets up the content window in preparation for starting an overscroll | 64 // Sets up the content window in preparation for starting an overscroll |
71 // gesture. | 65 // gesture. |
72 void PrepareContentWindowForOverscroll(); | 66 void PrepareContentWindowForOverscroll(); |
73 | 67 |
74 // Resets any in-progress animation for the overscroll gesture. Note that this | |
75 // doesn't immediately reset the internal states; that happens after an | |
76 // animation. | |
77 void ResetOverscrollTransform(); | |
78 | |
79 // Completes the navigation in response to a completed overscroll gesture. | 68 // Completes the navigation in response to a completed overscroll gesture. |
80 // The navigation happens after an animation (either the overlay window | 69 // The navigation happens after an animation (either the overlay window |
81 // animates in, or the content window animates out). | 70 // animates in, or the content window animates out). |
82 void CompleteOverscrollNavigation(OverscrollMode mode); | 71 void CompleteOverscrollNavigation(OverscrollMode mode); |
83 | 72 |
84 // Returns the window that should be animated for the overscroll gesture. | |
85 // (note that during the overscroll gesture, either the overlay window or the | |
86 // content window can be animated). | |
87 aura::Window* GetWindowToAnimateForOverscroll(); | |
88 | |
89 // Returns the amount the animating window should be translated in response to | |
90 // the overscroll gesture. | |
91 gfx::Vector2dF GetTranslationForOverscroll(float delta_x, float delta_y); | |
92 | |
93 // A window showing the screenshot is overlayed during a navigation triggered | |
94 // by overscroll. This function sets this up. | |
95 void PrepareOverscrollNavigationOverlay(); | |
96 | |
97 // Changes the brightness of the layer depending on the amount of horizontal | |
98 // overscroll (|delta_x|, in pixels). | |
99 void UpdateOverscrollWindowBrightness(float delta_x); | |
100 | |
101 void AttachTouchEditableToRenderView(); | 73 void AttachTouchEditableToRenderView(); |
102 | 74 |
103 void OverscrollUpdateForWebContentsDelegate(float delta_y); | 75 void OverscrollUpdateForWebContentsDelegate(float delta_y); |
104 | 76 |
105 // Overridden from WebContentsView: | 77 // Overridden from WebContentsView: |
106 gfx::NativeView GetNativeView() const override; | 78 gfx::NativeView GetNativeView() const override; |
107 gfx::NativeView GetContentNativeView() const override; | 79 gfx::NativeView GetContentNativeView() const override; |
108 gfx::NativeWindow GetTopLevelNativeWindow() const override; | 80 gfx::NativeWindow GetTopLevelNativeWindow() const override; |
109 void GetContainerBounds(gfx::Rect* out) const override; | 81 void GetContainerBounds(gfx::Rect* out) const override; |
110 void SizeContents(const gfx::Size& size) override; | 82 void SizeContents(const gfx::Size& size) override; |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) override; | 116 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) override; |
145 void HideDisambiguationPopup() override; | 117 void HideDisambiguationPopup() override; |
146 | 118 |
147 // Overridden from OverscrollControllerDelegate: | 119 // Overridden from OverscrollControllerDelegate: |
148 gfx::Rect GetVisibleBounds() const override; | 120 gfx::Rect GetVisibleBounds() const override; |
149 bool OnOverscrollUpdate(float delta_x, float delta_y) override; | 121 bool OnOverscrollUpdate(float delta_x, float delta_y) override; |
150 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; | 122 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; |
151 void OnOverscrollModeChange(OverscrollMode old_mode, | 123 void OnOverscrollModeChange(OverscrollMode old_mode, |
152 OverscrollMode new_mode) override; | 124 OverscrollMode new_mode) override; |
153 | 125 |
154 // Overridden from ui::ImplicitAnimationObserver: | |
155 void OnImplicitAnimationsCompleted() override; | |
156 | |
157 // Overridden from aura::WindowDelegate: | 126 // Overridden from aura::WindowDelegate: |
158 gfx::Size GetMinimumSize() const override; | 127 gfx::Size GetMinimumSize() const override; |
159 gfx::Size GetMaximumSize() const override; | 128 gfx::Size GetMaximumSize() const override; |
160 void OnBoundsChanged(const gfx::Rect& old_bounds, | 129 void OnBoundsChanged(const gfx::Rect& old_bounds, |
161 const gfx::Rect& new_bounds) override; | 130 const gfx::Rect& new_bounds) override; |
162 ui::TextInputClient* GetFocusedTextInputClient() override; | 131 ui::TextInputClient* GetFocusedTextInputClient() override; |
163 gfx::NativeCursor GetCursor(const gfx::Point& point) override; | 132 gfx::NativeCursor GetCursor(const gfx::Point& point) override; |
164 int GetNonClientComponent(const gfx::Point& point) const override; | 133 int GetNonClientComponent(const gfx::Point& point) const override; |
165 bool ShouldDescendIntoChildForEventHandling( | 134 bool ShouldDescendIntoChildForEventHandling( |
166 aura::Window* child, | 135 aura::Window* child, |
(...skipping 19 matching lines...) Expand all Loading... |
186 int OnPerformDrop(const ui::DropTargetEvent& event) override; | 155 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
187 | 156 |
188 // Overridden from aura::WindowObserver: | 157 // Overridden from aura::WindowObserver: |
189 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; | 158 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; |
190 | 159 |
191 // Update the web contents visiblity. | 160 // Update the web contents visiblity. |
192 void UpdateWebContentsVisibility(bool visible); | 161 void UpdateWebContentsVisibility(bool visible); |
193 | 162 |
194 scoped_ptr<aura::Window> window_; | 163 scoped_ptr<aura::Window> window_; |
195 | 164 |
196 // The window that shows the screenshot of the history page during an | |
197 // overscroll navigation gesture. | |
198 scoped_ptr<aura::Window> overscroll_window_; | |
199 | |
200 scoped_ptr<WindowObserver> window_observer_; | 165 scoped_ptr<WindowObserver> window_observer_; |
201 | 166 |
202 // The WebContentsImpl whose contents we display. | 167 // The WebContentsImpl whose contents we display. |
203 WebContentsImpl* web_contents_; | 168 WebContentsImpl* web_contents_; |
204 | 169 |
205 scoped_ptr<WebContentsViewDelegate> delegate_; | 170 scoped_ptr<WebContentsViewDelegate> delegate_; |
206 | 171 |
207 blink::WebDragOperationsMask current_drag_op_; | 172 blink::WebDragOperationsMask current_drag_op_; |
208 | 173 |
209 scoped_ptr<DropData> current_drop_data_; | 174 scoped_ptr<DropData> current_drop_data_; |
210 | 175 |
211 WebDragDestDelegate* drag_dest_delegate_; | 176 WebDragDestDelegate* drag_dest_delegate_; |
212 | 177 |
213 // We keep track of the render view host we're dragging over. If it changes | 178 // We keep track of the render view host we're dragging over. If it changes |
214 // during a drag, we need to re-send the DragEnter message. WARNING: | 179 // during a drag, we need to re-send the DragEnter message. WARNING: |
215 // this pointer should never be dereferenced. We only use it for comparing | 180 // this pointer should never be dereferenced. We only use it for comparing |
216 // pointers. | 181 // pointers. |
217 void* current_rvh_for_drag_; | 182 void* current_rvh_for_drag_; |
218 | 183 |
219 bool overscroll_change_brightness_; | |
220 | |
221 // The overscroll gesture currently in progress. | 184 // The overscroll gesture currently in progress. |
222 OverscrollMode current_overscroll_gesture_; | 185 OverscrollMode current_overscroll_gesture_; |
223 | 186 |
224 // This is the completed overscroll gesture. This is used for the animation | 187 // This is the completed overscroll gesture. This is used for the animation |
225 // callback that happens in response to a completed overscroll gesture. | 188 // callback that happens in response to a completed overscroll gesture. |
226 OverscrollMode completed_overscroll_gesture_; | 189 OverscrollMode completed_overscroll_gesture_; |
227 | 190 |
228 // This manages the overlay window that shows the screenshot during a history | 191 // This manages the overlay window that shows the screenshot during a history |
229 // navigation triggered by the overscroll gesture. | 192 // navigation triggered by the overscroll gesture. |
230 scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_; | 193 scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_; |
231 | 194 |
232 scoped_ptr<ShadowLayerDelegate> overscroll_shadow_; | |
233 | |
234 scoped_ptr<TouchEditableImplAura> touch_editable_; | 195 scoped_ptr<TouchEditableImplAura> touch_editable_; |
235 scoped_ptr<GestureNavSimple> gesture_nav_simple_; | 196 scoped_ptr<GestureNavSimple> gesture_nav_simple_; |
236 | 197 |
237 // On Windows we can run into problems if resources get released within the | 198 // On Windows we can run into problems if resources get released within the |
238 // initialization phase while the content (and its dimensions) are not known. | 199 // initialization phase while the content (and its dimensions) are not known. |
239 bool is_or_was_visible_; | 200 bool is_or_was_visible_; |
240 | 201 |
241 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura); | 202 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura); |
242 }; | 203 }; |
243 | 204 |
244 } // namespace content | 205 } // namespace content |
245 | 206 |
246 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ | 207 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ |
OLD | NEW |