Chromium Code Reviews| Index: ash/wm/partial_screenshot_view.cc | 
| diff --git a/ash/wm/partial_screenshot_view.cc b/ash/wm/partial_screenshot_view.cc | 
| index 03116e7cf941e30e3b8ef3ecbbbec902a3895c12..03f4d828f04bcd92f5a56b62512c51fc4f58b408 100644 | 
| --- a/ash/wm/partial_screenshot_view.cc | 
| +++ b/ash/wm/partial_screenshot_view.cc | 
| @@ -140,6 +140,31 @@ gfx::Rect PartialScreenshotView::GetScreenshotRect() const { | 
| return gfx::Rect(left, top, width, height); | 
| } | 
| +void PartialScreenshotView::OnSelectionStarted(const gfx::Point& position) { | 
| + start_position_ = position; | 
| +} | 
| + | 
| +void PartialScreenshotView::OnSelectionChanged(const gfx::Point& position) { | 
| + current_position_ = position; | 
| 
 
sky
2013/03/25 23:42:29
Can this early out if is_dragging_ and current_pos
 
Yufeng Shen (Slow to review)
2013/03/26 01:24:03
Done.
 
 | 
| + SchedulePaint(); | 
| + is_dragging_ = true; | 
| +} | 
| + | 
| +void PartialScreenshotView::OnSelectionFinished() { | 
| + overlay_delegate_->Cancel(); | 
| + if (!is_dragging_) | 
| + return; | 
| + | 
| + is_dragging_ = false; | 
| + if (screenshot_delegate_) { | 
| + aura::RootWindow *root_window = | 
| + GetWidget()->GetNativeWindow()->GetRootWindow(); | 
| + screenshot_delegate_->HandleTakePartialScreenshot( | 
| + root_window, | 
| + gfx::IntersectRects(root_window->bounds(), GetScreenshotRect())); | 
| + } | 
| +} | 
| + | 
| gfx::NativeCursor PartialScreenshotView::GetCursor( | 
| const ui::MouseEvent& event) { | 
| // Always use "crosshair" cursor. | 
| @@ -167,14 +192,12 @@ bool PartialScreenshotView::OnMousePressed(const ui::MouseEvent& event) { | 
| Shell::GetInstance()->mouse_cursor_filter(); | 
| mouse_cursor_filter->set_mouse_warp_mode( | 
| internal::MouseCursorEventFilter::WARP_NONE); | 
| - start_position_ = event.location(); | 
| + OnSelectionStarted(event.location()); | 
| return true; | 
| } | 
| bool PartialScreenshotView::OnMouseDragged(const ui::MouseEvent& event) { | 
| - current_position_ = event.location(); | 
| - SchedulePaint(); | 
| - is_dragging_ = true; | 
| + OnSelectionChanged(event.location()); | 
| return true; | 
| } | 
| @@ -184,18 +207,27 @@ bool PartialScreenshotView::OnMouseWheel(const ui::MouseWheelEvent& event) { | 
| } | 
| void PartialScreenshotView::OnMouseReleased(const ui::MouseEvent& event) { | 
| - overlay_delegate_->Cancel(); | 
| - if (!is_dragging_) | 
| - return; | 
| + OnSelectionFinished(); | 
| 
 
sky
2013/03/25 23:42:29
What about if capture is lost?
 
Yufeng Shen (Slow to review)
2013/03/26 01:24:03
Added OnMouseCaptureLost() which basically cancels
 
 | 
| +} | 
| - is_dragging_ = false; | 
| - if (screenshot_delegate_) { | 
| - aura::RootWindow *root_window = | 
| - GetWidget()->GetNativeWindow()->GetRootWindow(); | 
| - screenshot_delegate_->HandleTakePartialScreenshot( | 
| - root_window, | 
| - gfx::IntersectRects(root_window->bounds(), GetScreenshotRect())); | 
| +void PartialScreenshotView::OnGestureEvent(ui::GestureEvent* event) { | 
| + gfx::Point position = event->location(); | 
| 
 
sky
2013/03/25 23:42:29
const gfx::Point&, although you only use this in t
 
Yufeng Shen (Slow to review)
2013/03/26 01:24:03
Done.
 
 | 
| + switch(event->type()) { | 
| + case ui::ET_GESTURE_TAP_DOWN: | 
| + OnSelectionStarted(position); | 
| + break; | 
| + case ui::ET_GESTURE_SCROLL_UPDATE: | 
| + OnSelectionChanged(position); | 
| + break; | 
| + case ui::ET_GESTURE_SCROLL_END: | 
| + case ui::ET_SCROLL_FLING_START: | 
| + OnSelectionFinished(); | 
| + break; | 
| + default: | 
| + break; | 
| } | 
| + | 
| + event->SetHandled(); | 
| } | 
| } // namespace ash |