| 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) { |
| 289 host_->SetView(this); | 290 host_->SetView(this); |
| 290 window_observer_.reset(new WindowObserver(this)); | 291 window_observer_.reset(new WindowObserver(this)); |
| 291 window_->AddObserver(window_observer_.get()); | 292 window_->AddObserver(window_observer_.get()); |
| 292 aura::client::SetTooltipText(window_, &tooltip_); | 293 aura::client::SetTooltipText(window_, &tooltip_); |
| 293 aura::client::SetActivationDelegate(window_, this); | 294 aura::client::SetActivationDelegate(window_, this); |
| 294 gfx::Screen::GetScreenFor(window_)->AddObserver(this); | 295 gfx::Screen::GetScreenFor(window_)->AddObserver(this); |
| 295 } | 296 } |
| 296 | 297 |
| 297 //////////////////////////////////////////////////////////////////////////////// | 298 //////////////////////////////////////////////////////////////////////////////// |
| 298 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: | 299 // RenderWidgetHostViewAura, RenderWidgetHostView implementation: |
| (...skipping 1235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1534 } else { | 1535 } else { |
| 1535 NativeWebKeyboardEvent webkit_event(event); | 1536 NativeWebKeyboardEvent webkit_event(event); |
| 1536 host_->ForwardKeyboardEvent(webkit_event); | 1537 host_->ForwardKeyboardEvent(webkit_event); |
| 1537 } | 1538 } |
| 1538 } | 1539 } |
| 1539 return ui::ER_HANDLED; | 1540 return ui::ER_HANDLED; |
| 1540 } | 1541 } |
| 1541 | 1542 |
| 1542 ui::EventResult RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { | 1543 ui::EventResult RenderWidgetHostViewAura::OnMouseEvent(ui::MouseEvent* event) { |
| 1543 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); | 1544 TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); |
| 1545 pointer_activate_ = event->type() == ui::ET_MOUSE_PRESSED; |
| 1546 |
| 1544 if (mouse_locked_) { | 1547 if (mouse_locked_) { |
| 1545 // Hide the cursor if someone else has shown it. | 1548 // Hide the cursor if someone else has shown it. |
| 1546 aura::client::CursorClient* cursor_client = | 1549 aura::client::CursorClient* cursor_client = |
| 1547 aura::client::GetCursorClient(window_->GetRootWindow()); | 1550 aura::client::GetCursorClient(window_->GetRootWindow()); |
| 1548 if (cursor_client && cursor_client->IsCursorVisible()) | 1551 if (cursor_client && cursor_client->IsCursorVisible()) |
| 1549 cursor_client->ShowCursor(false); | 1552 cursor_client->ShowCursor(false); |
| 1550 | 1553 |
| 1551 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); | 1554 WebKit::WebMouseEvent mouse_event = MakeWebMouseEvent(event); |
| 1552 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); | 1555 gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); |
| 1553 | 1556 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1674 // Pinch gestures are currently disabled by default. See crbug.com/128477. | 1677 // Pinch gestures are currently disabled by default. See crbug.com/128477. |
| 1675 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || | 1678 if ((event->type() == ui::ET_GESTURE_PINCH_BEGIN || |
| 1676 event->type() == ui::ET_GESTURE_PINCH_UPDATE || | 1679 event->type() == ui::ET_GESTURE_PINCH_UPDATE || |
| 1677 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { | 1680 event->type() == ui::ET_GESTURE_PINCH_END) && !ShouldSendPinchGesture()) { |
| 1678 return ui::ER_CONSUMED; | 1681 return ui::ER_CONSUMED; |
| 1679 } | 1682 } |
| 1680 | 1683 |
| 1681 RenderViewHostDelegate* delegate = NULL; | 1684 RenderViewHostDelegate* delegate = NULL; |
| 1682 if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_) | 1685 if (popup_type_ == WebKit::WebPopupTypeNone && !is_fullscreen_) |
| 1683 delegate = RenderViewHost::From(host_)->GetDelegate(); | 1686 delegate = RenderViewHost::From(host_)->GetDelegate(); |
| 1684 if (delegate && event->type() == ui::ET_GESTURE_BEGIN && | 1687 |
| 1685 event->details().touch_points() == 1) { | 1688 bool gesture_begin = event->type() == ui::ET_GESTURE_BEGIN && |
| 1689 event->details().touch_points() == 1; |
| 1690 if (delegate && gesture_begin) |
| 1686 delegate->HandleGestureBegin(); | 1691 delegate->HandleGestureBegin(); |
| 1687 } | 1692 pointer_activate_ = gesture_begin; |
| 1688 | 1693 |
| 1689 WebKit::WebGestureEvent gesture = MakeWebGestureEvent(event); | 1694 WebKit::WebGestureEvent gesture = MakeWebGestureEvent(event); |
| 1690 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { | 1695 if (event->type() == ui::ET_GESTURE_TAP_DOWN) { |
| 1691 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an | 1696 // Webkit does not stop a fling-scroll on tap-down. So explicitly send an |
| 1692 // event to stop any in-progress flings. | 1697 // event to stop any in-progress flings. |
| 1693 WebKit::WebGestureEvent fling_cancel = gesture; | 1698 WebKit::WebGestureEvent fling_cancel = gesture; |
| 1694 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; | 1699 fling_cancel.type = WebKit::WebInputEvent::GestureFlingCancel; |
| 1695 host_->ForwardGestureEvent(fling_cancel); | 1700 host_->ForwardGestureEvent(fling_cancel); |
| 1696 } | 1701 } |
| 1697 | 1702 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 1715 // If a gesture is not processed by the webpage, then WebKit processes it | 1720 // If a gesture is not processed by the webpage, then WebKit processes it |
| 1716 // (e.g. generates synthetic mouse events). So CONSUMED should be returned | 1721 // (e.g. generates synthetic mouse events). So CONSUMED should be returned |
| 1717 // from here to avoid any duplicate synthetic mouse-events being generated | 1722 // from here to avoid any duplicate synthetic mouse-events being generated |
| 1718 // from aura. | 1723 // from aura. |
| 1719 return ui::ER_CONSUMED; | 1724 return ui::ER_CONSUMED; |
| 1720 } | 1725 } |
| 1721 | 1726 |
| 1722 //////////////////////////////////////////////////////////////////////////////// | 1727 //////////////////////////////////////////////////////////////////////////////// |
| 1723 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: | 1728 // RenderWidgetHostViewAura, aura::client::ActivationDelegate implementation: |
| 1724 | 1729 |
| 1725 bool RenderWidgetHostViewAura::ShouldActivate(const ui::Event* event) { | 1730 bool RenderWidgetHostViewAura::ShouldActivate() const { |
| 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(); | |
| 1739 return is_fullscreen_; | 1731 return is_fullscreen_; |
| 1740 } | 1732 } |
| 1741 | 1733 |
| 1742 void RenderWidgetHostViewAura::OnActivated() { | 1734 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 |