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 698 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
709 web_contents_->GetController().CanGoForward()) { | 709 web_contents_->GetController().CanGoForward()) { |
710 return overscroll_window_.get(); | 710 return overscroll_window_.get(); |
711 } | 711 } |
712 return GetContentNativeView(); | 712 return GetContentNativeView(); |
713 } | 713 } |
714 | 714 |
715 gfx::Vector2d WebContentsViewAura::GetTranslationForOverscroll(int delta_x, | 715 gfx::Vector2d WebContentsViewAura::GetTranslationForOverscroll(int delta_x, |
716 int delta_y) { | 716 int delta_y) { |
717 if (current_overscroll_gesture_ == OVERSCROLL_NORTH || | 717 if (current_overscroll_gesture_ == OVERSCROLL_NORTH || |
718 current_overscroll_gesture_ == OVERSCROLL_SOUTH) { | 718 current_overscroll_gesture_ == OVERSCROLL_SOUTH) { |
719 // For vertical overscroll, always do a resisted drag. | 719 // Ignore vertical overscroll. |
720 const float threshold = GetOverscrollConfig( | 720 return gfx::Vector2d(); |
721 OVERSCROLL_CONFIG_VERT_RESIST_AFTER); | |
722 int scroll = GetResistedScrollAmount(abs(delta_y), | |
723 static_cast<int>(threshold)); | |
724 return gfx::Vector2d(0, delta_y < 0 ? -scroll : scroll); | |
725 } | 721 } |
726 | 722 |
727 // For horizontal overscroll, scroll freely if a navigation is possible. Do a | 723 // For horizontal overscroll, scroll freely if a navigation is possible. Do a |
728 // resistive scroll otherwise. | 724 // resistive scroll otherwise. |
729 const NavigationControllerImpl& controller = web_contents_->GetController(); | 725 const NavigationControllerImpl& controller = web_contents_->GetController(); |
730 const gfx::Rect& bounds = GetViewBounds(); | 726 const gfx::Rect& bounds = GetViewBounds(); |
731 if (current_overscroll_gesture_ == OVERSCROLL_WEST) { | 727 if (current_overscroll_gesture_ == OVERSCROLL_WEST) { |
732 if (controller.CanGoForward()) | 728 if (controller.CanGoForward()) |
733 return gfx::Vector2d(std::max(-bounds.width(), delta_x), 0); | 729 return gfx::Vector2d(std::max(-bounds.width(), delta_x), 0); |
734 } else if (current_overscroll_gesture_ == OVERSCROLL_EAST) { | 730 } else if (current_overscroll_gesture_ == OVERSCROLL_EAST) { |
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
823 RenderWidgetHostViewAura*>(view)); | 819 RenderWidgetHostViewAura*>(view)); |
824 } | 820 } |
825 | 821 |
826 view->Show(); | 822 view->Show(); |
827 | 823 |
828 // We listen to drag drop events in the newly created view's window. | 824 // We listen to drag drop events in the newly created view's window. |
829 aura::client::SetDragDropDelegate(view->GetNativeView(), this); | 825 aura::client::SetDragDropDelegate(view->GetNativeView(), this); |
830 | 826 |
831 RenderWidgetHostImpl* host_impl = | 827 RenderWidgetHostImpl* host_impl = |
832 RenderWidgetHostImpl::From(render_widget_host); | 828 RenderWidgetHostImpl::From(render_widget_host); |
833 if (host_impl->overscroll_controller() && web_contents_->GetDelegate() && | 829 if (host_impl->overscroll_controller() && |
834 web_contents_->GetDelegate()->CanOverscrollContent()) { | 830 (!web_contents_->GetDelegate() || |
831 web_contents_->GetDelegate()->CanOverscrollContent())) { | |
sky
2013/01/24 18:10:10
nit: indent this line one more space.
sadrul
2013/01/24 20:05:27
Done.
| |
835 host_impl->overscroll_controller()->set_delegate(this); | 832 host_impl->overscroll_controller()->set_delegate(this); |
836 if (!navigation_overlay_.get()) | 833 if (!navigation_overlay_.get()) |
837 navigation_overlay_.reset(new OverscrollNavigationOverlay()); | 834 navigation_overlay_.reset(new OverscrollNavigationOverlay()); |
838 } | 835 } |
839 | 836 |
840 return view; | 837 return view; |
841 } | 838 } |
842 | 839 |
843 RenderWidgetHostView* WebContentsViewAura::CreateViewForPopupWidget( | 840 RenderWidgetHostView* WebContentsViewAura::CreateViewForPopupWidget( |
844 RenderWidgetHost* render_widget_host) { | 841 RenderWidgetHost* render_widget_host) { |
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1283 event.location(), | 1280 event.location(), |
1284 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), | 1281 gfx::Screen::GetScreenFor(GetNativeView())->GetCursorScreenPoint(), |
1285 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); | 1282 ConvertAuraEventFlagsToWebInputEventModifiers(event.flags())); |
1286 if (drag_dest_delegate_) | 1283 if (drag_dest_delegate_) |
1287 drag_dest_delegate_->OnDrop(); | 1284 drag_dest_delegate_->OnDrop(); |
1288 current_drop_data_.reset(); | 1285 current_drop_data_.reset(); |
1289 return current_drag_op_; | 1286 return current_drag_op_; |
1290 } | 1287 } |
1291 | 1288 |
1292 } // namespace content | 1289 } // namespace content |
OLD | NEW |