| 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_view_aura.h" | 5 #include "content/browser/renderer_host/render_widget_host_view_aura.h" | 
| 6 | 6 | 
| 7 #include "base/auto_reset.h" | 7 #include "base/auto_reset.h" | 
| 8 #include "base/basictypes.h" | 8 #include "base/basictypes.h" | 
| 9 #include "base/bind.h" | 9 #include "base/bind.h" | 
| 10 #include "base/callback_helpers.h" | 10 #include "base/callback_helpers.h" | 
| (...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 327 | 327 | 
| 328   if (event.type() == ui::ET_GESTURE_BEGIN) { | 328   if (event.type() == ui::ET_GESTURE_BEGIN) { | 
| 329     const ui::GestureEvent& gesture = | 329     const ui::GestureEvent& gesture = | 
| 330         static_cast<const ui::GestureEvent&>(event); | 330         static_cast<const ui::GestureEvent&>(event); | 
| 331     return gesture.details().touch_points() == 1; | 331     return gesture.details().touch_points() == 1; | 
| 332   } | 332   } | 
| 333 | 333 | 
| 334   return false; | 334   return false; | 
| 335 } | 335 } | 
| 336 | 336 | 
|  | 337 bool IsFractionalScaleFactor(float scale_factor) { | 
|  | 338   return (scale_factor - static_cast<int>(scale_factor)) > 0; | 
|  | 339 } | 
|  | 340 | 
| 337 }  // namespace | 341 }  // namespace | 
| 338 | 342 | 
| 339 // We need to watch for mouse events outside a Web Popup or its parent | 343 // We need to watch for mouse events outside a Web Popup or its parent | 
| 340 // and dismiss the popup for certain events. | 344 // and dismiss the popup for certain events. | 
| 341 class RenderWidgetHostViewAura::EventFilterForPopupExit | 345 class RenderWidgetHostViewAura::EventFilterForPopupExit | 
| 342     : public ui::EventHandler { | 346     : public ui::EventHandler { | 
| 343  public: | 347  public: | 
| 344   explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 348   explicit EventFilterForPopupExit(RenderWidgetHostViewAura* rwhva) | 
| 345       : rwhva_(rwhva) { | 349       : rwhva_(rwhva) { | 
| 346     DCHECK(rwhva_); | 350     DCHECK(rwhva_); | 
| (...skipping 1573 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1920       window_->MoveCursorTo(center); | 1924       window_->MoveCursorTo(center); | 
| 1921       return; | 1925       return; | 
| 1922     } | 1926     } | 
| 1923 | 1927 | 
| 1924     blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 1928     blink::WebMouseEvent mouse_event = MakeWebMouseEvent(*event); | 
| 1925 | 1929 | 
| 1926     bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || | 1930     bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || | 
| 1927         event->type() == ui::ET_MOUSE_DRAGGED) && | 1931         event->type() == ui::ET_MOUSE_DRAGGED) && | 
| 1928         mouse_event.x == center.x() && mouse_event.y == center.y(); | 1932         mouse_event.x == center.x() && mouse_event.y == center.y(); | 
| 1929 | 1933 | 
|  | 1934     // For fractional scale factors, the conversion from pixels to dip and | 
|  | 1935     // vice versa could result in off by 1 or 2 errors which hurts us because | 
|  | 1936     // we want to avoid sending the artificial move to center event to the | 
|  | 1937     // renderer. Sending the move to center to the renderer cause the cursor | 
|  | 1938     // to bounce around the center of the screen leading to the lock operation | 
|  | 1939     // not working correctly. | 
|  | 1940     // Workaround is to treat a mouse move or drag event off by at most 2 px | 
|  | 1941     // from the center as a move to center event. | 
|  | 1942     if (synthetic_move_sent_ && | 
|  | 1943         IsFractionalScaleFactor(current_device_scale_factor_)) { | 
|  | 1944       if (event->type() == ui::ET_MOUSE_MOVED || | 
|  | 1945           event->type() == ui::ET_MOUSE_DRAGGED) { | 
|  | 1946         if ((abs(mouse_event.x - center.x()) <= 2) && | 
|  | 1947             (abs(mouse_event.y - center.y()) <= 2)) { | 
|  | 1948           is_move_to_center_event = true; | 
|  | 1949         } | 
|  | 1950       } | 
|  | 1951     } | 
|  | 1952 | 
| 1930     ModifyEventMovementAndCoords(&mouse_event); | 1953     ModifyEventMovementAndCoords(&mouse_event); | 
| 1931 | 1954 | 
| 1932     bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; | 1955     bool should_not_forward = is_move_to_center_event && synthetic_move_sent_; | 
| 1933     if (should_not_forward) { | 1956     if (should_not_forward) { | 
| 1934       synthetic_move_sent_ = false; | 1957       synthetic_move_sent_ = false; | 
| 1935     } else { | 1958     } else { | 
| 1936       // Check if the mouse has reached the border and needs to be centered. | 1959       // Check if the mouse has reached the border and needs to be centered. | 
| 1937       if (ShouldMoveToCenter()) { | 1960       if (ShouldMoveToCenter()) { | 
| 1938         synthetic_move_sent_ = true; | 1961         synthetic_move_sent_ = true; | 
| 1939         window_->MoveCursorTo(center); | 1962         window_->MoveCursorTo(center); | 
| (...skipping 750 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 2690 | 2713 | 
| 2691 //////////////////////////////////////////////////////////////////////////////// | 2714 //////////////////////////////////////////////////////////////////////////////// | 
| 2692 // RenderWidgetHostViewBase, public: | 2715 // RenderWidgetHostViewBase, public: | 
| 2693 | 2716 | 
| 2694 // static | 2717 // static | 
| 2695 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 2718 void RenderWidgetHostViewBase::GetDefaultScreenInfo(WebScreenInfo* results) { | 
| 2696   GetScreenInfoForWindow(results, NULL); | 2719   GetScreenInfoForWindow(results, NULL); | 
| 2697 } | 2720 } | 
| 2698 | 2721 | 
| 2699 }  // namespace content | 2722 }  // namespace content | 
| OLD | NEW | 
|---|