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

Side by Side Diff: chrome/browser/ui/views/tabs/tab.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.h" 5 #include "chrome/browser/ui/views/tabs/tab.h"
6 6
7 #include <limits> 7 #include <limits>
8 8
9 #include "base/command_line.h" 9 #include "base/command_line.h"
10 #include "base/debug/alias.h" 10 #include "base/debug/alias.h"
(...skipping 884 matching lines...) Expand 10 before | Expand all | Expand 10 after
895 // In some cases, ending the drag will schedule the tab for destruction; if 895 // In some cases, ending the drag will schedule the tab for destruction; if
896 // so, bail immediately, since our members are already dead and we shouldn't 896 // so, bail immediately, since our members are already dead and we shouldn't
897 // do anything else except drop the tab where it is. 897 // do anything else except drop the tab where it is.
898 if (controller_->EndDrag(END_DRAG_COMPLETE)) 898 if (controller_->EndDrag(END_DRAG_COMPLETE))
899 return; 899 return;
900 900
901 // Close tab on middle click, but only if the button is released over the tab 901 // Close tab on middle click, but only if the button is released over the tab
902 // (normal windows behavior is to discard presses of a UI element where the 902 // (normal windows behavior is to discard presses of a UI element where the
903 // releases happen off the element). 903 // releases happen off the element).
904 if (event.IsMiddleMouseButton()) { 904 if (event.IsMiddleMouseButton()) {
905 if (HitTestPoint(event.location())) { 905 if (HitTestPoint(gfx::ToFlooredPoint(event.location()))) {
906 controller_->CloseTab(this, CLOSE_TAB_FROM_MOUSE); 906 controller_->CloseTab(this, CLOSE_TAB_FROM_MOUSE);
907 } else if (closing_) { 907 } else if (closing_) {
908 // We're animating closed and a middle mouse button was pushed on us but 908 // We're animating closed and a middle mouse button was pushed on us but
909 // we don't contain the mouse anymore. We assume the user is clicking 909 // we don't contain the mouse anymore. We assume the user is clicking
910 // quicker than the animation and we should close the tab that falls under 910 // quicker than the animation and we should close the tab that falls under
911 // the mouse. 911 // the mouse.
912 Tab* closest_tab = controller_->GetTabAt(this, event.location()); 912 Tab* closest_tab =
913 controller_->GetTabAt(this, gfx::ToFlooredPoint(event.location()));
913 if (closest_tab) 914 if (closest_tab)
914 controller_->CloseTab(closest_tab, CLOSE_TAB_FROM_MOUSE); 915 controller_->CloseTab(closest_tab, CLOSE_TAB_FROM_MOUSE);
915 } 916 }
916 } else if (event.IsOnlyLeftMouseButton() && !event.IsShiftDown() && 917 } else if (event.IsOnlyLeftMouseButton() && !event.IsShiftDown() &&
917 !event.IsControlDown()) { 918 !event.IsControlDown()) {
918 // If the tab was already selected mouse pressed doesn't change the 919 // If the tab was already selected mouse pressed doesn't change the
919 // selection. Reset it now to handle the case where multiple tabs were 920 // selection. Reset it now to handle the case where multiple tabs were
920 // selected. 921 // selected.
921 controller_->SelectTab(this); 922 controller_->SelectTab(this);
922 } 923 }
923 } 924 }
924 925
925 void Tab::OnMouseCaptureLost() { 926 void Tab::OnMouseCaptureLost() {
926 controller_->EndDrag(END_DRAG_CAPTURE_LOST); 927 controller_->EndDrag(END_DRAG_CAPTURE_LOST);
927 } 928 }
928 929
929 void Tab::OnMouseEntered(const ui::MouseEvent& event) { 930 void Tab::OnMouseEntered(const ui::MouseEvent& event) {
930 hover_controller_.Show(views::GlowHoverController::SUBTLE); 931 hover_controller_.Show(views::GlowHoverController::SUBTLE);
931 } 932 }
932 933
933 void Tab::OnMouseMoved(const ui::MouseEvent& event) { 934 void Tab::OnMouseMoved(const ui::MouseEvent& event) {
934 hover_controller_.SetLocation(event.location()); 935 hover_controller_.SetLocation(gfx::ToFlooredPoint(event.location()));
935 controller_->OnMouseEventInTab(this, event); 936 controller_->OnMouseEventInTab(this, event);
936 } 937 }
937 938
938 void Tab::OnMouseExited(const ui::MouseEvent& event) { 939 void Tab::OnMouseExited(const ui::MouseEvent& event) {
939 hover_controller_.Hide(); 940 hover_controller_.Hide();
940 } 941 }
941 942
942 void Tab::OnGestureEvent(ui::GestureEvent* event) { 943 void Tab::OnGestureEvent(ui::GestureEvent* event) {
943 switch (event->type()) { 944 switch (event->type()) {
944 case ui::ET_GESTURE_BEGIN: { 945 case ui::ET_GESTURE_BEGIN: {
945 if (event->details().touch_points() != 1) 946 if (event->details().touch_points() != 1)
946 return; 947 return;
947 948
948 // See comment in OnMousePressed() as to why we copy the event. 949 // See comment in OnMousePressed() as to why we copy the event.
949 ui::GestureEvent event_in_parent(*event, static_cast<View*>(this), 950 ui::GestureEvent event_in_parent(*event, static_cast<View*>(this),
950 parent()); 951 parent());
951 ui::ListSelectionModel original_selection; 952 ui::ListSelectionModel original_selection;
952 original_selection.Copy(controller_->GetSelectionModel()); 953 original_selection.Copy(controller_->GetSelectionModel());
953 tab_activated_with_last_gesture_begin_ = !IsActive(); 954 tab_activated_with_last_gesture_begin_ = !IsActive();
954 if (!IsSelected()) 955 if (!IsSelected())
955 controller_->SelectTab(this); 956 controller_->SelectTab(this);
956 gfx::Point loc(event->location()); 957 gfx::Point loc(gfx::ToFlooredPoint(event->location()));
957 views::View::ConvertPointToScreen(this, &loc); 958 views::View::ConvertPointToScreen(this, &loc);
958 ui::GestureEvent cloned_event(event_in_parent, parent(), 959 ui::GestureEvent cloned_event(event_in_parent, parent(),
959 static_cast<View*>(this)); 960 static_cast<View*>(this));
960 controller_->MaybeStartDrag(this, cloned_event, original_selection); 961 controller_->MaybeStartDrag(this, cloned_event, original_selection);
961 break; 962 break;
962 } 963 }
963 964
964 case ui::ET_GESTURE_END: 965 case ui::ET_GESTURE_END:
965 controller_->EndDrag(END_DRAG_COMPLETE); 966 controller_->EndDrag(END_DRAG_COMPLETE);
966 break; 967 break;
(...skipping 680 matching lines...) Expand 10 before | Expand all | Expand 10 after
1647 const gfx::ImageSkia& image) { 1648 const gfx::ImageSkia& image) {
1648 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); 1649 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE);
1649 ImageCacheEntry entry; 1650 ImageCacheEntry entry;
1650 entry.resource_id = resource_id; 1651 entry.resource_id = resource_id;
1651 entry.scale_factor = scale_factor; 1652 entry.scale_factor = scale_factor;
1652 entry.image = image; 1653 entry.image = image;
1653 image_cache_->push_front(entry); 1654 image_cache_->push_front(entry);
1654 if (image_cache_->size() > kMaxImageCacheSize) 1655 if (image_cache_->size() > kMaxImageCacheSize)
1655 image_cache_->pop_back(); 1656 image_cache_->pop_back();
1656 } 1657 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698