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 #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/utf_string_conversions.h" | 8 #include "base/utf_string_conversions.h" |
9 #include "content/browser/renderer_host/dip_util.h" | 9 #include "content/browser/renderer_host/dip_util.h" |
10 #include "content/browser/renderer_host/overscroll_controller.h" | 10 #include "content/browser/renderer_host/overscroll_controller.h" |
(...skipping 710 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
721 | 721 |
722 return ShouldNavigateForward(web_contents_->GetController(), | 722 return ShouldNavigateForward(web_contents_->GetController(), |
723 current_overscroll_gesture_) ? | 723 current_overscroll_gesture_) ? |
724 overscroll_window_.get() : GetContentNativeView(); | 724 overscroll_window_.get() : GetContentNativeView(); |
725 } | 725 } |
726 | 726 |
727 gfx::Vector2d WebContentsViewAura::GetTranslationForOverscroll(int delta_x, | 727 gfx::Vector2d WebContentsViewAura::GetTranslationForOverscroll(int delta_x, |
728 int delta_y) { | 728 int delta_y) { |
729 if (current_overscroll_gesture_ == OVERSCROLL_NORTH || | 729 if (current_overscroll_gesture_ == OVERSCROLL_NORTH || |
730 current_overscroll_gesture_ == OVERSCROLL_SOUTH) { | 730 current_overscroll_gesture_ == OVERSCROLL_SOUTH) { |
731 // Ignore vertical overscroll. | 731 // For vertical overscroll, always do a resisted drag. |
732 return gfx::Vector2d(); | 732 const float threshold = GetOverscrollConfig( |
| 733 OVERSCROLL_CONFIG_VERT_RESIST_AFTER); |
| 734 int scroll = GetResistedScrollAmount(abs(delta_y), |
| 735 static_cast<int>(threshold)); |
| 736 return gfx::Vector2d(0, delta_y < 0 ? -scroll : scroll); |
733 } | 737 } |
734 | 738 |
735 // For horizontal overscroll, scroll freely if a navigation is possible. Do a | 739 // For horizontal overscroll, scroll freely if a navigation is possible. Do a |
736 // resistive scroll otherwise. | 740 // resistive scroll otherwise. |
737 const NavigationControllerImpl& controller = web_contents_->GetController(); | 741 const NavigationControllerImpl& controller = web_contents_->GetController(); |
738 const gfx::Rect& bounds = GetViewBounds(); | 742 const gfx::Rect& bounds = GetViewBounds(); |
739 if (ShouldNavigateForward(controller, current_overscroll_gesture_)) | 743 if (ShouldNavigateForward(controller, current_overscroll_gesture_)) |
740 return gfx::Vector2d(std::max(-bounds.width(), delta_x), 0); | 744 return gfx::Vector2d(std::max(-bounds.width(), delta_x), 0); |
741 else if (ShouldNavigateBack(controller, current_overscroll_gesture_)) | 745 else if (ShouldNavigateBack(controller, current_overscroll_gesture_)) |
742 return gfx::Vector2d(std::min(bounds.width(), delta_x), 0); | 746 return gfx::Vector2d(std::min(bounds.width(), delta_x), 0); |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
834 RenderWidgetHostViewAura*>(view)); | 838 RenderWidgetHostViewAura*>(view)); |
835 } | 839 } |
836 | 840 |
837 view->Show(); | 841 view->Show(); |
838 | 842 |
839 // We listen to drag drop events in the newly created view's window. | 843 // We listen to drag drop events in the newly created view's window. |
840 aura::client::SetDragDropDelegate(view->GetNativeView(), this); | 844 aura::client::SetDragDropDelegate(view->GetNativeView(), this); |
841 | 845 |
842 RenderWidgetHostImpl* host_impl = | 846 RenderWidgetHostImpl* host_impl = |
843 RenderWidgetHostImpl::From(render_widget_host); | 847 RenderWidgetHostImpl::From(render_widget_host); |
844 if (host_impl->overscroll_controller() && | 848 if (host_impl->overscroll_controller() && web_contents_->GetDelegate() && |
845 (!web_contents_->GetDelegate() || | 849 web_contents_->GetDelegate()->CanOverscrollContent()) { |
846 web_contents_->GetDelegate()->CanOverscrollContent())) { | |
847 host_impl->overscroll_controller()->set_delegate(this); | 850 host_impl->overscroll_controller()->set_delegate(this); |
848 if (!navigation_overlay_.get()) | 851 if (!navigation_overlay_.get()) |
849 navigation_overlay_.reset(new OverscrollNavigationOverlay()); | 852 navigation_overlay_.reset(new OverscrollNavigationOverlay()); |
850 } | 853 } |
851 | 854 |
852 return view; | 855 return view; |
853 } | 856 } |
854 | 857 |
855 RenderWidgetHostView* WebContentsViewAura::CreateViewForPopupWidget( | 858 RenderWidgetHostView* WebContentsViewAura::CreateViewForPopupWidget( |
856 RenderWidgetHost* render_widget_host) { | 859 RenderWidgetHost* render_widget_host) { |
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1285 event.location(), | 1288 event.location(), |
1286 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1289 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1287 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1290 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1288 if (drag_dest_delegate_) | 1291 if (drag_dest_delegate_) |
1289 drag_dest_delegate_->OnDrop(); | 1292 drag_dest_delegate_->OnDrop(); |
1290 current_drop_data_.reset(); | 1293 current_drop_data_.reset(); |
1291 return current_drag_op_; | 1294 return current_drag_op_; |
1292 } | 1295 } |
1293 | 1296 |
1294 } // namespace content | 1297 } // namespace content |
OLD | NEW |