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/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 Loading... |
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 Loading... |
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 1276 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1981 // TODO(estade): hit test the event against focused node to make sure | 1974 // TODO(estade): hit test the event against focused node to make sure |
1982 // the tap actually hit the focused node. | 1975 // the tap actually hit the focused node. |
1983 blink::WebTextInputType text_input_type = GetWebView()->textInputType(); | 1976 blink::WebTextInputType text_input_type = GetWebView()->textInputType(); |
1984 | 1977 |
1985 Send(new ViewHostMsg_FocusedNodeTouched( | 1978 Send(new ViewHostMsg_FocusedNodeTouched( |
1986 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone)); | 1979 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone)); |
1987 #endif | 1980 #endif |
1988 } | 1981 } |
1989 | 1982 |
1990 void RenderViewImpl::initializeLayerTreeView() { | 1983 void RenderViewImpl::initializeLayerTreeView() { |
| 1984 // TODO(!wjmaclean): We should be able to just remove this function, and |
| 1985 // expect the RenderWidget version of the function to be called instead. |
| 1986 // However, we have a diamond inheritance pattern going on: |
| 1987 // WebWidgetClient |
| 1988 // | | |
| 1989 // RenderWidget WebViewClient |
| 1990 // | | |
| 1991 // RenderViewImpl |
| 1992 // |
| 1993 // and this seems to prefer calling the empty version in WebWidgetClient |
| 1994 // or WebViewClient over the non-empty one in RenderWidget. |
1991 RenderWidget::initializeLayerTreeView(); | 1995 RenderWidget::initializeLayerTreeView(); |
1992 RenderWidgetCompositor* rwc = compositor(); | |
1993 if (!rwc) | |
1994 return; | |
1995 | |
1996 bool use_threaded_event_handling = true; | |
1997 #if defined(OS_MACOSX) | |
1998 // Disable threaded event handling if content is not handling the elastic | |
1999 // overscroll effect. This includes the cases where the elastic overscroll | |
2000 // effect is being handled by Blink (because of command line flags) and older | |
2001 // operating system versions which do not have an elastic overscroll effect | |
2002 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates). | |
2003 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled(); | |
2004 #endif | |
2005 if (!use_threaded_event_handling) | |
2006 return; | |
2007 | |
2008 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | |
2009 // render_thread may be NULL in tests. | |
2010 InputHandlerManager* input_handler_manager = | |
2011 render_thread ? render_thread->input_handler_manager() : NULL; | |
2012 if (input_handler_manager) { | |
2013 input_handler_manager->AddInputHandler( | |
2014 GetRoutingID(), rwc->GetInputHandler(), AsWeakPtr(), | |
2015 webkit_preferences_.enable_scroll_animator); | |
2016 has_added_input_handler_ = true; | |
2017 } | |
2018 } | 1996 } |
2019 | 1997 |
2020 void RenderViewImpl::closeWidgetSoon() { | 1998 void RenderViewImpl::closeWidgetSoon() { |
2021 RenderWidget::closeWidgetSoon(); | 1999 RenderWidget::closeWidgetSoon(); |
2022 } | 2000 } |
2023 | 2001 |
2024 void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) { | 2002 void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) { |
2025 RenderWidget::convertViewportToWindow(rect); | 2003 RenderWidget::convertViewportToWindow(rect); |
2026 } | 2004 } |
2027 | 2005 |
(...skipping 701 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2729 WebURL intent = detector->FindTappedContent(touch_hit); | 2707 WebURL intent = detector->FindTappedContent(touch_hit); |
2730 if (intent.isValid()) { | 2708 if (intent.isValid()) { |
2731 return intent; | 2709 return intent; |
2732 } | 2710 } |
2733 } | 2711 } |
2734 return WebURL(); | 2712 return WebURL(); |
2735 } | 2713 } |
2736 | 2714 |
2737 void RenderViewImpl::scheduleContentIntent(const WebURL& intent, | 2715 void RenderViewImpl::scheduleContentIntent(const WebURL& intent, |
2738 bool is_main_frame) { | 2716 bool is_main_frame) { |
2739 // Introduce a short delay so that the user can notice the content. | 2717 scheduleContentIntentForRenderView(intent, is_main_frame, |
2740 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( | 2718 expected_content_intent_id_); |
2741 FROM_HERE, | |
2742 base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(), | |
2743 intent, expected_content_intent_id_, is_main_frame), | |
2744 base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds)); | |
2745 } | 2719 } |
2746 | 2720 |
2747 void RenderViewImpl::cancelScheduledContentIntents() { | 2721 void RenderViewImpl::cancelScheduledContentIntents() { |
2748 ++expected_content_intent_id_; | 2722 ++expected_content_intent_id_; |
2749 } | 2723 } |
2750 | 2724 |
2751 void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, | 2725 void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, |
2752 size_t request_id, | 2726 size_t request_id, |
2753 bool is_main_frame) { | 2727 bool is_main_frame) { |
2754 if (request_id != expected_content_intent_id_) | 2728 if (request_id != expected_content_intent_id_) |
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2995 NotifyInputEventHandled(input_event->type, | 2969 NotifyInputEventHandled(input_event->type, |
2996 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); | 2970 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); |
2997 } | 2971 } |
2998 | 2972 |
2999 std::unique_ptr<InputEventAck> ack( | 2973 std::unique_ptr<InputEventAck> ack( |
3000 new InputEventAck(input_event->type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); | 2974 new InputEventAck(input_event->type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); |
3001 OnInputEventAck(std::move(ack)); | 2975 OnInputEventAck(std::move(ack)); |
3002 } | 2976 } |
3003 | 2977 |
3004 } // namespace content | 2978 } // namespace content |
OLD | NEW |