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

Side by Side Diff: content/renderer/render_view_impl.cc

Issue 2479663002: Move compositor InputHandler from RenderViewImpl to RenderWidget. (Closed)
Patch Set: Add early out to accommodate null frameWidget in webkit_unit_tests. Created 4 years, 1 month 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/renderer/render_view_impl.h" 5 #include "content/renderer/render_view_impl.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <cmath> 8 #include <cmath>
9 #include <memory> 9 #include <memory>
10 10
(...skipping 264 matching lines...) Expand 10 before | Expand all | Expand 10 after
275 // state and scroll position) to the browser. We delay sending changes to avoid 275 // state and scroll position) to the browser. We delay sending changes to avoid
276 // spamming the browser. 276 // spamming the browser.
277 // To avoid having tab/session restore require sending a message to get the 277 // To avoid having tab/session restore require sending a message to get the
278 // current content state during tab closing we use a shorter timeout for the 278 // current content state during tab closing we use a shorter timeout for the
279 // foreground renderer. This means there is a small window of time from which 279 // foreground renderer. This means there is a small window of time from which
280 // content state is modified and not sent to session restore, but this is 280 // content state is modified and not sent to session restore, but this is
281 // better than having to wake up all renderers during shutdown. 281 // better than having to wake up all renderers during shutdown.
282 const int kDelaySecondsForContentStateSyncHidden = 5; 282 const int kDelaySecondsForContentStateSyncHidden = 5;
283 const int kDelaySecondsForContentStateSync = 1; 283 const int kDelaySecondsForContentStateSync = 1;
284 284
285 #if defined(OS_ANDROID)
286 // Delay between tapping in content and launching the associated android intent.
287 // Used to allow users see what has been recognized as content.
288 const size_t kContentIntentDelayMilliseconds = 700;
289 #endif
290
291 static RenderViewImpl* (*g_create_render_view_impl)( 285 static RenderViewImpl* (*g_create_render_view_impl)(
292 CompositorDependencies* compositor_deps, 286 CompositorDependencies* compositor_deps,
293 const mojom::CreateViewParams&) = nullptr; 287 const mojom::CreateViewParams&) = nullptr;
294 288
295 // static 289 // static
296 Referrer RenderViewImpl::GetReferrerFromRequest( 290 Referrer RenderViewImpl::GetReferrerFromRequest(
297 WebFrame* frame, 291 WebFrame* frame,
298 const WebURLRequest& request) { 292 const WebURLRequest& request) {
299 return Referrer( 293 return Referrer(
300 blink::WebStringToGURL(request.httpHeaderField( 294 blink::WebStringToGURL(request.httpHeaderField(
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
683 webview_(nullptr), 677 webview_(nullptr),
684 has_scrolled_focused_editable_node_into_rect_(false), 678 has_scrolled_focused_editable_node_into_rect_(false),
685 page_zoom_level_(params.page_zoom_level), 679 page_zoom_level_(params.page_zoom_level),
686 main_render_frame_(nullptr), 680 main_render_frame_(nullptr),
687 frame_widget_(nullptr), 681 frame_widget_(nullptr),
688 speech_recognition_dispatcher_(NULL), 682 speech_recognition_dispatcher_(NULL),
689 #if defined(OS_ANDROID) 683 #if defined(OS_ANDROID)
690 expected_content_intent_id_(0), 684 expected_content_intent_id_(0),
691 #endif 685 #endif
692 enumeration_completion_id_(0), 686 enumeration_completion_id_(0),
693 session_storage_namespace_id_(params.session_storage_namespace_id), 687 session_storage_namespace_id_(params.session_storage_namespace_id) {
694 has_added_input_handler_(false) {
695 GetWidget()->set_owner_delegate(this); 688 GetWidget()->set_owner_delegate(this);
696 } 689 }
697 690
698 void RenderViewImpl::Initialize(const mojom::CreateViewParams& params, 691 void RenderViewImpl::Initialize(const mojom::CreateViewParams& params,
699 bool was_created_by_renderer) { 692 bool was_created_by_renderer) {
700 SetRoutingID(params.view_id); 693 SetRoutingID(params.view_id);
701 694
702 int opener_view_routing_id; 695 int opener_view_routing_id;
703 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( 696 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener(
704 params.opener_frame_route_id, &opener_view_routing_id); 697 params.opener_frame_route_id, &opener_view_routing_id);
(...skipping 1247 matching lines...) Expand 10 before | Expand all | Expand 10 after
1952 // TODO(estade): hit test the event against focused node to make sure 1945 // TODO(estade): hit test the event against focused node to make sure
1953 // the tap actually hit the focused node. 1946 // the tap actually hit the focused node.
1954 blink::WebTextInputType text_input_type = GetWebView()->textInputType(); 1947 blink::WebTextInputType text_input_type = GetWebView()->textInputType();
1955 1948
1956 Send(new ViewHostMsg_FocusedNodeTouched( 1949 Send(new ViewHostMsg_FocusedNodeTouched(
1957 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone)); 1950 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone));
1958 #endif 1951 #endif
1959 } 1952 }
1960 1953
1961 void RenderViewImpl::initializeLayerTreeView() { 1954 void RenderViewImpl::initializeLayerTreeView() {
1955 // TODO(!wjmaclean): We should be able to just remove this function, and
1956 // expect the RenderWidget version of the function to be called instead.
1957 // However, we have a diamond inheritance pattern going on:
1958 // WebWidgetClient
1959 // | |
1960 // RenderWidget WebViewClient
1961 // | |
1962 // RenderViewImpl
1963 //
1964 // and this seems to prefer calling the empty version in WebWidgetClient
1965 // or WebViewClient over the non-empty one in RenderWidget.
1962 RenderWidget::initializeLayerTreeView(); 1966 RenderWidget::initializeLayerTreeView();
1963 RenderWidgetCompositor* rwc = compositor();
1964 if (!rwc)
1965 return;
1966
1967 bool use_threaded_event_handling = true;
1968 #if defined(OS_MACOSX)
1969 // Disable threaded event handling if content is not handling the elastic
1970 // overscroll effect. This includes the cases where the elastic overscroll
1971 // effect is being handled by Blink (because of command line flags) and older
1972 // operating system versions which do not have an elastic overscroll effect
1973 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates).
1974 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled();
1975 #endif
1976 if (!use_threaded_event_handling)
1977 return;
1978
1979 RenderThreadImpl* render_thread = RenderThreadImpl::current();
1980 // render_thread may be NULL in tests.
1981 InputHandlerManager* input_handler_manager =
1982 render_thread ? render_thread->input_handler_manager() : NULL;
1983 if (input_handler_manager) {
1984 input_handler_manager->AddInputHandler(
1985 GetRoutingID(), rwc->GetInputHandler(), AsWeakPtr(),
1986 webkit_preferences_.enable_scroll_animator);
1987 has_added_input_handler_ = true;
1988 }
1989 } 1967 }
1990 1968
1991 void RenderViewImpl::closeWidgetSoon() { 1969 void RenderViewImpl::closeWidgetSoon() {
1992 RenderWidget::closeWidgetSoon(); 1970 RenderWidget::closeWidgetSoon();
1993 } 1971 }
1994 1972
1995 void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) { 1973 void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) {
1996 RenderWidget::convertViewportToWindow(rect); 1974 RenderWidget::convertViewportToWindow(rect);
1997 } 1975 }
1998 1976
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after
2700 WebURL intent = detector->FindTappedContent(touch_hit); 2678 WebURL intent = detector->FindTappedContent(touch_hit);
2701 if (intent.isValid()) { 2679 if (intent.isValid()) {
2702 return intent; 2680 return intent;
2703 } 2681 }
2704 } 2682 }
2705 return WebURL(); 2683 return WebURL();
2706 } 2684 }
2707 2685
2708 void RenderViewImpl::scheduleContentIntent(const WebURL& intent, 2686 void RenderViewImpl::scheduleContentIntent(const WebURL& intent,
2709 bool is_main_frame) { 2687 bool is_main_frame) {
2710 // Introduce a short delay so that the user can notice the content. 2688 scheduleContentIntentForRenderView(intent, is_main_frame,
2711 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 2689 expected_content_intent_id_);
2712 FROM_HERE,
2713 base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(),
2714 intent, expected_content_intent_id_, is_main_frame),
2715 base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds));
2716 } 2690 }
2717 2691
2718 void RenderViewImpl::cancelScheduledContentIntents() { 2692 void RenderViewImpl::cancelScheduledContentIntents() {
2719 ++expected_content_intent_id_; 2693 ++expected_content_intent_id_;
2720 } 2694 }
2721 2695
2722 void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, 2696 void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent,
2723 size_t request_id, 2697 size_t request_id,
2724 bool is_main_frame) { 2698 bool is_main_frame) {
2725 if (request_id != expected_content_intent_id_) 2699 if (request_id != expected_content_intent_id_)
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
2967 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2941 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2968 } 2942 }
2969 2943
2970 std::unique_ptr<InputEventAck> ack( 2944 std::unique_ptr<InputEventAck> ack(
2971 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type, 2945 new InputEventAck(InputEventAckSource::MAIN_THREAD, input_event->type,
2972 INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 2946 INPUT_EVENT_ACK_STATE_NOT_CONSUMED));
2973 OnInputEventAck(std::move(ack)); 2947 OnInputEventAck(std::move(ack));
2974 } 2948 }
2975 2949
2976 } // namespace content 2950 } // namespace content
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698