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; |
| 31 class OverscrollWindowAnimation; |
32 class RenderWidgetHostImpl; | 32 class RenderWidgetHostImpl; |
33 class RenderWidgetHostViewAura; | 33 class RenderWidgetHostViewAura; |
34 class ShadowLayerDelegate; | 34 class ShadowLayerDelegate; |
35 class TouchEditableImplAura; | 35 class TouchEditableImplAura; |
36 class WebContentsViewDelegate; | 36 class WebContentsViewDelegate; |
37 class WebContentsImpl; | 37 class WebContentsImpl; |
38 class WebDragDestDelegate; | 38 class WebDragDestDelegate; |
39 | 39 |
40 class WebContentsViewAura | 40 class WebContentsViewAura |
41 : public WebContentsView, | 41 : public WebContentsView, |
42 public RenderViewHostDelegateView, | 42 public RenderViewHostDelegateView, |
43 public OverscrollControllerDelegate, | 43 public OverscrollControllerDelegate, |
44 public ui::ImplicitAnimationObserver, | |
45 public aura::WindowDelegate, | 44 public aura::WindowDelegate, |
46 public aura::client::DragDropDelegate, | 45 public aura::client::DragDropDelegate, |
47 public aura::WindowObserver { | 46 public aura::WindowObserver { |
48 public: | 47 public: |
49 WebContentsViewAura(WebContentsImpl* web_contents, | 48 WebContentsViewAura(WebContentsImpl* web_contents, |
50 WebContentsViewDelegate* delegate); | 49 WebContentsViewDelegate* delegate); |
51 | 50 |
52 CONTENT_EXPORT void SetTouchEditableForTest( | 51 CONTENT_EXPORT void SetTouchEditableForTest( |
53 TouchEditableImplAura* touch_editable); | 52 TouchEditableImplAura* touch_editable); |
54 | 53 |
55 private: | 54 private: |
56 class WindowObserver; | 55 class WindowObserver; |
57 | 56 |
58 ~WebContentsViewAura() override; | 57 ~WebContentsViewAura() override; |
59 | 58 |
60 void SizeChangedCommon(const gfx::Size& size); | 59 void SizeChangedCommon(const gfx::Size& size); |
61 | 60 |
62 void EndDrag(blink::WebDragOperationsMask ops); | 61 void EndDrag(blink::WebDragOperationsMask ops); |
63 | 62 |
64 void InstallOverscrollControllerDelegate(RenderWidgetHostViewAura* view); | 63 void InstallOverscrollControllerDelegate(RenderWidgetHostViewAura* view); |
65 | 64 |
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 | 65 // Sets up the content window in preparation for starting an overscroll |
71 // gesture. | 66 // gesture. |
72 void PrepareContentWindowForOverscroll(); | 67 void PrepareContentWindowForOverscroll(); |
73 | 68 |
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. | 69 // Completes the navigation in response to a completed overscroll gesture. |
80 // The navigation happens after an animation (either the overlay window | 70 // The navigation happens after an animation (either the overlay window |
81 // animates in, or the content window animates out). | 71 // animates in, or the content window animates out). |
82 void CompleteOverscrollNavigation(OverscrollMode mode); | 72 void CompleteOverscrollNavigation(OverscrollMode mode); |
83 | 73 |
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 | 74 // Returns the amount the animating window should be translated in response to |
90 // the overscroll gesture. | 75 // the overscroll gesture. |
91 gfx::Vector2dF GetTranslationForOverscroll(float delta_x, float delta_y); | 76 gfx::Vector2dF GetTranslationForOverscroll(float delta_x, float delta_y); |
92 | 77 |
93 // A window showing the screenshot is overlayed during a navigation triggered | 78 // A window showing the screenshot is overlayed during a navigation triggered |
94 // by overscroll. This function sets this up. | 79 // by overscroll. This function sets this up. |
95 void PrepareOverscrollNavigationOverlay(); | 80 void PrepareOverscrollNavigationOverlay(); |
96 | 81 |
97 // Changes the brightness of the layer depending on the amount of horizontal | 82 // Changes the brightness of the layer depending on the amount of horizontal |
98 // overscroll (|delta_x|, in pixels). | 83 // overscroll (|delta_x|, in pixels). |
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
144 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) override; | 129 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) override; |
145 void HideDisambiguationPopup() override; | 130 void HideDisambiguationPopup() override; |
146 | 131 |
147 // Overridden from OverscrollControllerDelegate: | 132 // Overridden from OverscrollControllerDelegate: |
148 gfx::Rect GetVisibleBounds() const override; | 133 gfx::Rect GetVisibleBounds() const override; |
149 bool OnOverscrollUpdate(float delta_x, float delta_y) override; | 134 bool OnOverscrollUpdate(float delta_x, float delta_y) override; |
150 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; | 135 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; |
151 void OnOverscrollModeChange(OverscrollMode old_mode, | 136 void OnOverscrollModeChange(OverscrollMode old_mode, |
152 OverscrollMode new_mode) override; | 137 OverscrollMode new_mode) override; |
153 | 138 |
154 // Overridden from ui::ImplicitAnimationObserver: | |
155 void OnImplicitAnimationsCompleted() override; | |
156 | |
157 // Overridden from aura::WindowDelegate: | 139 // Overridden from aura::WindowDelegate: |
158 gfx::Size GetMinimumSize() const override; | 140 gfx::Size GetMinimumSize() const override; |
159 gfx::Size GetMaximumSize() const override; | 141 gfx::Size GetMaximumSize() const override; |
160 void OnBoundsChanged(const gfx::Rect& old_bounds, | 142 void OnBoundsChanged(const gfx::Rect& old_bounds, |
161 const gfx::Rect& new_bounds) override; | 143 const gfx::Rect& new_bounds) override; |
162 ui::TextInputClient* GetFocusedTextInputClient() override; | 144 ui::TextInputClient* GetFocusedTextInputClient() override; |
163 gfx::NativeCursor GetCursor(const gfx::Point& point) override; | 145 gfx::NativeCursor GetCursor(const gfx::Point& point) override; |
164 int GetNonClientComponent(const gfx::Point& point) const override; | 146 int GetNonClientComponent(const gfx::Point& point) const override; |
165 bool ShouldDescendIntoChildForEventHandling( | 147 bool ShouldDescendIntoChildForEventHandling( |
166 aura::Window* child, | 148 aura::Window* child, |
(...skipping 19 matching lines...) Expand all Loading... |
186 int OnPerformDrop(const ui::DropTargetEvent& event) override; | 168 int OnPerformDrop(const ui::DropTargetEvent& event) override; |
187 | 169 |
188 // Overridden from aura::WindowObserver: | 170 // Overridden from aura::WindowObserver: |
189 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; | 171 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; |
190 | 172 |
191 // Update the web contents visiblity. | 173 // Update the web contents visiblity. |
192 void UpdateWebContentsVisibility(bool visible); | 174 void UpdateWebContentsVisibility(bool visible); |
193 | 175 |
194 scoped_ptr<aura::Window> window_; | 176 scoped_ptr<aura::Window> window_; |
195 | 177 |
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_; | 178 scoped_ptr<WindowObserver> window_observer_; |
201 | 179 |
202 // The WebContentsImpl whose contents we display. | 180 // The WebContentsImpl whose contents we display. |
203 WebContentsImpl* web_contents_; | 181 WebContentsImpl* web_contents_; |
204 | 182 |
205 scoped_ptr<WebContentsViewDelegate> delegate_; | 183 scoped_ptr<WebContentsViewDelegate> delegate_; |
206 | 184 |
207 blink::WebDragOperationsMask current_drag_op_; | 185 blink::WebDragOperationsMask current_drag_op_; |
208 | 186 |
209 scoped_ptr<DropData> current_drop_data_; | 187 scoped_ptr<DropData> current_drop_data_; |
210 | 188 |
211 WebDragDestDelegate* drag_dest_delegate_; | 189 WebDragDestDelegate* drag_dest_delegate_; |
212 | 190 |
213 // We keep track of the render view host we're dragging over. If it changes | 191 // 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: | 192 // 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 | 193 // this pointer should never be dereferenced. We only use it for comparing |
216 // pointers. | 194 // pointers. |
217 void* current_rvh_for_drag_; | 195 void* current_rvh_for_drag_; |
218 | 196 |
219 bool overscroll_change_brightness_; | |
220 | |
221 // The overscroll gesture currently in progress. | 197 // The overscroll gesture currently in progress. |
222 OverscrollMode current_overscroll_gesture_; | 198 OverscrollMode current_overscroll_gesture_; |
223 | 199 |
224 // This is the completed overscroll gesture. This is used for the animation | 200 // This is the completed overscroll gesture. This is used for the animation |
225 // callback that happens in response to a completed overscroll gesture. | 201 // callback that happens in response to a completed overscroll gesture. |
226 OverscrollMode completed_overscroll_gesture_; | 202 OverscrollMode completed_overscroll_gesture_; |
227 | 203 |
228 // This manages the overlay window that shows the screenshot during a history | 204 // This manages the overlay window that shows the screenshot during a history |
229 // navigation triggered by the overscroll gesture. | 205 // navigation triggered by the overscroll gesture. |
230 scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_; | 206 scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_; |
231 | 207 |
232 scoped_ptr<ShadowLayerDelegate> overscroll_shadow_; | |
233 | |
234 scoped_ptr<TouchEditableImplAura> touch_editable_; | 208 scoped_ptr<TouchEditableImplAura> touch_editable_; |
235 scoped_ptr<GestureNavSimple> gesture_nav_simple_; | 209 scoped_ptr<GestureNavSimple> gesture_nav_simple_; |
236 | 210 |
237 // On Windows we can run into problems if resources get released within the | 211 // 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. | 212 // initialization phase while the content (and its dimensions) are not known. |
239 bool is_or_was_visible_; | 213 bool is_or_was_visible_; |
240 | 214 |
| 215 // The animation controller for overscroll navigation. |
| 216 scoped_ptr<OverscrollWindowAnimation> overscroll_window_animation_; |
| 217 |
241 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura); | 218 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura); |
242 }; | 219 }; |
243 | 220 |
244 } // namespace content | 221 } // namespace content |
245 | 222 |
246 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ | 223 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ |
OLD | NEW |