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

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

Issue 1962923002: Fix rendering of flash content inside an out-of-process iframe. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: fix for android builds Created 4 years, 7 months 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_widget.h ('k') | content/renderer/render_widget_owner_delegate.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_widget.h" 5 #include "content/renderer/render_widget.h"
6 6
7 #include <memory> 7 #include <memory>
8 #include <utility> 8 #include <utility>
9 9
10 #include "base/auto_reset.h" 10 #include "base/auto_reset.h"
(...skipping 14 matching lines...) Expand all
25 #include "build/build_config.h" 25 #include "build/build_config.h"
26 #include "cc/base/switches.h" 26 #include "cc/base/switches.h"
27 #include "cc/debug/benchmark_instrumentation.h" 27 #include "cc/debug/benchmark_instrumentation.h"
28 #include "cc/output/output_surface.h" 28 #include "cc/output/output_surface.h"
29 #include "cc/output/vulkan_in_process_context_provider.h" 29 #include "cc/output/vulkan_in_process_context_provider.h"
30 #include "cc/scheduler/begin_frame_source.h" 30 #include "cc/scheduler/begin_frame_source.h"
31 #include "cc/trees/layer_tree_host.h" 31 #include "cc/trees/layer_tree_host.h"
32 #include "components/scheduler/renderer/render_widget_scheduling_state.h" 32 #include "components/scheduler/renderer/render_widget_scheduling_state.h"
33 #include "components/scheduler/renderer/renderer_scheduler.h" 33 #include "components/scheduler/renderer/renderer_scheduler.h"
34 #include "content/common/content_switches_internal.h" 34 #include "content/common/content_switches_internal.h"
35 #include "content/common/frame_messages.h"
35 #include "content/common/gpu/client/context_provider_command_buffer.h" 36 #include "content/common/gpu/client/context_provider_command_buffer.h"
36 #include "content/common/gpu_process_launch_causes.h" 37 #include "content/common/gpu_process_launch_causes.h"
37 #include "content/common/input/synthetic_gesture_packet.h" 38 #include "content/common/input/synthetic_gesture_packet.h"
38 #include "content/common/input/web_input_event_traits.h" 39 #include "content/common/input/web_input_event_traits.h"
39 #include "content/common/input_messages.h" 40 #include "content/common/input_messages.h"
40 #include "content/common/swapped_out_messages.h" 41 #include "content/common/swapped_out_messages.h"
41 #include "content/common/text_input_state.h" 42 #include "content/common/text_input_state.h"
42 #include "content/common/view_messages.h" 43 #include "content/common/view_messages.h"
43 #include "content/public/common/content_features.h" 44 #include "content/public/common/content_features.h"
44 #include "content/public/common/content_switches.h" 45 #include "content/public/common/content_switches.h"
(...skipping 29 matching lines...) Expand all
74 #include "third_party/WebKit/public/platform/WebString.h" 75 #include "third_party/WebKit/public/platform/WebString.h"
75 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" 76 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h"
76 #include "third_party/WebKit/public/web/WebFrameWidget.h" 77 #include "third_party/WebKit/public/web/WebFrameWidget.h"
77 #include "third_party/WebKit/public/web/WebLocalFrame.h" 78 #include "third_party/WebKit/public/web/WebLocalFrame.h"
78 #include "third_party/WebKit/public/web/WebNode.h" 79 #include "third_party/WebKit/public/web/WebNode.h"
79 #include "third_party/WebKit/public/web/WebPagePopup.h" 80 #include "third_party/WebKit/public/web/WebPagePopup.h"
80 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" 81 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h"
81 #include "third_party/WebKit/public/web/WebRange.h" 82 #include "third_party/WebKit/public/web/WebRange.h"
82 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" 83 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h"
83 #include "third_party/WebKit/public/web/WebView.h" 84 #include "third_party/WebKit/public/web/WebView.h"
85 #include "third_party/WebKit/public/web/WebWidget.h"
84 #include "third_party/skia/include/core/SkShader.h" 86 #include "third_party/skia/include/core/SkShader.h"
85 #include "ui/base/ui_base_switches.h" 87 #include "ui/base/ui_base_switches.h"
86 #include "ui/gfx/geometry/point_conversions.h" 88 #include "ui/gfx/geometry/point_conversions.h"
87 #include "ui/gfx/geometry/rect_conversions.h" 89 #include "ui/gfx/geometry/rect_conversions.h"
88 #include "ui/gfx/geometry/size_conversions.h" 90 #include "ui/gfx/geometry/size_conversions.h"
89 #include "ui/gfx/skia_util.h" 91 #include "ui/gfx/skia_util.h"
90 #include "ui/gl/gl_switches.h" 92 #include "ui/gl/gl_switches.h"
91 #include "ui/surface/transport_dib.h" 93 #include "ui/surface/transport_dib.h"
92 94
93 #if defined(OS_ANDROID) 95 #if defined(OS_ANDROID)
94 #include <android/keycodes.h> 96 #include <android/keycodes.h>
95 #include "content/renderer/android/synchronous_compositor_filter.h" 97 #include "content/renderer/android/synchronous_compositor_filter.h"
96 #include "content/renderer/android/synchronous_compositor_output_surface.h" 98 #include "content/renderer/android/synchronous_compositor_output_surface.h"
97 #endif 99 #endif
98 100
101 #if defined(ENABLE_PLUGINS)
102 #include "content/renderer/pepper/pepper_plugin_instance_impl.h"
103 #include "content/renderer/pepper/pepper_plugin_registry.h"
104 #endif
105
99 #if defined(OS_POSIX) 106 #if defined(OS_POSIX)
100 #include "ipc/ipc_channel_posix.h" 107 #include "ipc/ipc_channel_posix.h"
101 #include "third_party/skia/include/core/SkMallocPixelRef.h" 108 #include "third_party/skia/include/core/SkMallocPixelRef.h"
102 #include "third_party/skia/include/core/SkPixelRef.h" 109 #include "third_party/skia/include/core/SkPixelRef.h"
103 #endif // defined(OS_POSIX) 110 #endif // defined(OS_POSIX)
104 111
105 #if defined(MOJO_SHELL_CLIENT) 112 #if defined(MOJO_SHELL_CLIENT)
106 #include "content/public/common/mojo_shell_connection.h" 113 #include "content/public/common/mojo_shell_connection.h"
107 #include "content/renderer/mus/render_widget_mus_connection.h" 114 #include "content/renderer/mus/render_widget_mus_connection.h"
108 #endif 115 #endif
109 116
110 #include "third_party/WebKit/public/web/WebWidget.h"
111
112 using blink::WebCompositionUnderline; 117 using blink::WebCompositionUnderline;
113 using blink::WebCursorInfo; 118 using blink::WebCursorInfo;
114 using blink::WebDeviceEmulationParams; 119 using blink::WebDeviceEmulationParams;
115 using blink::WebGestureEvent; 120 using blink::WebGestureEvent;
116 using blink::WebInputEvent; 121 using blink::WebInputEvent;
117 using blink::WebInputEventResult; 122 using blink::WebInputEventResult;
118 using blink::WebKeyboardEvent; 123 using blink::WebKeyboardEvent;
119 using blink::WebMouseEvent; 124 using blink::WebMouseEvent;
120 using blink::WebMouseWheelEvent; 125 using blink::WebMouseWheelEvent;
121 using blink::WebNavigationPolicy; 126 using blink::WebNavigationPolicy;
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after
240 pending_window_rect_count_(0), 245 pending_window_rect_count_(0),
241 screen_info_(screen_info), 246 screen_info_(screen_info),
242 device_scale_factor_(screen_info_.deviceScaleFactor), 247 device_scale_factor_(screen_info_.deviceScaleFactor),
243 next_output_surface_id_(0), 248 next_output_surface_id_(0),
244 #if defined(OS_ANDROID) 249 #if defined(OS_ANDROID)
245 text_field_is_dirty_(false), 250 text_field_is_dirty_(false),
246 #endif 251 #endif
247 popup_origin_scale_for_emulation_(0.f), 252 popup_origin_scale_for_emulation_(0.f),
248 frame_swap_message_queue_(new FrameSwapMessageQueue()), 253 frame_swap_message_queue_(new FrameSwapMessageQueue()),
249 resizing_mode_selector_(new ResizingModeSelector()), 254 resizing_mode_selector_(new ResizingModeSelector()),
255 #if defined(ENABLE_PLUGINS)
256 focused_pepper_plugin_(nullptr),
257 pepper_last_mouse_event_target_(nullptr),
258 #endif
250 has_host_context_menu_location_(false) { 259 has_host_context_menu_location_(false) {
251 if (!swapped_out) 260 if (!swapped_out)
252 RenderProcess::current()->AddRefProcess(); 261 RenderProcess::current()->AddRefProcess();
253 DCHECK(RenderThread::Get()); 262 DCHECK(RenderThread::Get());
254 device_color_profile_.push_back('0'); 263 device_color_profile_.push_back('0');
255 #if defined(OS_ANDROID) 264 #if defined(OS_ANDROID)
256 text_input_info_history_.push_back(blink::WebTextInputInfo()); 265 text_input_info_history_.push_back(blink::WebTextInputInfo());
257 #endif 266 #endif
258 267
259 // In tests there may not be a RenderThreadImpl. 268 // In tests there may not be a RenderThreadImpl.
(...skipping 347 matching lines...) Expand 10 before | Expand all | Expand 10 after
607 if (webwidget_) 616 if (webwidget_)
608 webwidget_->didChangeWindowResizerRect(); 617 webwidget_->didChangeWindowResizerRect();
609 } 618 }
610 619
611 void RenderWidget::OnWasHidden() { 620 void RenderWidget::OnWasHidden() {
612 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden"); 621 TRACE_EVENT0("renderer", "RenderWidget::OnWasHidden");
613 // Go into a mode where we stop generating paint and scrolling events. 622 // Go into a mode where we stop generating paint and scrolling events.
614 SetHidden(true); 623 SetHidden(true);
615 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, 624 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
616 WasHidden()); 625 WasHidden());
626
627 #if defined(ENABLE_PLUGINS)
628 for (PepperPluginSet::iterator i = active_pepper_instances_.begin();
dcheng 2016/05/10 18:57:58 Drive-by: I know the original code was written lik
629 i != active_pepper_instances_.end(); ++i)
630 (*i)->PageVisibilityChanged(false);
631 #endif // ENABLE_PLUGINS
617 } 632 }
618 633
619 void RenderWidget::OnWasShown(bool needs_repainting, 634 void RenderWidget::OnWasShown(bool needs_repainting,
620 const ui::LatencyInfo& latency_info) { 635 const ui::LatencyInfo& latency_info) {
621 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown"); 636 TRACE_EVENT0("renderer", "RenderWidget::OnWasShown");
622 // During shutdown we can just ignore this message. 637 // During shutdown we can just ignore this message.
623 if (!webwidget_) 638 if (!webwidget_)
624 return; 639 return;
625 640
626 // See OnWasHidden 641 // See OnWasHidden
627 SetHidden(false); 642 SetHidden(false);
628 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, 643 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_,
629 WasShown()); 644 WasShown());
630 645
631 if (!needs_repainting) 646 if (!needs_repainting)
632 return; 647 return;
633 648
634 // Generate a full repaint. 649 // Generate a full repaint.
635 if (compositor_) { 650 if (compositor_) {
636 ui::LatencyInfo swap_latency_info(latency_info); 651 ui::LatencyInfo swap_latency_info(latency_info);
637 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor( 652 std::unique_ptr<cc::SwapPromiseMonitor> latency_info_swap_promise_monitor(
638 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info)); 653 compositor_->CreateLatencyInfoSwapPromiseMonitor(&swap_latency_info));
639 compositor_->SetNeedsForcedRedraw(); 654 compositor_->SetNeedsForcedRedraw();
640 } 655 }
641 ScheduleComposite(); 656 ScheduleComposite();
657
658 #if defined(ENABLE_PLUGINS)
659 for (PepperPluginSet::iterator i = active_pepper_instances_.begin();
660 i != active_pepper_instances_.end(); ++i)
661 (*i)->PageVisibilityChanged(true);
662 #endif // ENABLE_PLUGINS
642 } 663 }
643 664
644 void RenderWidget::OnRequestMoveAck() { 665 void RenderWidget::OnRequestMoveAck() {
645 DCHECK(pending_window_rect_count_); 666 DCHECK(pending_window_rect_count_);
646 pending_window_rect_count_--; 667 pending_window_rect_count_--;
647 if (!pending_window_rect_count_) 668 if (!pending_window_rect_count_)
648 view_screen_rect_ = pending_window_rect_; 669 view_screen_rect_ = pending_window_rect_;
649 } 670 }
650 671
651 GURL RenderWidget::GetURLForGraphicsContext3D() { 672 GURL RenderWidget::GetURLForGraphicsContext3D() {
(...skipping 14 matching lines...) Expand all
666 } 687 }
667 688
668 void RenderWidget::OnMouseCaptureLost() { 689 void RenderWidget::OnMouseCaptureLost() {
669 if (webwidget_) 690 if (webwidget_)
670 webwidget_->mouseCaptureLost(); 691 webwidget_->mouseCaptureLost();
671 } 692 }
672 693
673 void RenderWidget::OnSetFocus(bool enable) { 694 void RenderWidget::OnSetFocus(bool enable) {
674 if (webwidget_) 695 if (webwidget_)
675 webwidget_->setFocus(enable); 696 webwidget_->setFocus(enable);
697
698 #if defined(ENABLE_PLUGINS)
699 // Notify all Pepper plugins.
700 for (PepperPluginSet::iterator i = active_pepper_instances_.begin();
701 i != active_pepper_instances_.end(); ++i)
702 (*i)->SetContentAreaFocus(enable);
703 #endif
676 } 704 }
677 705
678 /////////////////////////////////////////////////////////////////////////////// 706 ///////////////////////////////////////////////////////////////////////////////
679 // RenderWidgetCompositorDelegate 707 // RenderWidgetCompositorDelegate
680 708
681 void RenderWidget::ApplyViewportDeltas( 709 void RenderWidget::ApplyViewportDeltas(
682 const gfx::Vector2dF& inner_delta, 710 const gfx::Vector2dF& inner_delta,
683 const gfx::Vector2dF& outer_delta, 711 const gfx::Vector2dF& outer_delta,
684 const gfx::Vector2dF& elastic_overscroll_delta, 712 const gfx::Vector2dF& elastic_overscroll_delta,
685 float page_scale, 713 float page_scale,
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
1050 1078
1051 text_input_info_ = new_info; 1079 text_input_info_ = new_info;
1052 text_input_type_ = new_type; 1080 text_input_type_ = new_type;
1053 text_input_mode_ = new_mode; 1081 text_input_mode_ = new_mode;
1054 can_compose_inline_ = new_can_compose_inline; 1082 can_compose_inline_ = new_can_compose_inline;
1055 text_input_flags_ = new_info.flags; 1083 text_input_flags_ = new_info.flags;
1056 } 1084 }
1057 } 1085 }
1058 1086
1059 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { 1087 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) {
1088 #if defined(ENABLE_PLUGINS)
1089 // This method is called for every mouse event that the RenderWidget receives.
1090 // And then the mouse event is forwarded to blink, which dispatches it to the
1091 // event target. Potentially a Pepper plugin will receive the event.
1092 // In order to tell whether a plugin gets the last mouse event and which it
1093 // is, we set |pepper_last_mouse_event_target_| to null here. If a plugin gets
1094 // the event, it will notify us via DidReceiveMouseEvent() and set itself as
1095 // |pepper_last_mouse_event_target_|.
1096 pepper_last_mouse_event_target_ = nullptr;
1097 #endif
1098
1060 if (owner_delegate_) 1099 if (owner_delegate_)
1061 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); 1100 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event);
1062 1101
1063 return false; 1102 return false;
1064 } 1103 }
1065 1104
1066 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { 1105 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) {
1067 if (owner_delegate_) 1106 if (owner_delegate_)
1068 return owner_delegate_->RenderWidgetWillHandleMouseEvent(event); 1107 return owner_delegate_->RenderWidgetWillHandleMouseEvent(event);
1069 1108
(...skipping 617 matching lines...) Expand 10 before | Expand all | Expand 10 after
1687 if (owner_delegate_) 1726 if (owner_delegate_)
1688 owner_delegate_->RenderWidgetDidSetColorProfile(color_profile); 1727 owner_delegate_->RenderWidgetDidSetColorProfile(color_profile);
1689 1728
1690 return true; 1729 return true;
1691 } 1730 }
1692 1731
1693 void RenderWidget::OnOrientationChange() { 1732 void RenderWidget::OnOrientationChange() {
1694 } 1733 }
1695 1734
1696 void RenderWidget::DidInitiatePaint() { 1735 void RenderWidget::DidInitiatePaint() {
1697 if (owner_delegate_) 1736 #if defined(ENABLE_PLUGINS)
1698 owner_delegate_->RenderWidgetDidCommitAndDrawCompositorFrame(); 1737 // Notify all instances that we painted. The same caveats apply as for
1738 // ViewFlushedPaint regarding instances closing themselves, so we take
1739 // similar precautions.
1740 PepperPluginSet plugins = active_pepper_instances_;
1741 for (PepperPluginSet::iterator i = plugins.begin(); i != plugins.end(); ++i) {
1742 if (active_pepper_instances_.find(*i) != active_pepper_instances_.end())
1743 (*i)->ViewInitiatedPaint();
1744 }
1745 #endif
1699 } 1746 }
1700 1747
1701 void RenderWidget::DidFlushPaint() { 1748 void RenderWidget::DidFlushPaint() {
1702 if (owner_delegate_) 1749 if (owner_delegate_)
1703 owner_delegate_->RenderWidgetDidFlushPaint(); 1750 owner_delegate_->RenderWidgetDidFlushPaint();
1704 } 1751 }
1705 1752
1706 void RenderWidget::SetHidden(bool hidden) { 1753 void RenderWidget::SetHidden(bool hidden) {
1707 if (is_hidden_ == hidden) 1754 if (is_hidden_ == hidden)
1708 return; 1755 return;
(...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after
2073 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE); 2120 MESSAGE_DELIVERY_POLICY_WITH_VISUAL_STATE);
2074 } 2121 }
2075 2122
2076 float RenderWidget::GetOriginalDeviceScaleFactor() const { 2123 float RenderWidget::GetOriginalDeviceScaleFactor() const {
2077 return 2124 return
2078 screen_metrics_emulator_ ? 2125 screen_metrics_emulator_ ?
2079 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : 2126 screen_metrics_emulator_->original_screen_info().deviceScaleFactor :
2080 device_scale_factor_; 2127 device_scale_factor_;
2081 } 2128 }
2082 2129
2130 #if defined(ENABLE_PLUGINS)
2131 void RenderWidget::PepperInstanceCreated(PepperPluginInstanceImpl* instance) {
2132 active_pepper_instances_.insert(instance);
2133
2134 RenderFrameImpl* const render_frame = instance->render_frame();
2135 render_frame->Send(
2136 new FrameHostMsg_PepperInstanceCreated(render_frame->GetRoutingID()));
2137 }
2138
2139 void RenderWidget::PepperInstanceDeleted(PepperPluginInstanceImpl* instance) {
2140 active_pepper_instances_.erase(instance);
2141
2142 if (pepper_last_mouse_event_target_ == instance)
2143 pepper_last_mouse_event_target_ = nullptr;
2144 if (focused_pepper_plugin_ == instance)
2145 PepperFocusChanged(instance, false);
2146
2147 RenderFrameImpl* const render_frame = instance->render_frame();
2148 if (render_frame)
2149 render_frame->Send(
2150 new FrameHostMsg_PepperInstanceDeleted(render_frame->GetRoutingID()));
2151 }
2152
2153 void RenderWidget::PepperFocusChanged(PepperPluginInstanceImpl* instance,
2154 bool focused) {
2155 if (focused)
2156 focused_pepper_plugin_ = instance;
2157 else if (focused_pepper_plugin_ == instance)
2158 focused_pepper_plugin_ = nullptr;
2159
2160 UpdateTextInputState(ShowIme::HIDE_IME, ChangeSource::FROM_NON_IME);
2161 UpdateSelectionBounds();
2162 }
2163
2164 #endif // ENABLE_PLUGINS
2165
2083 } // namespace content 2166 } // namespace content
OLDNEW
« no previous file with comments | « content/renderer/render_widget.h ('k') | content/renderer/render_widget_owner_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698