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

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

Issue 2417783005: [Master/Overview CL] Make PageScaleFactor work for oopif subframe.
Patch Set: Rebase to master@{#429656}. 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
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 268 matching lines...) Expand 10 before | Expand all | Expand 10 after
279 // state and scroll position) to the browser. We delay sending changes to avoid 279 // state and scroll position) to the browser. We delay sending changes to avoid
280 // spamming the browser. 280 // spamming the browser.
281 // To avoid having tab/session restore require sending a message to get the 281 // To avoid having tab/session restore require sending a message to get the
282 // current content state during tab closing we use a shorter timeout for the 282 // current content state during tab closing we use a shorter timeout for the
283 // foreground renderer. This means there is a small window of time from which 283 // foreground renderer. This means there is a small window of time from which
284 // content state is modified and not sent to session restore, but this is 284 // content state is modified and not sent to session restore, but this is
285 // better than having to wake up all renderers during shutdown. 285 // better than having to wake up all renderers during shutdown.
286 const int kDelaySecondsForContentStateSyncHidden = 5; 286 const int kDelaySecondsForContentStateSyncHidden = 5;
287 const int kDelaySecondsForContentStateSync = 1; 287 const int kDelaySecondsForContentStateSync = 1;
288 288
289 #if defined(OS_ANDROID)
290 // Delay between tapping in content and launching the associated android intent.
291 // Used to allow users see what has been recognized as content.
292 const size_t kContentIntentDelayMilliseconds = 700;
293 #endif
294
295 static RenderViewImpl* (*g_create_render_view_impl)( 289 static RenderViewImpl* (*g_create_render_view_impl)(
296 CompositorDependencies* compositor_deps, 290 CompositorDependencies* compositor_deps,
297 const mojom::CreateViewParams&) = nullptr; 291 const mojom::CreateViewParams&) = nullptr;
298 292
299 // static 293 // static
300 Referrer RenderViewImpl::GetReferrerFromRequest( 294 Referrer RenderViewImpl::GetReferrerFromRequest(
301 WebFrame* frame, 295 WebFrame* frame,
302 const WebURLRequest& request) { 296 const WebURLRequest& request) {
303 return Referrer( 297 return Referrer(
304 blink::WebStringToGURL(request.httpHeaderField( 298 blink::WebStringToGURL(request.httpHeaderField(
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after
687 webview_(nullptr), 681 webview_(nullptr),
688 has_scrolled_focused_editable_node_into_rect_(false), 682 has_scrolled_focused_editable_node_into_rect_(false),
689 page_zoom_level_(params.page_zoom_level), 683 page_zoom_level_(params.page_zoom_level),
690 main_render_frame_(nullptr), 684 main_render_frame_(nullptr),
691 frame_widget_(nullptr), 685 frame_widget_(nullptr),
692 speech_recognition_dispatcher_(NULL), 686 speech_recognition_dispatcher_(NULL),
693 #if defined(OS_ANDROID) 687 #if defined(OS_ANDROID)
694 expected_content_intent_id_(0), 688 expected_content_intent_id_(0),
695 #endif 689 #endif
696 enumeration_completion_id_(0), 690 enumeration_completion_id_(0),
697 session_storage_namespace_id_(params.session_storage_namespace_id), 691 session_storage_namespace_id_(params.session_storage_namespace_id) {
698 has_added_input_handler_(false) {
699 GetWidget()->set_owner_delegate(this); 692 GetWidget()->set_owner_delegate(this);
700 } 693 }
701 694
702 void RenderViewImpl::Initialize(const mojom::CreateViewParams& params, 695 void RenderViewImpl::Initialize(const mojom::CreateViewParams& params,
703 bool was_created_by_renderer) { 696 bool was_created_by_renderer) {
704 SetRoutingID(params.view_id); 697 SetRoutingID(params.view_id);
705 698
706 int opener_view_routing_id; 699 int opener_view_routing_id;
707 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener( 700 WebFrame* opener_frame = RenderFrameImpl::ResolveOpener(
708 params.opener_frame_route_id, &opener_view_routing_id); 701 params.opener_frame_route_id, &opener_view_routing_id);
(...skipping 647 matching lines...) Expand 10 before | Expand all | Expand 10 after
1356 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap, 1349 IPC_MESSAGE_HANDLER(ViewMsg_ReleaseDisambiguationPopupBitmap,
1357 OnReleaseDisambiguationPopupBitmap) 1350 OnReleaseDisambiguationPopupBitmap)
1358 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw) 1351 IPC_MESSAGE_HANDLER(ViewMsg_ForceRedraw, OnForceRedraw)
1359 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret) 1352 IPC_MESSAGE_HANDLER(ViewMsg_SelectWordAroundCaret, OnSelectWordAroundCaret)
1360 1353
1361 // Page messages. 1354 // Page messages.
1362 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect, 1355 IPC_MESSAGE_HANDLER(PageMsg_UpdateWindowScreenRect,
1363 OnUpdateWindowScreenRect) 1356 OnUpdateWindowScreenRect)
1364 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel) 1357 IPC_MESSAGE_HANDLER(PageMsg_SetZoomLevel, OnSetZoomLevel)
1365 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor); 1358 IPC_MESSAGE_HANDLER(PageMsg_SetDeviceScaleFactor, OnSetDeviceScaleFactor);
1359 IPC_MESSAGE_HANDLER(PageMsg_SetPageScaleFactor,
1360 OnSetPageScaleFactorForSubframes);
1366 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden) 1361 IPC_MESSAGE_HANDLER(PageMsg_WasHidden, OnPageWasHidden)
1367 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown) 1362 IPC_MESSAGE_HANDLER(PageMsg_WasShown, OnPageWasShown)
1368 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength, 1363 IPC_MESSAGE_HANDLER(PageMsg_SetHistoryOffsetAndLength,
1369 OnSetHistoryOffsetAndLength) 1364 OnSetHistoryOffsetAndLength)
1370 1365
1371 #if defined(OS_ANDROID) 1366 #if defined(OS_ANDROID)
1372 IPC_MESSAGE_HANDLER(ViewMsg_UpdateBrowserControlsState, 1367 IPC_MESSAGE_HANDLER(ViewMsg_UpdateBrowserControlsState,
1373 OnUpdateBrowserControlsState) 1368 OnUpdateBrowserControlsState)
1374 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData) 1369 IPC_MESSAGE_HANDLER(ViewMsg_ExtractSmartClipData, OnExtractSmartClipData)
1375 #elif defined(OS_MACOSX) 1370 #elif defined(OS_MACOSX)
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1980 // TODO(estade): hit test the event against focused node to make sure 1975 // TODO(estade): hit test the event against focused node to make sure
1981 // the tap actually hit the focused node. 1976 // the tap actually hit the focused node.
1982 blink::WebTextInputType text_input_type = GetWebView()->textInputType(); 1977 blink::WebTextInputType text_input_type = GetWebView()->textInputType();
1983 1978
1984 Send(new ViewHostMsg_FocusedNodeTouched( 1979 Send(new ViewHostMsg_FocusedNodeTouched(
1985 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone)); 1980 GetRoutingID(), text_input_type != blink::WebTextInputTypeNone));
1986 #endif 1981 #endif
1987 } 1982 }
1988 1983
1989 void RenderViewImpl::initializeLayerTreeView() { 1984 void RenderViewImpl::initializeLayerTreeView() {
1985 // TODO(!wjmaclean): We should be able to just remove this function, and
1986 // expect the RenderWidget version of the function to be called instead.
1987 // However, we have a diamond inheritance pattern going on:
1988 // WebWidgetClient
1989 // | |
1990 // RenderWidget WebViewClient
1991 // | |
1992 // RenderViewImpl
1993 //
1994 // and this seems to prefer calling the empty version in WebWidgetClient
1995 // or WebViewClient over the non-empty one in RenderWidget.
1990 RenderWidget::initializeLayerTreeView(); 1996 RenderWidget::initializeLayerTreeView();
1991 RenderWidgetCompositor* rwc = compositor();
1992 if (!rwc)
1993 return;
1994
1995 bool use_threaded_event_handling = true;
1996 #if defined(OS_MACOSX)
1997 // Disable threaded event handling if content is not handling the elastic
1998 // overscroll effect. This includes the cases where the elastic overscroll
1999 // effect is being handled by Blink (because of command line flags) and older
2000 // operating system versions which do not have an elastic overscroll effect
2001 // (SnowLeopard, which has Aqua scrollbars which need synchronous updates).
2002 use_threaded_event_handling = compositor_deps_->IsElasticOverscrollEnabled();
2003 #endif
2004 if (!use_threaded_event_handling)
2005 return;
2006
2007 RenderThreadImpl* render_thread = RenderThreadImpl::current();
2008 // render_thread may be NULL in tests.
2009 InputHandlerManager* input_handler_manager =
2010 render_thread ? render_thread->input_handler_manager() : NULL;
2011 if (input_handler_manager) {
2012 input_handler_manager->AddInputHandler(
2013 GetRoutingID(), rwc->GetInputHandler(), AsWeakPtr(),
2014 webkit_preferences_.enable_scroll_animator);
2015 has_added_input_handler_ = true;
2016 }
2017 } 1997 }
2018 1998
2019 void RenderViewImpl::closeWidgetSoon() { 1999 void RenderViewImpl::closeWidgetSoon() {
2020 RenderWidget::closeWidgetSoon(); 2000 RenderWidget::closeWidgetSoon();
2021 } 2001 }
2022 2002
2023 void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) { 2003 void RenderViewImpl::convertViewportToWindow(blink::WebRect* rect) {
2024 RenderWidget::convertViewportToWindow(rect); 2004 RenderWidget::convertViewportToWindow(rect);
2025 } 2005 }
2026 2006
(...skipping 602 matching lines...) Expand 10 before | Expand all | Expand 10 after
2629 GetWidget()->FocusChangeComplete(); 2609 GetWidget()->FocusChangeComplete();
2630 } 2610 }
2631 2611
2632 void RenderViewImpl::OnDeviceScaleFactorChanged() { 2612 void RenderViewImpl::OnDeviceScaleFactorChanged() {
2633 RenderWidget::OnDeviceScaleFactorChanged(); 2613 RenderWidget::OnDeviceScaleFactorChanged();
2634 UpdateWebViewWithDeviceScaleFactor(); 2614 UpdateWebViewWithDeviceScaleFactor();
2635 if (auto_resize_mode_) 2615 if (auto_resize_mode_)
2636 AutoResizeCompositor(); 2616 AutoResizeCompositor();
2637 } 2617 }
2638 2618
2619 void RenderViewImpl::OnSetPageScaleFactorForSubframes(double page_scale) {
2620 if (webview() && webview()->mainFrame() &&
2621 !webview()->mainFrame()->isWebLocalFrame()) {
2622 // TODO(wjmaclean): Find a better way to identify the local roots in the
2623 // frame tree. Still, this is likely better than sending a separate IPC for
2624 // every frame in a renderer.
2625 for (WebFrame* frame = webview()->mainFrame(); frame;
2626 frame = frame->traverseNext()) {
2627 if (frame->isWebLocalFrame() && !frame->parent()->isWebLocalFrame()) {
2628 RenderFrameImpl* rfi = RenderFrameImpl::FromWebFrame(frame);
2629 RenderWidgetCompositor* widget_compositor =
2630 rfi->GetRenderWidget()->compositor();
2631 widget_compositor->SetPageScaleFactorForSubframe(page_scale);
2632 }
2633 }
2634 }
2635 }
2636
2639 void RenderViewImpl::SetScreenMetricsEmulationParameters( 2637 void RenderViewImpl::SetScreenMetricsEmulationParameters(
2640 bool enabled, 2638 bool enabled,
2641 const blink::WebDeviceEmulationParams& params) { 2639 const blink::WebDeviceEmulationParams& params) {
2642 if (webview() && compositor()) { 2640 if (webview() && compositor()) {
2643 if (enabled) 2641 if (enabled)
2644 webview()->enableDeviceEmulation(params); 2642 webview()->enableDeviceEmulation(params);
2645 else 2643 else
2646 webview()->disableDeviceEmulation(); 2644 webview()->disableDeviceEmulation();
2647 } 2645 }
2648 } 2646 }
(...skipping 79 matching lines...) Expand 10 before | Expand all | Expand 10 after
2728 WebURL intent = detector->FindTappedContent(touch_hit); 2726 WebURL intent = detector->FindTappedContent(touch_hit);
2729 if (intent.isValid()) { 2727 if (intent.isValid()) {
2730 return intent; 2728 return intent;
2731 } 2729 }
2732 } 2730 }
2733 return WebURL(); 2731 return WebURL();
2734 } 2732 }
2735 2733
2736 void RenderViewImpl::scheduleContentIntent(const WebURL& intent, 2734 void RenderViewImpl::scheduleContentIntent(const WebURL& intent,
2737 bool is_main_frame) { 2735 bool is_main_frame) {
2738 // Introduce a short delay so that the user can notice the content. 2736 scheduleContentIntentForRenderView(intent, is_main_frame,
2739 base::ThreadTaskRunnerHandle::Get()->PostDelayedTask( 2737 expected_content_intent_id_);
2740 FROM_HERE,
2741 base::Bind(&RenderViewImpl::LaunchAndroidContentIntent, AsWeakPtr(),
2742 intent, expected_content_intent_id_, is_main_frame),
2743 base::TimeDelta::FromMilliseconds(kContentIntentDelayMilliseconds));
2744 } 2738 }
2745 2739
2746 void RenderViewImpl::cancelScheduledContentIntents() { 2740 void RenderViewImpl::cancelScheduledContentIntents() {
2747 ++expected_content_intent_id_; 2741 ++expected_content_intent_id_;
2748 } 2742 }
2749 2743
2750 void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent, 2744 void RenderViewImpl::LaunchAndroidContentIntent(const GURL& intent,
2751 size_t request_id, 2745 size_t request_id,
2752 bool is_main_frame) { 2746 bool is_main_frame) {
2753 if (request_id != expected_content_intent_id_) 2747 if (request_id != expected_content_intent_id_)
(...skipping 240 matching lines...) Expand 10 before | Expand all | Expand 10 after
2994 NotifyInputEventHandled(input_event->type, 2988 NotifyInputEventHandled(input_event->type,
2995 INPUT_EVENT_ACK_STATE_NOT_CONSUMED); 2989 INPUT_EVENT_ACK_STATE_NOT_CONSUMED);
2996 } 2990 }
2997 2991
2998 std::unique_ptr<InputEventAck> ack( 2992 std::unique_ptr<InputEventAck> ack(
2999 new InputEventAck(input_event->type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED)); 2993 new InputEventAck(input_event->type, INPUT_EVENT_ACK_STATE_NOT_CONSUMED));
3000 OnInputEventAck(std::move(ack)); 2994 OnInputEventAck(std::move(ack));
3001 } 2995 }
3002 2996
3003 } // namespace content 2997 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_view_impl.h ('k') | content/renderer/render_widget.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698