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_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 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
88 #include "ui/base/ui_base_switches.h" | 88 #include "ui/base/ui_base_switches.h" |
89 #include "ui/gfx/geometry/point_conversions.h" | 89 #include "ui/gfx/geometry/point_conversions.h" |
90 #include "ui/gfx/geometry/rect_conversions.h" | 90 #include "ui/gfx/geometry/rect_conversions.h" |
91 #include "ui/gfx/geometry/size_conversions.h" | 91 #include "ui/gfx/geometry/size_conversions.h" |
92 #include "ui/gfx/skia_util.h" | 92 #include "ui/gfx/skia_util.h" |
93 #include "ui/gl/gl_switches.h" | 93 #include "ui/gl/gl_switches.h" |
94 #include "ui/surface/transport_dib.h" | 94 #include "ui/surface/transport_dib.h" |
95 | 95 |
96 #if defined(OS_ANDROID) | 96 #if defined(OS_ANDROID) |
97 #include <android/keycodes.h> | 97 #include <android/keycodes.h> |
98 #include "base/time/time.h" | |
99 #endif | 98 #endif |
100 | 99 |
101 #if defined(OS_POSIX) | 100 #if defined(OS_POSIX) |
102 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 101 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
103 #include "third_party/skia/include/core/SkPixelRef.h" | 102 #include "third_party/skia/include/core/SkPixelRef.h" |
104 #endif // defined(OS_POSIX) | 103 #endif // defined(OS_POSIX) |
105 | 104 |
106 #if defined(USE_AURA) | 105 #if defined(USE_AURA) |
107 #include "content/public/common/service_manager_connection.h" | 106 #include "content/public/common/service_manager_connection.h" |
108 #include "content/renderer/mus/render_widget_mus_connection.h" | 107 #include "content/renderer/mus/render_widget_mus_connection.h" |
(...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
374 composition_range_(gfx::Range::InvalidRange()), | 373 composition_range_(gfx::Range::InvalidRange()), |
375 popup_type_(popup_type), | 374 popup_type_(popup_type), |
376 pending_window_rect_count_(0), | 375 pending_window_rect_count_(0), |
377 screen_info_(screen_info), | 376 screen_info_(screen_info), |
378 device_scale_factor_(screen_info_.device_scale_factor), | 377 device_scale_factor_(screen_info_.device_scale_factor), |
379 monitor_composition_info_(false), | 378 monitor_composition_info_(false), |
380 popup_origin_scale_for_emulation_(0.f), | 379 popup_origin_scale_for_emulation_(0.f), |
381 frame_swap_message_queue_(new FrameSwapMessageQueue()), | 380 frame_swap_message_queue_(new FrameSwapMessageQueue()), |
382 resizing_mode_selector_(new ResizingModeSelector()), | 381 resizing_mode_selector_(new ResizingModeSelector()), |
383 has_host_context_menu_location_(false), | 382 has_host_context_menu_location_(false), |
384 has_added_input_handler_(false), | |
385 has_focus_(false), | 383 has_focus_(false), |
386 #if defined(OS_MACOSX) | 384 #if defined(OS_MACOSX) |
387 text_input_client_observer_(new TextInputClientObserver(this)), | 385 text_input_client_observer_(new TextInputClientObserver(this)), |
388 #endif | 386 #endif |
389 focused_pepper_plugin_(nullptr), | 387 focused_pepper_plugin_(nullptr) { |
390 weak_ptr_factory_(this) { | |
391 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); | 388 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
392 if (!swapped_out) | 389 if (!swapped_out) |
393 RenderProcess::current()->AddRefProcess(); | 390 RenderProcess::current()->AddRefProcess(); |
394 DCHECK(RenderThread::Get()); | 391 DCHECK(RenderThread::Get()); |
395 | 392 |
396 // In tests there may not be a RenderThreadImpl. | 393 // In tests there may not be a RenderThreadImpl. |
397 if (RenderThreadImpl::current()) { | 394 if (RenderThreadImpl::current()) { |
398 render_widget_scheduling_state_ = RenderThreadImpl::current() | 395 render_widget_scheduling_state_ = RenderThreadImpl::current() |
399 ->GetRendererScheduler() | 396 ->GetRendererScheduler() |
400 ->NewRenderWidgetSchedulingState(); | 397 ->NewRenderWidgetSchedulingState(); |
(...skipping 28 matching lines...) Expand all Loading... |
429 int32_t routing_id = MSG_ROUTING_NONE; | 426 int32_t routing_id = MSG_ROUTING_NONE; |
430 if (!RenderThreadImpl::current_render_message_filter()->CreateNewWidget( | 427 if (!RenderThreadImpl::current_render_message_filter()->CreateNewWidget( |
431 opener->GetRoutingID(), popup_type, &routing_id)) { | 428 opener->GetRoutingID(), popup_type, &routing_id)) { |
432 return nullptr; | 429 return nullptr; |
433 } | 430 } |
434 | 431 |
435 scoped_refptr<RenderWidget> widget( | 432 scoped_refptr<RenderWidget> widget( |
436 new RenderWidget(routing_id, compositor_deps, popup_type, screen_info, | 433 new RenderWidget(routing_id, compositor_deps, popup_type, screen_info, |
437 false, false, false)); | 434 false, false, false)); |
438 ShowCallback opener_callback = | 435 ShowCallback opener_callback = |
439 base::Bind(&RenderViewImpl::ShowCreatedPopupWidget, opener->GetWeakPtr()); | 436 base::Bind(&RenderViewImpl::ShowCreatedPopupWidget, opener->AsWeakPtr()); |
440 widget->Init(opener_callback, RenderWidget::CreateWebWidget(widget.get())); | 437 widget->Init(opener_callback, RenderWidget::CreateWebWidget(widget.get())); |
441 DCHECK(!widget->HasOneRef()); // RenderWidget::Init() adds a reference. | 438 DCHECK(!widget->HasOneRef()); // RenderWidget::Init() adds a reference. |
442 return widget.get(); | 439 return widget.get(); |
443 } | 440 } |
444 | 441 |
445 // static | 442 // static |
446 RenderWidget* RenderWidget::CreateForFrame( | 443 RenderWidget* RenderWidget::CreateForFrame( |
447 int widget_routing_id, | 444 int widget_routing_id, |
448 bool hidden, | 445 bool hidden, |
449 const ScreenInfo& screen_info, | 446 const ScreenInfo& screen_info, |
(...skipping 779 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1229 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_); | 1226 physical_backing_size_ = gfx::ScaleToCeiledSize(size_, device_scale_factor_); |
1230 if (compositor_) | 1227 if (compositor_) |
1231 compositor_->setViewportSize(physical_backing_size_); | 1228 compositor_->setViewportSize(physical_backing_size_); |
1232 } | 1229 } |
1233 | 1230 |
1234 blink::WebLayerTreeView* RenderWidget::initializeLayerTreeView() { | 1231 blink::WebLayerTreeView* RenderWidget::initializeLayerTreeView() { |
1235 DCHECK(!host_closing_); | 1232 DCHECK(!host_closing_); |
1236 | 1233 |
1237 compositor_ = RenderWidgetCompositor::Create(this, device_scale_factor_, | 1234 compositor_ = RenderWidgetCompositor::Create(this, device_scale_factor_, |
1238 screen_info_, compositor_deps_); | 1235 screen_info_, compositor_deps_); |
1239 compositor_->SetIsForOopif(for_oopif_); | |
1240 compositor_->setViewportSize(physical_backing_size_); | 1236 compositor_->setViewportSize(physical_backing_size_); |
1241 OnDeviceScaleFactorChanged(); | 1237 OnDeviceScaleFactorChanged(); |
1242 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); | 1238 compositor_->SetDeviceColorSpace(screen_info_.icc_profile.GetColorSpace()); |
1243 // For background pages and certain tests, we don't want to trigger | 1239 // For background pages and certain tests, we don't want to trigger |
1244 // CompositorFrameSink creation. | 1240 // CompositorFrameSink creation. |
1245 if (compositor_never_visible_ || !RenderThreadImpl::current()) | 1241 if (compositor_never_visible_ || !RenderThreadImpl::current()) |
1246 compositor_->SetNeverVisible(); | 1242 compositor_->SetNeverVisible(); |
1247 | 1243 |
1248 StartCompositor(); | 1244 StartCompositor(); |
1249 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); | 1245 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); |
1250 compositor_->SetFrameSinkId( | 1246 compositor_->SetFrameSinkId( |
1251 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); | 1247 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); |
1252 | 1248 |
1253 RenderThreadImpl* render_thread = RenderThreadImpl::current(); | |
1254 // render_thread may be NULL in tests. | |
1255 InputHandlerManager* input_handler_manager = | |
1256 render_thread ? render_thread->input_handler_manager() : NULL; | |
1257 if (input_handler_manager) { | |
1258 input_handler_manager->AddInputHandler( | |
1259 routing_id_, compositor()->GetInputHandler(), | |
1260 weak_ptr_factory_.GetWeakPtr(), | |
1261 compositor_deps_->IsScrollAnimatorEnabled()); | |
1262 has_added_input_handler_ = true; | |
1263 } | |
1264 | |
1265 return compositor_.get(); | 1249 return compositor_.get(); |
1266 } | 1250 } |
1267 | 1251 |
1268 void RenderWidget::WillCloseLayerTreeView() { | 1252 void RenderWidget::WillCloseLayerTreeView() { |
1269 if (host_closing_) | 1253 if (host_closing_) |
1270 return; | 1254 return; |
1271 | 1255 |
1272 // Prevent new compositors or output surfaces from being created. | 1256 // Prevent new compositors or output surfaces from being created. |
1273 host_closing_ = true; | 1257 host_closing_ = true; |
1274 | 1258 |
(...skipping 911 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2186 } | 2170 } |
2187 | 2171 |
2188 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { | 2172 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { |
2189 if (render_widget_scheduling_state_) | 2173 if (render_widget_scheduling_state_) |
2190 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); | 2174 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); |
2191 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); | 2175 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); |
2192 } | 2176 } |
2193 | 2177 |
2194 void RenderWidget::setTouchAction( | 2178 void RenderWidget::setTouchAction( |
2195 blink::WebTouchAction web_touch_action) { | 2179 blink::WebTouchAction web_touch_action) { |
| 2180 |
2196 // Ignore setTouchAction calls that result from synthetic touch events (eg. | 2181 // Ignore setTouchAction calls that result from synthetic touch events (eg. |
2197 // when blink is emulating touch with mouse). | 2182 // when blink is emulating touch with mouse). |
2198 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) | 2183 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) |
2199 return; | 2184 return; |
2200 | 2185 |
2201 content::TouchAction content_touch_action = | 2186 content::TouchAction content_touch_action = |
2202 static_cast<content::TouchAction>(web_touch_action); | 2187 static_cast<content::TouchAction>(web_touch_action); |
2203 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2188 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
2204 } | 2189 } |
2205 | 2190 |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2278 // browser side (https://crbug.com/669219). | 2263 // browser side (https://crbug.com/669219). |
2279 // If there is no WebFrameWidget, then there will be no | 2264 // If there is no WebFrameWidget, then there will be no |
2280 // InputMethodControllers for a WebLocalFrame. | 2265 // InputMethodControllers for a WebLocalFrame. |
2281 return nullptr; | 2266 return nullptr; |
2282 } | 2267 } |
2283 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2268 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
2284 ->getActiveWebInputMethodController(); | 2269 ->getActiveWebInputMethodController(); |
2285 } | 2270 } |
2286 | 2271 |
2287 } // namespace content | 2272 } // namespace content |
OLD | NEW |