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 1559 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1734 if (is_accelerated_compositing_active_) { | 1733 if (is_accelerated_compositing_active_) { |
1735 if (compositor_) | 1734 if (compositor_) |
1736 compositor_->setNeedsRedraw(); | 1735 compositor_->setNeedsRedraw(); |
1737 scheduleComposite(); | 1736 scheduleComposite(); |
1738 } else { | 1737 } else { |
1739 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); | 1738 gfx::Rect repaint_rect(size_to_paint.width(), size_to_paint.height()); |
1740 didInvalidateRect(repaint_rect); | 1739 didInvalidateRect(repaint_rect); |
1741 } | 1740 } |
1742 } | 1741 } |
1743 | 1742 |
1744 void RenderWidget::OnSmoothScrollCompleted(int gesture_id) { | 1743 void RenderWidget::OnSmoothScrollCompleted() { |
1745 PendingSmoothScrollGestureMap::iterator it = | 1744 pending_smooth_scroll_gesture_.Run(); |
1746 pending_smooth_scroll_gestures_.find(gesture_id); | |
1747 DCHECK(it != pending_smooth_scroll_gestures_.end()); | |
1748 it->second.Run(); | |
1749 pending_smooth_scroll_gestures_.erase(it); | |
1750 } | 1745 } |
1751 | 1746 |
1752 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { | 1747 void RenderWidget::OnSetTextDirection(WebTextDirection direction) { |
1753 if (!webwidget_) | 1748 if (!webwidget_) |
1754 return; | 1749 return; |
1755 webwidget_->setTextDirection(direction); | 1750 webwidget_->setTextDirection(direction); |
1756 } | 1751 } |
1757 | 1752 |
1758 void RenderWidget::OnScreenInfoChanged( | 1753 void RenderWidget::OnScreenInfoChanged( |
1759 const WebKit::WebScreenInfo& screen_info) { | 1754 const WebKit::WebScreenInfo& screen_info) { |
(...skipping 344 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 } | 2099 } |
2105 | 2100 |
2106 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { | 2101 bool RenderWidget::GetGpuRenderingStats(GpuRenderingStats* stats) const { |
2107 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); | 2102 GpuChannelHost* gpu_channel = RenderThreadImpl::current()->GetGpuChannel(); |
2108 if (!gpu_channel) | 2103 if (!gpu_channel) |
2109 return false; | 2104 return false; |
2110 | 2105 |
2111 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); | 2106 return gpu_channel->CollectRenderingStatsForSurface(surface_id(), stats); |
2112 } | 2107 } |
2113 | 2108 |
2114 void RenderWidget::BeginSmoothScroll( | 2109 bool RenderWidget::BeginSmoothScroll( |
2115 bool down, | 2110 bool down, |
2116 const SmoothScrollCompletionCallback& callback, | 2111 const SmoothScrollCompletionCallback& callback, |
2117 int pixels_to_scroll, | 2112 int pixels_to_scroll, |
2118 int mouse_event_x, | 2113 int mouse_event_x, |
2119 int mouse_event_y) { | 2114 int mouse_event_y) { |
2120 DCHECK(!callback.is_null()); | 2115 DCHECK(!callback.is_null()); |
2121 int id = next_smooth_scroll_gesture_id_++; | |
2122 | 2116 |
2123 ViewHostMsg_BeginSmoothScroll_Params params; | 2117 ViewHostMsg_BeginSmoothScroll_Params params; |
2124 params.scroll_down = down; | 2118 params.scroll_down = down; |
2125 params.pixels_to_scroll = pixels_to_scroll; | 2119 params.pixels_to_scroll = pixels_to_scroll; |
2126 params.mouse_event_x = mouse_event_x; | 2120 params.mouse_event_x = mouse_event_x; |
2127 params.mouse_event_y = mouse_event_y; | 2121 params.mouse_event_y = mouse_event_y; |
2128 | 2122 |
2129 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, id, params)); | 2123 bool ret = false; |
2130 pending_smooth_scroll_gestures_.insert(std::make_pair(id, callback)); | 2124 Send(new ViewHostMsg_BeginSmoothScroll(routing_id_, params, &ret)); |
| 2125 pending_smooth_scroll_gesture_ = callback; |
| 2126 return ret; |
2131 } | 2127 } |
2132 | 2128 |
2133 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { | 2129 bool RenderWidget::WillHandleMouseEvent(const WebKit::WebMouseEvent& event) { |
2134 return false; | 2130 return false; |
2135 } | 2131 } |
2136 | 2132 |
2137 bool RenderWidget::WillHandleGestureEvent( | 2133 bool RenderWidget::WillHandleGestureEvent( |
2138 const WebKit::WebGestureEvent& event) { | 2134 const WebKit::WebGestureEvent& event) { |
2139 return false; | 2135 return false; |
2140 } | 2136 } |
2141 | 2137 |
2142 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { | 2138 bool RenderWidget::HasTouchEventHandlersAt(const gfx::Point& point) const { |
2143 return true; | 2139 return true; |
2144 } | 2140 } |
2145 | 2141 |
2146 } // namespace content | 2142 } // namespace content |
OLD | NEW |