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