Chromium Code Reviews| 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/renderer_host/render_widget_host_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" |
| 6 | 6 |
| 7 #include <set> | 7 #include <set> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 2702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2713 snapped = window_->GetRootWindow(); | 2713 snapped = window_->GetRootWindow(); |
| 2714 } else { | 2714 } else { |
| 2715 snapped = window_->GetToplevelWindow(); | 2715 snapped = window_->GetToplevelWindow(); |
| 2716 } | 2716 } |
| 2717 if (snapped && snapped != window_) | 2717 if (snapped && snapped != window_) |
| 2718 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer()); | 2718 ui::SnapLayerToPhysicalPixelBoundary(snapped->layer(), window_->layer()); |
| 2719 | 2719 |
| 2720 has_snapped_to_boundary_ = true; | 2720 has_snapped_to_boundary_ = true; |
| 2721 } | 2721 } |
| 2722 | 2722 |
| 2723 void RenderWidgetHostViewAura::OnShowContextMenu() { | 2723 bool RenderWidgetHostViewAura::OnShowContextMenu( |
| 2724 const ContextMenuParams& params) { | |
| 2724 #if defined(OS_WIN) | 2725 #if defined(OS_WIN) |
| 2726 last_context_menu_params_.reset(); | |
| 2727 | |
| 2728 if (params.source_type == ui::MENU_SOURCE_TOUCH) { | |
| 2729 last_context_menu_params_.reset(new ContextMenuParams); | |
| 2730 *last_context_menu_params_ = params; | |
| 2731 return false; | |
| 2732 } | |
| 2725 showing_context_menu_ = true; | 2733 showing_context_menu_ = true; |
| 2726 #endif | 2734 #endif |
| 2735 return true; | |
| 2727 } | 2736 } |
| 2728 | 2737 |
| 2729 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest( | 2738 void RenderWidgetHostViewAura::SetSelectionControllerClientForTest( |
| 2730 scoped_ptr<TouchSelectionControllerClientAura> client) { | 2739 scoped_ptr<TouchSelectionControllerClientAura> client) { |
| 2731 selection_controller_client_.swap(client); | 2740 selection_controller_client_.swap(client); |
| 2732 CreateSelectionController(); | 2741 CreateSelectionController(); |
| 2733 } | 2742 } |
| 2734 | 2743 |
| 2735 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { | 2744 void RenderWidgetHostViewAura::InternalSetBounds(const gfx::Rect& rect) { |
| 2736 SnapToPhysicalPixelBoundary(); | 2745 SnapToPhysicalPixelBoundary(); |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2924 event->SetHandled(); | 2933 event->SetHandled(); |
| 2925 } | 2934 } |
| 2926 break; | 2935 break; |
| 2927 case ui::ET_GESTURE_TAP: | 2936 case ui::ET_GESTURE_TAP: |
| 2928 if (selection_controller_->WillHandleTapEvent( | 2937 if (selection_controller_->WillHandleTapEvent( |
| 2929 event->location_f(), event->details().tap_count())) { | 2938 event->location_f(), event->details().tap_count())) { |
| 2930 event->SetHandled(); | 2939 event->SetHandled(); |
| 2931 } | 2940 } |
| 2932 break; | 2941 break; |
| 2933 case ui::ET_GESTURE_SCROLL_BEGIN: | 2942 case ui::ET_GESTURE_SCROLL_BEGIN: |
| 2934 selection_controller_->OnScrollBeginEvent(); | |
| 2935 selection_controller_client_->OnScrollStarted(); | 2943 selection_controller_client_->OnScrollStarted(); |
| 2936 break; | 2944 break; |
| 2937 case ui::ET_GESTURE_SCROLL_END: | 2945 case ui::ET_GESTURE_SCROLL_END: |
| 2938 selection_controller_client_->OnScrollCompleted(); | 2946 selection_controller_client_->OnScrollCompleted(); |
| 2939 break; | 2947 break; |
| 2948 #if defined(OS_WIN) | |
| 2949 case ui::ET_GESTURE_LONG_TAP: { | |
| 2950 if (!last_context_menu_params_) | |
| 2951 break; | |
| 2952 | |
| 2953 scoped_ptr<ContextMenuParams> context_menu_params = | |
| 2954 std::move(last_context_menu_params_); | |
| 2955 | |
| 2956 // On Windows we want to display the context menu when the long press | |
| 2957 // gesture is released. To achieve that, we switch the saved context | |
| 2958 // menu params source type to MENU_SOURCE_MOUSE. This is to ensure that | |
| 2959 // the RenderWidgetHostViewAura::OnShowContextMenu function which is | |
| 2960 // called from the ShowContextMenu call below, does not treat it as | |
| 2961 // a context menu request coming in from touch. | |
| 2962 DCHECK(context_menu_params->source_type == ui::MENU_SOURCE_TOUCH); | |
| 2963 context_menu_params->source_type = ui::MENU_SOURCE_MOUSE; | |
|
tdresser
2016/01/21 15:40:28
I think it would be slightly preferable to have a
ananta
2016/01/21 21:11:18
Yeah. Once this stabilizes we can add the new enum
| |
| 2964 | |
| 2965 RenderViewHostDelegateView* delegate_view = | |
| 2966 GetRenderViewHostDelegateView(); | |
| 2967 if (delegate_view) | |
| 2968 delegate_view->ShowContextMenu(GetFocusedFrame(), | |
| 2969 *context_menu_params); | |
| 2970 | |
| 2971 event->SetHandled(); | |
| 2972 // WARNING: we may have been deleted during the call to ShowContextMenu(). | |
| 2973 break; | |
| 2974 } | |
| 2975 #endif | |
| 2940 default: | 2976 default: |
| 2941 break; | 2977 break; |
| 2942 } | 2978 } |
| 2943 } | 2979 } |
| 2944 | 2980 |
| 2981 RenderViewHostDelegateView* | |
| 2982 RenderWidgetHostViewAura::GetRenderViewHostDelegateView() { | |
| 2983 // Use RenderViewHostDelegate to get to the WebContentsViewAura, which will | |
| 2984 // actually show the disambiguation popup. | |
| 2985 RenderViewHost* rvh = RenderViewHost::From(host_); | |
| 2986 if (!rvh) | |
| 2987 return nullptr; | |
| 2988 | |
| 2989 RenderViewHostDelegate* delegate = rvh->GetDelegate(); | |
| 2990 if (!delegate) | |
| 2991 return nullptr; | |
| 2992 | |
| 2993 return delegate->GetDelegateView(); | |
| 2994 } | |
| 2995 | |
| 2945 //////////////////////////////////////////////////////////////////////////////// | 2996 //////////////////////////////////////////////////////////////////////////////// |
| 2946 // DelegatedFrameHost, public: | 2997 // DelegatedFrameHost, public: |
| 2947 | 2998 |
| 2948 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { | 2999 ui::Layer* RenderWidgetHostViewAura::DelegatedFrameHostGetLayer() const { |
| 2949 return window_->layer(); | 3000 return window_->layer(); |
| 2950 } | 3001 } |
| 2951 | 3002 |
| 2952 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { | 3003 bool RenderWidgetHostViewAura::DelegatedFrameHostIsVisible() const { |
| 2953 return !host_->is_hidden(); | 3004 return !host_->is_hidden(); |
| 2954 } | 3005 } |
| (...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 3029 | 3080 |
| 3030 //////////////////////////////////////////////////////////////////////////////// | 3081 //////////////////////////////////////////////////////////////////////////////// |
| 3031 // RenderWidgetHostViewBase, public: | 3082 // RenderWidgetHostViewBase, public: |
| 3032 | 3083 |
| 3033 // static | 3084 // static |
| 3034 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 3085 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 3035 GetScreenInfoForWindow(results, NULL); | 3086 GetScreenInfoForWindow(results, NULL); |
| 3036 } | 3087 } |
| 3037 | 3088 |
| 3038 } // namespace content | 3089 } // namespace content |
| OLD | NEW |