| 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/browser/renderer_host/render_widget_host_impl.h" | 5 #include "content/browser/renderer_host/render_widget_host_impl.h" |
| 6 | 6 |
| 7 #include <math.h> | 7 #include <math.h> |
| 8 #include <utility> | 8 #include <utility> |
| 9 | 9 |
| 10 #include "base/auto_reset.h" | 10 #include "base/auto_reset.h" |
| (...skipping 287 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 298 waiting_for_screen_rects_ack_ = true; | 298 waiting_for_screen_rects_ack_ = true; |
| 299 } | 299 } |
| 300 | 300 |
| 301 int RenderWidgetHostImpl::SyntheticScrollMessageInterval() const { | 301 int RenderWidgetHostImpl::SyntheticScrollMessageInterval() const { |
| 302 return kSyntheticScrollMessageIntervalMs; | 302 return kSyntheticScrollMessageIntervalMs; |
| 303 } | 303 } |
| 304 | 304 |
| 305 void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) { | 305 void RenderWidgetHostImpl::SetOverscrollControllerEnabled(bool enabled) { |
| 306 if (!enabled) | 306 if (!enabled) |
| 307 overscroll_controller_.reset(); | 307 overscroll_controller_.reset(); |
| 308 else if (!overscroll_controller_.get()) | 308 else if (!overscroll_controller_) |
| 309 overscroll_controller_.reset(new OverscrollController(this)); | 309 overscroll_controller_.reset(new OverscrollController(this)); |
| 310 } | 310 } |
| 311 | 311 |
| 312 void RenderWidgetHostImpl::SuppressNextCharEvents() { | 312 void RenderWidgetHostImpl::SuppressNextCharEvents() { |
| 313 suppress_next_char_events_ = true; | 313 suppress_next_char_events_ = true; |
| 314 } | 314 } |
| 315 | 315 |
| 316 void RenderWidgetHostImpl::Init() { | 316 void RenderWidgetHostImpl::Init() { |
| 317 DCHECK(process_->HasConnection()); | 317 DCHECK(process_->HasConnection()); |
| 318 | 318 |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1021 SimulateTouchGestureWithMouse(mouse_event); | 1021 SimulateTouchGestureWithMouse(mouse_event); |
| 1022 return; | 1022 return; |
| 1023 } | 1023 } |
| 1024 | 1024 |
| 1025 // Avoid spamming the renderer with mouse move events. It is important | 1025 // Avoid spamming the renderer with mouse move events. It is important |
| 1026 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our | 1026 // to note that WM_MOUSEMOVE events are anyways synthetic, but since our |
| 1027 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way | 1027 // thread is able to rapidly consume WM_MOUSEMOVE events, we may get way |
| 1028 // more WM_MOUSEMOVE events than we wish to send to the renderer. | 1028 // more WM_MOUSEMOVE events than we wish to send to the renderer. |
| 1029 if (mouse_event.type == WebInputEvent::MouseMove) { | 1029 if (mouse_event.type == WebInputEvent::MouseMove) { |
| 1030 if (mouse_move_pending_) { | 1030 if (mouse_move_pending_) { |
| 1031 if (!next_mouse_move_.get()) { | 1031 if (!next_mouse_move_) { |
| 1032 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); | 1032 next_mouse_move_.reset(new WebMouseEvent(mouse_event)); |
| 1033 } else { | 1033 } else { |
| 1034 // Accumulate movement deltas. | 1034 // Accumulate movement deltas. |
| 1035 int x = next_mouse_move_->movementX; | 1035 int x = next_mouse_move_->movementX; |
| 1036 int y = next_mouse_move_->movementY; | 1036 int y = next_mouse_move_->movementY; |
| 1037 *next_mouse_move_ = mouse_event; | 1037 *next_mouse_move_ = mouse_event; |
| 1038 next_mouse_move_->movementX += x; | 1038 next_mouse_move_->movementX += x; |
| 1039 next_mouse_move_->movementY += y; | 1039 next_mouse_move_->movementY += y; |
| 1040 } | 1040 } |
| 1041 return; | 1041 return; |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1315 | 1315 |
| 1316 // Must reset these to ensure that MoveCaret works with a new renderer. | 1316 // Must reset these to ensure that MoveCaret works with a new renderer. |
| 1317 move_caret_pending_ = false; | 1317 move_caret_pending_ = false; |
| 1318 next_move_caret_.reset(); | 1318 next_move_caret_.reset(); |
| 1319 | 1319 |
| 1320 touch_event_queue_->Reset(); | 1320 touch_event_queue_->Reset(); |
| 1321 | 1321 |
| 1322 // Must reset these to ensure that gesture events work with a new renderer. | 1322 // Must reset these to ensure that gesture events work with a new renderer. |
| 1323 gesture_event_filter_->Reset(); | 1323 gesture_event_filter_->Reset(); |
| 1324 | 1324 |
| 1325 if (overscroll_controller_.get()) | 1325 if (overscroll_controller_) |
| 1326 overscroll_controller_->Reset(); | 1326 overscroll_controller_->Reset(); |
| 1327 | 1327 |
| 1328 // Must reset these to ensure that keyboard events work with a new renderer. | 1328 // Must reset these to ensure that keyboard events work with a new renderer. |
| 1329 key_queue_.clear(); | 1329 key_queue_.clear(); |
| 1330 suppress_next_char_events_ = false; | 1330 suppress_next_char_events_ = false; |
| 1331 | 1331 |
| 1332 // Reset some fields in preparation for recovering from a crash. | 1332 // Reset some fields in preparation for recovering from a crash. |
| 1333 ResetSizeAndRepaintPendingFlags(); | 1333 ResetSizeAndRepaintPendingFlags(); |
| 1334 current_size_.SetSize(0, 0); | 1334 current_size_.SetSize(0, 0); |
| 1335 is_hidden_ = false; | 1335 is_hidden_ = false; |
| (...skipping 485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1821 TickActiveSmoothScrollGesture(); | 1821 TickActiveSmoothScrollGesture(); |
| 1822 | 1822 |
| 1823 int type = static_cast<int>(event_type); | 1823 int type = static_cast<int>(event_type); |
| 1824 if (type < WebInputEvent::Undefined) { | 1824 if (type < WebInputEvent::Undefined) { |
| 1825 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); | 1825 RecordAction(UserMetricsAction("BadMessageTerminate_RWH2")); |
| 1826 process_->ReceivedBadMessage(); | 1826 process_->ReceivedBadMessage(); |
| 1827 } else if (type == WebInputEvent::MouseMove) { | 1827 } else if (type == WebInputEvent::MouseMove) { |
| 1828 mouse_move_pending_ = false; | 1828 mouse_move_pending_ = false; |
| 1829 | 1829 |
| 1830 // now, we can send the next mouse move event | 1830 // now, we can send the next mouse move event |
| 1831 if (next_mouse_move_.get()) { | 1831 if (next_mouse_move_) { |
| 1832 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); | 1832 DCHECK(next_mouse_move_->type == WebInputEvent::MouseMove); |
| 1833 ForwardMouseEvent(*next_mouse_move_); | 1833 ForwardMouseEvent(*next_mouse_move_); |
| 1834 } | 1834 } |
| 1835 } else if (WebInputEvent::isKeyboardEventType(type)) { | 1835 } else if (WebInputEvent::isKeyboardEventType(type)) { |
| 1836 ProcessKeyboardEventAck(type, processed); | 1836 ProcessKeyboardEventAck(type, processed); |
| 1837 } else if (type == WebInputEvent::MouseWheel) { | 1837 } else if (type == WebInputEvent::MouseWheel) { |
| 1838 ProcessWheelAck(processed); | 1838 ProcessWheelAck(processed); |
| 1839 } else if (WebInputEvent::isTouchEventType(type)) { | 1839 } else if (WebInputEvent::isTouchEventType(type)) { |
| 1840 ProcessTouchAck(ack_result); | 1840 ProcessTouchAck(ack_result); |
| 1841 } else if (WebInputEvent::isGestureEventType(type)) { | 1841 } else if (WebInputEvent::isGestureEventType(type)) { |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1939 tick_active_smooth_scroll_gestures_task_posted_ = true; | 1939 tick_active_smooth_scroll_gestures_task_posted_ = true; |
| 1940 MessageLoop::current()->PostDelayedTask( | 1940 MessageLoop::current()->PostDelayedTask( |
| 1941 FROM_HERE, | 1941 FROM_HERE, |
| 1942 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, | 1942 base::Bind(&RenderWidgetHostImpl::TickActiveSmoothScrollGesture, |
| 1943 weak_factory_.GetWeakPtr()), | 1943 weak_factory_.GetWeakPtr()), |
| 1944 preferred_interval); | 1944 preferred_interval); |
| 1945 } | 1945 } |
| 1946 | 1946 |
| 1947 void RenderWidgetHostImpl::OnSelectRangeAck() { | 1947 void RenderWidgetHostImpl::OnSelectRangeAck() { |
| 1948 select_range_pending_ = false; | 1948 select_range_pending_ = false; |
| 1949 if (next_selection_range_.get()) { | 1949 if (next_selection_range_) { |
| 1950 scoped_ptr<SelectionRange> next(next_selection_range_.Pass()); | 1950 scoped_ptr<SelectionRange> next(next_selection_range_.Pass()); |
| 1951 SelectRange(next->start, next->end); | 1951 SelectRange(next->start, next->end); |
| 1952 } | 1952 } |
| 1953 } | 1953 } |
| 1954 | 1954 |
| 1955 void RenderWidgetHostImpl::OnMsgMoveCaretAck() { | 1955 void RenderWidgetHostImpl::OnMsgMoveCaretAck() { |
| 1956 move_caret_pending_ = false; | 1956 move_caret_pending_ = false; |
| 1957 if (next_move_caret_.get()) { | 1957 if (next_move_caret_) { |
| 1958 scoped_ptr<gfx::Point> next(next_move_caret_.Pass()); | 1958 scoped_ptr<gfx::Point> next(next_move_caret_.Pass()); |
| 1959 MoveCaret(*next); | 1959 MoveCaret(*next); |
| 1960 } | 1960 } |
| 1961 } | 1961 } |
| 1962 | 1962 |
| 1963 void RenderWidgetHostImpl::ProcessWheelAck(bool processed) { | 1963 void RenderWidgetHostImpl::ProcessWheelAck(bool processed) { |
| 1964 mouse_wheel_pending_ = false; | 1964 mouse_wheel_pending_ = false; |
| 1965 | 1965 |
| 1966 if (overscroll_controller_.get()) | 1966 if (overscroll_controller_) |
| 1967 overscroll_controller_->ReceivedEventACK(current_wheel_event_, processed); | 1967 overscroll_controller_->ReceivedEventACK(current_wheel_event_, processed); |
| 1968 | 1968 |
| 1969 // Now send the next (coalesced) mouse wheel event. | 1969 // Now send the next (coalesced) mouse wheel event. |
| 1970 if (!coalesced_mouse_wheel_events_.empty()) { | 1970 if (!coalesced_mouse_wheel_events_.empty()) { |
| 1971 WebMouseWheelEvent next_wheel_event = | 1971 WebMouseWheelEvent next_wheel_event = |
| 1972 coalesced_mouse_wheel_events_.front(); | 1972 coalesced_mouse_wheel_events_.front(); |
| 1973 coalesced_mouse_wheel_events_.pop_front(); | 1973 coalesced_mouse_wheel_events_.pop_front(); |
| 1974 ForwardWheelEvent(next_wheel_event); | 1974 ForwardWheelEvent(next_wheel_event); |
| 1975 } | 1975 } |
| 1976 | 1976 |
| 1977 if (!processed && !is_hidden_ && view_) | 1977 if (!processed && !is_hidden_ && view_) |
| 1978 view_->UnhandledWheelEvent(current_wheel_event_); | 1978 view_->UnhandledWheelEvent(current_wheel_event_); |
| 1979 } | 1979 } |
| 1980 | 1980 |
| 1981 void RenderWidgetHostImpl::ProcessGestureAck(bool processed, int type) { | 1981 void RenderWidgetHostImpl::ProcessGestureAck(bool processed, int type) { |
| 1982 if (overscroll_controller_.get()) { | 1982 if (overscroll_controller_) { |
| 1983 overscroll_controller_->ReceivedEventACK( | 1983 overscroll_controller_->ReceivedEventACK( |
| 1984 gesture_event_filter_->GetGestureEventAwaitingAck(), processed); | 1984 gesture_event_filter_->GetGestureEventAwaitingAck(), processed); |
| 1985 } | 1985 } |
| 1986 gesture_event_filter_->ProcessGestureAck(processed, type); | 1986 gesture_event_filter_->ProcessGestureAck(processed, type); |
| 1987 } | 1987 } |
| 1988 | 1988 |
| 1989 void RenderWidgetHostImpl::ProcessTouchAck(InputEventAckState ack_result) { | 1989 void RenderWidgetHostImpl::ProcessTouchAck(InputEventAckState ack_result) { |
| 1990 touch_event_queue_->ProcessTouchAck(ack_result); | 1990 touch_event_queue_->ProcessTouchAck(ack_result); |
| 1991 } | 1991 } |
| 1992 | 1992 |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2317 } | 2317 } |
| 2318 | 2318 |
| 2319 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( | 2319 void RenderWidgetHostImpl::ScrollFocusedEditableNodeIntoRect( |
| 2320 const gfx::Rect& rect) { | 2320 const gfx::Rect& rect) { |
| 2321 Send(new ViewMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); | 2321 Send(new ViewMsg_ScrollFocusedEditableNodeIntoRect(GetRoutingID(), rect)); |
| 2322 } | 2322 } |
| 2323 | 2323 |
| 2324 void RenderWidgetHostImpl::SelectRange(const gfx::Point& start, | 2324 void RenderWidgetHostImpl::SelectRange(const gfx::Point& start, |
| 2325 const gfx::Point& end) { | 2325 const gfx::Point& end) { |
| 2326 if (select_range_pending_) { | 2326 if (select_range_pending_) { |
| 2327 if (!next_selection_range_.get()) { | 2327 if (!next_selection_range_) { |
| 2328 next_selection_range_.reset(new SelectionRange()); | 2328 next_selection_range_.reset(new SelectionRange()); |
| 2329 } | 2329 } |
| 2330 next_selection_range_->start = start; | 2330 next_selection_range_->start = start; |
| 2331 next_selection_range_->end = end; | 2331 next_selection_range_->end = end; |
| 2332 return; | 2332 return; |
| 2333 } | 2333 } |
| 2334 | 2334 |
| 2335 select_range_pending_ = true; | 2335 select_range_pending_ = true; |
| 2336 Send(new ViewMsg_SelectRange(GetRoutingID(), start, end)); | 2336 Send(new ViewMsg_SelectRange(GetRoutingID(), start, end)); |
| 2337 } | 2337 } |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2465 return; | 2465 return; |
| 2466 | 2466 |
| 2467 OnRenderAutoResized(new_size); | 2467 OnRenderAutoResized(new_size); |
| 2468 } | 2468 } |
| 2469 | 2469 |
| 2470 void RenderWidgetHostImpl::DetachDelegate() { | 2470 void RenderWidgetHostImpl::DetachDelegate() { |
| 2471 delegate_ = NULL; | 2471 delegate_ = NULL; |
| 2472 } | 2472 } |
| 2473 | 2473 |
| 2474 } // namespace content | 2474 } // namespace content |
| OLD | NEW |