| 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 #include "third_party/WebKit/public/platform/WebString.h" | 74 #include "third_party/WebKit/public/platform/WebString.h" |
| 75 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" | 75 #include "third_party/WebKit/public/web/WebDeviceEmulationParams.h" |
| 76 #include "third_party/WebKit/public/web/WebFrameWidget.h" | 76 #include "third_party/WebKit/public/web/WebFrameWidget.h" |
| 77 #include "third_party/WebKit/public/web/WebLocalFrame.h" | 77 #include "third_party/WebKit/public/web/WebLocalFrame.h" |
| 78 #include "third_party/WebKit/public/web/WebNode.h" | 78 #include "third_party/WebKit/public/web/WebNode.h" |
| 79 #include "third_party/WebKit/public/web/WebPagePopup.h" | 79 #include "third_party/WebKit/public/web/WebPagePopup.h" |
| 80 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" | 80 #include "third_party/WebKit/public/web/WebPopupMenuInfo.h" |
| 81 #include "third_party/WebKit/public/web/WebRange.h" | 81 #include "third_party/WebKit/public/web/WebRange.h" |
| 82 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" | 82 #include "third_party/WebKit/public/web/WebRuntimeFeatures.h" |
| 83 #include "third_party/WebKit/public/web/WebView.h" | 83 #include "third_party/WebKit/public/web/WebView.h" |
| 84 #include "third_party/WebKit/public/web/WebWidget.h" |
| 84 #include "third_party/skia/include/core/SkShader.h" | 85 #include "third_party/skia/include/core/SkShader.h" |
| 85 #include "ui/base/ui_base_switches.h" | 86 #include "ui/base/ui_base_switches.h" |
| 86 #include "ui/gfx/geometry/point_conversions.h" | 87 #include "ui/gfx/geometry/point_conversions.h" |
| 87 #include "ui/gfx/geometry/rect_conversions.h" | 88 #include "ui/gfx/geometry/rect_conversions.h" |
| 88 #include "ui/gfx/geometry/size_conversions.h" | 89 #include "ui/gfx/geometry/size_conversions.h" |
| 89 #include "ui/gfx/skia_util.h" | 90 #include "ui/gfx/skia_util.h" |
| 90 #include "ui/gl/gl_switches.h" | 91 #include "ui/gl/gl_switches.h" |
| 91 #include "ui/surface/transport_dib.h" | 92 #include "ui/surface/transport_dib.h" |
| 92 | 93 |
| 93 #if defined(OS_ANDROID) | 94 #if defined(OS_ANDROID) |
| 94 #include <android/keycodes.h> | 95 #include <android/keycodes.h> |
| 95 #include "content/renderer/android/synchronous_compositor_filter.h" | 96 #include "content/renderer/android/synchronous_compositor_filter.h" |
| 96 #include "content/renderer/android/synchronous_compositor_output_surface.h" | 97 #include "content/renderer/android/synchronous_compositor_output_surface.h" |
| 97 #endif | 98 #endif |
| 98 | 99 |
| 99 #if defined(OS_POSIX) | 100 #if defined(OS_POSIX) |
| 100 #include "ipc/ipc_channel_posix.h" | 101 #include "ipc/ipc_channel_posix.h" |
| 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(MOJO_SHELL_CLIENT) | 106 #if defined(MOJO_SHELL_CLIENT) |
| 106 #include "content/public/common/mojo_shell_connection.h" | 107 #include "content/public/common/mojo_shell_connection.h" |
| 107 #include "content/renderer/mus/render_widget_mus_connection.h" | 108 #include "content/renderer/mus/render_widget_mus_connection.h" |
| 108 #endif | 109 #endif |
| 109 | 110 |
| 110 #include "third_party/WebKit/public/web/WebWidget.h" | |
| 111 | |
| 112 using blink::WebCompositionUnderline; | 111 using blink::WebCompositionUnderline; |
| 113 using blink::WebCursorInfo; | 112 using blink::WebCursorInfo; |
| 114 using blink::WebDeviceEmulationParams; | 113 using blink::WebDeviceEmulationParams; |
| 115 using blink::WebGestureEvent; | 114 using blink::WebGestureEvent; |
| 116 using blink::WebInputEvent; | 115 using blink::WebInputEvent; |
| 117 using blink::WebInputEventResult; | 116 using blink::WebInputEventResult; |
| 118 using blink::WebKeyboardEvent; | 117 using blink::WebKeyboardEvent; |
| 119 using blink::WebMouseEvent; | 118 using blink::WebMouseEvent; |
| 120 using blink::WebMouseWheelEvent; | 119 using blink::WebMouseWheelEvent; |
| 121 using blink::WebNavigationPolicy; | 120 using blink::WebNavigationPolicy; |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 pending_window_rect_count_(0), | 239 pending_window_rect_count_(0), |
| 241 screen_info_(screen_info), | 240 screen_info_(screen_info), |
| 242 device_scale_factor_(screen_info_.deviceScaleFactor), | 241 device_scale_factor_(screen_info_.deviceScaleFactor), |
| 243 next_output_surface_id_(0), | 242 next_output_surface_id_(0), |
| 244 #if defined(OS_ANDROID) | 243 #if defined(OS_ANDROID) |
| 245 text_field_is_dirty_(false), | 244 text_field_is_dirty_(false), |
| 246 #endif | 245 #endif |
| 247 popup_origin_scale_for_emulation_(0.f), | 246 popup_origin_scale_for_emulation_(0.f), |
| 248 frame_swap_message_queue_(new FrameSwapMessageQueue()), | 247 frame_swap_message_queue_(new FrameSwapMessageQueue()), |
| 249 resizing_mode_selector_(new ResizingModeSelector()), | 248 resizing_mode_selector_(new ResizingModeSelector()), |
| 250 has_host_context_menu_location_(false) { | 249 has_host_context_menu_location_(false), |
| 250 has_focus_(false) { |
| 251 if (!swapped_out) | 251 if (!swapped_out) |
| 252 RenderProcess::current()->AddRefProcess(); | 252 RenderProcess::current()->AddRefProcess(); |
| 253 DCHECK(RenderThread::Get()); | 253 DCHECK(RenderThread::Get()); |
| 254 device_color_profile_.push_back('0'); | 254 device_color_profile_.push_back('0'); |
| 255 #if defined(OS_ANDROID) | 255 #if defined(OS_ANDROID) |
| 256 text_input_info_history_.push_back(blink::WebTextInputInfo()); | 256 text_input_info_history_.push_back(blink::WebTextInputInfo()); |
| 257 #endif | 257 #endif |
| 258 | 258 |
| 259 // In tests there may not be a RenderThreadImpl. | 259 // In tests there may not be a RenderThreadImpl. |
| 260 if (RenderThreadImpl::current()) { | 260 if (RenderThreadImpl::current()) { |
| (...skipping 403 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 664 if (webwidget_) | 664 if (webwidget_) |
| 665 webwidget_->setCursorVisibilityState(is_visible); | 665 webwidget_->setCursorVisibilityState(is_visible); |
| 666 } | 666 } |
| 667 | 667 |
| 668 void RenderWidget::OnMouseCaptureLost() { | 668 void RenderWidget::OnMouseCaptureLost() { |
| 669 if (webwidget_) | 669 if (webwidget_) |
| 670 webwidget_->mouseCaptureLost(); | 670 webwidget_->mouseCaptureLost(); |
| 671 } | 671 } |
| 672 | 672 |
| 673 void RenderWidget::OnSetFocus(bool enable) { | 673 void RenderWidget::OnSetFocus(bool enable) { |
| 674 has_focus_ = enable; |
| 675 |
| 674 if (webwidget_) | 676 if (webwidget_) |
| 675 webwidget_->setFocus(enable); | 677 webwidget_->setFocus(enable); |
| 678 |
| 679 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
| 680 RenderWidgetSetFocus(enable)); |
| 676 } | 681 } |
| 677 | 682 |
| 678 /////////////////////////////////////////////////////////////////////////////// | 683 /////////////////////////////////////////////////////////////////////////////// |
| 679 // RenderWidgetCompositorDelegate | 684 // RenderWidgetCompositorDelegate |
| 680 | 685 |
| 681 void RenderWidget::ApplyViewportDeltas( | 686 void RenderWidget::ApplyViewportDeltas( |
| 682 const gfx::Vector2dF& inner_delta, | 687 const gfx::Vector2dF& inner_delta, |
| 683 const gfx::Vector2dF& outer_delta, | 688 const gfx::Vector2dF& outer_delta, |
| 684 const gfx::Vector2dF& elastic_overscroll_delta, | 689 const gfx::Vector2dF& elastic_overscroll_delta, |
| 685 float page_scale, | 690 float page_scale, |
| (...skipping 126 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 812 | 817 |
| 813 std::unique_ptr<cc::BeginFrameSource> | 818 std::unique_ptr<cc::BeginFrameSource> |
| 814 RenderWidget::CreateExternalBeginFrameSource() { | 819 RenderWidget::CreateExternalBeginFrameSource() { |
| 815 return compositor_deps_->CreateExternalBeginFrameSource(routing_id_); | 820 return compositor_deps_->CreateExternalBeginFrameSource(routing_id_); |
| 816 } | 821 } |
| 817 | 822 |
| 818 void RenderWidget::DidCommitAndDrawCompositorFrame() { | 823 void RenderWidget::DidCommitAndDrawCompositorFrame() { |
| 819 // NOTE: Tests may break if this event is renamed or moved. See | 824 // NOTE: Tests may break if this event is renamed or moved. See |
| 820 // tab_capture_performancetest.cc. | 825 // tab_capture_performancetest.cc. |
| 821 TRACE_EVENT0("gpu", "RenderWidget::DidCommitAndDrawCompositorFrame"); | 826 TRACE_EVENT0("gpu", "RenderWidget::DidCommitAndDrawCompositorFrame"); |
| 827 |
| 828 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
| 829 DidCommitAndDrawCompositorFrame()); |
| 830 |
| 822 // Notify subclasses that we initiated the paint operation. | 831 // Notify subclasses that we initiated the paint operation. |
| 823 DidInitiatePaint(); | 832 DidInitiatePaint(); |
| 824 } | 833 } |
| 825 | 834 |
| 826 void RenderWidget::DidCommitCompositorFrame() { | 835 void RenderWidget::DidCommitCompositorFrame() { |
| 827 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, | 836 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
| 828 DidCommitCompositorFrame()); | 837 DidCommitCompositorFrame()); |
| 829 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, | 838 FOR_EACH_OBSERVER(RenderFrameProxy, render_frame_proxies_, |
| 830 DidCommitCompositorFrame()); | 839 DidCommitCompositorFrame()); |
| 831 #if defined(VIDEO_HOLE) | 840 #if defined(VIDEO_HOLE) |
| (...skipping 225 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1057 } | 1066 } |
| 1058 | 1067 |
| 1059 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { | 1068 bool RenderWidget::WillHandleGestureEvent(const blink::WebGestureEvent& event) { |
| 1060 if (owner_delegate_) | 1069 if (owner_delegate_) |
| 1061 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); | 1070 return owner_delegate_->RenderWidgetWillHandleGestureEvent(event); |
| 1062 | 1071 |
| 1063 return false; | 1072 return false; |
| 1064 } | 1073 } |
| 1065 | 1074 |
| 1066 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { | 1075 bool RenderWidget::WillHandleMouseEvent(const blink::WebMouseEvent& event) { |
| 1076 FOR_EACH_OBSERVER(RenderFrameImpl, render_frames_, |
| 1077 RenderWidgetWillHandleMouseEvent()); |
| 1078 |
| 1067 if (owner_delegate_) | 1079 if (owner_delegate_) |
| 1068 return owner_delegate_->RenderWidgetWillHandleMouseEvent(event); | 1080 return owner_delegate_->RenderWidgetWillHandleMouseEvent(event); |
| 1069 | 1081 |
| 1070 return false; | 1082 return false; |
| 1071 } | 1083 } |
| 1072 | 1084 |
| 1073 /////////////////////////////////////////////////////////////////////////////// | 1085 /////////////////////////////////////////////////////////////////////////////// |
| 1074 // RenderWidgetScreenMetricsDelegate | 1086 // RenderWidgetScreenMetricsDelegate |
| 1075 | 1087 |
| 1076 void RenderWidget::Redraw() { | 1088 void RenderWidget::Redraw() { |
| (...skipping 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1686 | 1698 |
| 1687 if (owner_delegate_) | 1699 if (owner_delegate_) |
| 1688 owner_delegate_->RenderWidgetDidSetColorProfile(color_profile); | 1700 owner_delegate_->RenderWidgetDidSetColorProfile(color_profile); |
| 1689 | 1701 |
| 1690 return true; | 1702 return true; |
| 1691 } | 1703 } |
| 1692 | 1704 |
| 1693 void RenderWidget::OnOrientationChange() { | 1705 void RenderWidget::OnOrientationChange() { |
| 1694 } | 1706 } |
| 1695 | 1707 |
| 1696 void RenderWidget::DidInitiatePaint() { | |
| 1697 if (owner_delegate_) | |
| 1698 owner_delegate_->RenderWidgetDidCommitAndDrawCompositorFrame(); | |
| 1699 } | |
| 1700 | |
| 1701 void RenderWidget::DidFlushPaint() { | 1708 void RenderWidget::DidFlushPaint() { |
| 1702 if (owner_delegate_) | 1709 if (owner_delegate_) |
| 1703 owner_delegate_->RenderWidgetDidFlushPaint(); | 1710 owner_delegate_->RenderWidgetDidFlushPaint(); |
| 1704 } | 1711 } |
| 1705 | 1712 |
| 1706 void RenderWidget::SetHidden(bool hidden) { | 1713 void RenderWidget::SetHidden(bool hidden) { |
| 1707 if (is_hidden_ == hidden) | 1714 if (is_hidden_ == hidden) |
| 1708 return; | 1715 return; |
| 1709 | 1716 |
| 1710 // The status has changed. Tell the RenderThread about it and ensure | 1717 // The status has changed. Tell the RenderThread about it and ensure |
| (...skipping 363 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2074 } | 2081 } |
| 2075 | 2082 |
| 2076 float RenderWidget::GetOriginalDeviceScaleFactor() const { | 2083 float RenderWidget::GetOriginalDeviceScaleFactor() const { |
| 2077 return | 2084 return |
| 2078 screen_metrics_emulator_ ? | 2085 screen_metrics_emulator_ ? |
| 2079 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : | 2086 screen_metrics_emulator_->original_screen_info().deviceScaleFactor : |
| 2080 device_scale_factor_; | 2087 device_scale_factor_; |
| 2081 } | 2088 } |
| 2082 | 2089 |
| 2083 } // namespace content | 2090 } // namespace content |
| OLD | NEW |