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

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

Issue 698253004: Reland: Implement Aura side of unified touch text selection for contents (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Cleanup - ready for review Created 5 years, 10 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 #include "content/browser/web_contents/web_contents_view_aura.h" 5 #include "content/browser/web_contents/web_contents_view_aura.h"
6 6
7 #include "base/auto_reset.h" 7 #include "base/auto_reset.h"
8 #include "base/command_line.h" 8 #include "base/command_line.h"
9 #include "base/files/file_util.h" 9 #include "base/files/file_util.h"
10 #include "base/metrics/histogram.h" 10 #include "base/metrics/histogram.h"
11 #include "base/strings/utf_string_conversions.h" 11 #include "base/strings/utf_string_conversions.h"
12 #include "content/browser/browser_plugin/browser_plugin_guest.h" 12 #include "content/browser/browser_plugin/browser_plugin_guest.h"
13 #include "content/browser/download/drag_download_util.h" 13 #include "content/browser/download/drag_download_util.h"
14 #include "content/browser/frame_host/interstitial_page_impl.h" 14 #include "content/browser/frame_host/interstitial_page_impl.h"
15 #include "content/browser/frame_host/navigation_entry_impl.h" 15 #include "content/browser/frame_host/navigation_entry_impl.h"
16 #include "content/browser/renderer_host/dip_util.h" 16 #include "content/browser/renderer_host/dip_util.h"
17 #include "content/browser/renderer_host/overscroll_controller.h" 17 #include "content/browser/renderer_host/overscroll_controller.h"
18 #include "content/browser/renderer_host/render_view_host_factory.h" 18 #include "content/browser/renderer_host/render_view_host_factory.h"
19 #include "content/browser/renderer_host/render_view_host_impl.h" 19 #include "content/browser/renderer_host/render_view_host_impl.h"
20 #include "content/browser/renderer_host/render_widget_host_impl.h" 20 #include "content/browser/renderer_host/render_widget_host_impl.h"
21 #include "content/browser/renderer_host/render_widget_host_view_aura.h" 21 #include "content/browser/renderer_host/render_widget_host_view_aura.h"
22 #include "content/browser/renderer_host/web_input_event_aura.h" 22 #include "content/browser/renderer_host/web_input_event_aura.h"
23 #include "content/browser/web_contents/aura/gesture_nav_simple.h" 23 #include "content/browser/web_contents/aura/gesture_nav_simple.h"
24 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h" 24 #include "content/browser/web_contents/aura/overscroll_navigation_overlay.h"
25 #include "content/browser/web_contents/aura/shadow_layer_delegate.h" 25 #include "content/browser/web_contents/aura/shadow_layer_delegate.h"
26 #include "content/browser/web_contents/aura/window_slider.h" 26 #include "content/browser/web_contents/aura/window_slider.h"
27 #include "content/browser/web_contents/touch_editable_impl_aura.h" 27 #include "content/browser/web_contents/touch_selection_controller_aura_client_im pl.h"
28 #include "content/browser/web_contents/web_contents_impl.h" 28 #include "content/browser/web_contents/web_contents_impl.h"
29 #include "content/public/browser/content_browser_client.h" 29 #include "content/public/browser/content_browser_client.h"
30 #include "content/public/browser/notification_observer.h" 30 #include "content/public/browser/notification_observer.h"
31 #include "content/public/browser/notification_registrar.h" 31 #include "content/public/browser/notification_registrar.h"
32 #include "content/public/browser/notification_source.h" 32 #include "content/public/browser/notification_source.h"
33 #include "content/public/browser/notification_types.h" 33 #include "content/public/browser/notification_types.h"
34 #include "content/public/browser/overscroll_configuration.h" 34 #include "content/public/browser/overscroll_configuration.h"
35 #include "content/public/browser/render_view_host.h" 35 #include "content/public/browser/render_view_host.h"
36 #include "content/public/browser/render_widget_host.h" 36 #include "content/public/browser/render_widget_host.h"
37 #include "content/public/browser/render_widget_host_view.h" 37 #include "content/public/browser/render_widget_host_view.h"
(...skipping 24 matching lines...) Expand all
62 #include "ui/base/hit_test.h" 62 #include "ui/base/hit_test.h"
63 #include "ui/compositor/layer.h" 63 #include "ui/compositor/layer.h"
64 #include "ui/compositor/scoped_layer_animation_settings.h" 64 #include "ui/compositor/scoped_layer_animation_settings.h"
65 #include "ui/events/event.h" 65 #include "ui/events/event.h"
66 #include "ui/events/event_utils.h" 66 #include "ui/events/event_utils.h"
67 #include "ui/gfx/canvas.h" 67 #include "ui/gfx/canvas.h"
68 #include "ui/gfx/image/image.h" 68 #include "ui/gfx/image/image.h"
69 #include "ui/gfx/image/image_png_rep.h" 69 #include "ui/gfx/image/image_png_rep.h"
70 #include "ui/gfx/image/image_skia.h" 70 #include "ui/gfx/image/image_skia.h"
71 #include "ui/gfx/screen.h" 71 #include "ui/gfx/screen.h"
72 #include "ui/touch_selection/touch_selection_controller_aura.h"
72 #include "ui/wm/public/drag_drop_client.h" 73 #include "ui/wm/public/drag_drop_client.h"
73 #include "ui/wm/public/drag_drop_delegate.h" 74 #include "ui/wm/public/drag_drop_delegate.h"
74 75
75 namespace content { 76 namespace content {
76 WebContentsView* CreateWebContentsView( 77 WebContentsView* CreateWebContentsView(
77 WebContentsImpl* web_contents, 78 WebContentsImpl* web_contents,
78 WebContentsViewDelegate* delegate, 79 WebContentsViewDelegate* delegate,
79 RenderViewHostDelegateView** render_view_host_delegate_view) { 80 RenderViewHostDelegateView** render_view_host_delegate_view) {
80 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate); 81 WebContentsViewAura* rv = new WebContentsViewAura(web_contents, delegate);
81 *render_view_host_delegate_view = rv; 82 *render_view_host_delegate_view = rv;
(...skipping 530 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 } 613 }
613 #endif 614 #endif
614 } 615 }
615 } 616 }
616 617
617 void OnWindowBoundsChanged(aura::Window* window, 618 void OnWindowBoundsChanged(aura::Window* window,
618 const gfx::Rect& old_bounds, 619 const gfx::Rect& old_bounds,
619 const gfx::Rect& new_bounds) override { 620 const gfx::Rect& new_bounds) override {
620 if (window == host_window_ || window == view_->window_) { 621 if (window == host_window_ || window == view_->window_) {
621 SendScreenRects(); 622 SendScreenRects();
622 if (view_->touch_editable_) 623 if (old_bounds.origin() != new_bounds.origin()) {
623 view_->touch_editable_->UpdateEditingController(); 624 ui::TouchSelectionControllerAura* selection_controller =
625 view_->GetSelectionController();
626 if (selection_controller)
627 selection_controller->OnWindowMoved();
628 }
624 #if defined(OS_WIN) 629 #if defined(OS_WIN)
625 } else { 630 } else {
626 UpdateConstrainedWindows(NULL); 631 UpdateConstrainedWindows(NULL);
627 #endif 632 #endif
628 } 633 }
629 } 634 }
630 635
631 void OnWindowDestroying(aura::Window* window) override { 636 void OnWindowDestroying(aura::Window* window) override {
632 if (window == host_window_) { 637 if (window == host_window_) {
633 host_window_->RemoveObserver(this); 638 host_window_->RemoveObserver(this);
(...skipping 98 matching lines...) Expand 10 before | Expand all | Expand 10 after
732 WebContentsImpl* web_contents, 737 WebContentsImpl* web_contents,
733 WebContentsViewDelegate* delegate) 738 WebContentsViewDelegate* delegate)
734 : web_contents_(web_contents), 739 : web_contents_(web_contents),
735 delegate_(delegate), 740 delegate_(delegate),
736 current_drag_op_(blink::WebDragOperationNone), 741 current_drag_op_(blink::WebDragOperationNone),
737 drag_dest_delegate_(NULL), 742 drag_dest_delegate_(NULL),
738 current_rvh_for_drag_(NULL), 743 current_rvh_for_drag_(NULL),
739 overscroll_change_brightness_(false), 744 overscroll_change_brightness_(false),
740 current_overscroll_gesture_(OVERSCROLL_NONE), 745 current_overscroll_gesture_(OVERSCROLL_NONE),
741 completed_overscroll_gesture_(OVERSCROLL_NONE), 746 completed_overscroll_gesture_(OVERSCROLL_NONE),
742 touch_editable_(TouchEditableImplAura::Create()),
743 is_or_was_visible_(false) { 747 is_or_was_visible_(false) {
744 } 748 }
745 749
746 //////////////////////////////////////////////////////////////////////////////// 750 ////////////////////////////////////////////////////////////////////////////////
747 // WebContentsViewAura, private: 751 // WebContentsViewAura, private:
748 752
749 WebContentsViewAura::~WebContentsViewAura() { 753 WebContentsViewAura::~WebContentsViewAura() {
750 if (!window_) 754 if (!window_)
751 return; 755 return;
752 756
753 window_observer_.reset(); 757 window_observer_.reset();
754 window_->RemoveObserver(this); 758 window_->RemoveObserver(this);
755 759
756 // Window needs a valid delegate during its destructor, so we explicitly 760 // Window needs a valid delegate during its destructor, so we explicitly
757 // delete it here. 761 // delete it here.
758 window_.reset(); 762 window_.reset();
759 } 763 }
760 764
761 void WebContentsViewAura::SetTouchEditableForTest(
762 TouchEditableImplAura* touch_editable) {
763 touch_editable_.reset(touch_editable);
764 AttachTouchEditableToRenderView();
765 }
766
767 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) { 765 void WebContentsViewAura::SizeChangedCommon(const gfx::Size& size) {
768 if (web_contents_->GetInterstitialPage()) 766 if (web_contents_->GetInterstitialPage())
769 web_contents_->GetInterstitialPage()->SetSize(size); 767 web_contents_->GetInterstitialPage()->SetSize(size);
770 RenderWidgetHostView* rwhv = 768 RenderWidgetHostView* rwhv =
771 web_contents_->GetRenderWidgetHostView(); 769 web_contents_->GetRenderWidgetHostView();
772 if (rwhv) 770 if (rwhv)
773 rwhv->SetSize(size); 771 rwhv->SetSize(size);
774 } 772 }
775 773
776 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) { 774 void WebContentsViewAura::EndDrag(blink::WebDragOperationsMask ops) {
(...skipping 193 matching lines...) Expand 10 before | Expand all | Expand 10 after
970 ratio = 1.f - ratio; 968 ratio = 1.f - ratio;
971 float brightness = current_overscroll_gesture_ == OVERSCROLL_WEST ? 969 float brightness = current_overscroll_gesture_ == OVERSCROLL_WEST ?
972 kBrightnessMin + ratio * (kBrightnessMax - kBrightnessMin) : 970 kBrightnessMin + ratio * (kBrightnessMax - kBrightnessMin) :
973 kBrightnessMax - ratio * (kBrightnessMax - kBrightnessMin); 971 kBrightnessMax - ratio * (kBrightnessMax - kBrightnessMin);
974 brightness = std::max(kBrightnessMin, brightness); 972 brightness = std::max(kBrightnessMin, brightness);
975 brightness = std::min(kBrightnessMax, brightness); 973 brightness = std::min(kBrightnessMax, brightness);
976 aura::Window* window = GetWindowToAnimateForOverscroll(); 974 aura::Window* window = GetWindowToAnimateForOverscroll();
977 window->layer()->SetLayerBrightness(brightness); 975 window->layer()->SetLayerBrightness(brightness);
978 } 976 }
979 977
980 void WebContentsViewAura::AttachTouchEditableToRenderView() {
981 if (!touch_editable_)
982 return;
983 RenderWidgetHostViewAura* rwhva = ToRenderWidgetHostViewAura(
984 web_contents_->GetRenderWidgetHostView());
985 touch_editable_->AttachToView(rwhva);
986 }
987
988 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate( 978 void WebContentsViewAura::OverscrollUpdateForWebContentsDelegate(
989 float delta_y) { 979 float delta_y) {
990 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled()) 980 if (web_contents_->GetDelegate() && IsScrollEndEffectEnabled())
991 web_contents_->GetDelegate()->OverscrollUpdate(delta_y); 981 web_contents_->GetDelegate()->OverscrollUpdate(delta_y);
992 } 982 }
993 983
984 ui::TouchSelectionControllerAura*
985 WebContentsViewAura::GetSelectionController() {
986 RenderWidgetHostViewAura* view =
987 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView());
988 return view ? view->selection_controller() : nullptr;
989 }
990
994 //////////////////////////////////////////////////////////////////////////////// 991 ////////////////////////////////////////////////////////////////////////////////
995 // WebContentsViewAura, WebContentsView implementation: 992 // WebContentsViewAura, WebContentsView implementation:
996 993
997 gfx::NativeView WebContentsViewAura::GetNativeView() const { 994 gfx::NativeView WebContentsViewAura::GetNativeView() const {
998 return window_.get(); 995 return window_.get();
999 } 996 }
1000 997
1001 gfx::NativeView WebContentsViewAura::GetContentNativeView() const { 998 gfx::NativeView WebContentsViewAura::GetContentNativeView() const {
1002 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView(); 999 RenderWidgetHostView* rwhv = web_contents_->GetRenderWidgetHostView();
1003 return rwhv ? rwhv->GetNativeView() : NULL; 1000 return rwhv ? rwhv->GetNativeView() : NULL;
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after
1123 // this actually is happening (and somebody isn't accidentally creating the 1120 // this actually is happening (and somebody isn't accidentally creating the
1124 // view twice), we check for the RVH Factory, which will be set when we're 1121 // view twice), we check for the RVH Factory, which will be set when we're
1125 // making special ones (which go along with the special views). 1122 // making special ones (which go along with the special views).
1126 DCHECK(RenderViewHostFactory::has_factory()); 1123 DCHECK(RenderViewHostFactory::has_factory());
1127 return static_cast<RenderWidgetHostViewBase*>( 1124 return static_cast<RenderWidgetHostViewBase*>(
1128 render_widget_host->GetView()); 1125 render_widget_host->GetView());
1129 } 1126 }
1130 1127
1131 RenderWidgetHostViewAura* view = 1128 RenderWidgetHostViewAura* view =
1132 new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack); 1129 new RenderWidgetHostViewAura(render_widget_host, is_guest_view_hack);
1130 TouchSelectionControllerAuraClientImpl* selection_controller_client =
1131 new TouchSelectionControllerAuraClientImpl(view);
1132 view->InitSelectionController(selection_controller_client);
1133
1133 view->InitAsChild(NULL); 1134 view->InitAsChild(NULL);
1134 GetNativeView()->AddChild(view->GetNativeView()); 1135 GetNativeView()->AddChild(view->GetNativeView());
1135 1136
1136 if (navigation_overlay_.get() && navigation_overlay_->has_window()) { 1137 if (navigation_overlay_.get() && navigation_overlay_->has_window()) {
1137 navigation_overlay_->StartObserving(); 1138 navigation_overlay_->StartObserving();
1138 } 1139 }
1139 1140
1140 RenderWidgetHostImpl* host_impl = 1141 RenderWidgetHostImpl* host_impl =
1141 RenderWidgetHostImpl::From(render_widget_host); 1142 RenderWidgetHostImpl::From(render_widget_host);
1142 1143
1143 if (!host_impl->is_hidden()) 1144 if (!host_impl->is_hidden())
1144 view->Show(); 1145 view->Show();
1145 1146
1146 // We listen to drag drop events in the newly created view's window. 1147 // We listen to drag drop events in the newly created view's window.
1147 aura::client::SetDragDropDelegate(view->GetNativeView(), this); 1148 aura::client::SetDragDropDelegate(view->GetNativeView(), this);
1148 1149
1149 if (view->overscroll_controller() && 1150 if (view->overscroll_controller() &&
1150 (!web_contents_->GetDelegate() || 1151 (!web_contents_->GetDelegate() ||
1151 web_contents_->GetDelegate()->CanOverscrollContent())) { 1152 web_contents_->GetDelegate()->CanOverscrollContent())) {
1152 InstallOverscrollControllerDelegate(view); 1153 InstallOverscrollControllerDelegate(view);
1153 } 1154 }
1154 1155
1155 AttachTouchEditableToRenderView();
1156 return view; 1156 return view;
1157 } 1157 }
1158 1158
1159 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget( 1159 RenderWidgetHostViewBase* WebContentsViewAura::CreateViewForPopupWidget(
1160 RenderWidgetHost* render_widget_host) { 1160 RenderWidgetHost* render_widget_host) {
1161 return new RenderWidgetHostViewAura(render_widget_host, false); 1161 return new RenderWidgetHostViewAura(render_widget_host, false);
1162 } 1162 }
1163 1163
1164 void WebContentsViewAura::SetPageTitle(const base::string16& title) { 1164 void WebContentsViewAura::SetPageTitle(const base::string16& title) {
1165 window_->SetTitle(title); 1165 window_->SetTitle(title);
1166 } 1166 }
1167 1167
1168 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) { 1168 void WebContentsViewAura::RenderViewCreated(RenderViewHost* host) {
1169 } 1169 }
1170 1170
1171 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) { 1171 void WebContentsViewAura::RenderViewSwappedIn(RenderViewHost* host) {
1172 if (navigation_overlay_.get() && navigation_overlay_->has_window()) 1172 if (navigation_overlay_.get() && navigation_overlay_->has_window())
1173 navigation_overlay_->StartObserving(); 1173 navigation_overlay_->StartObserving();
1174 AttachTouchEditableToRenderView();
1175 } 1174 }
1176 1175
1177 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) { 1176 void WebContentsViewAura::SetOverscrollControllerEnabled(bool enabled) {
1178 RenderWidgetHostViewAura* view = 1177 RenderWidgetHostViewAura* view =
1179 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView()); 1178 ToRenderWidgetHostViewAura(web_contents_->GetRenderWidgetHostView());
1180 if (view) { 1179 if (view) {
1181 view->SetOverscrollControllerEnabled(enabled); 1180 view->SetOverscrollControllerEnabled(enabled);
1182 if (enabled) 1181 if (enabled)
1183 InstallOverscrollControllerDelegate(view); 1182 InstallOverscrollControllerDelegate(view);
1184 } 1183 }
1185 1184
1186 if (!enabled) 1185 if (!enabled)
1187 navigation_overlay_.reset(); 1186 navigation_overlay_.reset();
1188 else if (!navigation_overlay_) 1187 else if (!navigation_overlay_)
1189 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_)); 1188 navigation_overlay_.reset(new OverscrollNavigationOverlay(web_contents_));
1190 } 1189 }
1191 1190
1192 //////////////////////////////////////////////////////////////////////////////// 1191 ////////////////////////////////////////////////////////////////////////////////
1193 // WebContentsViewAura, RenderViewHostDelegateView implementation: 1192 // WebContentsViewAura, RenderViewHostDelegateView implementation:
1194 1193
1195 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host, 1194 void WebContentsViewAura::ShowContextMenu(RenderFrameHost* render_frame_host,
1196 const ContextMenuParams& params) { 1195 const ContextMenuParams& params) {
1197 if (touch_editable_) { 1196 ui::TouchSelectionControllerAura* selection_controller =
1198 touch_editable_->EndTouchEditing(false); 1197 GetSelectionController();
1199 } 1198 if (selection_controller)
1199 selection_controller->HideAndDisallowShowingAutomatically();
1200 if (delegate_) { 1200 if (delegate_) {
1201 delegate_->ShowContextMenu(render_frame_host, params); 1201 delegate_->ShowContextMenu(render_frame_host, params);
1202 // WARNING: we may have been deleted during the call to ShowContextMenu(). 1202 // WARNING: we may have been deleted during the call to ShowContextMenu().
1203 } 1203 }
1204 } 1204 }
1205 1205
1206 void WebContentsViewAura::StartDragging( 1206 void WebContentsViewAura::StartDragging(
1207 const DropData& drop_data, 1207 const DropData& drop_data,
1208 blink::WebDragOperationsMask operations, 1208 blink::WebDragOperationsMask operations,
1209 const gfx::ImageSkia& image, 1209 const gfx::ImageSkia& image,
1210 const gfx::Vector2d& image_offset, 1210 const gfx::Vector2d& image_offset,
1211 const DragEventSourceInfo& event_info) { 1211 const DragEventSourceInfo& event_info) {
1212 aura::Window* root_window = GetNativeView()->GetRootWindow(); 1212 aura::Window* root_window = GetNativeView()->GetRootWindow();
1213 if (!aura::client::GetDragDropClient(root_window)) { 1213 if (!aura::client::GetDragDropClient(root_window)) {
1214 web_contents_->SystemDragEnded(); 1214 web_contents_->SystemDragEnded();
1215 return; 1215 return;
1216 } 1216 }
1217 1217
1218 if (touch_editable_) 1218 ui::TouchSelectionControllerAura* selection_controller =
1219 touch_editable_->EndTouchEditing(false); 1219 GetSelectionController();
1220 1220 if (selection_controller)
1221 selection_controller->HideAndDisallowShowingAutomatically();
1221 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider(); 1222 ui::OSExchangeData::Provider* provider = ui::OSExchangeData::CreateProvider();
1222 PrepareDragData(drop_data, provider, web_contents_); 1223 PrepareDragData(drop_data, provider, web_contents_);
1223 1224
1224 ui::OSExchangeData data(provider); // takes ownership of |provider|. 1225 ui::OSExchangeData data(provider); // takes ownership of |provider|.
1225 1226
1226 if (!image.isNull()) 1227 if (!image.isNull())
1227 drag_utils::SetDragImageOnDataObject(image, image_offset, &data); 1228 drag_utils::SetDragImageOnDataObject(image, image_offset, &data);
1228 1229
1229 scoped_ptr<WebDragSourceAura> drag_source( 1230 scoped_ptr<WebDragSourceAura> drag_source(
1230 new WebDragSourceAura(GetNativeView(), web_contents_)); 1231 new WebDragSourceAura(GetNativeView(), web_contents_));
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
1349 } 1350 }
1350 1351
1351 void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode, 1352 void WebContentsViewAura::OnOverscrollModeChange(OverscrollMode old_mode,
1352 OverscrollMode new_mode) { 1353 OverscrollMode new_mode) {
1353 // Reset any in-progress overscroll animation first. 1354 // Reset any in-progress overscroll animation first.
1354 ResetOverscrollTransform(); 1355 ResetOverscrollTransform();
1355 1356
1356 if (old_mode == OVERSCROLL_NORTH || old_mode == OVERSCROLL_SOUTH) 1357 if (old_mode == OVERSCROLL_NORTH || old_mode == OVERSCROLL_SOUTH)
1357 OverscrollUpdateForWebContentsDelegate(0); 1358 OverscrollUpdateForWebContentsDelegate(0);
1358 1359
1359 if (new_mode != OVERSCROLL_NONE && touch_editable_) 1360 if (new_mode != OVERSCROLL_NONE) {
1360 touch_editable_->OverscrollStarted(); 1361 ui::TouchSelectionControllerAura* selection_controller =
1361 1362 GetSelectionController();
1363 if (selection_controller)
1364 selection_controller->OnOverscrollStarted();
1365 }
1362 if (new_mode == OVERSCROLL_NONE || 1366 if (new_mode == OVERSCROLL_NONE ||
1363 !GetContentNativeView() || 1367 !GetContentNativeView() ||
1364 ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) && 1368 ((new_mode == OVERSCROLL_EAST || new_mode == OVERSCROLL_WEST) &&
1365 navigation_overlay_.get() && navigation_overlay_->has_window())) { 1369 navigation_overlay_.get() && navigation_overlay_->has_window())) {
1366 current_overscroll_gesture_ = OVERSCROLL_NONE; 1370 current_overscroll_gesture_ = OVERSCROLL_NONE;
1367 } else { 1371 } else {
1368 aura::Window* target = GetWindowToAnimateForOverscroll(); 1372 aura::Window* target = GetWindowToAnimateForOverscroll();
1369 if (target) { 1373 if (target) {
1370 StopObservingImplicitAnimations(); 1374 StopObservingImplicitAnimations();
1371 target->layer()->GetAnimator()->AbortAllAnimations(); 1375 target->layer()->GetAnimator()->AbortAllAnimations();
(...skipping 20 matching lines...) Expand all
1392 1396
1393 if (ShouldNavigateForward(web_contents_->GetController(), 1397 if (ShouldNavigateForward(web_contents_->GetController(),
1394 completed_overscroll_gesture_)) { 1398 completed_overscroll_gesture_)) {
1395 web_contents_->GetController().GoForward(); 1399 web_contents_->GetController().GoForward();
1396 PrepareOverscrollNavigationOverlay(); 1400 PrepareOverscrollNavigationOverlay();
1397 } else if (ShouldNavigateBack(web_contents_->GetController(), 1401 } else if (ShouldNavigateBack(web_contents_->GetController(),
1398 completed_overscroll_gesture_)) { 1402 completed_overscroll_gesture_)) {
1399 web_contents_->GetController().GoBack(); 1403 web_contents_->GetController().GoBack();
1400 PrepareOverscrollNavigationOverlay(); 1404 PrepareOverscrollNavigationOverlay();
1401 } else { 1405 } else {
1402 if (touch_editable_) 1406 ui::TouchSelectionControllerAura* selection_controller =
1403 touch_editable_->OverscrollCompleted(); 1407 GetSelectionController();
1408 if (selection_controller)
1409 selection_controller->OnOverscrollCompleted();
1404 } 1410 }
1405 1411
1406 aura::Window* content = GetContentNativeView(); 1412 aura::Window* content = GetContentNativeView();
1407 if (content) { 1413 if (content) {
1408 content->SetTransform(gfx::Transform()); 1414 content->SetTransform(gfx::Transform());
1409 content->layer()->SetLayerBrightness(0.f); 1415 content->layer()->SetLayerBrightness(0.f);
1410 } 1416 }
1411 current_overscroll_gesture_ = OVERSCROLL_NONE; 1417 current_overscroll_gesture_ = OVERSCROLL_NONE;
1412 completed_overscroll_gesture_ = OVERSCROLL_NONE; 1418 completed_overscroll_gesture_ = OVERSCROLL_NONE;
1413 overscroll_window_.reset(); 1419 overscroll_window_.reset();
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after
1645 if (visible) { 1651 if (visible) {
1646 if (!web_contents_->should_normally_be_visible()) 1652 if (!web_contents_->should_normally_be_visible())
1647 web_contents_->WasShown(); 1653 web_contents_->WasShown();
1648 } else { 1654 } else {
1649 if (web_contents_->should_normally_be_visible()) 1655 if (web_contents_->should_normally_be_visible())
1650 web_contents_->WasHidden(); 1656 web_contents_->WasHidden();
1651 } 1657 }
1652 } 1658 }
1653 1659
1654 } // namespace content 1660 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698