Chromium Code Reviews| 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/logging.h" | 10 #include "base/logging.h" |
| (...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 72 #endif // defined(OS_POSIX) | 72 #endif // defined(OS_POSIX) |
| 73 | 73 |
| 74 #include "third_party/WebKit/public/web/WebWidget.h" | 74 #include "third_party/WebKit/public/web/WebWidget.h" |
| 75 | 75 |
| 76 using WebKit::WebCompositionUnderline; | 76 using WebKit::WebCompositionUnderline; |
| 77 using WebKit::WebCursorInfo; | 77 using WebKit::WebCursorInfo; |
| 78 using WebKit::WebGestureEvent; | 78 using WebKit::WebGestureEvent; |
| 79 using WebKit::WebInputEvent; | 79 using WebKit::WebInputEvent; |
| 80 using WebKit::WebKeyboardEvent; | 80 using WebKit::WebKeyboardEvent; |
| 81 using WebKit::WebMouseEvent; | 81 using WebKit::WebMouseEvent; |
| 82 using WebKit::WebMouseWheelEvent; | |
| 82 using WebKit::WebNavigationPolicy; | 83 using WebKit::WebNavigationPolicy; |
| 83 using WebKit::WebPagePopup; | 84 using WebKit::WebPagePopup; |
| 84 using WebKit::WebPoint; | 85 using WebKit::WebPoint; |
| 85 using WebKit::WebPopupMenu; | 86 using WebKit::WebPopupMenu; |
| 86 using WebKit::WebPopupMenuInfo; | 87 using WebKit::WebPopupMenuInfo; |
| 87 using WebKit::WebPopupType; | 88 using WebKit::WebPopupType; |
| 88 using WebKit::WebRange; | 89 using WebKit::WebRange; |
| 89 using WebKit::WebRect; | 90 using WebKit::WebRect; |
| 90 using WebKit::WebScreenInfo; | 91 using WebKit::WebScreenInfo; |
| 91 using WebKit::WebSize; | 92 using WebKit::WebSize; |
| (...skipping 281 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 373 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) | 374 IPC_MESSAGE_HANDLER(ViewMsg_Close, OnClose) |
| 374 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) | 375 IPC_MESSAGE_HANDLER(ViewMsg_CreatingNew_ACK, OnCreatingNewAck) |
| 375 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) | 376 IPC_MESSAGE_HANDLER(ViewMsg_Resize, OnResize) |
| 376 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) | 377 IPC_MESSAGE_HANDLER(ViewMsg_ChangeResizeRect, OnChangeResizeRect) |
| 377 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) | 378 IPC_MESSAGE_HANDLER(ViewMsg_WasHidden, OnWasHidden) |
| 378 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) | 379 IPC_MESSAGE_HANDLER(ViewMsg_WasShown, OnWasShown) |
| 379 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) | 380 IPC_MESSAGE_HANDLER(ViewMsg_WasSwappedOut, OnWasSwappedOut) |
| 380 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) | 381 IPC_MESSAGE_HANDLER(ViewMsg_UpdateRect_ACK, OnUpdateRectAck) |
| 381 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, | 382 IPC_MESSAGE_HANDLER(ViewMsg_SwapBuffers_ACK, |
| 382 OnViewContextSwapBuffersComplete) | 383 OnViewContextSwapBuffersComplete) |
| 384 IPC_MESSAGE_HANDLER(ViewMsg_EmulateDevice_ACK, OnEmulateDeviceAck) | |
| 383 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) | 385 IPC_MESSAGE_HANDLER(ViewMsg_SetInputMethodActive, OnSetInputMethodActive) |
| 384 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) | 386 IPC_MESSAGE_HANDLER(ViewMsg_ImeSetComposition, OnImeSetComposition) |
| 385 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) | 387 IPC_MESSAGE_HANDLER(ViewMsg_ImeConfirmComposition, OnImeConfirmComposition) |
| 386 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize) | 388 IPC_MESSAGE_HANDLER(ViewMsg_PaintAtSize, OnPaintAtSize) |
| 387 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) | 389 IPC_MESSAGE_HANDLER(ViewMsg_Repaint, OnRepaint) |
| 388 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted) | 390 IPC_MESSAGE_HANDLER(ViewMsg_SmoothScrollCompleted, OnSmoothScrollCompleted) |
| 389 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) | 391 IPC_MESSAGE_HANDLER(ViewMsg_SetTextDirection, OnSetTextDirection) |
| 390 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) | 392 IPC_MESSAGE_HANDLER(ViewMsg_Move_ACK, OnRequestMoveAck) |
| 391 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) | 393 IPC_MESSAGE_HANDLER(ViewMsg_UpdateScreenRects, OnUpdateScreenRects) |
| 392 #if defined(OS_ANDROID) | 394 #if defined(OS_ANDROID) |
| (...skipping 115 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 508 // If there is a Send call on the stack, then it could be dangerous to close | 510 // If there is a Send call on the stack, then it could be dangerous to close |
| 509 // now. Post a task that only gets invoked when there are no nested message | 511 // now. Post a task that only gets invoked when there are no nested message |
| 510 // loops. | 512 // loops. |
| 511 base::MessageLoop::current()->PostNonNestableTask( | 513 base::MessageLoop::current()->PostNonNestableTask( |
| 512 FROM_HERE, base::Bind(&RenderWidget::Close, this)); | 514 FROM_HERE, base::Bind(&RenderWidget::Close, this)); |
| 513 | 515 |
| 514 // Balances the AddRef taken when we called AddRoute. | 516 // Balances the AddRef taken when we called AddRoute. |
| 515 Release(); | 517 Release(); |
| 516 } | 518 } |
| 517 | 519 |
| 520 void RenderWidget::EmulateDevice( | |
| 521 bool enabled, | |
| 522 const gfx::Size& device_size, | |
| 523 const gfx::Rect& widget_rect, | |
| 524 float device_scale_factor, | |
| 525 bool fit_to_view) { | |
| 526 pending_device_emulation_enabled_ = enabled; | |
| 527 if (enabled) { | |
| 528 pending_device_emulation_helper_.reset(new DeviceEmulationHelper( | |
| 529 device_size, | |
| 530 widget_rect, | |
| 531 device_scale_factor, | |
| 532 fit_to_view)); | |
| 533 } else { | |
| 534 pending_device_emulation_helper_.reset(); | |
| 535 } | |
| 536 Send(new ViewHostMsg_EmulateDevice(routing_id_, enabled)); | |
| 537 } | |
| 538 | |
| 539 void RenderWidget::OnEmulateDeviceAck(bool enabled) { | |
| 540 // We may have got another emulate device request while sending message | |
| 541 // to the host. If the host idea of whether device emulation is enabled | |
| 542 // differs, wait for another ack with the right |enabled| value. | |
| 543 if (enabled != pending_device_emulation_enabled_) | |
| 544 return; | |
| 545 | |
| 546 if (pending_device_emulation_enabled_) { | |
| 547 if (!device_emulation_helper_) { | |
| 548 device_emulation_helper_ = pending_device_emulation_helper_.Pass(); | |
| 549 device_emulation_helper_->BeginEmulation(this); | |
| 550 } else { | |
| 551 device_emulation_helper_->ChangeEmulationParams( | |
| 552 this, pending_device_emulation_helper_.get()); | |
| 553 pending_device_emulation_helper_.reset(); | |
| 554 } | |
| 555 } else { | |
| 556 if (device_emulation_helper_) | |
| 557 device_emulation_helper_->EndEmulation(this); | |
| 558 device_emulation_helper_.reset(); | |
| 559 } | |
| 560 } | |
| 561 | |
| 518 // Got a response from the browser after the renderer decided to create a new | 562 // Got a response from the browser after the renderer decided to create a new |
| 519 // view. | 563 // view. |
| 520 void RenderWidget::OnCreatingNewAck() { | 564 void RenderWidget::OnCreatingNewAck() { |
| 521 DCHECK(routing_id_ != MSG_ROUTING_NONE); | 565 DCHECK(routing_id_ != MSG_ROUTING_NONE); |
| 522 | 566 |
| 523 CompleteInit(); | 567 CompleteInit(); |
| 524 } | 568 } |
| 525 | 569 |
| 526 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { | 570 void RenderWidget::OnResize(const ViewMsg_Resize_Params& params) { |
| 571 if (device_emulation_helper_) { | |
| 572 device_emulation_helper_->OnResizeMessage(this, params); | |
| 573 return; | |
| 574 } | |
| 575 | |
| 527 screen_info_ = params.screen_info; | 576 screen_info_ = params.screen_info; |
| 528 SetDeviceScaleFactor(screen_info_.deviceScaleFactor); | 577 SetDeviceScaleFactor(screen_info_.deviceScaleFactor); |
| 529 Resize(params.new_size, params.physical_backing_size, | 578 Resize(params.new_size, params.physical_backing_size, |
| 530 params.overdraw_bottom_height, params.resizer_rect, | 579 params.overdraw_bottom_height, params.resizer_rect, |
| 531 params.is_fullscreen, SEND_RESIZE_ACK); | 580 params.is_fullscreen, SEND_RESIZE_ACK); |
| 532 } | 581 } |
| 533 | 582 |
| 534 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { | 583 void RenderWidget::OnChangeResizeRect(const gfx::Rect& resizer_rect) { |
| 535 if (resizer_rect_ != resizer_rect) { | 584 if (resizer_rect_ != resizer_rect) { |
| 536 gfx::Rect view_rect(size_); | 585 gfx::Rect view_rect(size_); |
| (...skipping 245 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 782 } | 831 } |
| 783 | 832 |
| 784 // Continue painting if necessary... | 833 // Continue painting if necessary... |
| 785 DoDeferredUpdateAndSendInputAck(); | 834 DoDeferredUpdateAndSendInputAck(); |
| 786 } | 835 } |
| 787 | 836 |
| 788 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, | 837 void RenderWidget::OnHandleInputEvent(const WebKit::WebInputEvent* input_event, |
| 789 const ui::LatencyInfo& latency_info, | 838 const ui::LatencyInfo& latency_info, |
| 790 bool is_keyboard_shortcut) { | 839 bool is_keyboard_shortcut) { |
| 791 handling_input_event_ = true; | 840 handling_input_event_ = true; |
| 841 | |
| 842 scoped_ptr<const WebKit::WebInputEvent> owner; | |
| 843 if (device_emulation_helper_) { | |
| 844 input_event = device_emulation_helper_->ConvertInputEventToEmulated( | |
| 845 this, input_event); | |
| 846 if (input_event) | |
| 847 owner.reset(input_event); | |
| 848 } | |
| 849 | |
| 792 if (!input_event) { | 850 if (!input_event) { |
| 793 handling_input_event_ = false; | 851 handling_input_event_ = false; |
| 794 return; | 852 return; |
| 795 } | 853 } |
| 796 | 854 |
| 797 const char* const event_name = GetEventName(input_event->type); | 855 const char* const event_name = GetEventName(input_event->type); |
| 798 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", | 856 TRACE_EVENT1("renderer", "RenderWidget::OnHandleInputEvent", |
| 799 "event", event_name); | 857 "event", event_name); |
| 800 | 858 |
| 801 if (compositor_) | 859 if (compositor_) |
| (...skipping 959 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1761 return pending_window_rect_; | 1819 return pending_window_rect_; |
| 1762 | 1820 |
| 1763 return view_screen_rect_; | 1821 return view_screen_rect_; |
| 1764 } | 1822 } |
| 1765 | 1823 |
| 1766 void RenderWidget::setToolTipText(const WebKit::WebString& text, | 1824 void RenderWidget::setToolTipText(const WebKit::WebString& text, |
| 1767 WebTextDirection hint) { | 1825 WebTextDirection hint) { |
| 1768 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); | 1826 Send(new ViewHostMsg_SetTooltipText(routing_id_, text, hint)); |
| 1769 } | 1827 } |
| 1770 | 1828 |
| 1771 void RenderWidget::setWindowRect(const WebRect& pos) { | 1829 void RenderWidget::setWindowRect(const WebRect& rect) { |
| 1830 WebRect pos = rect; | |
| 1831 if (popup_device_emulation_helper_) { | |
| 1832 pos = popup_device_emulation_helper_->ConvertPopupScreenRectFromEmulated( | |
| 1833 this, rect); | |
| 1834 } | |
| 1835 | |
| 1772 if (did_show_) { | 1836 if (did_show_) { |
| 1773 if (!RenderThreadImpl::current()->layout_test_mode()) { | 1837 if (!RenderThreadImpl::current()->layout_test_mode()) { |
| 1774 Send(new ViewHostMsg_RequestMove(routing_id_, pos)); | 1838 Send(new ViewHostMsg_RequestMove(routing_id_, pos)); |
| 1775 SetPendingWindowRect(pos); | 1839 SetPendingWindowRect(pos); |
| 1776 } else { | 1840 } else { |
| 1777 WebSize new_size(pos.width, pos.height); | 1841 WebSize new_size(pos.width, pos.height); |
| 1778 Resize(new_size, new_size, overdraw_bottom_height_, | 1842 Resize(new_size, new_size, overdraw_bottom_height_, |
| 1779 WebRect(), is_fullscreen_, NO_RESIZE_ACK); | 1843 WebRect(), is_fullscreen_, NO_RESIZE_ACK); |
| 1780 view_screen_rect_ = pos; | 1844 view_screen_rect_ = pos; |
| 1781 window_screen_rect_ = pos; | 1845 window_screen_rect_ = pos; |
| (...skipping 220 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2002 } | 2066 } |
| 2003 | 2067 |
| 2004 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 2068 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
| 2005 if (!webwidget_) | 2069 if (!webwidget_) |
| 2006 return; | 2070 return; |
| 2007 webwidget_->setTextDirection(direction); | 2071 webwidget_->setTextDirection(direction); |
| 2008 } | 2072 } |
| 2009 | 2073 |
| 2010 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, | 2074 void RenderWidget::OnUpdateScreenRects(const gfx::Rect& view_screen_rect, |
| 2011 const gfx::Rect& window_screen_rect) { | 2075 const gfx::Rect& window_screen_rect) { |
| 2076 if (device_emulation_helper_) { | |
| 2077 device_emulation_helper_->OnUpdateScreenRectsMessage( | |
| 2078 this, view_screen_rect, window_screen_rect); | |
| 2079 return; | |
| 2080 } | |
| 2012 view_screen_rect_ = view_screen_rect; | 2081 view_screen_rect_ = view_screen_rect; |
| 2013 window_screen_rect_ = window_screen_rect; | 2082 window_screen_rect_ = window_screen_rect; |
| 2014 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); | 2083 Send(new ViewHostMsg_UpdateScreenRects_ACK(routing_id())); |
| 2015 } | 2084 } |
| 2016 | 2085 |
| 2017 #if defined(OS_ANDROID) | 2086 #if defined(OS_ANDROID) |
| 2018 void RenderWidget::OnImeBatchStateChanged(bool is_begin) { | 2087 void RenderWidget::OnImeBatchStateChanged(bool is_begin) { |
| 2019 Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin)); | 2088 Send(new ViewHostMsg_ImeBatchStateChanged_ACK(routing_id(), is_begin)); |
| 2020 } | 2089 } |
| 2021 | 2090 |
| (...skipping 499 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2521 weak_ptr_factory_.GetWeakPtr())); | 2590 weak_ptr_factory_.GetWeakPtr())); |
| 2522 | 2591 |
| 2523 if (!context->InitializeWithDefaultBufferSizes( | 2592 if (!context->InitializeWithDefaultBufferSizes( |
| 2524 attributes, | 2593 attributes, |
| 2525 false /* bind generates resources */, | 2594 false /* bind generates resources */, |
| 2526 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) | 2595 CAUSE_FOR_GPU_LAUNCH_WEBGRAPHICSCONTEXT3DCOMMANDBUFFERIMPL_INITIALIZE) ) |
| 2527 return NULL; | 2596 return NULL; |
| 2528 return context.release(); | 2597 return context.release(); |
| 2529 } | 2598 } |
| 2530 | 2599 |
| 2600 RenderWidget::DeviceEmulationHelper::DeviceEmulationHelper( | |
| 2601 const gfx::Size& device_size, | |
| 2602 const gfx::Rect& widget_rect, | |
| 2603 float device_scale_factor, | |
| 2604 bool fit_to_view) | |
| 2605 : device_size_(device_size), | |
| 2606 widget_rect_(widget_rect), | |
| 2607 device_scale_factor_(device_scale_factor), | |
| 2608 fit_to_view_(fit_to_view), | |
| 2609 weak_ptr_factory_(this) { | |
| 2610 } | |
| 2611 | |
| 2612 RenderWidget::DeviceEmulationHelper::~DeviceEmulationHelper() { | |
| 2613 } | |
| 2614 | |
| 2615 void RenderWidget::DeviceEmulationHelper::BeginEmulation(RenderWidget* widget) { | |
| 2616 original_size_ = widget->size_; | |
| 2617 original_physical_backing_size_ = widget->physical_backing_size_; | |
| 2618 original_screen_info_ = widget->screen_info_; | |
| 2619 original_view_screen_rect_ = widget->view_screen_rect_; | |
| 2620 original_window_screen_rect_ = widget->window_screen_rect_; | |
| 2621 Apply(widget, widget->overdraw_bottom_height_, widget->resizer_rect_, | |
| 2622 widget->is_fullscreen_); | |
| 2623 } | |
| 2624 | |
| 2625 void RenderWidget::DeviceEmulationHelper::ChangeEmulationParams( | |
| 2626 RenderWidget* widget, DeviceEmulationHelper* params) { | |
| 2627 device_size_ = params->device_size_; | |
| 2628 widget_rect_ = params->widget_rect_; | |
| 2629 device_scale_factor_ = params->device_scale_factor_; | |
| 2630 fit_to_view_ = params->fit_to_view_; | |
| 2631 Apply(widget, widget->overdraw_bottom_height_, widget->resizer_rect_, | |
| 2632 widget->is_fullscreen_); | |
| 2633 } | |
| 2634 | |
| 2635 void RenderWidget::DeviceEmulationHelper::EndEmulation(RenderWidget* widget) { | |
| 2636 widget->screen_info_ = original_screen_info_; | |
| 2637 if (widget->compositor_) { | |
| 2638 // Passing zero cancels override. | |
| 2639 widget->compositor_->OverrideDeviceScaleFactor(0.f); | |
| 2640 } | |
| 2641 widget->SetDeviceScaleFactor(original_screen_info_.deviceScaleFactor); | |
| 2642 widget->view_screen_rect_ = original_view_screen_rect_; | |
| 2643 widget->window_screen_rect_ = original_window_screen_rect_; | |
| 2644 widget->Resize(original_size_, | |
| 2645 original_physical_backing_size_, | |
| 2646 widget->overdraw_bottom_height_, widget->resizer_rect_, | |
| 2647 widget->is_fullscreen_, NO_RESIZE_ACK); | |
| 2648 } | |
| 2649 | |
| 2650 void RenderWidget::DeviceEmulationHelper::Apply(RenderWidget* widget, | |
| 2651 float overdraw_bottom_height, gfx::Rect resizer_rect, bool is_fullscreen) { | |
| 2652 widget->screen_info_.rect = gfx::Rect(device_size_); | |
| 2653 widget->screen_info_.availableRect = gfx::Rect(device_size_); | |
| 2654 widget->screen_info_.deviceScaleFactor = device_scale_factor_; | |
| 2655 | |
| 2656 if (widget->compositor_) { | |
| 2657 // We keep the real device scale factor in compositor to prevent unnecessary | |
| 2658 // scaling on browser side. This override ensures that compositor | |
| 2659 // will not change scale factor due to WebLayerTreeView's call. | |
| 2660 widget->compositor_->OverrideDeviceScaleFactor( | |
| 2661 original_screen_info_.deviceScaleFactor); | |
| 2662 } | |
| 2663 | |
| 2664 widget->SetDeviceScaleFactor(device_scale_factor_); | |
| 2665 widget->view_screen_rect_ = widget_rect_; | |
| 2666 widget->window_screen_rect_ = widget->screen_info_.availableRect; | |
| 2667 | |
| 2668 gfx::Size physical_backing_size = gfx::ToCeiledSize(gfx::ScaleSize( | |
| 2669 widget_rect_.size(), original_screen_info_.deviceScaleFactor)); | |
| 2670 widget->Resize(widget_rect_.size(), physical_backing_size, | |
| 2671 overdraw_bottom_height, resizer_rect, | |
| 2672 is_fullscreen, NO_RESIZE_ACK); | |
| 2673 } | |
| 2674 | |
| 2675 void RenderWidget::DeviceEmulationHelper::OnResizeMessage( | |
| 2676 RenderWidget* widget, const ViewMsg_Resize_Params& params) { | |
| 2677 bool need_ack = params.new_size != original_size_; | |
| 2678 original_size_ = params.new_size; | |
| 2679 original_physical_backing_size_ = params.physical_backing_size; | |
| 2680 original_screen_info_ = params.screen_info; | |
| 2681 Apply(widget, params.overdraw_bottom_height, params.resizer_rect, | |
| 2682 params.is_fullscreen); | |
| 2683 | |
| 2684 if (need_ack) { | |
| 2685 widget->set_next_paint_is_resize_ack(); | |
| 2686 if (widget->is_accelerated_compositing_active_ && widget->compositor_) | |
| 2687 widget->compositor_->SetNeedsRedrawRect(gfx::Rect(widget->size_)); | |
| 2688 else | |
| 2689 widget->didInvalidateRect(gfx::Rect(widget->size_)); | |
| 2690 } | |
| 2691 } | |
| 2692 | |
| 2693 void RenderWidget::DeviceEmulationHelper::OnUpdateScreenRectsMessage( | |
| 2694 RenderWidget* widget, | |
| 2695 const gfx::Rect view_screen_rect, | |
| 2696 const gfx::Rect window_screen_rect) { | |
| 2697 original_view_screen_rect_ = view_screen_rect; | |
| 2698 original_window_screen_rect_ = window_screen_rect; | |
| 2699 widget->Send(new ViewHostMsg_UpdateScreenRects_ACK(widget->routing_id())); | |
| 2700 } | |
| 2701 | |
| 2702 WebKit::WebInputEvent* RenderWidget::DeviceEmulationHelper::ConvertInputEventToE mulated( | |
|
aelias_OOO_until_Jul13
2013/09/05 08:26:49
The CC impl thread captures input events as well.
dgozman
2013/09/10 19:54:02
As I understand, CC event handling is not interest
aelias_OOO_until_Jul13
2013/09/10 20:33:34
OK, I didn't notice you were only changing those s
dgozman
2013/09/10 20:55:36
Well, wrong screen position of events will conflic
aelias_OOO_until_Jul13
2013/09/10 21:00:02
should be restored back to apply backward scale.
| |
| 2703 RenderWidget* widget, const WebKit::WebInputEvent* event) { | |
| 2704 if (!event) | |
| 2705 return NULL; | |
| 2706 | |
| 2707 if (WebInputEvent::isKeyboardEventType(event->type)) { | |
| 2708 const WebKeyboardEvent& keyboard_event = | |
| 2709 *static_cast<const WebKeyboardEvent*>(event); | |
| 2710 WebKeyboardEvent* result = new WebKeyboardEvent(keyboard_event); | |
| 2711 return result; | |
| 2712 } | |
| 2713 | |
| 2714 if (WebInputEvent::isMouseEventType(event->type)) { | |
| 2715 const WebMouseEvent& mouse_event = | |
| 2716 *static_cast<const WebMouseEvent*>(event); | |
| 2717 WebMouseEvent* result = new WebMouseEvent(mouse_event); | |
| 2718 ConvertMouseEventToEmulated(result); | |
| 2719 return result; | |
| 2720 } | |
| 2721 | |
| 2722 if (WebInputEvent::MouseWheel == event->type) { | |
| 2723 const WebMouseWheelEvent& mouse_wheel_event = | |
| 2724 *static_cast<const WebMouseWheelEvent*>(event); | |
| 2725 WebMouseWheelEvent* result = new WebMouseWheelEvent(mouse_wheel_event); | |
| 2726 ConvertMouseEventToEmulated(result); | |
| 2727 return result; | |
| 2728 } | |
| 2729 | |
| 2730 if (WebInputEvent::isGestureEventType(event->type)) { | |
| 2731 const WebGestureEvent& gesture_event = | |
| 2732 *static_cast<const WebGestureEvent*>(event); | |
| 2733 WebGestureEvent* result = new WebGestureEvent(gesture_event); | |
| 2734 result->globalX = widget_rect_.x() + result->x; | |
| 2735 result->globalY = widget_rect_.y() + result->y; | |
| 2736 return result; | |
| 2737 } | |
| 2738 | |
| 2739 if (WebInputEvent::isTouchEventType(event->type)) { | |
| 2740 const WebTouchEvent& touch_event = | |
| 2741 *static_cast<const WebTouchEvent*>(event); | |
| 2742 WebTouchEvent* result = new WebTouchEvent(touch_event); | |
| 2743 for (size_t index = 0; index < result->touchesLength; ++index) { | |
| 2744 ConvertTouchPointToEmulated(&result->touches[index]); | |
| 2745 } | |
| 2746 for (size_t index = 0; index < result->changedTouchesLength; ++index) { | |
| 2747 ConvertTouchPointToEmulated(&result->changedTouches[index]); | |
| 2748 } | |
| 2749 for (size_t index = 0; index < result->targetTouchesLength; ++index) { | |
| 2750 ConvertTouchPointToEmulated(&result->targetTouches[index]); | |
| 2751 } | |
| 2752 return result; | |
| 2753 } | |
| 2754 | |
| 2755 return NULL; | |
| 2756 } | |
| 2757 | |
| 2758 void RenderWidget::DeviceEmulationHelper::ConvertMouseEventToEmulated( | |
| 2759 WebKit::WebMouseEvent* event) { | |
| 2760 event->windowX = widget_rect_.x() + event->x; | |
| 2761 event->windowY = widget_rect_.y() + event->y; | |
| 2762 event->globalX = event->windowX; | |
| 2763 event->globalY = event->windowY; | |
| 2764 } | |
| 2765 | |
| 2766 void RenderWidget::DeviceEmulationHelper::ConvertTouchPointToEmulated( | |
| 2767 WebKit::WebTouchPoint* point) { | |
| 2768 point->screenPosition.x = widget_rect_.x() + point->position.x; | |
| 2769 point->screenPosition.y = widget_rect_.y() + point->position.y; | |
| 2770 } | |
| 2771 | |
| 2772 void RenderWidget::DeviceEmulationHelper::PopupCreated( | |
| 2773 RenderWidget* widget, RenderWidget* popup) { | |
| 2774 popup->popup_device_emulation_helper_ = weak_ptr_factory_.GetWeakPtr(); | |
| 2775 } | |
| 2776 | |
| 2777 WebKit::WebRect RenderWidget::DeviceEmulationHelper::ConvertPopupScreenRectFromE mulated( | |
| 2778 RenderWidget* popup, const WebKit::WebRect& rect) { | |
| 2779 WebKit::WebRect result = rect; | |
| 2780 result.x = original_view_screen_rect_.x() + | |
| 2781 result.x - widget_rect_.x(); | |
| 2782 result.y = original_view_screen_rect_.y() + | |
| 2783 result.y - widget_rect_.y(); | |
| 2784 return result; | |
| 2785 } | |
| 2786 | |
| 2531 } // namespace content | 2787 } // namespace content |
| OLD | NEW |