OLD | NEW |
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 339 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
350 tab_->controller()->OnMouseEventInTab(this, event); | 350 tab_->controller()->OnMouseEventInTab(this, event); |
351 CustomButton::OnMouseMoved(event); | 351 CustomButton::OnMouseMoved(event); |
352 } | 352 } |
353 | 353 |
354 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { | 354 virtual void OnMouseReleased(const ui::MouseEvent& event) OVERRIDE { |
355 if (tab_->controller()) | 355 if (tab_->controller()) |
356 tab_->controller()->OnMouseEventInTab(this, event); | 356 tab_->controller()->OnMouseEventInTab(this, event); |
357 CustomButton::OnMouseReleased(event); | 357 CustomButton::OnMouseReleased(event); |
358 } | 358 } |
359 | 359 |
360 virtual ui::EventResult OnGestureEvent(ui::GestureEvent* event) OVERRIDE { | 360 virtual void OnGestureEvent(ui::GestureEvent* event) OVERRIDE { |
361 // Consume all gesture events here so that the parent (Tab) does not | 361 // Consume all gesture events here so that the parent (Tab) does not |
362 // start consuming gestures. | 362 // start consuming gestures. |
363 ImageButton::OnGestureEvent(event); | 363 ImageButton::OnGestureEvent(event); |
364 return ui::ER_CONSUMED; | 364 event->SetHandled(); |
365 } | 365 } |
366 | 366 |
367 private: | 367 private: |
368 Tab* tab_; | 368 Tab* tab_; |
369 | 369 |
370 DISALLOW_COPY_AND_ASSIGN(TabCloseButton); | 370 DISALLOW_COPY_AND_ASSIGN(TabCloseButton); |
371 }; | 371 }; |
372 | 372 |
373 //////////////////////////////////////////////////////////////////////////////// | 373 //////////////////////////////////////////////////////////////////////////////// |
374 // ImageCacheEntry | 374 // ImageCacheEntry |
(...skipping 554 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
929 void Tab::OnMouseMoved(const ui::MouseEvent& event) { | 929 void Tab::OnMouseMoved(const ui::MouseEvent& event) { |
930 hover_controller_.SetLocation(event.location()); | 930 hover_controller_.SetLocation(event.location()); |
931 if (controller()) | 931 if (controller()) |
932 controller()->OnMouseEventInTab(this, event); | 932 controller()->OnMouseEventInTab(this, event); |
933 } | 933 } |
934 | 934 |
935 void Tab::OnMouseExited(const ui::MouseEvent& event) { | 935 void Tab::OnMouseExited(const ui::MouseEvent& event) { |
936 hover_controller_.Hide(); | 936 hover_controller_.Hide(); |
937 } | 937 } |
938 | 938 |
939 ui::EventResult Tab::OnGestureEvent(ui::GestureEvent* event) { | 939 void Tab::OnGestureEvent(ui::GestureEvent* event) { |
940 if (!controller()) | 940 if (!controller()) { |
941 return ui::ER_CONSUMED; | 941 event->SetHandled(); |
| 942 return; |
| 943 } |
942 | 944 |
943 switch (event->type()) { | 945 switch (event->type()) { |
944 case ui::ET_GESTURE_BEGIN: { | 946 case ui::ET_GESTURE_BEGIN: { |
945 if (event->details().touch_points() != 1) | 947 if (event->details().touch_points() != 1) |
946 return ui::ER_UNHANDLED; | 948 return; |
947 | 949 |
948 TabStripSelectionModel original_selection; | 950 TabStripSelectionModel original_selection; |
949 original_selection.Copy(controller()->GetSelectionModel()); | 951 original_selection.Copy(controller()->GetSelectionModel()); |
950 if (!IsSelected()) | 952 if (!IsSelected()) |
951 controller()->SelectTab(this); | 953 controller()->SelectTab(this); |
952 gfx::Point loc(event->location()); | 954 gfx::Point loc(event->location()); |
953 views::View::ConvertPointToScreen(this, &loc); | 955 views::View::ConvertPointToScreen(this, &loc); |
954 controller()->MaybeStartDrag(this, *event, original_selection); | 956 controller()->MaybeStartDrag(this, *event, original_selection); |
955 break; | 957 break; |
956 } | 958 } |
957 | 959 |
958 case ui::ET_GESTURE_END: | 960 case ui::ET_GESTURE_END: |
959 controller()->EndDrag(END_DRAG_COMPLETE); | 961 controller()->EndDrag(END_DRAG_COMPLETE); |
960 break; | 962 break; |
961 | 963 |
962 case ui::ET_GESTURE_SCROLL_UPDATE: | 964 case ui::ET_GESTURE_SCROLL_UPDATE: |
963 controller()->ContinueDrag(this, event->location()); | 965 controller()->ContinueDrag(this, event->location()); |
964 break; | 966 break; |
965 | 967 |
966 default: | 968 default: |
967 break; | 969 break; |
968 } | 970 } |
969 return ui::ER_CONSUMED; | 971 event->SetHandled(); |
970 } | 972 } |
971 | 973 |
972 void Tab::GetAccessibleState(ui::AccessibleViewState* state) { | 974 void Tab::GetAccessibleState(ui::AccessibleViewState* state) { |
973 state->role = ui::AccessibilityTypes::ROLE_PAGETAB; | 975 state->role = ui::AccessibilityTypes::ROLE_PAGETAB; |
974 state->name = data_.title; | 976 state->name = data_.title; |
975 } | 977 } |
976 | 978 |
977 //////////////////////////////////////////////////////////////////////////////// | 979 //////////////////////////////////////////////////////////////////////////////// |
978 // Tab, private | 980 // Tab, private |
979 | 981 |
(...skipping 585 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1565 const gfx::ImageSkia& image) { | 1567 const gfx::ImageSkia& image) { |
1566 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1568 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
1567 ImageCacheEntry entry; | 1569 ImageCacheEntry entry; |
1568 entry.resource_id = resource_id; | 1570 entry.resource_id = resource_id; |
1569 entry.scale_factor = scale_factor; | 1571 entry.scale_factor = scale_factor; |
1570 entry.image = image; | 1572 entry.image = image; |
1571 image_cache_->push_front(entry); | 1573 image_cache_->push_front(entry); |
1572 if (image_cache_->size() > kMaxImageCacheSize) | 1574 if (image_cache_->size() > kMaxImageCacheSize) |
1573 image_cache_->pop_back(); | 1575 image_cache_->pop_back(); |
1574 } | 1576 } |
OLD | NEW |