Commit 7e92a9b6 authored by Avery Musbach's avatar Avery Musbach Committed by Commit Bot

split view: Use DCHECK(!IsDividerAnimating()) in SnapWindow

BEFORE: SplitViewController::SnapWindow bails out if called during the
divider snap animation. Callers check for the divider snap animation
before calling SplitViewController::SnapWindow, because correct behavior
is never achieved just by allowing SplitViewController::SnapWindow to
silently fail.

AFTER: SplitViewController::SnapWindow has a DCHECK that fails during
the divider snap animation.

FYI: It behooves me to discuss why snapping a window during the divider
snap animation is problematic in the first place. See [1] for my
commentary about what can happen if the window becomes snapped and the
divider continues to animate. Another idea would be to interrupt the
divider snap animation, but that proposition is not as simple as it may
sound, because if the divider is animating to an edge of the work area,
then split view mode will end.

[1] https://chromium-review.googlesource.com/c/chromium/src/+/1480869/1/ash/wm/splitview/split_view_controller.cc

Bug: None
Change-Id: Ie457e53448ffe440c738f171e4c4b0d0affcf76c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1911704Reviewed-by: default avatarMitsuru Oshima <oshima@chromium.org>
Commit-Queue: Avery Musbach <amusbach@chromium.org>
Cr-Commit-Position: refs/heads/master@{#714557}
parent 139ffb82
...@@ -328,15 +328,9 @@ void SplitViewController::SnapWindow(aura::Window* window, ...@@ -328,15 +328,9 @@ void SplitViewController::SnapWindow(aura::Window* window,
DCHECK(window && CanSnapInSplitview(window)); DCHECK(window && CanSnapInSplitview(window));
DCHECK_NE(snap_position, NONE); DCHECK_NE(snap_position, NONE);
DCHECK(!is_resizing_); DCHECK(!is_resizing_);
DCHECK(!IsDividerAnimating());
DCHECK_EQ(root_window_, window->GetRootWindow()); DCHECK_EQ(root_window_, window->GetRootWindow());
// This check detects the case that you try to snap a window while watching
// the divider snap animation. It also detects the case that you click a
// window in overview while tap dragging the divider (possible by using the
// emulator or chrome://flags/#force-tablet-mode).
if (IsDividerAnimating())
return;
UpdateSnappingWindowTransformedBounds(window); UpdateSnappingWindowTransformedBounds(window);
RemoveWindowFromOverviewIfApplicable(window); RemoveWindowFromOverviewIfApplicable(window);
......
...@@ -1121,36 +1121,6 @@ TEST_P(SplitViewControllerTest, DragAndDoubleTapDivider) { ...@@ -1121,36 +1121,6 @@ TEST_P(SplitViewControllerTest, DragAndDoubleTapDivider) {
EXPECT_EQ(split_view_controller()->right_window(), window2.get()); EXPECT_EQ(split_view_controller()->right_window(), window2.get());
} }
// Verify that you cannot snap a window during the divider snap animation.
TEST_P(SplitViewControllerTest, SnapWindowDuringDividerSnapAnimation) {
const gfx::Rect bounds(0, 0, 400, 400);
std::unique_ptr<aura::Window> window1(CreateWindow(bounds));
std::unique_ptr<aura::Window> window2(CreateWindow(bounds));
std::unique_ptr<aura::Window> window3(CreateWindow(bounds));
std::unique_ptr<aura::Window> window4(CreateWindow(bounds));
split_view_controller()->SnapWindow(window1.get(), SplitViewController::LEFT);
split_view_controller()->SnapWindow(window2.get(),
SplitViewController::RIGHT);
ASSERT_EQ(split_view_controller()->left_window(), window1.get());
ASSERT_EQ(split_view_controller()->right_window(), window2.get());
// Drag the divider to trigger the snap animation.
const gfx::Point divider_center =
split_view_divider()
->GetDividerBoundsInScreen(false /* is_dragging */)
.CenterPoint();
GetEventGenerator()->set_current_screen_location(divider_center);
GetEventGenerator()->DragMouseBy(20, 0);
ASSERT_TRUE(IsDividerAnimating());
split_view_controller()->SnapWindow(window3.get(), SplitViewController::LEFT);
split_view_controller()->SnapWindow(window4.get(),
SplitViewController::RIGHT);
EXPECT_EQ(split_view_controller()->left_window(), window1.get());
EXPECT_EQ(split_view_controller()->right_window(), window2.get());
}
// Verify that you cannot start dragging the divider during its snap animation. // Verify that you cannot start dragging the divider during its snap animation.
TEST_P(SplitViewControllerTest, StartDraggingDividerDuringSnapAnimation) { TEST_P(SplitViewControllerTest, StartDraggingDividerDuringSnapAnimation) {
const gfx::Rect bounds(0, 0, 400, 400); const gfx::Rect bounds(0, 0, 400, 400);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment