Chromium Code Reviews| 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 405 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 416 closing_(false), | 416 closing_(false), |
| 417 dragging_(false), | 417 dragging_(false), |
| 418 detached_(false), | 418 detached_(false), |
| 419 favicon_hiding_offset_(0), | 419 favicon_hiding_offset_(0), |
| 420 loading_animation_frame_(0), | 420 loading_animation_frame_(0), |
| 421 immersive_loading_step_(0), | 421 immersive_loading_step_(0), |
| 422 should_display_crashed_favicon_(false), | 422 should_display_crashed_favicon_(false), |
| 423 animating_media_state_(TAB_MEDIA_STATE_NONE), | 423 animating_media_state_(TAB_MEDIA_STATE_NONE), |
| 424 close_button_(NULL), | 424 close_button_(NULL), |
| 425 title_(new views::Label()), | 425 title_(new views::Label()), |
| 426 tab_activated_with_last_gesture_begin_(false), | 426 tab_activated_with_last_tap_down_(false), |
| 427 hover_controller_(this), | 427 hover_controller_(this), |
| 428 showing_icon_(false), | 428 showing_icon_(false), |
| 429 showing_media_indicator_(false), | 429 showing_media_indicator_(false), |
| 430 showing_close_button_(false), | 430 showing_close_button_(false), |
| 431 close_button_color_(0) { | 431 close_button_color_(0) { |
| 432 DCHECK(controller); | 432 DCHECK(controller); |
| 433 InitTabResources(); | 433 InitTabResources(); |
| 434 | 434 |
| 435 // So we get don't get enter/exit on children and don't prematurely stop the | 435 // So we get don't get enter/exit on children and don't prematurely stop the |
| 436 // hover. | 436 // hover. |
| (...skipping 531 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 968 hover_controller_.SetLocation(event.location()); | 968 hover_controller_.SetLocation(event.location()); |
| 969 controller_->OnMouseEventInTab(this, event); | 969 controller_->OnMouseEventInTab(this, event); |
| 970 } | 970 } |
| 971 | 971 |
| 972 void Tab::OnMouseExited(const ui::MouseEvent& event) { | 972 void Tab::OnMouseExited(const ui::MouseEvent& event) { |
| 973 hover_controller_.Hide(); | 973 hover_controller_.Hide(); |
| 974 } | 974 } |
| 975 | 975 |
| 976 void Tab::OnGestureEvent(ui::GestureEvent* event) { | 976 void Tab::OnGestureEvent(ui::GestureEvent* event) { |
| 977 switch (event->type()) { | 977 switch (event->type()) { |
| 978 case ui::ET_GESTURE_BEGIN: { | 978 case ui::ET_GESTURE_TAP_DOWN: { |
| 979 if (event->details().touch_points() != 1) | 979 if (event->details().touch_points() != 1) |
|
tdanderson
2014/07/24 18:07:21
This is always true for TAP_DOWN, right?
tdresser
2014/07/24 18:17:23
Yeah, you can safely remove this early-out.
| |
| 980 return; | 980 return; |
| 981 | 981 |
| 982 // See comment in OnMousePressed() as to why we copy the event. | 982 // See comment in OnMousePressed() as to why we copy the event. |
| 983 ui::GestureEvent event_in_parent(*event, static_cast<View*>(this), | 983 ui::GestureEvent event_in_parent(*event, static_cast<View*>(this), |
| 984 parent()); | 984 parent()); |
| 985 ui::ListSelectionModel original_selection; | 985 ui::ListSelectionModel original_selection; |
| 986 original_selection.Copy(controller_->GetSelectionModel()); | 986 original_selection.Copy(controller_->GetSelectionModel()); |
| 987 tab_activated_with_last_gesture_begin_ = !IsActive(); | 987 tab_activated_with_last_tap_down_ = !IsActive(); |
| 988 if (!IsSelected()) | 988 if (!IsSelected()) |
| 989 controller_->SelectTab(this); | 989 controller_->SelectTab(this); |
| 990 gfx::Point loc(event->location()); | 990 gfx::Point loc(event->location()); |
| 991 views::View::ConvertPointToScreen(this, &loc); | 991 views::View::ConvertPointToScreen(this, &loc); |
| 992 ui::GestureEvent cloned_event(event_in_parent, parent(), | 992 ui::GestureEvent cloned_event(event_in_parent, parent(), |
| 993 static_cast<View*>(this)); | 993 static_cast<View*>(this)); |
| 994 controller_->MaybeStartDrag(this, cloned_event, original_selection); | 994 controller_->MaybeStartDrag(this, cloned_event, original_selection); |
| 995 break; | 995 break; |
| 996 } | 996 } |
| 997 | 997 |
| 998 case ui::ET_GESTURE_END: | 998 case ui::ET_GESTURE_SCROLL_END: |
| 999 case ui::ET_SCROLL_FLING_START: | |
| 999 controller_->EndDrag(END_DRAG_COMPLETE); | 1000 controller_->EndDrag(END_DRAG_COMPLETE); |
| 1000 break; | 1001 break; |
| 1001 | 1002 |
| 1002 case ui::ET_GESTURE_SCROLL_UPDATE: | 1003 case ui::ET_GESTURE_SCROLL_UPDATE: |
|
tdanderson
2014/07/24 18:07:21
If this class doesn't handle SCROLL_BEGIN, is it c
tdresser
2014/07/24 18:17:23
Yeah, that's fine.
sadrul
2014/07/24 19:12:13
Should it handle SCROLL_BEGIN, though?
tdanderson
2014/07/25 17:16:10
I will look into this in more detail when I put up
| |
| 1003 controller_->ContinueDrag(this, *event); | 1004 controller_->ContinueDrag(this, *event); |
| 1004 break; | 1005 break; |
| 1005 | 1006 |
| 1006 default: | 1007 default: |
| 1007 break; | 1008 break; |
| 1008 } | 1009 } |
| 1009 event->SetHandled(); | 1010 event->SetHandled(); |
| 1010 } | 1011 } |
| 1011 | 1012 |
| 1012 void Tab::GetAccessibleState(ui::AXViewState* state) { | 1013 void Tab::GetAccessibleState(ui::AXViewState* state) { |
| (...skipping 638 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1651 const gfx::ImageSkia& image) { | 1652 const gfx::ImageSkia& image) { |
| 1652 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); | 1653 DCHECK_NE(scale_factor, ui::SCALE_FACTOR_NONE); |
| 1653 ImageCacheEntry entry; | 1654 ImageCacheEntry entry; |
| 1654 entry.resource_id = resource_id; | 1655 entry.resource_id = resource_id; |
| 1655 entry.scale_factor = scale_factor; | 1656 entry.scale_factor = scale_factor; |
| 1656 entry.image = image; | 1657 entry.image = image; |
| 1657 image_cache_->push_front(entry); | 1658 image_cache_->push_front(entry); |
| 1658 if (image_cache_->size() > kMaxImageCacheSize) | 1659 if (image_cache_->size() > kMaxImageCacheSize) |
| 1659 image_cache_->pop_back(); | 1660 image_cache_->pop_back(); |
| 1660 } | 1661 } |
| OLD | NEW |