Commit ffae320d authored by pkotwicz@chromium.org's avatar pkotwicz@chromium.org

Avoid changing |drag_reverted_| if the drag was already completed on ChromeOS

This is part #2 of https://codereview.chromium.org/354343002/

BUG=None
TEST=None

Review URL: https://codereview.chromium.org/345133005

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@282392 0039d316-1c4b-4281-b951-d872f2087c98
parent 3bb99779
...@@ -219,10 +219,8 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) { ...@@ -219,10 +219,8 @@ void ToplevelWindowEventHandler::OnGestureEvent(ui::GestureEvent* event) {
} }
if (event->details().touch_points() > 2) { if (event->details().touch_points() > 2) {
if (window_resizer_.get()) { if (CompleteDrag(DRAG_COMPLETE))
CompleteDrag(DRAG_COMPLETE);
event->StopPropagation(); event->StopPropagation();
}
return; return;
} }
...@@ -446,20 +444,30 @@ bool ToplevelWindowEventHandler::AttemptToStartDrag( ...@@ -446,20 +444,30 @@ bool ToplevelWindowEventHandler::AttemptToStartDrag(
return true; return true;
} }
void ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status) { bool ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status) {
if (!window_resizer_)
return false;
scoped_ptr<ScopedWindowResizer> resizer(window_resizer_.release()); scoped_ptr<ScopedWindowResizer> resizer(window_resizer_.release());
if (resizer) { switch (status) {
if (status == DRAG_COMPLETE) case DRAG_COMPLETE:
resizer->resizer()->CompleteDrag(); resizer->resizer()->CompleteDrag();
else break;
case DRAG_REVERT:
resizer->resizer()->RevertDrag(); resizer->resizer()->RevertDrag();
break;
case DRAG_RESIZER_WINDOW_DESTROYED:
// We explicitly do not invoke RevertDrag() since that may do things to
// WindowResizer::GetTarget() which was destroyed.
break;
} }
drag_reverted_ = (status == DRAG_REVERT); drag_reverted_ = (status != DRAG_COMPLETE);
first_finger_hittest_ = HTNOWHERE; first_finger_hittest_ = HTNOWHERE;
in_gesture_drag_ = false; in_gesture_drag_ = false;
if (in_move_loop_) if (in_move_loop_)
quit_closure_.Run(); quit_closure_.Run();
return true;
} }
void ToplevelWindowEventHandler::HandleMousePressed( void ToplevelWindowEventHandler::HandleMousePressed(
...@@ -494,20 +502,8 @@ void ToplevelWindowEventHandler::HandleMouseReleased( ...@@ -494,20 +502,8 @@ void ToplevelWindowEventHandler::HandleMouseReleased(
if (event->phase() != ui::EP_PRETARGET) if (event->phase() != ui::EP_PRETARGET)
return; return;
if (window_resizer_) {
CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ? CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
DRAG_COMPLETE : DRAG_REVERT); DRAG_COMPLETE : DRAG_REVERT);
}
// Completing the drag may result in hiding the window. If this happens
// mark the event as handled so no other handlers/observers act upon the
// event. They should see the event on a hidden window, to determine targets
// of destructive actions such as hiding. They should not act upon them.
if (window_resizer_ &&
event->type() == ui::ET_MOUSE_CAPTURE_CHANGED &&
!target->IsVisible()) {
event->SetHandled();
}
} }
void ToplevelWindowEventHandler::HandleDrag( void ToplevelWindowEventHandler::HandleDrag(
...@@ -611,11 +607,7 @@ void ToplevelWindowEventHandler::SetWindowStateTypeFromGesture( ...@@ -611,11 +607,7 @@ void ToplevelWindowEventHandler::SetWindowStateTypeFromGesture(
} }
void ToplevelWindowEventHandler::ResizerWindowDestroyed() { void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
// We explicitly don't invoke RevertDrag() since that may do things to window. CompleteDrag(DRAG_RESIZER_WINDOW_DESTROYED);
// Instead we destroy the resizer.
window_resizer_.reset();
CompleteDrag(DRAG_REVERT);
} }
} // namespace ash } // namespace ash
...@@ -58,7 +58,12 @@ class ASH_EXPORT ToplevelWindowEventHandler ...@@ -58,7 +58,12 @@ class ASH_EXPORT ToplevelWindowEventHandler
enum DragCompletionStatus { enum DragCompletionStatus {
DRAG_COMPLETE, DRAG_COMPLETE,
DRAG_REVERT DRAG_REVERT,
// To be used when WindowResizer::GetTarget() is destroyed. Neither
// completes nor reverts the drag because both access the WindowResizer's
// window.
DRAG_RESIZER_WINDOW_DESTROYED
}; };
// Attempts to start a drag if one is not already in progress. Returns true if // Attempts to start a drag if one is not already in progress. Returns true if
...@@ -68,8 +73,9 @@ class ASH_EXPORT ToplevelWindowEventHandler ...@@ -68,8 +73,9 @@ class ASH_EXPORT ToplevelWindowEventHandler
int window_component, int window_component,
aura::client::WindowMoveSource source); aura::client::WindowMoveSource source);
// Finishes the drag. // Completes or reverts the drag if one is in progress. Returns true if a
void CompleteDrag(DragCompletionStatus status); // drag was completed or reverted.
bool CompleteDrag(DragCompletionStatus status);
void HandleMousePressed(aura::Window* target, ui::MouseEvent* event); void HandleMousePressed(aura::Window* target, ui::MouseEvent* event);
void HandleMouseReleased(aura::Window* target, ui::MouseEvent* event); void HandleMouseReleased(aura::Window* target, ui::MouseEvent* event);
......
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