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/bind.h" | 7 #include "base/bind.h" |
8 #include "base/bind_helpers.h" | 8 #include "base/bind_helpers.h" |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/debug/trace_event.h" | 10 #include "base/debug/trace_event.h" |
(...skipping 1484 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1495 base::Time::Now().ToDoubleT()); | 1495 base::Time::Now().ToDoubleT()); |
1496 host_->ForwardKeyboardEvent(webkit_event); | 1496 host_->ForwardKeyboardEvent(webkit_event); |
1497 } else { | 1497 } else { |
1498 NativeWebKeyboardEvent webkit_event(event); | 1498 NativeWebKeyboardEvent webkit_event(event); |
1499 host_->ForwardKeyboardEvent(webkit_event); | 1499 host_->ForwardKeyboardEvent(webkit_event); |
1500 } | 1500 } |
1501 } | 1501 } |
1502 event->SetHandled(); | 1502 event->SetHandled(); |
1503 } | 1503 } |
1504 | 1504 |
1505 ui::EventResult RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { | 1505 void RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
1506 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); | 1506 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); |
1507 | 1507 |
1508 if (mouse_locked_) { | 1508 if (mouse_locked_) { |
1509 // Hide the cursor if someone else has shown it. | 1509 // Hide the cursor if someone else has shown it. |
1510 aura::client::CursorClient* cursor_client = | 1510 aura::client::CursorClient* cursor_client = |
1511 aura::client::GetCursorClient(window_->GetRootWindow()); | 1511 aura::client::GetCursorClient(window_->GetRootWindow()); |
1512 if (cursor_client && cursor_client->IsCursorVisible()) | 1512 if (cursor_client && cursor_client->IsCursorVisible()) |
1513 cursor_client->ShowCursor(false); | 1513 cursor_client->ShowCursor(false); |
1514 | 1514 |
1515 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 1515 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
(...skipping 12 matching lines...) Expand all Loading... |
1528 // Check if the mouse has reached the border and needs to be centered. | 1528 // Check if the mouse has reached the border and needs to be centered. |
1529 if (ShouldMoveToCenter()) { | 1529 if (ShouldMoveToCenter()) { |
1530 synthetic_move_sent_ = true; | 1530 synthetic_move_sent_ = true; |
1531 window_->MoveCursorTo(center); | 1531 window_->MoveCursorTo(center); |
1532 } | 1532 } |
1533 | 1533 |
1534 // Forward event to renderer. | 1534 // Forward event to renderer. |
1535 if (CanRendererHandleEvent(event)) | 1535 if (CanRendererHandleEvent(event)) |
1536 host_->ForwardMouseEvent(mouse_event); | 1536 host_->ForwardMouseEvent(mouse_event); |
1537 } | 1537 } |
1538 | 1538 return; |
1539 return ui::ER_UNHANDLED; | |
1540 } | 1539 } |
1541 | 1540 |
1542 // As the overscroll is handled during scroll events from the trackpad, the | 1541 // As the overscroll is handled during scroll events from the trackpad, the |
1543 // RWHVA window is transformed by the overscroll controller. This transform | 1542 // RWHVA window is transformed by the overscroll controller. This transform |
1544 // triggers a synthetic mouse-move event to be generated (by the aura | 1543 // triggers a synthetic mouse-move event to be generated (by the aura |
1545 // RootWindow). But this event interferes with the overscroll gesture. So, | 1544 // RootWindow). But this event interferes with the overscroll gesture. So, |
1546 // ignore such synthetic mouse-move events if an overscroll gesture is in | 1545 // ignore such synthetic mouse-move events if an overscroll gesture is in |
1547 // progress. | 1546 // progress. |
1548 if (host_->overscroll_controller() && | 1547 if (host_->overscroll_controller() && |
1549 host_->overscroll_controller()->overscroll_mode() != OVERSCROLL_NONE && | 1548 host_->overscroll_controller()->overscroll_mode() != OVERSCROLL_NONE && |
1550 event->flags() & ui::EF_IS_SYNTHESIZED && | 1549 event->flags() & ui::EF_IS_SYNTHESIZED && |
1551 (event->type() == ui::ET_MOUSE_ENTERED || | 1550 (event->type() == ui::ET_MOUSE_ENTERED || |
1552 event->type() == ui::ET_MOUSE_MOVED)) { | 1551 event->type() == ui::ET_MOUSE_MOVED)) { |
1553 return ui::ER_CONSUMED; | 1552 event->StopPropagation(); |
| 1553 return; |
1554 } | 1554 } |
1555 | 1555 |
1556 if (event->type() == ui::ET_MOUSEWHEEL) { | 1556 if (event->type() == ui::ET_MOUSEWHEEL) { |
1557 WebKit::WebMouseWheelEvent mouse_wheel_event = | 1557 WebKit::WebMouseWheelEvent mouse_wheel_event = |
1558 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); | 1558 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); |
1559 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 1559 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
1560 host_->ForwardWheelEvent(mouse_wheel_event); | 1560 host_->ForwardWheelEvent(mouse_wheel_event); |
1561 } else if (CanRendererHandleEvent(event)) { | 1561 } else if (CanRendererHandleEvent(event)) { |
1562 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 1562 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
1563 ModifyEventMovementAndCoords(&mouse_event); | 1563 ModifyEventMovementAndCoords(&mouse_event); |
(...skipping 12 matching lines...) Expand all Loading... |
1576 break; | 1576 break; |
1577 default: | 1577 default: |
1578 break; | 1578 break; |
1579 } | 1579 } |
1580 | 1580 |
1581 // Needed to propagate mouse event to native_tab_contents_view_aura. | 1581 // Needed to propagate mouse event to native_tab_contents_view_aura. |
1582 // TODO(pkotwicz): Find a better way of doing this. | 1582 // TODO(pkotwicz): Find a better way of doing this. |
1583 if (window_->parent()->delegate()) | 1583 if (window_->parent()->delegate()) |
1584 window_->parent()->delegate()->OnMouseEvent(event); | 1584 window_->parent()->delegate()->OnMouseEvent(event); |
1585 | 1585 |
1586 // Return true so that we receive released/drag events. | 1586 event->SetHandled(); |
1587 return ui::ER_HANDLED; | |
1588 } | 1587 } |
1589 | 1588 |
1590 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 1589 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
1591 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnScrollEvent"); | 1590 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnScrollEvent"); |
1592 if (event->type() == ui::ET_SCROLL) { | 1591 if (event->type() == ui::ET_SCROLL) { |
1593 WebKit::WebGestureEvent gesture_event = | 1592 WebKit::WebGestureEvent gesture_event = |
1594 MakeWebGestureEventFlingCancel(); | 1593 MakeWebGestureEventFlingCancel(); |
1595 host_->ForwardGestureEvent(gesture_event); | 1594 host_->ForwardGestureEvent(gesture_event); |
1596 WebKit::WebMouseWheelEvent mouse_wheel_event = | 1595 WebKit::WebMouseWheelEvent mouse_wheel_event = |
1597 MakeWebMouseWheelEvent(static_cast<ui::ScrollEvent*>(event)); | 1596 MakeWebMouseWheelEvent(static_cast<ui::ScrollEvent*>(event)); |
(...skipping 396 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1994 RenderWidgetHost* widget) { | 1993 RenderWidgetHost* widget) { |
1995 return new RenderWidgetHostViewAura(widget); | 1994 return new RenderWidgetHostViewAura(widget); |
1996 } | 1995 } |
1997 | 1996 |
1998 // static | 1997 // static |
1999 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1998 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
2000 GetScreenInfoForWindow(results, NULL); | 1999 GetScreenInfoForWindow(results, NULL); |
2001 } | 2000 } |
2002 | 2001 |
2003 } // namespace content | 2002 } // namespace content |
OLD | NEW |