Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(114)

Side by Side Diff: content/browser/web_contents/web_contents_view_aura.h

Issue 895543005: Refactor GestureNavigation to eliminate code redundancy (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Brought back gesture cancellation by mouse and linted code. Created 5 years, 9 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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
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 74 // Changes the brightness of the layer depending on the amount of horizontal
98 // overscroll (|delta_x|, in pixels). 75 // overscroll (|delta_x|, in pixels).
99 void UpdateOverscrollWindowBrightness(float delta_x); 76 void UpdateOverscrollWindowBrightness(float delta_x);
100 77
101 void AttachTouchEditableToRenderView(); 78 void AttachTouchEditableToRenderView();
102 79
103 void OverscrollUpdateForWebContentsDelegate(float delta_y); 80 void OverscrollUpdateForWebContentsDelegate(float delta_y);
104 81
105 // Overridden from WebContentsView: 82 // Overridden from WebContentsView:
106 gfx::NativeView GetNativeView() const override; 83 gfx::NativeView GetNativeView() const override;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
144 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) override; 121 const base::Callback<void(ui::MouseEvent*)>& mouse_cb) override;
145 void HideDisambiguationPopup() override; 122 void HideDisambiguationPopup() override;
146 123
147 // Overridden from OverscrollControllerDelegate: 124 // Overridden from OverscrollControllerDelegate:
148 gfx::Rect GetVisibleBounds() const override; 125 gfx::Rect GetVisibleBounds() const override;
149 bool OnOverscrollUpdate(float delta_x, float delta_y) override; 126 bool OnOverscrollUpdate(float delta_x, float delta_y) override;
150 void OnOverscrollComplete(OverscrollMode overscroll_mode) override; 127 void OnOverscrollComplete(OverscrollMode overscroll_mode) override;
151 void OnOverscrollModeChange(OverscrollMode old_mode, 128 void OnOverscrollModeChange(OverscrollMode old_mode,
152 OverscrollMode new_mode) override; 129 OverscrollMode new_mode) override;
153 130
154 // Overridden from ui::ImplicitAnimationObserver:
155 void OnImplicitAnimationsCompleted() override;
156
157 // Overridden from aura::WindowDelegate: 131 // Overridden from aura::WindowDelegate:
158 gfx::Size GetMinimumSize() const override; 132 gfx::Size GetMinimumSize() const override;
159 gfx::Size GetMaximumSize() const override; 133 gfx::Size GetMaximumSize() const override;
160 void OnBoundsChanged(const gfx::Rect& old_bounds, 134 void OnBoundsChanged(const gfx::Rect& old_bounds,
161 const gfx::Rect& new_bounds) override; 135 const gfx::Rect& new_bounds) override;
162 ui::TextInputClient* GetFocusedTextInputClient() override; 136 ui::TextInputClient* GetFocusedTextInputClient() override;
163 gfx::NativeCursor GetCursor(const gfx::Point& point) override; 137 gfx::NativeCursor GetCursor(const gfx::Point& point) override;
164 int GetNonClientComponent(const gfx::Point& point) const override; 138 int GetNonClientComponent(const gfx::Point& point) const override;
165 bool ShouldDescendIntoChildForEventHandling( 139 bool ShouldDescendIntoChildForEventHandling(
166 aura::Window* child, 140 aura::Window* child,
(...skipping 19 matching lines...) Expand all
186 int OnPerformDrop(const ui::DropTargetEvent& event) override; 160 int OnPerformDrop(const ui::DropTargetEvent& event) override;
187 161
188 // Overridden from aura::WindowObserver: 162 // Overridden from aura::WindowObserver:
189 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override; 163 void OnWindowVisibilityChanged(aura::Window* window, bool visible) override;
190 164
191 // Update the web contents visiblity. 165 // Update the web contents visiblity.
192 void UpdateWebContentsVisibility(bool visible); 166 void UpdateWebContentsVisibility(bool visible);
193 167
194 scoped_ptr<aura::Window> window_; 168 scoped_ptr<aura::Window> window_;
195 169
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_; 170 scoped_ptr<WindowObserver> window_observer_;
201 171
202 // The WebContentsImpl whose contents we display. 172 // The WebContentsImpl whose contents we display.
203 WebContentsImpl* web_contents_; 173 WebContentsImpl* web_contents_;
204 174
205 scoped_ptr<WebContentsViewDelegate> delegate_; 175 scoped_ptr<WebContentsViewDelegate> delegate_;
206 176
207 blink::WebDragOperationsMask current_drag_op_; 177 blink::WebDragOperationsMask current_drag_op_;
208 178
209 scoped_ptr<DropData> current_drop_data_; 179 scoped_ptr<DropData> current_drop_data_;
210 180
211 WebDragDestDelegate* drag_dest_delegate_; 181 WebDragDestDelegate* drag_dest_delegate_;
212 182
213 // We keep track of the render view host we're dragging over. If it changes 183 // 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: 184 // 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 185 // this pointer should never be dereferenced. We only use it for comparing
216 // pointers. 186 // pointers.
217 void* current_rvh_for_drag_; 187 void* current_rvh_for_drag_;
218 188
219 bool overscroll_change_brightness_;
220
221 // The overscroll gesture currently in progress. 189 // The overscroll gesture currently in progress.
222 OverscrollMode current_overscroll_gesture_; 190 OverscrollMode current_overscroll_gesture_;
223 191
224 // This is the completed overscroll gesture. This is used for the animation 192 // This is the completed overscroll gesture. This is used for the animation
225 // callback that happens in response to a completed overscroll gesture. 193 // callback that happens in response to a completed overscroll gesture.
226 OverscrollMode completed_overscroll_gesture_; 194 OverscrollMode completed_overscroll_gesture_;
227 195
228 // This manages the overlay window that shows the screenshot during a history 196 // This manages the overlay window that shows the screenshot during a history
229 // navigation triggered by the overscroll gesture. 197 // navigation triggered by the overscroll gesture.
230 scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_; 198 scoped_ptr<OverscrollNavigationOverlay> navigation_overlay_;
231 199
232 scoped_ptr<ShadowLayerDelegate> overscroll_shadow_; 200 // Receives overscroll events and manages the overscroll animation.
mfomitchev 2015/03/26 15:36:01 Owned by navigation_overlay_
Nina 2015/03/27 17:52:36 Done.
201 OverscrollWindowAnimation* overscroll_window_animation_;
233 202
234 scoped_ptr<TouchEditableImplAura> touch_editable_; 203 scoped_ptr<TouchEditableImplAura> touch_editable_;
235 scoped_ptr<GestureNavSimple> gesture_nav_simple_; 204 scoped_ptr<GestureNavSimple> gesture_nav_simple_;
236 205
237 // On Windows we can run into problems if resources get released within the 206 // 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. 207 // initialization phase while the content (and its dimensions) are not known.
239 bool is_or_was_visible_; 208 bool is_or_was_visible_;
240 209
241 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura); 210 DISALLOW_COPY_AND_ASSIGN(WebContentsViewAura);
242 }; 211 };
243 212
244 } // namespace content 213 } // namespace content
245 214
246 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_ 215 #endif // CONTENT_BROWSER_WEB_CONTENTS_WEB_CONTENTS_VIEW_AURA_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698