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) {
}
if (event->details().touch_points() > 2) {
if (window_resizer_.get()) {
CompleteDrag(DRAG_COMPLETE);
if (CompleteDrag(DRAG_COMPLETE))
event->StopPropagation();
}
return;
}
......@@ -446,20 +444,30 @@ bool ToplevelWindowEventHandler::AttemptToStartDrag(
return true;
}
void ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status) {
bool ToplevelWindowEventHandler::CompleteDrag(DragCompletionStatus status) {
if (!window_resizer_)
return false;
scoped_ptr<ScopedWindowResizer> resizer(window_resizer_.release());
if (resizer) {
if (status == DRAG_COMPLETE)
switch (status) {
case DRAG_COMPLETE:
resizer->resizer()->CompleteDrag();
else
break;
case DRAG_REVERT:
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;
in_gesture_drag_ = false;
if (in_move_loop_)
quit_closure_.Run();
return true;
}
void ToplevelWindowEventHandler::HandleMousePressed(
......@@ -494,20 +502,8 @@ void ToplevelWindowEventHandler::HandleMouseReleased(
if (event->phase() != ui::EP_PRETARGET)
return;
if (window_resizer_) {
CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
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();
}
CompleteDrag(event->type() == ui::ET_MOUSE_RELEASED ?
DRAG_COMPLETE : DRAG_REVERT);
}
void ToplevelWindowEventHandler::HandleDrag(
......@@ -611,11 +607,7 @@ void ToplevelWindowEventHandler::SetWindowStateTypeFromGesture(
}
void ToplevelWindowEventHandler::ResizerWindowDestroyed() {
// We explicitly don't invoke RevertDrag() since that may do things to window.
// Instead we destroy the resizer.
window_resizer_.reset();
CompleteDrag(DRAG_REVERT);
CompleteDrag(DRAG_RESIZER_WINDOW_DESTROYED);
}
} // namespace ash
......@@ -58,7 +58,12 @@ class ASH_EXPORT ToplevelWindowEventHandler
enum DragCompletionStatus {
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
......@@ -68,8 +73,9 @@ class ASH_EXPORT ToplevelWindowEventHandler
int window_component,
aura::client::WindowMoveSource source);
// Finishes the drag.
void CompleteDrag(DragCompletionStatus status);
// Completes or reverts the drag if one is in progress. Returns true if a
// drag was completed or reverted.
bool CompleteDrag(DragCompletionStatus status);
void HandleMousePressed(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