| 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" |
| 98 #endif | 99 #endif |
| 99 | 100 |
| 100 #if defined(OS_POSIX) | 101 #if defined(OS_POSIX) |
| 101 #include "third_party/skia/include/core/SkMallocPixelRef.h" | 102 #include "third_party/skia/include/core/SkMallocPixelRef.h" |
| 102 #include "third_party/skia/include/core/SkPixelRef.h" | 103 #include "third_party/skia/include/core/SkPixelRef.h" |
| 103 #endif // defined(OS_POSIX) | 104 #endif // defined(OS_POSIX) |
| 104 | 105 |
| 105 #if defined(USE_AURA) | 106 #if defined(USE_AURA) |
| 106 #include "content/public/common/service_manager_connection.h" | 107 #include "content/public/common/service_manager_connection.h" |
| 107 #include "content/renderer/mus/render_widget_mus_connection.h" | 108 #include "content/renderer/mus/render_widget_mus_connection.h" |
| (...skipping 265 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 373 composition_range_(gfx::Range::InvalidRange()), | 374 composition_range_(gfx::Range::InvalidRange()), |
| 374 popup_type_(popup_type), | 375 popup_type_(popup_type), |
| 375 pending_window_rect_count_(0), | 376 pending_window_rect_count_(0), |
| 376 screen_info_(screen_info), | 377 screen_info_(screen_info), |
| 377 device_scale_factor_(screen_info_.device_scale_factor), | 378 device_scale_factor_(screen_info_.device_scale_factor), |
| 378 monitor_composition_info_(false), | 379 monitor_composition_info_(false), |
| 379 popup_origin_scale_for_emulation_(0.f), | 380 popup_origin_scale_for_emulation_(0.f), |
| 380 frame_swap_message_queue_(new FrameSwapMessageQueue()), | 381 frame_swap_message_queue_(new FrameSwapMessageQueue()), |
| 381 resizing_mode_selector_(new ResizingModeSelector()), | 382 resizing_mode_selector_(new ResizingModeSelector()), |
| 382 has_host_context_menu_location_(false), | 383 has_host_context_menu_location_(false), |
| 384 has_added_input_handler_(false), |
| 383 has_focus_(false), | 385 has_focus_(false), |
| 384 #if defined(OS_MACOSX) | 386 #if defined(OS_MACOSX) |
| 385 text_input_client_observer_(new TextInputClientObserver(this)), | 387 text_input_client_observer_(new TextInputClientObserver(this)), |
| 386 #endif | 388 #endif |
| 387 focused_pepper_plugin_(nullptr) { | 389 focused_pepper_plugin_(nullptr), |
| 390 weak_ptr_factory_(this) { |
| 388 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); | 391 DCHECK_NE(routing_id_, MSG_ROUTING_NONE); |
| 389 if (!swapped_out) | 392 if (!swapped_out) |
| 390 RenderProcess::current()->AddRefProcess(); | 393 RenderProcess::current()->AddRefProcess(); |
| 391 DCHECK(RenderThread::Get()); | 394 DCHECK(RenderThread::Get()); |
| 392 | 395 |
| 393 // In tests there may not be a RenderThreadImpl. | 396 // In tests there may not be a RenderThreadImpl. |
| 394 if (RenderThreadImpl::current()) { | 397 if (RenderThreadImpl::current()) { |
| 395 render_widget_scheduling_state_ = RenderThreadImpl::current() | 398 render_widget_scheduling_state_ = RenderThreadImpl::current() |
| 396 ->GetRendererScheduler() | 399 ->GetRendererScheduler() |
| 397 ->NewRenderWidgetSchedulingState(); | 400 ->NewRenderWidgetSchedulingState(); |
| (...skipping 28 matching lines...) Expand all Loading... |
| 426 int32_t routing_id = MSG_ROUTING_NONE; | 429 int32_t routing_id = MSG_ROUTING_NONE; |
| 427 if (!RenderThreadImpl::current_render_message_filter()->CreateNewWidget( | 430 if (!RenderThreadImpl::current_render_message_filter()->CreateNewWidget( |
| 428 opener->GetRoutingID(), popup_type, &routing_id)) { | 431 opener->GetRoutingID(), popup_type, &routing_id)) { |
| 429 return nullptr; | 432 return nullptr; |
| 430 } | 433 } |
| 431 | 434 |
| 432 scoped_refptr<RenderWidget> widget( | 435 scoped_refptr<RenderWidget> widget( |
| 433 new RenderWidget(routing_id, compositor_deps, popup_type, screen_info, | 436 new RenderWidget(routing_id, compositor_deps, popup_type, screen_info, |
| 434 false, false, false)); | 437 false, false, false)); |
| 435 ShowCallback opener_callback = | 438 ShowCallback opener_callback = |
| 436 base::Bind(&RenderViewImpl::ShowCreatedPopupWidget, opener->AsWeakPtr()); | 439 base::Bind(&RenderViewImpl::ShowCreatedPopupWidget, opener->GetWeakPtr()); |
| 437 widget->Init(opener_callback, RenderWidget::CreateWebWidget(widget.get())); | 440 widget->Init(opener_callback, RenderWidget::CreateWebWidget(widget.get())); |
| 438 DCHECK(!widget->HasOneRef()); // RenderWidget::Init() adds a reference. | 441 DCHECK(!widget->HasOneRef()); // RenderWidget::Init() adds a reference. |
| 439 return widget.get(); | 442 return widget.get(); |
| 440 } | 443 } |
| 441 | 444 |
| 442 // static | 445 // static |
| 443 RenderWidget* RenderWidget::CreateForFrame( | 446 RenderWidget* RenderWidget::CreateForFrame( |
| 444 int widget_routing_id, | 447 int widget_routing_id, |
| 445 bool hidden, | 448 bool hidden, |
| 446 const ScreenInfo& screen_info, | 449 const ScreenInfo& screen_info, |
| (...skipping 797 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1244 // For background pages and certain tests, we don't want to trigger | 1247 // For background pages and certain tests, we don't want to trigger |
| 1245 // CompositorFrameSink creation. | 1248 // CompositorFrameSink creation. |
| 1246 if (compositor_never_visible_ || !RenderThreadImpl::current()) | 1249 if (compositor_never_visible_ || !RenderThreadImpl::current()) |
| 1247 compositor_->SetNeverVisible(); | 1250 compositor_->SetNeverVisible(); |
| 1248 | 1251 |
| 1249 StartCompositor(); | 1252 StartCompositor(); |
| 1250 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); | 1253 DCHECK_NE(MSG_ROUTING_NONE, routing_id_); |
| 1251 compositor_->SetFrameSinkId( | 1254 compositor_->SetFrameSinkId( |
| 1252 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); | 1255 cc::FrameSinkId(RenderThread::Get()->GetClientId(), routing_id_)); |
| 1253 | 1256 |
| 1257 RenderThreadImpl* render_thread = RenderThreadImpl::current(); |
| 1258 // render_thread may be NULL in tests. |
| 1259 InputHandlerManager* input_handler_manager = |
| 1260 render_thread ? render_thread->input_handler_manager() : NULL; |
| 1261 if (input_handler_manager) { |
| 1262 input_handler_manager->AddInputHandler( |
| 1263 routing_id_, compositor()->GetInputHandler(), |
| 1264 weak_ptr_factory_.GetWeakPtr(), |
| 1265 compositor_deps_->IsScrollAnimatorEnabled()); |
| 1266 has_added_input_handler_ = true; |
| 1267 } |
| 1268 |
| 1254 return compositor_.get(); | 1269 return compositor_.get(); |
| 1255 } | 1270 } |
| 1256 | 1271 |
| 1257 void RenderWidget::WillCloseLayerTreeView() { | 1272 void RenderWidget::WillCloseLayerTreeView() { |
| 1258 if (host_closing_) | 1273 if (host_closing_) |
| 1259 return; | 1274 return; |
| 1260 | 1275 |
| 1261 // Prevent new compositors or output surfaces from being created. | 1276 // Prevent new compositors or output surfaces from being created. |
| 1262 host_closing_ = true; | 1277 host_closing_ = true; |
| 1263 | 1278 |
| (...skipping 916 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2180 } | 2195 } |
| 2181 | 2196 |
| 2182 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { | 2197 void RenderWidget::hasTouchEventHandlers(bool has_handlers) { |
| 2183 if (render_widget_scheduling_state_) | 2198 if (render_widget_scheduling_state_) |
| 2184 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); | 2199 render_widget_scheduling_state_->SetHasTouchHandler(has_handlers); |
| 2185 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); | 2200 Send(new ViewHostMsg_HasTouchEventHandlers(routing_id_, has_handlers)); |
| 2186 } | 2201 } |
| 2187 | 2202 |
| 2188 void RenderWidget::setTouchAction( | 2203 void RenderWidget::setTouchAction( |
| 2189 blink::WebTouchAction web_touch_action) { | 2204 blink::WebTouchAction web_touch_action) { |
| 2190 | |
| 2191 // Ignore setTouchAction calls that result from synthetic touch events (eg. | 2205 // Ignore setTouchAction calls that result from synthetic touch events (eg. |
| 2192 // when blink is emulating touch with mouse). | 2206 // when blink is emulating touch with mouse). |
| 2193 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) | 2207 if (input_handler_->handling_event_type() != WebInputEvent::TouchStart) |
| 2194 return; | 2208 return; |
| 2195 | 2209 |
| 2196 content::TouchAction content_touch_action = | 2210 content::TouchAction content_touch_action = |
| 2197 static_cast<content::TouchAction>(web_touch_action); | 2211 static_cast<content::TouchAction>(web_touch_action); |
| 2198 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); | 2212 Send(new InputHostMsg_SetTouchAction(routing_id_, content_touch_action)); |
| 2199 } | 2213 } |
| 2200 | 2214 |
| (...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2273 // browser side (https://crbug.com/669219). | 2287 // browser side (https://crbug.com/669219). |
| 2274 // If there is no WebFrameWidget, then there will be no | 2288 // If there is no WebFrameWidget, then there will be no |
| 2275 // InputMethodControllers for a WebLocalFrame. | 2289 // InputMethodControllers for a WebLocalFrame. |
| 2276 return nullptr; | 2290 return nullptr; |
| 2277 } | 2291 } |
| 2278 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) | 2292 return static_cast<blink::WebFrameWidget*>(GetWebWidget()) |
| 2279 ->getActiveWebInputMethodController(); | 2293 ->getActiveWebInputMethodController(); |
| 2280 } | 2294 } |
| 2281 | 2295 |
| 2282 } // namespace content | 2296 } // namespace content |
| OLD | NEW |