Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(471)

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 139983009: ui::LocatedEvent location() returns gfx::PointF (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Undo accidental change. Created 6 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "chrome/browser/ui/views/tabs/tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #if defined(OS_WIN) 7 #if defined(OS_WIN)
8 #include <windowsx.h> 8 #include <windowsx.h>
9 #endif 9 #endif
10 10
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 path->lineTo(w - 1, v_offset + 17); 283 path->lineTo(w - 1, v_offset + 17);
284 path->lineTo(7, v_offset + 17); 284 path->lineTo(7, v_offset + 17);
285 path->lineTo(4, v_offset + 13); 285 path->lineTo(4, v_offset + 13);
286 path->lineTo(0, v_offset + 1); 286 path->lineTo(0, v_offset + 1);
287 path->close(); 287 path->close();
288 } 288 }
289 289
290 #if defined(OS_WIN) 290 #if defined(OS_WIN)
291 void NewTabButton::OnMouseReleased(const ui::MouseEvent& event) { 291 void NewTabButton::OnMouseReleased(const ui::MouseEvent& event) {
292 if (event.IsOnlyRightMouseButton()) { 292 if (event.IsOnlyRightMouseButton()) {
293 gfx::Point point = event.location(); 293 gfx::Point point = gfx::ToFlooredPoint(event.location());
294 views::View::ConvertPointToScreen(this, &point); 294 views::View::ConvertPointToScreen(this, &point);
295 bool destroyed = false; 295 bool destroyed = false;
296 destroyed_ = &destroyed; 296 destroyed_ = &destroyed;
297 gfx::ShowSystemMenuAtPoint(views::HWNDForView(this), point); 297 gfx::ShowSystemMenuAtPoint(views::HWNDForView(this), point);
298 if (destroyed) 298 if (destroyed)
299 return; 299 return;
300 300
301 destroyed_ = NULL; 301 destroyed_ = NULL;
302 SetState(views::CustomButton::STATE_NORMAL); 302 SetState(views::CustomButton::STATE_NORMAL);
303 return; 303 return;
(...skipping 727 matching lines...) Expand 10 before | Expand all | Expand 10 after
1031 1031
1032 drag_controller_.reset(new TabDragController); 1032 drag_controller_.reset(new TabDragController);
1033 drag_controller_->Init( 1033 drag_controller_->Init(
1034 this, tab, tabs, gfx::Point(x, y), event.x(), selection_model, 1034 this, tab, tabs, gfx::Point(x, y), event.x(), selection_model,
1035 detach_behavior, move_behavior, EventSourceFromEvent(event)); 1035 detach_behavior, move_behavior, EventSourceFromEvent(event));
1036 } 1036 }
1037 1037
1038 void TabStrip::ContinueDrag(views::View* view, const ui::LocatedEvent& event) { 1038 void TabStrip::ContinueDrag(views::View* view, const ui::LocatedEvent& event) {
1039 if (drag_controller_.get() && 1039 if (drag_controller_.get() &&
1040 drag_controller_->event_source() == EventSourceFromEvent(event)) { 1040 drag_controller_->event_source() == EventSourceFromEvent(event)) {
1041 gfx::Point screen_location(event.location()); 1041 gfx::Point screen_location(gfx::ToFlooredPoint(event.location()));
1042 views::View::ConvertPointToScreen(view, &screen_location); 1042 views::View::ConvertPointToScreen(view, &screen_location);
1043 drag_controller_->Drag(screen_location); 1043 drag_controller_->Drag(screen_location);
1044 } 1044 }
1045 } 1045 }
1046 1046
1047 bool TabStrip::EndDrag(EndDragReason reason) { 1047 bool TabStrip::EndDrag(EndDragReason reason) {
1048 if (!drag_controller_.get()) 1048 if (!drag_controller_.get())
1049 return false; 1049 return false;
1050 bool started_drag = drag_controller_->started_drag(); 1050 bool started_drag = drag_controller_->started_drag();
1051 drag_controller_->EndDrag(reason); 1051 drag_controller_->EndDrag(reason);
(...skipping 441 matching lines...) Expand 10 before | Expand all | Expand 10 after
1493 } 1493 }
1494 break; 1494 break;
1495 1495
1496 case ui::ET_GESTURE_LONG_PRESS: 1496 case ui::ET_GESTURE_LONG_PRESS:
1497 if (drag_controller_.get()) 1497 if (drag_controller_.get())
1498 drag_controller_->SetMoveBehavior(TabDragController::REORDER); 1498 drag_controller_->SetMoveBehavior(TabDragController::REORDER);
1499 break; 1499 break;
1500 1500
1501 case ui::ET_GESTURE_LONG_TAP: { 1501 case ui::ET_GESTURE_LONG_TAP: {
1502 EndDrag(END_DRAG_CANCEL); 1502 EndDrag(END_DRAG_CANCEL);
1503 gfx::Point local_point = event->location(); 1503 gfx::Point local_point = gfx::ToFlooredPoint(event->location());
1504 Tab* tab = FindTabForEvent(local_point); 1504 Tab* tab = FindTabForEvent(local_point);
1505 if (tab) { 1505 if (tab) {
1506 ConvertPointToScreen(this, &local_point); 1506 ConvertPointToScreen(this, &local_point);
1507 ShowContextMenuForTab(tab, local_point, ui::MENU_SOURCE_TOUCH); 1507 ShowContextMenuForTab(tab, local_point, ui::MENU_SOURCE_TOUCH);
1508 } 1508 }
1509 break; 1509 break;
1510 } 1510 }
1511 1511
1512 case ui::ET_GESTURE_SCROLL_UPDATE: 1512 case ui::ET_GESTURE_SCROLL_UPDATE:
1513 ContinueDrag(this, *event); 1513 ContinueDrag(this, *event);
(...skipping 488 matching lines...) Expand 10 before | Expand all | Expand 10 after
2002 // layout then else everything shifts. Instead we wait for the release. 2002 // layout then else everything shifts. Instead we wait for the release.
2003 // 2003 //
2004 // TODO(sky): revisit this when touch events are really plumbed through. 2004 // TODO(sky): revisit this when touch events are really plumbed through.
2005 2005
2006 switch (event.type()) { 2006 switch (event.type()) {
2007 case ui::ET_MOUSE_PRESSED: 2007 case ui::ET_MOUSE_PRESSED:
2008 mouse_move_count_ = 0; 2008 mouse_move_count_ = 0;
2009 last_mouse_move_time_ = base::TimeTicks(); 2009 last_mouse_move_time_ = base::TimeTicks();
2010 SetResetToShrinkOnExit((event.flags() & ui::EF_FROM_TOUCH) == 0); 2010 SetResetToShrinkOnExit((event.flags() & ui::EF_FROM_TOUCH) == 0);
2011 if (reset_to_shrink_on_exit_ && touch_layout_.get()) { 2011 if (reset_to_shrink_on_exit_ && touch_layout_.get()) {
2012 gfx::Point tab_strip_point(event.location()); 2012 gfx::Point tab_strip_point(gfx::ToFlooredPoint(event.location()));
2013 views::View::ConvertPointToTarget(source, this, &tab_strip_point); 2013 views::View::ConvertPointToTarget(source, this, &tab_strip_point);
2014 Tab* tab = FindTabForEvent(tab_strip_point); 2014 Tab* tab = FindTabForEvent(tab_strip_point);
2015 if (tab && touch_layout_->IsStacked(GetModelIndexOfTab(tab))) { 2015 if (tab && touch_layout_->IsStacked(GetModelIndexOfTab(tab))) {
2016 SetLayoutType(TAB_STRIP_LAYOUT_SHRINK, true); 2016 SetLayoutType(TAB_STRIP_LAYOUT_SHRINK, true);
2017 controller_->LayoutTypeMaybeChanged(); 2017 controller_->LayoutTypeMaybeChanged();
2018 } 2018 }
2019 } 2019 }
2020 break; 2020 break;
2021 2021
2022 case ui::ET_MOUSE_MOVED: { 2022 case ui::ET_MOUSE_MOVED: {
2023 #if defined(USE_ASH) 2023 #if defined(USE_ASH)
2024 // Ash does not synthesize mouse events from touch events. 2024 // Ash does not synthesize mouse events from touch events.
2025 SetResetToShrinkOnExit(true); 2025 SetResetToShrinkOnExit(true);
2026 #else 2026 #else
2027 gfx::Point location(event.location()); 2027 gfx::Point location(gfx::ToFlooredPoint(event.location()));
2028 ConvertPointToTarget(source, this, &location); 2028 ConvertPointToTarget(source, this, &location);
2029 if (location == last_mouse_move_location_) 2029 if (location == last_mouse_move_location_)
2030 return; // Ignore spurious moves. 2030 return; // Ignore spurious moves.
2031 last_mouse_move_location_ = location; 2031 last_mouse_move_location_ = location;
2032 if ((event.flags() & ui::EF_FROM_TOUCH) == 0 && 2032 if ((event.flags() & ui::EF_FROM_TOUCH) == 0 &&
2033 (event.flags() & ui::EF_IS_SYNTHESIZED) == 0) { 2033 (event.flags() & ui::EF_IS_SYNTHESIZED) == 0) {
2034 if ((base::TimeTicks::Now() - last_mouse_move_time_).InMilliseconds() < 2034 if ((base::TimeTicks::Now() - last_mouse_move_time_).InMilliseconds() <
2035 kMouseMoveTimeMS) { 2035 kMouseMoveTimeMS) {
2036 if (mouse_move_count_++ == kMouseMoveCountBeforeConsiderReal) 2036 if (mouse_move_count_++ == kMouseMoveCountBeforeConsiderReal)
2037 SetResetToShrinkOnExit(true); 2037 SetResetToShrinkOnExit(true);
2038 } else { 2038 } else {
2039 mouse_move_count_ = 1; 2039 mouse_move_count_ = 1;
2040 last_mouse_move_time_ = base::TimeTicks::Now(); 2040 last_mouse_move_time_ = base::TimeTicks::Now();
2041 } 2041 }
2042 } else { 2042 } else {
2043 last_mouse_move_time_ = base::TimeTicks(); 2043 last_mouse_move_time_ = base::TimeTicks();
2044 } 2044 }
2045 #endif 2045 #endif
2046 break; 2046 break;
2047 } 2047 }
2048 2048
2049 case ui::ET_MOUSE_RELEASED: { 2049 case ui::ET_MOUSE_RELEASED: {
2050 gfx::Point location(event.location()); 2050 gfx::Point location(gfx::ToFlooredPoint(event.location()));
2051 ConvertPointToTarget(source, this, &location); 2051 ConvertPointToTarget(source, this, &location);
2052 last_mouse_move_location_ = location; 2052 last_mouse_move_location_ = location;
2053 mouse_move_count_ = 0; 2053 mouse_move_count_ = 0;
2054 last_mouse_move_time_ = base::TimeTicks(); 2054 last_mouse_move_time_ = base::TimeTicks();
2055 if ((event.flags() & ui::EF_FROM_TOUCH) == ui::EF_FROM_TOUCH) { 2055 if ((event.flags() & ui::EF_FROM_TOUCH) == ui::EF_FROM_TOUCH) {
2056 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true); 2056 SetLayoutType(TAB_STRIP_LAYOUT_STACKED, true);
2057 controller_->LayoutTypeMaybeChanged(); 2057 controller_->LayoutTypeMaybeChanged();
2058 } 2058 }
2059 break; 2059 break;
2060 } 2060 }
(...skipping 582 matching lines...) Expand 10 before | Expand all | Expand 10 after
2643 else 2643 else
2644 RemoveMessageLoopObserver(); 2644 RemoveMessageLoopObserver();
2645 } 2645 }
2646 2646
2647 bool TabStrip::GetAdjustLayout() const { 2647 bool TabStrip::GetAdjustLayout() const {
2648 if (!adjust_layout_) 2648 if (!adjust_layout_)
2649 return false; 2649 return false;
2650 return chrome::GetHostDesktopTypeForNativeView( 2650 return chrome::GetHostDesktopTypeForNativeView(
2651 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH; 2651 GetWidget()->GetNativeView()) == chrome::HOST_DESKTOP_TYPE_ASH;
2652 } 2652 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698