| 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 1485 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1496 if (should_not_forward) { | 1496 if (should_not_forward) { |
| 1497 synthetic_move_sent_ = false; | 1497 synthetic_move_sent_ = false; |
| 1498 } else { | 1498 } else { |
| 1499 // Check if the mouse has reached the border and needs to be centered. | 1499 // Check if the mouse has reached the border and needs to be centered. |
| 1500 if (ShouldMoveToCenter()) { | 1500 if (ShouldMoveToCenter()) { |
| 1501 synthetic_move_sent_ = true; | 1501 synthetic_move_sent_ = true; |
| 1502 window_->MoveCursorTo(center); | 1502 window_->MoveCursorTo(center); |
| 1503 } | 1503 } |
| 1504 | 1504 |
| 1505 // Forward event to renderer. | 1505 // Forward event to renderer. |
| 1506 if (CanRendererHandleEvent(event)) | 1506 if (CanRendererHandleEvent(event) && |
| 1507 !(event->flags() & ui::EF_FROM_TOUCH)) |
| 1507 host_->ForwardMouseEvent(mouse_event); | 1508 host_->ForwardMouseEvent(mouse_event); |
| 1508 } | 1509 } |
| 1509 return; | 1510 return; |
| 1510 } | 1511 } |
| 1511 | 1512 |
| 1512 // As the overscroll is handled during scroll events from the trackpad, the | 1513 // As the overscroll is handled during scroll events from the trackpad, the |
| 1513 // RWHVA window is transformed by the overscroll controller. This transform | 1514 // RWHVA window is transformed by the overscroll controller. This transform |
| 1514 // triggers a synthetic mouse-move event to be generated (by the aura | 1515 // triggers a synthetic mouse-move event to be generated (by the aura |
| 1515 // RootWindow). But this event interferes with the overscroll gesture. So, | 1516 // RootWindow). But this event interferes with the overscroll gesture. So, |
| 1516 // ignore such synthetic mouse-move events if an overscroll gesture is in | 1517 // ignore such synthetic mouse-move events if an overscroll gesture is in |
| 1517 // progress. | 1518 // progress. |
| 1518 if (host_->overscroll_controller() && | 1519 if (host_->overscroll_controller() && |
| 1519 host_->overscroll_controller()->overscroll_mode() != OVERSCROLL_NONE && | 1520 host_->overscroll_controller()->overscroll_mode() != OVERSCROLL_NONE && |
| 1520 event->flags() & ui::EF_IS_SYNTHESIZED && | 1521 event->flags() & ui::EF_IS_SYNTHESIZED && |
| 1521 (event->type() == ui::ET_MOUSE_ENTERED || | 1522 (event->type() == ui::ET_MOUSE_ENTERED || |
| 1522 event->type() == ui::ET_MOUSE_EXITED || | 1523 event->type() == ui::ET_MOUSE_EXITED || |
| 1523 event->type() == ui::ET_MOUSE_MOVED)) { | 1524 event->type() == ui::ET_MOUSE_MOVED)) { |
| 1524 event->StopPropagation(); | 1525 event->StopPropagation(); |
| 1525 return; | 1526 return; |
| 1526 } | 1527 } |
| 1527 | 1528 |
| 1528 if (event->type() == ui::ET_MOUSEWHEEL) { | 1529 if (event->type() == ui::ET_MOUSEWHEEL) { |
| 1529 WebKit::WebMouseWheelEvent mouse_wheel_event = | 1530 WebKit::WebMouseWheelEvent mouse_wheel_event = |
| 1530 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); | 1531 MakeWebMouseWheelEvent(static_cast<ui::MouseWheelEvent*>(event)); |
| 1531 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) | 1532 if (mouse_wheel_event.deltaX != 0 || mouse_wheel_event.deltaY != 0) |
| 1532 host_->ForwardWheelEvent(mouse_wheel_event); | 1533 host_->ForwardWheelEvent(mouse_wheel_event); |
| 1533 } else if (CanRendererHandleEvent(event)) { | 1534 } else if (CanRendererHandleEvent(event) && |
| 1535 !(event->flags() & ui::EF_FROM_TOUCH)) { |
| 1534 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 1536 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
| 1535 ModifyEventMovementAndCoords(&mouse_event); | 1537 ModifyEventMovementAndCoords(&mouse_event); |
| 1536 host_->ForwardMouseEvent(mouse_event); | 1538 host_->ForwardMouseEvent(mouse_event); |
| 1537 } | 1539 } |
| 1538 | 1540 |
| 1539 switch (event->type()) { | 1541 switch (event->type()) { |
| 1540 case ui::ET_MOUSE_PRESSED: | 1542 case ui::ET_MOUSE_PRESSED: |
| 1541 window_->SetCapture(); | 1543 window_->SetCapture(); |
| 1542 // Confirm existing composition text on mouse click events, to make sure | 1544 // Confirm existing composition text on mouse click events, to make sure |
| 1543 // the input caret won't be moved with an ongoing composition text. | 1545 // the input caret won't be moved with an ongoing composition text. |
| 1544 FinishImeCompositionSession(); | 1546 FinishImeCompositionSession(); |
| 1545 break; | 1547 break; |
| 1546 case ui::ET_MOUSE_RELEASED: | 1548 case ui::ET_MOUSE_RELEASED: |
| 1547 window_->ReleaseCapture(); | 1549 window_->ReleaseCapture(); |
| 1548 break; | 1550 break; |
| 1549 default: | 1551 default: |
| 1550 break; | 1552 break; |
| 1551 } | 1553 } |
| 1552 | 1554 |
| 1553 // Needed to propagate mouse event to native_tab_contents_view_aura. | 1555 // Needed to propagate mouse event to native_tab_contents_view_aura. |
| 1554 // TODO(pkotwicz): Find a better way of doing this. | 1556 // TODO(pkotwicz): Find a better way of doing this. |
| 1555 if (window_->parent()->delegate()) | 1557 if (window_->parent()->delegate() && !(event->flags() & ui::EF_FROM_TOUCH)) |
| 1556 window_->parent()->delegate()->OnMouseEvent(event); | 1558 window_->parent()->delegate()->OnMouseEvent(event); |
| 1557 | 1559 |
| 1558 event->SetHandled(); | 1560 event->SetHandled(); |
| 1559 } | 1561 } |
| 1560 | 1562 |
| 1561 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { | 1563 void RenderWidgetHostViewAura::OnScrollEvent(ui::ScrollEvent* event) { |
| 1562 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnScrollEvent"); | 1564 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnScrollEvent"); |
| 1563 if (event->type() == ui::ET_SCROLL) { | 1565 if (event->type() == ui::ET_SCROLL) { |
| 1564 WebKit::WebGestureEvent gesture_event = | 1566 WebKit::WebGestureEvent gesture_event = |
| 1565 MakeWebGestureEventFlingCancel(); | 1567 MakeWebGestureEventFlingCancel(); |
| (...skipping 402 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1968 RenderWidgetHost* widget) { | 1970 RenderWidgetHost* widget) { |
| 1969 return new RenderWidgetHostViewAura(widget); | 1971 return new RenderWidgetHostViewAura(widget); |
| 1970 } | 1972 } |
| 1971 | 1973 |
| 1972 // static | 1974 // static |
| 1973 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 1975 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
| 1974 GetScreenInfoForWindow(results, NULL); | 1976 GetScreenInfoForWindow(results, NULL); |
| 1975 } | 1977 } |
| 1976 | 1978 |
| 1977 } // namespace content | 1979 } // namespace content |
| OLD | NEW |