| 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 "base/bind.h" | 7 #include "base/bind.h" |
| 8 #include "base/command_line.h" | 8 #include "base/command_line.h" |
| 9 #include "base/debug/trace_event.h" | 9 #include "base/debug/trace_event.h" |
| 10 #include "base/debug/trace_event_synthetic_delay.h" | 10 #include "base/debug/trace_event_synthetic_delay.h" |
| (...skipping 330 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 341 params->x += offset_.x(); | 341 params->x += offset_.x(); |
| 342 params->y *= scale_; | 342 params->y *= scale_; |
| 343 params->y += offset_.y(); | 343 params->y += offset_.y(); |
| 344 } | 344 } |
| 345 | 345 |
| 346 // RenderWidget --------------------------------------------------------------- | 346 // RenderWidget --------------------------------------------------------------- |
| 347 | 347 |
| 348 RenderWidget::RenderWidget(blink::WebPopupType popup_type, | 348 RenderWidget::RenderWidget(blink::WebPopupType popup_type, |
| 349 const blink::WebScreenInfo& screen_info, | 349 const blink::WebScreenInfo& screen_info, |
| 350 bool swapped_out, | 350 bool swapped_out, |
| 351 bool hidden) | 351 bool hidden, |
| 352 bool never_visible) |
| 352 : routing_id_(MSG_ROUTING_NONE), | 353 : routing_id_(MSG_ROUTING_NONE), |
| 353 surface_id_(0), | 354 surface_id_(0), |
| 354 webwidget_(NULL), | 355 webwidget_(NULL), |
| 355 opener_id_(MSG_ROUTING_NONE), | 356 opener_id_(MSG_ROUTING_NONE), |
| 356 init_complete_(false), | 357 init_complete_(false), |
| 357 current_paint_buf_(NULL), | 358 current_paint_buf_(NULL), |
| 358 overdraw_bottom_height_(0.f), | 359 overdraw_bottom_height_(0.f), |
| 359 next_paint_flags_(0), | 360 next_paint_flags_(0), |
| 360 filtered_time_per_frame_(0.0f), | 361 filtered_time_per_frame_(0.0f), |
| 361 update_reply_pending_(false), | 362 update_reply_pending_(false), |
| 362 auto_resize_mode_(false), | 363 auto_resize_mode_(false), |
| 363 need_update_rect_for_auto_resize_(false), | 364 need_update_rect_for_auto_resize_(false), |
| 364 using_asynchronous_swapbuffers_(false), | 365 using_asynchronous_swapbuffers_(false), |
| 365 num_swapbuffers_complete_pending_(0), | 366 num_swapbuffers_complete_pending_(0), |
| 366 did_show_(false), | 367 did_show_(false), |
| 367 is_hidden_(hidden), | 368 is_hidden_(hidden), |
| 369 never_visible_(never_visible), |
| 368 is_fullscreen_(false), | 370 is_fullscreen_(false), |
| 369 needs_repainting_on_restore_(false), | 371 needs_repainting_on_restore_(false), |
| 370 has_focus_(false), | 372 has_focus_(false), |
| 371 handling_input_event_(false), | 373 handling_input_event_(false), |
| 372 handling_ime_event_(false), | 374 handling_ime_event_(false), |
| 373 handling_touchstart_event_(false), | 375 handling_touchstart_event_(false), |
| 374 closing_(false), | 376 closing_(false), |
| 375 is_swapped_out_(swapped_out), | 377 is_swapped_out_(swapped_out), |
| 376 input_method_is_active_(false), | 378 input_method_is_active_(false), |
| 377 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), | 379 text_input_type_(ui::TEXT_INPUT_TYPE_NONE), |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 426 if (!is_swapped_out_ && RenderProcess::current()) | 428 if (!is_swapped_out_ && RenderProcess::current()) |
| 427 RenderProcess::current()->ReleaseProcess(); | 429 RenderProcess::current()->ReleaseProcess(); |
| 428 } | 430 } |
| 429 | 431 |
| 430 // static | 432 // static |
| 431 RenderWidget* RenderWidget::Create(int32 opener_id, | 433 RenderWidget* RenderWidget::Create(int32 opener_id, |
| 432 blink::WebPopupType popup_type, | 434 blink::WebPopupType popup_type, |
| 433 const blink::WebScreenInfo& screen_info) { | 435 const blink::WebScreenInfo& screen_info) { |
| 434 DCHECK(opener_id != MSG_ROUTING_NONE); | 436 DCHECK(opener_id != MSG_ROUTING_NONE); |
| 435 scoped_refptr<RenderWidget> widget( | 437 scoped_refptr<RenderWidget> widget( |
| 436 new RenderWidget(popup_type, screen_info, false, false)); | 438 new RenderWidget(popup_type, screen_info, false, false, false)); |
| 437 if (widget->Init(opener_id)) { // adds reference on success. | 439 if (widget->Init(opener_id)) { // adds reference on success. |
| 438 return widget.get(); | 440 return widget.get(); |
| 439 } | 441 } |
| 440 return NULL; | 442 return NULL; |
| 441 } | 443 } |
| 442 | 444 |
| 443 // static | 445 // static |
| 444 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { | 446 WebWidget* RenderWidget::CreateWebWidget(RenderWidget* render_widget) { |
| 445 switch (render_widget->popup_type_) { | 447 switch (render_widget->popup_type_) { |
| 446 case blink::WebPopupTypeNone: // Nothing to create. | 448 case blink::WebPopupTypeNone: // Nothing to create. |
| (...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 493 | 495 |
| 494 // This is used to complete pending inits and non-pending inits. | 496 // This is used to complete pending inits and non-pending inits. |
| 495 void RenderWidget::CompleteInit() { | 497 void RenderWidget::CompleteInit() { |
| 496 DCHECK(routing_id_ != MSG_ROUTING_NONE); | 498 DCHECK(routing_id_ != MSG_ROUTING_NONE); |
| 497 | 499 |
| 498 init_complete_ = true; | 500 init_complete_ = true; |
| 499 | 501 |
| 500 if (webwidget_ && is_threaded_compositing_enabled_) { | 502 if (webwidget_ && is_threaded_compositing_enabled_) { |
| 501 webwidget_->enterForceCompositingMode(true); | 503 webwidget_->enterForceCompositingMode(true); |
| 502 } | 504 } |
| 503 if (compositor_) { | 505 if (compositor_) |
| 504 compositor_->setSurfaceReady(); | 506 StartCompositor(); |
| 505 } | |
| 506 DoDeferredUpdate(); | 507 DoDeferredUpdate(); |
| 507 | 508 |
| 508 Send(new ViewHostMsg_RenderViewReady(routing_id_)); | 509 Send(new ViewHostMsg_RenderViewReady(routing_id_)); |
| 509 } | 510 } |
| 510 | 511 |
| 511 void RenderWidget::SetSwappedOut(bool is_swapped_out) { | 512 void RenderWidget::SetSwappedOut(bool is_swapped_out) { |
| 512 // We should only toggle between states. | 513 // We should only toggle between states. |
| 513 DCHECK(is_swapped_out_ != is_swapped_out); | 514 DCHECK(is_swapped_out_ != is_swapped_out); |
| 514 is_swapped_out_ = is_swapped_out; | 515 is_swapped_out_ = is_swapped_out; |
| 515 | 516 |
| (...skipping 357 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 873 | 874 |
| 874 GURL RenderWidget::GetURLForGraphicsContext3D() { | 875 GURL RenderWidget::GetURLForGraphicsContext3D() { |
| 875 return GURL(); | 876 return GURL(); |
| 876 } | 877 } |
| 877 | 878 |
| 878 bool RenderWidget::ForceCompositingModeEnabled() { | 879 bool RenderWidget::ForceCompositingModeEnabled() { |
| 879 return false; | 880 return false; |
| 880 } | 881 } |
| 881 | 882 |
| 882 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { | 883 scoped_ptr<cc::OutputSurface> RenderWidget::CreateOutputSurface(bool fallback) { |
| 884 // For widgets that are never visible, we don't start the compositor, so we |
| 885 // never get a request for a cc::OutputSurface. |
| 886 DCHECK(!never_visible_); |
| 883 | 887 |
| 884 #if defined(OS_ANDROID) | 888 #if defined(OS_ANDROID) |
| 885 if (SynchronousCompositorFactory* factory = | 889 if (SynchronousCompositorFactory* factory = |
| 886 SynchronousCompositorFactory::GetInstance()) { | 890 SynchronousCompositorFactory::GetInstance()) { |
| 887 return factory->CreateOutputSurface(routing_id()); | 891 return factory->CreateOutputSurface(routing_id()); |
| 888 } | 892 } |
| 889 #endif | 893 #endif |
| 890 | 894 |
| 891 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); | 895 const CommandLine& command_line = *CommandLine::ForCurrentProcess(); |
| 892 bool use_software = fallback; | 896 bool use_software = fallback; |
| (...skipping 965 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1858 } | 1862 } |
| 1859 | 1863 |
| 1860 void RenderWidget::initializeLayerTreeView() { | 1864 void RenderWidget::initializeLayerTreeView() { |
| 1861 compositor_ = RenderWidgetCompositor::Create( | 1865 compositor_ = RenderWidgetCompositor::Create( |
| 1862 this, is_threaded_compositing_enabled_); | 1866 this, is_threaded_compositing_enabled_); |
| 1863 if (!compositor_) | 1867 if (!compositor_) |
| 1864 return; | 1868 return; |
| 1865 | 1869 |
| 1866 compositor_->setViewportSize(size_, physical_backing_size_); | 1870 compositor_->setViewportSize(size_, physical_backing_size_); |
| 1867 if (init_complete_) | 1871 if (init_complete_) |
| 1868 compositor_->setSurfaceReady(); | 1872 StartCompositor(); |
| 1869 } | 1873 } |
| 1870 | 1874 |
| 1871 blink::WebLayerTreeView* RenderWidget::layerTreeView() { | 1875 blink::WebLayerTreeView* RenderWidget::layerTreeView() { |
| 1872 return compositor_.get(); | 1876 return compositor_.get(); |
| 1873 } | 1877 } |
| 1874 | 1878 |
| 1875 void RenderWidget::suppressCompositorScheduling(bool enable) { | 1879 void RenderWidget::suppressCompositorScheduling(bool enable) { |
| 1876 if (compositor_) | 1880 if (compositor_) |
| 1877 compositor_->SetSuppressScheduleComposite(enable); | 1881 compositor_->SetSuppressScheduleComposite(enable); |
| 1878 } | 1882 } |
| (...skipping 772 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2651 #if defined(OS_ANDROID) || defined(USE_AURA) | 2655 #if defined(OS_ANDROID) || defined(USE_AURA) |
| 2652 if (event_cancelled) | 2656 if (event_cancelled) |
| 2653 return; | 2657 return; |
| 2654 if (event.type == WebInputEvent::GestureTap || | 2658 if (event.type == WebInputEvent::GestureTap || |
| 2655 event.type == WebInputEvent::GestureLongPress) { | 2659 event.type == WebInputEvent::GestureLongPress) { |
| 2656 UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_NON_IME); | 2660 UpdateTextInputState(SHOW_IME_IF_NEEDED, FROM_NON_IME); |
| 2657 } | 2661 } |
| 2658 #endif | 2662 #endif |
| 2659 } | 2663 } |
| 2660 | 2664 |
| 2665 void RenderWidget::StartCompositor() { |
| 2666 // For widgets that are never visible, we don't need the compositor to run |
| 2667 // at all. |
| 2668 if (never_visible_) |
| 2669 return; |
| 2670 compositor_->setSurfaceReady(); |
| 2671 } |
| 2672 |
| 2661 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { | 2673 void RenderWidget::SchedulePluginMove(const WebPluginGeometry& move) { |
| 2662 size_t i = 0; | 2674 size_t i = 0; |
| 2663 for (; i < plugin_window_moves_.size(); ++i) { | 2675 for (; i < plugin_window_moves_.size(); ++i) { |
| 2664 if (plugin_window_moves_[i].window == move.window) { | 2676 if (plugin_window_moves_[i].window == move.window) { |
| 2665 if (move.rects_valid) { | 2677 if (move.rects_valid) { |
| 2666 plugin_window_moves_[i] = move; | 2678 plugin_window_moves_[i] = move; |
| 2667 } else { | 2679 } else { |
| 2668 plugin_window_moves_[i].visible = move.visible; | 2680 plugin_window_moves_[i].visible = move.visible; |
| 2669 } | 2681 } |
| 2670 break; | 2682 break; |
| (...skipping 148 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2819 | 2831 |
| 2820 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2832 void RenderWidget::RegisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
| 2821 swapped_out_frames_.AddObserver(frame); | 2833 swapped_out_frames_.AddObserver(frame); |
| 2822 } | 2834 } |
| 2823 | 2835 |
| 2824 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { | 2836 void RenderWidget::UnregisterSwappedOutChildFrame(RenderFrameImpl* frame) { |
| 2825 swapped_out_frames_.RemoveObserver(frame); | 2837 swapped_out_frames_.RemoveObserver(frame); |
| 2826 } | 2838 } |
| 2827 | 2839 |
| 2828 } // namespace content | 2840 } // namespace content |
| OLD | NEW |