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 267 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
278 has_composition_text_(false), | 278 has_composition_text_(false), |
279 device_scale_factor_(1.0f), | 279 device_scale_factor_(1.0f), |
280 current_surface_(0), | 280 current_surface_(0), |
281 current_surface_is_protected_(true), | 281 current_surface_is_protected_(true), |
282 current_surface_in_use_by_compositor_(true), | 282 current_surface_in_use_by_compositor_(true), |
283 protection_state_id_(0), | 283 protection_state_id_(0), |
284 surface_route_id_(0), | 284 surface_route_id_(0), |
285 paint_canvas_(NULL), | 285 paint_canvas_(NULL), |
286 synthetic_move_sent_(false), | 286 synthetic_move_sent_(false), |
287 accelerated_compositing_state_changed_(false), | 287 accelerated_compositing_state_changed_(false), |
288 can_lock_compositor_(YES), | 288 can_lock_compositor_(YES) { |
289 pointer_activate_(false) { | |
290 host_->SetView(this); | 289 host_->SetView(this); |
291 window_observer_.reset(new WindowObserver(this)); | 290 window_observer_.reset(new WindowObserver(this)); |
292 window_->AddObserver(window_observer_.get()); | 291 window_->AddObserver(window_observer_.get()); |
293 aura::client::SetTooltipText(window_, &tooltip_); | 292 aura::client::SetTooltipText(window_, &tooltip_); |
294 aura::client::SetActivationDelegate(window_, this); | 293 aura::client::SetActivationDelegate(window_, this); |
295 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 294 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
296 } | 295 } |
297 | 296 |
298 //////////////////////////////////////////////////////////////////////////////// | 297 //////////////////////////////////////////////////////////////////////////////// |
299 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 298 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
(...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1535 } else { | 1534 } else { |
1536 NativeWebKeyboardEvent webkit_event(event); | 1535 NativeWebKeyboardEvent webkit_event(event); |
1537 host_->ForwardKeyboardEvent(webkit_event); | 1536 host_->ForwardKeyboardEvent(webkit_event); |
1538 } | 1537 } |
1539 } | 1538 } |
1540 return ui::ER_HANDLED; | 1539 return ui::ER_HANDLED; |
1541 } | 1540 } |
1542 | 1541 |
1543 ui::EventResult RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { | 1542 ui::EventResult RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
1544 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); | 1543 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); |
1545 pointer_activate_ = event->type() == ui::ET_MOUSE_PRESSED; | |
1546 | |
1547 if (mouse_locked_) { | 1544 if (mouse_locked_) { |
1548 // Hide the cursor if someone else has shown it. | 1545 // Hide the cursor if someone else has shown it. |
1549 aura::client::CursorClient* cursor_client = | 1546 aura::client::CursorClient* cursor_client = |
1550 aura::client::GetCursorClient(window_->GetRootWindow()); | 1547 aura::client::GetCursorClient(window_->GetRootWindow()); |
1551 if (cursor_client && cursor_client->IsCursorVisible()) | 1548 if (cursor_client && cursor_client->IsCursorVisible()) |
1552 cursor_client->ShowCursor(false); | 1549 cursor_client->ShowCursor(false); |
1553 | 1550 |
1554 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 1551 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
1555 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); | 1552 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); |
1556 | 1553 |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1677 // Pinch gestures are currently disabled by default. See crbug.com/128477. | 1674 // Pinch gestures are currently disabled by default. See crbug.com/128477. |
1678 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 1675 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
1679 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 1676 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
1680 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { | 1677 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { |
1681 return ui::ER_CONSUMED; | 1678 return ui::ER_CONSUMED; |
1682 } | 1679 } |
1683 | 1680 |
1684 RenderViewHostDelegate* delegate = NULL; | 1681 RenderViewHostDelegate* delegate = NULL; |
1685 if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_) | 1682 if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_) |
1686 delegate = RenderViewHost::From(host_)->GetDelegate(); | 1683 delegate = RenderViewHost::From(host_)->GetDelegate(); |
1687 | 1684 if (delegate && event->type() == ui::ET_GESTURE_BEGIN && |
1688 bool gesture_begin = event->type() == ui::ET_GESTURE_BEGIN && | 1685 event->details().touch_points() == 1) { |
1689 event->details().touch_points() == 1; | |
1690 if (delegate && gesture_begin) | |
1691 delegate->HandleGestureBegin(); | 1686 delegate->HandleGestureBegin(); |
1692 pointer_activate_ = gesture_begin; | 1687 } |
1693 | 1688 |
1694 WebKit::WebGestureEvent gesture = MakeWebGestureEvent(event); | 1689 WebKit::WebGestureEvent gesture = MakeWebGestureEvent(event); |
1695 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 1690 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
1696 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 1691 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
1697 // event to stop any in-progress flings. | 1692 // event to stop any in-progress flings. |
1698 WebKit::WebGestureEvent fling_cancel = gesture; | 1693 WebKit::WebGestureEvent fling_cancel = gesture; |
1699 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; | 1694 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; |
1700 host_->ForwardGestureEvent(fling_cancel); | 1695 host_->ForwardGestureEvent(fling_cancel); |
1701 } | 1696 } |
1702 | 1697 |
(...skipping 17 matching lines...) Expand all Loading... |
1720 // If a gesture is not processed by the webpage, then WebKit processes it | 1715 // If a gesture is not processed by the webpage, then WebKit processes it |
1721 // (e.g. generates synthetic mouse events). So CONSUMED should be returned | 1716 // (e.g. generates synthetic mouse events). So CONSUMED should be returned |
1722 // from here to avoid any duplicate synthetic mouse-events being generated | 1717 // from here to avoid any duplicate synthetic mouse-events being generated |
1723 // from aura. | 1718 // from aura. |
1724 return ui::ER_CONSUMED; | 1719 return ui::ER_CONSUMED; |
1725 } | 1720 } |
1726 | 1721 |
1727 //////////////////////////////////////////////////////////////////////////////// | 1722 //////////////////////////////////////////////////////////////////////////////// |
1728 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: | 1723 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: |
1729 | 1724 |
1730 bool RenderWidgetHostViewAura::ShouldActivate() const { | 1725 bool RenderWidgetHostViewAura::ShouldActivate(const ui::Event* event) { |
| 1726 bool activate = false; |
| 1727 if (event) { |
| 1728 if (event->type() == ui::ET_MOUSE_PRESSED) { |
| 1729 activate = true; |
| 1730 } else if (event->type() == ui::ET_GESTURE_BEGIN) { |
| 1731 activate = static_cast<const ui::GestureEvent*>(event)-> |
| 1732 details().touch_points() == 1; |
| 1733 } |
| 1734 } else { |
| 1735 return true; |
| 1736 } |
| 1737 if (activate) |
| 1738 host_->OnPointerEventActivate(); |
1731 return is_fullscreen_; | 1739 return is_fullscreen_; |
1732 } | 1740 } |
1733 | 1741 |
1734 void RenderWidgetHostViewAura::OnActivated() { | 1742 void RenderWidgetHostViewAura::OnActivated() { |
1735 // |pointer_activate_| will be true when we are activated as the result of | |
1736 // a valid input event. | |
1737 // TODO(sadrul): It would be nice if we could get the currently processed | |
1738 // event from the RootWindow's EventDispatcher, then we could | |
1739 // avoid this extra field and just check the type/details on | |
1740 // the current event here. | |
1741 if (pointer_activate_) | |
1742 host_->OnPointerEventActivate(); | |
1743 } | 1743 } |
1744 | 1744 |
1745 void RenderWidgetHostViewAura::OnLostActive() { | 1745 void RenderWidgetHostViewAura::OnLostActive() { |
1746 } | 1746 } |
1747 | 1747 |
1748 //////////////////////////////////////////////////////////////////////////////// | 1748 //////////////////////////////////////////////////////////////////////////////// |
1749 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: | 1749 // RenderWidgetHostViewAura, ui::CompositorObserver implementation: |
1750 | 1750 |
1751 void RenderWidgetHostViewAura::OnCompositingDidCommit( | 1751 void RenderWidgetHostViewAura::OnCompositingDidCommit( |
1752 ui::Compositor* compositor) { | 1752 ui::Compositor* compositor) { |
(...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1999 RenderWidgetHost* widget) { | 1999 RenderWidgetHost* widget) { |
2000 return new RenderWidgetHostViewAura(widget); | 2000 return new RenderWidgetHostViewAura(widget); |
2001 } | 2001 } |
2002 | 2002 |
2003 // static | 2003 // static |
2004 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { | 2004 void RenderWidgetHostViewPort::GetDefaultScreenInfo(WebScreenInfo* results) { |
2005 GetScreenInfoForWindow(results, NULL); | 2005 GetScreenInfoForWindow(results, NULL); |
2006 } | 2006 } |
2007 | 2007 |
2008 } // namespace content | 2008 } // namespace content |
OLD | NEW |