diff options
author | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-07 23:27:46 +0000 |
---|---|---|
committer | pkotwicz@chromium.org <pkotwicz@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2013-10-07 23:27:46 +0000 |
commit | 06bb6fb96dbff552ed1608d7f47c51d2098a7b3f (patch) | |
tree | a46a4e0a4d8c84b7d3c6bb9559533d91e8146a81 /ash | |
parent | f7ab9b60439770558a1f97c758fbb812c88b552b (diff) | |
download | chromium_src-06bb6fb96dbff552ed1608d7f47c51d2098a7b3f.zip chromium_src-06bb6fb96dbff552ed1608d7f47c51d2098a7b3f.tar.gz chromium_src-06bb6fb96dbff552ed1608d7f47c51d2098a7b3f.tar.bz2 |
Fix regression wrt aura::Window::set_hit_test_bounds_override_inner() due to https://chromiumcodereview.appspot.com/14439006
BUG=304196
TEST=ToplevelWindowEventHandlerResizeTest.MouseResizeShadows
Review URL: https://codereview.chromium.org/25807005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@227376 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ash')
-rw-r--r-- | ash/wm/frame_painter.cc | 39 | ||||
-rw-r--r-- | ash/wm/frame_painter.h | 7 | ||||
-rw-r--r-- | ash/wm/toplevel_window_event_handler_unittest.cc | 40 | ||||
-rw-r--r-- | ash/wm/workspace/workspace_window_resizer_unittest.cc | 20 |
4 files changed, 70 insertions, 36 deletions
diff --git a/ash/wm/frame_painter.cc b/ash/wm/frame_painter.cc index 3368001..42c6b3f 100644 --- a/ash/wm/frame_painter.cc +++ b/ash/wm/frame_painter.cc @@ -256,16 +256,17 @@ void FramePainter::Init( rb.GetImageNamed(IDR_AURA_WINDOW_HEADER_SHADE_RIGHT).ToImageSkia(); window_ = frame->GetNativeWindow(); - gfx::Insets mouse_insets = gfx::Insets(-kResizeOutsideBoundsSize, - -kResizeOutsideBoundsSize, - -kResizeOutsideBoundsSize, - -kResizeOutsideBoundsSize); - gfx::Insets touch_insets = mouse_insets.Scale( + gfx::Insets mouse_outer_insets(-kResizeOutsideBoundsSize, + -kResizeOutsideBoundsSize, + -kResizeOutsideBoundsSize, + -kResizeOutsideBoundsSize); + gfx::Insets touch_outer_insets = mouse_outer_insets.Scale( kResizeOutsideBoundsScaleForTouch); // Ensure we get resize cursors for a few pixels outside our bounds. - window_->SetHitTestBoundsOverrideOuter(mouse_insets, touch_insets); + window_->SetHitTestBoundsOverrideOuter(mouse_outer_insets, + touch_outer_insets); // Ensure we get resize cursors just inside our bounds as well. - window_->set_hit_test_bounds_override_inner(mouse_insets); + UpdateHitTestBoundsOverrideInner(); // Watch for maximize/restore/fullscreen state changes. Observer removes // itself in OnWindowDestroying() below, or in the destructor if we go away @@ -627,16 +628,7 @@ void FramePainter::OnTrackedByWorkspaceChanged(wm::WindowState* window_state, void FramePainter::OnWindowShowTypeChanged(wm::WindowState* window_state, wm::WindowShowType old_type) { - // Maximized and fullscreen windows don't want resize handles overlapping the - // content area, because when the user moves the cursor to the right screen - // edge we want them to be able to hit the scroll bar. - if (window_state->IsMaximizedOrFullscreen()) { - window_state->window()->set_hit_test_bounds_override_inner(gfx::Insets()); - } else { - window_state->window()->set_hit_test_bounds_override_inner( - gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, - kResizeInsideBoundsSize, kResizeInsideBoundsSize)); - } + UpdateHitTestBoundsOverrideInner(); } /////////////////////////////////////////////////////////////////////////////// @@ -818,6 +810,19 @@ void FramePainter::UpdateSoloWindowInRoot(RootWindow* root, } } +void FramePainter::UpdateHitTestBoundsOverrideInner() { + // Maximized and fullscreen windows don't want resize handles overlapping the + // content area, because when the user moves the cursor to the right screen + // edge we want them to be able to hit the scroll bar. + if (wm::GetWindowState(window_)->IsMaximizedOrFullscreen()) { + window_->set_hit_test_bounds_override_inner(gfx::Insets()); + } else { + window_->set_hit_test_bounds_override_inner( + gfx::Insets(kResizeInsideBoundsSize, kResizeInsideBoundsSize, + kResizeInsideBoundsSize, kResizeInsideBoundsSize)); + } +} + void FramePainter::SchedulePaintForHeader() { int top_left_height = top_left_corner_->height(); int top_right_height = top_right_corner_->height(); diff --git a/ash/wm/frame_painter.h b/ash/wm/frame_painter.h index 37fb097..49b3398 100644 --- a/ash/wm/frame_painter.h +++ b/ash/wm/frame_painter.h @@ -182,9 +182,6 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, // Returns the radius of the header's top corners. int GetHeaderCornerRadius() const; - // Adjust frame operations for left / right maximized modes. - int AdjustFrameHitCodeForMaximizedModes(int hit_code); - // Returns true if |window_->GetRootWindow()| should be drawing transparent // window headers. bool UseSoloWindowHeader() const; @@ -203,6 +200,10 @@ class ASH_EXPORT FramePainter : public aura::WindowObserver, static void UpdateSoloWindowInRoot(aura::RootWindow* root_window, aura::Window* ignore_window); + // Updates the size of the region inside of |window_| in which the resize + // handles are shown based on |window_|'s show type. + void UpdateHitTestBoundsOverrideInner(); + // Schedules a paint for the header. Used when transitioning from no header to // a header (or other way around). void SchedulePaintForHeader(); diff --git a/ash/wm/toplevel_window_event_handler_unittest.cc b/ash/wm/toplevel_window_event_handler_unittest.cc index 45958e8..42ee673 100644 --- a/ash/wm/toplevel_window_event_handler_unittest.cc +++ b/ash/wm/toplevel_window_event_handler_unittest.cc @@ -703,14 +703,26 @@ class ToplevelWindowEventHandlerResizeTest target_.reset(CreateTestWindowInShellWithDelegate( delegate_, 0, gfx::Rect(0, 0, 100, 100))); - gfx::Insets mouse_insets = gfx::Insets(-ash::kResizeOutsideBoundsSize, - -ash::kResizeOutsideBoundsSize, - -ash::kResizeOutsideBoundsSize, - -ash::kResizeOutsideBoundsSize); - gfx::Insets touch_insets = - mouse_insets.Scale(ash::kResizeOutsideBoundsScaleForTouch); - target_->SetHitTestBoundsOverrideOuter(mouse_insets, touch_insets); - target_->set_hit_test_bounds_override_inner(mouse_insets); + // Add a child window to |target_| in order to properly test that the resize + // shadows are shown when the mouse is ash::kResizeInsideBoundsSize inside + // |target_|'s edges. + aura::Window* child = CreateTestWindowInShell( + SK_ColorWHITE, 0, gfx::Rect(0, 10, 100, 90)); + target_->AddChild(child); + + gfx::Insets mouse_outer_insets(-ash::kResizeOutsideBoundsSize, + -ash::kResizeOutsideBoundsSize, + -ash::kResizeOutsideBoundsSize, + -ash::kResizeOutsideBoundsSize); + gfx::Insets touch_outer_insets = + mouse_outer_insets.Scale(ash::kResizeOutsideBoundsScaleForTouch); + target_->SetHitTestBoundsOverrideOuter(mouse_outer_insets, + touch_outer_insets); + target_->set_hit_test_bounds_override_inner( + gfx::Insets(ash::kResizeInsideBoundsSize, + ash::kResizeInsideBoundsSize, + ash::kResizeInsideBoundsSize, + ash::kResizeInsideBoundsSize)); } virtual void TearDown() OVERRIDE { @@ -808,6 +820,18 @@ TEST_F(ToplevelWindowEventHandlerResizeTest, MouseResizeShadows) { ASSERT_TRUE(HasResizeShadow()); EXPECT_EQ(HTBOTTOM, ResizeShadowLastHitTest()); + // Move the mouse outside the bottom border but still within the window's + // resize area. + generator.MoveMouseTo(50, 100 + ash::kResizeOutsideBoundsSize - 1); + ASSERT_TRUE(HasResizeShadow()); + EXPECT_EQ(HTBOTTOM, ResizeShadowLastHitTest()); + + // Move the mouse above the bottom border but still within the window's + // resize area. + generator.MoveMouseTo(50, 100 - ash::kResizeInsideBoundsSize); + ASSERT_TRUE(HasResizeShadow()); + EXPECT_EQ(HTBOTTOM, ResizeShadowLastHitTest()); + // Move mouse out of the window. Shadows should disappear. generator.MoveMouseTo(150, 150); EXPECT_FALSE(HasResizeShadow()); diff --git a/ash/wm/workspace/workspace_window_resizer_unittest.cc b/ash/wm/workspace/workspace_window_resizer_unittest.cc index fcad68a..8451e83a 100644 --- a/ash/wm/workspace/workspace_window_resizer_unittest.cc +++ b/ash/wm/workspace/workspace_window_resizer_unittest.cc @@ -190,15 +190,19 @@ class WorkspaceWindowResizerTest : public test::AshTestBase { touch_resize_window_.reset( CreateTestWindowInShellWithDelegate(&touch_resize_delegate_, 0, bounds)); - gfx::Insets mouse_insets = gfx::Insets(-ash::kResizeOutsideBoundsSize, - -ash::kResizeOutsideBoundsSize, - -ash::kResizeOutsideBoundsSize, - -ash::kResizeOutsideBoundsSize); - gfx::Insets touch_insets = mouse_insets.Scale( + gfx::Insets mouse_outer_insets = gfx::Insets(-ash::kResizeOutsideBoundsSize, + -ash::kResizeOutsideBoundsSize, + -ash::kResizeOutsideBoundsSize, + -ash::kResizeOutsideBoundsSize); + gfx::Insets touch_outer_insets = mouse_outer_insets.Scale( ash::kResizeOutsideBoundsScaleForTouch); - touch_resize_window_->SetHitTestBoundsOverrideOuter(mouse_insets, - touch_insets); - touch_resize_window_->set_hit_test_bounds_override_inner(mouse_insets); + touch_resize_window_->SetHitTestBoundsOverrideOuter(mouse_outer_insets, + touch_outer_insets); + touch_resize_window_->set_hit_test_bounds_override_inner( + gfx::Insets(ash::kResizeInsideBoundsSize, + ash::kResizeInsideBoundsSize, + ash::kResizeInsideBoundsSize, + ash::kResizeInsideBoundsSize)); } // Simulate running the animation. |