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 143 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
154 can_compose_inline_(true), | 154 can_compose_inline_(true), |
155 popup_type_(popup_type), | 155 popup_type_(popup_type), |
156 pending_window_rect_count_(0), | 156 pending_window_rect_count_(0), |
157 suppress_next_char_events_(false), | 157 suppress_next_char_events_(false), |
158 is_accelerated_compositing_active_(false), | 158 is_accelerated_compositing_active_(false), |
159 animation_update_pending_(false), | 159 animation_update_pending_(false), |
160 invalidation_task_posted_(false), | 160 invalidation_task_posted_(false), |
161 screen_info_(screen_info), | 161 screen_info_(screen_info), |
162 device_scale_factor_(screen_info_.deviceScaleFactor), | 162 device_scale_factor_(screen_info_.deviceScaleFactor), |
163 throttle_input_events_(true), | 163 throttle_input_events_(true), |
164 next_smooth_scroll_gesture_id_(0), | |
165 is_threaded_compositing_enabled_(false) { | 164 is_threaded_compositing_enabled_(false) { |
166 if (!swapped_out) | 165 if (!swapped_out) |
167 RenderProcess::current()->AddRefProcess(); | 166 RenderProcess::current()->AddRefProcess(); |
168 DCHECK(RenderThread::Get()); | 167 DCHECK(RenderThread::Get()); |
169 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( | 168 has_disable_gpu_vsync_switch_ = CommandLine::ForCurrentProcess()->HasSwitch( |
170 switches::kDisableGpuVsync); | 169 switches::kDisableGpuVsync); |
171 is_threaded_compositing_enabled_ = | 170 is_threaded_compositing_enabled_ = |
172 CommandLine::ForCurrentProcess()->HasSwitch( | 171 CommandLine::ForCurrentProcess()->HasSwitch( |
173 switches::kEnableThreadedCompositing); | 172 switches::kEnableThreadedCompositing); |
174 } | 173 } |
(...skipping 1555 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 if (is_accelerated_compositing_active_) { | 1729 if (is_accelerated_compositing_active_) { |
1731 if (compositor_) | 1730 if (compositor_) |
1732 compositor_->setNeedsRedraw(); | 1731 compositor_->setNeedsRedraw(); |
1733 scheduleComposite(); | 1732 scheduleComposite(); |
1734 } else { | 1733 } else { |
1735 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); | 1734 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); |
1736 didInvalidateRect(repaint_rect); | 1735 didInvalidateRect(repaint_rect); |
1737 } | 1736 } |
1738 } | 1737 } |
1739 | 1738 |
1740 void RenderWidget::OnSmoothScrollCompleted(int gesture_id) { | 1739 void RenderWidget::OnSmoothScrollCompleted() { |
1741 PendingSmoothScrollGestureMap::iterator it = | 1740 pending_smooth_scroll_gesture_.Run(); |
1742 pending_smooth_scroll_gestures_.find(gesture_id); | |
1743 DCHECK(it != pending_smooth_scroll_gestures_.end()); | |
1744 it->second.Run(); | |
1745 pending_smooth_scroll_gestures_.erase(it); | |
1746 } | 1741 } |
1747 | 1742 |
1748 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 1743 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
1749 if (!webwidget_) | 1744 if (!webwidget_) |
1750 return; | 1745 return; |
1751 webwidget_->setTextDirection(direction); | 1746 webwidget_->setTextDirection(direction); |
1752 } | 1747 } |
1753 | 1748 |
1754 void RenderWidget::OnScreenInfoChanged( | 1749 void RenderWidget::OnScreenInfoChanged( |
1755 const WebKit::WebScreenInfo& screen_info) { | 1750 const WebKit::WebScreenInfo& screen_info) { |
(...skipping 338 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2094 } | 2089 } |
2095 | 2090 |
2096 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { | 2091 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
2097 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 2092 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
2098 if (!gpu_channel) | 2093 if (!gpu_channel) |
2099 return false; | 2094 return false; |
2100 | 2095 |
2101 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); | 2096 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); |
2102 } | 2097 } |
2103 | 2098 |
2104 void RenderWidget::BeginSmoothScroll( | 2099 bool RenderWidget::BeginSmoothScroll( |
2105 bool down, | 2100 bool down, |
2106 const SmoothScrollCompletionCallback& callback, | 2101 const SmoothScrollCompletionCallback& callback, |
2107 int pixels_to_scroll, | 2102 int pixels_to_scroll, |
2108 int mouse_event_x, | 2103 int mouse_event_x, |
2109 int mouse_event_y) { | 2104 int mouse_event_y) { |
2110 DCHECK(!callback.is_null()); | 2105 DCHECK(!callback.is_null()); |
2111 int id = next_smooth_scroll_gesture_id_++; | |
2112 | 2106 |
2113 ViewHostMsg_BeginSmoothScroll_Params params; | 2107 ViewHostMsg_BeginSmoothScroll_Params params; |
2114 params.scroll_down = down; | 2108 params.scroll_down = down; |
2115 params.pixels_to_scroll = pixels_to_scroll; | 2109 params.pixels_to_scroll = pixels_to_scroll; |
2116 params.mouse_event_x = mouse_event_x; | 2110 params.mouse_event_x = mouse_event_x; |
2117 params.mouse_event_y = mouse_event_y; | 2111 params.mouse_event_y = mouse_event_y; |
2118 | 2112 |
2119 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, id, params)); | 2113 bool ret = false; |
2120 pending_smooth_scroll_gestures_.insert(std::make_pair(id, callback)); | 2114 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, params, &ret)); |
| 2115 pending_smooth_scroll_gesture_ = callback; |
| 2116 return ret; |
2121 } | 2117 } |
2122 | 2118 |
2123 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 2119 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
2124 return false; | 2120 return false; |
2125 } | 2121 } |
2126 | 2122 |
2127 bool RenderWidget::WillHandleGestureEvent( | 2123 bool RenderWidget::WillHandleGestureEvent( |
2128 const WebKit::WebGestureEvent& event) { | 2124 const WebKit::WebGestureEvent& event) { |
2129 return false; | 2125 return false; |
2130 } | 2126 } |
2131 | 2127 |
2132 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2128 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
2133 return true; | 2129 return true; |
2134 } | 2130 } |
2135 | 2131 |
2136 } // namespace content | 2132 } // namespace content |
OLD | NEW |