diff options
author | yoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 23:50:34 +0000 |
---|---|---|
committer | yoshiki@chromium.org <yoshiki@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-18 23:50:34 +0000 |
commit | 85457bd21f5553e4e6630b3fd46b7af60cd1807a (patch) | |
tree | e844b466e765b543fc783c2174c1eae0baa996ec | |
parent | 3b9dc439a6d22327acbfa03a728a2245b1926ab8 (diff) | |
download | chromium_src-85457bd21f5553e4e6630b3fd46b7af60cd1807a.zip chromium_src-85457bd21f5553e4e6630b3fd46b7af60cd1807a.tar.gz chromium_src-85457bd21f5553e4e6630b3fd46b7af60cd1807a.tar.bz2 |
Revert 142852 - Aura: Add Window::MoveCursorTo() taking relative location to the window.
Previously, although RootWindow::MoveCursorTo() takes a ponit coordinate relative to Root, but OnMouseEvent/LockMouse in RWHVA are using coordinate relative to parent window (which may not be root). UnlockMouse is using global X/Y from webkit.
This CL added Window::MoveCursorTo() taking relative location to the window, and made RWHVA use it.
BUG=none
TEST=manual
Review URL: https://chromiumcodereview.appspot.com/10543174
TBR=yoshiki@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10574007
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142864 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | content/browser/renderer_host/render_widget_host_view_aura.cc | 10 | ||||
-rw-r--r-- | ui/aura/root_window.cc | 9 | ||||
-rw-r--r-- | ui/aura/root_window.h | 5 | ||||
-rw-r--r-- | ui/aura/window.cc | 8 | ||||
-rw-r--r-- | ui/aura/window.h | 3 | ||||
-rw-r--r-- | ui/aura/window_unittest.cc | 99 |
6 files changed, 7 insertions, 127 deletions
diff --git a/content/browser/renderer_host/render_widget_host_view_aura.cc b/content/browser/renderer_host/render_widget_host_view_aura.cc index 99c396a..4150ba5 100644 --- a/content/browser/renderer_host/render_widget_host_view_aura.cc +++ b/content/browser/renderer_host/render_widget_host_view_aura.cc @@ -715,7 +715,7 @@ bool RenderWidgetHostViewAura::LockMouse() { window_->SetCapture(); aura::Env::GetInstance()->cursor_manager()->ShowCursor(false); synthetic_move_sent_ = true; - window_->MoveCursorTo(gfx::Rect(window_->bounds().size()).CenterPoint()); + root_window->MoveCursorTo(window_->bounds().CenterPoint()); if (aura::client::GetTooltipClient(root_window)) aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(false); return true; @@ -729,7 +729,7 @@ void RenderWidgetHostViewAura::UnlockMouse() { mouse_locked_ = false; window_->ReleaseCapture(); - window_->MoveCursorTo(unlocked_mouse_position_); + root_window->MoveCursorTo(unlocked_global_mouse_position_); aura::Env::GetInstance()->cursor_manager()->ShowCursor(true); if (aura::client::GetTooltipClient(root_window)) aura::client::GetTooltipClient(root_window)->SetTooltipsEnabled(true); @@ -1013,11 +1013,11 @@ bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { TRACE_EVENT0("browser", "RenderWidgetHostViewAura::OnMouseEvent"); if (mouse_locked_) { WebKit::WebMouseEvent mouse_event = content::MakeWebMouseEvent(event); - gfx::Point center(gfx::Rect(window_->bounds().size()).CenterPoint()); + gfx::Point center = window_->bounds().CenterPoint(); bool is_move_to_center_event = (event->type() == ui::ET_MOUSE_MOVED || event->type() == ui::ET_MOUSE_DRAGGED) && - mouse_event.x == center.x() && mouse_event.y == center.y(); + mouse_event.globalX == center.x() && mouse_event.globalY == center.y(); ModifyEventMovementAndCoords(&mouse_event); @@ -1028,7 +1028,7 @@ bool RenderWidgetHostViewAura::OnMouseEvent(aura::MouseEvent* event) { // Check if the mouse has reached the border and needs to be centered. if (ShouldMoveToCenter()) { synthetic_move_sent_ = true; - window_->MoveCursorTo(center); + window_->GetRootWindow()->MoveCursorTo(center); } // Forward event to renderer. diff --git a/ui/aura/root_window.cc b/ui/aura/root_window.cc index b54c74f..864f735 100644 --- a/ui/aura/root_window.cc +++ b/ui/aura/root_window.cc @@ -224,10 +224,7 @@ void RootWindow::ShowCursor(bool show) { } void RootWindow::MoveCursorTo(const gfx::Point& location_in_dip) { - gfx::Point location = location_in_dip; - layer()->transform().TransformPoint(location); - host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location)); - last_mouse_location_ = location_in_dip; + host_->MoveCursorTo(ui::ConvertPointToPixel(layer(), location_in_dip)); } bool RootWindow::ConfineCursorToWindow() { @@ -661,10 +658,6 @@ void RootWindow::ReleaseNativeCapture() { host_->ReleaseCapture(); } -gfx::Point RootWindow::QueryMouseLocationForTest() const { - return host_->QueryMouseLocation(); -} - //////////////////////////////////////////////////////////////////////////////// // RootWindow, private: diff --git a/ui/aura/root_window.h b/ui/aura/root_window.h index f0722b5..4a9ac6a 100644 --- a/ui/aura/root_window.h +++ b/ui/aura/root_window.h @@ -129,7 +129,7 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, void ShowCursor(bool show); // Moves the cursor to the specified location relative to the root window. - virtual void MoveCursorTo(const gfx::Point& location) OVERRIDE; + void MoveCursorTo(const gfx::Point& location); // Clips the cursor movement to the root_window. bool ConfineCursorToWindow(); @@ -267,9 +267,6 @@ class AURA_EXPORT RootWindow : public ui::CompositorDelegate, virtual void SetNativeCapture() OVERRIDE; virtual void ReleaseNativeCapture() OVERRIDE; - // Exposes RootWindowHost::QueryMouseLocation() for test purposes. - gfx::Point QueryMouseLocationForTest() const; - private: friend class Window; friend class CompositorLock; diff --git a/ui/aura/window.cc b/ui/aura/window.cc index 6d6230c..92a4025 100644 --- a/ui/aura/window.cc +++ b/ui/aura/window.cc @@ -408,14 +408,6 @@ void Window::ConvertPointToWindow(const Window* source, ui::Layer::ConvertPointToLayer(source->layer(), target->layer(), point); } -void Window::MoveCursorTo(const gfx::Point& point_in_window) { - RootWindow* root_window = GetRootWindow(); - DCHECK(root_window); - gfx::Point point_in_root(point_in_window); - ConvertPointToWindow(this, root_window, &point_in_root); - root_window->MoveCursorTo(point_in_root); -} - gfx::NativeCursor Window::GetCursor(const gfx::Point& point) const { return delegate_ ? delegate_->GetCursor(point) : gfx::kNullCursor; } diff --git a/ui/aura/window.h b/ui/aura/window.h index 34a5702..a516730 100644 --- a/ui/aura/window.h +++ b/ui/aura/window.h @@ -213,9 +213,6 @@ class AURA_EXPORT Window : public ui::LayerDelegate, const Window* target, gfx::Point* point); - // Moves the cursor to the specified location relative to the window. - virtual void MoveCursorTo(const gfx::Point& point_in_window); - // Returns the cursor for the specified point, in window coordinates. gfx::NativeCursor GetCursor(const gfx::Point& point) const; diff --git a/ui/aura/window_unittest.cc b/ui/aura/window_unittest.cc index 96abaf6..d46ddbf 100644 --- a/ui/aura/window_unittest.cc +++ b/ui/aura/window_unittest.cc @@ -16,7 +16,6 @@ #include "ui/aura/event.h" #include "ui/aura/layout_manager.h" #include "ui/aura/root_window.h" -#include "ui/aura/root_window_host.h" #include "ui/aura/root_window_observer.h" #include "ui/aura/test/aura_test_base.h" #include "ui/aura/test/event_generator.h" @@ -324,104 +323,6 @@ TEST_F(WindowTest, ConvertPointToWindow) { EXPECT_EQ(reference_point, test_point); } -TEST_F(WindowTest, MoveCursorTo) { - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); - scoped_ptr<Window> w11( - CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); - scoped_ptr<Window> w111( - CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); - scoped_ptr<Window> w1111( - CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); - - RootWindow* root = root_window(); - root->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("10,10", root->last_mouse_location().ToString()); - w1->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("20,20", root->last_mouse_location().ToString()); - w11->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("25,25", root->last_mouse_location().ToString()); - w111->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("30,30", root->last_mouse_location().ToString()); - w1111->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("35,35", root->last_mouse_location().ToString()); -} - -// Test Window::ConvertPointToWindow() with transform to root_window. -TEST_F(WindowTest, MoveCursorToWithTransformRootWindow) { - RootWindow* root = root_window(); - ui::Transform transform; - transform.ConcatScale(2, 5); - transform.ConcatRotate(90.0f); - transform.ConcatTranslate(100, 100); - root->SetTransform(transform); - root->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("50,120", root->QueryMouseLocationForTest().ToString()); - EXPECT_EQ("10,10", root->last_mouse_location().ToString()); -} - -// Tests Window::ConvertPointToWindow() with transform to non-root windows. -TEST_F(WindowTest, MoveCursorToWithTransformWindow) { - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); - - RootWindow* root = root_window(); - ui::Transform transform1; - transform1.ConcatScale(2, 2); - w1->SetTransform(transform1); - w1->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("30,30", root->last_mouse_location().ToString()); - - ui::Transform transform2; - transform2.ConcatTranslate(-10, 20); - w1->SetTransform(transform2); - w1->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("10,40", root->last_mouse_location().ToString()); - - ui::Transform transform3; - transform3.ConcatRotate(90.0f); - w1->SetTransform(transform3); - w1->MoveCursorTo(gfx::Point(5, 5)); - EXPECT_EQ("5,15", root->last_mouse_location().ToString()); - - ui::Transform transform4; - transform4.ConcatScale(2, 5); - transform4.ConcatRotate(90.0f); - transform4.ConcatTranslate(100, 100); - w1->SetTransform(transform4); - w1->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("60,130", root->last_mouse_location().ToString()); -} - -// Test Window::ConvertPointToWindow() with complex transforms to both root and -// non-root windows. -TEST_F(WindowTest, MoveCursorToWithComplexTransform) { - scoped_ptr<Window> w1( - CreateTestWindow(SK_ColorWHITE, 1, gfx::Rect(10, 10, 500, 500), NULL)); - scoped_ptr<Window> w11( - CreateTestWindow(SK_ColorGREEN, 11, gfx::Rect(5, 5, 100, 100), w1.get())); - scoped_ptr<Window> w111( - CreateTestWindow(SK_ColorCYAN, 111, gfx::Rect(5, 5, 75, 75), w11.get())); - scoped_ptr<Window> w1111( - CreateTestWindow(SK_ColorRED, 1111, gfx::Rect(5, 5, 50, 50), w111.get())); - - RootWindow* root = root_window(); - ui::Transform transform; - transform.ConcatScale(0.3f, 0.5f); - transform.ConcatRotate(10.0f); - transform.ConcatTranslate(10, 20); - - root->SetTransform(transform); - w1->SetTransform(transform); - w11->SetTransform(transform); - w111->SetTransform(transform); - w1111->SetTransform(transform); - - w1111->MoveCursorTo(gfx::Point(10, 10)); - EXPECT_EQ("11,47", root->QueryMouseLocationForTest().ToString()); - EXPECT_EQ("20,53", root->last_mouse_location().ToString()); -} - TEST_F(WindowTest, HitTest) { Window w1(new ColorTestWindowDelegate(SK_ColorWHITE)); w1.set_id(1); |