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

Side by Side Diff: ash/shelf/shelf_view.cc

Issue 2033553003: Add MD ink drop ripple to shelf app items (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Added tests Created 4 years, 6 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
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 "ash/shelf/shelf_view.h" 5 #include "ash/shelf/shelf_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <memory> 8 #include <memory>
9 9
10 #include "ash/ash_constants.h" 10 #include "ash/ash_constants.h"
(...skipping 376 matching lines...) Expand 10 before | Expand all | Expand 10 after
387 got_deleted_(nullptr), 387 got_deleted_(nullptr),
388 drag_and_drop_item_pinned_(false), 388 drag_and_drop_item_pinned_(false),
389 drag_and_drop_shelf_id_(0), 389 drag_and_drop_shelf_id_(0),
390 drag_replaced_view_(nullptr), 390 drag_replaced_view_(nullptr),
391 dragged_off_shelf_(false), 391 dragged_off_shelf_(false),
392 snap_back_from_rip_off_view_(nullptr), 392 snap_back_from_rip_off_view_(nullptr),
393 item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()), 393 item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()),
394 overflow_mode_(false), 394 overflow_mode_(false),
395 main_shelf_(nullptr), 395 main_shelf_(nullptr),
396 dragged_off_from_overflow_to_shelf_(false), 396 dragged_off_from_overflow_to_shelf_(false),
397 is_repost_event_(false), 397 is_repost_event_on_same_item_(false),
398 last_pressed_index_(-1) { 398 last_pressed_index_(-1) {
399 DCHECK(model_); 399 DCHECK(model_);
400 DCHECK(wm_shelf_); 400 DCHECK(wm_shelf_);
401 bounds_animator_.reset(new views::BoundsAnimator(this)); 401 bounds_animator_.reset(new views::BoundsAnimator(this));
402 bounds_animator_->AddObserver(this); 402 bounds_animator_->AddObserver(this);
403 set_context_menu_controller(this); 403 set_context_menu_controller(this);
404 focus_search_.reset(new ShelfFocusSearch(view_model_.get())); 404 focus_search_.reset(new ShelfFocusSearch(view_model_.get()));
405 } 405 }
406 406
407 ShelfView::~ShelfView() { 407 ShelfView::~ShelfView() {
408 bounds_animator_->RemoveObserver(this); 408 bounds_animator_->RemoveObserver(this);
409 model_->RemoveObserver(this); 409 model_->RemoveObserver(this);
410 // If we are inside the MenuRunner, we need to know if we were getting 410 // If we are inside the MenuRunner, we need to know if we were getting
411 // deleted while it was running. 411 // deleted while it was running.
412 if (got_deleted_) 412 if (got_deleted_)
413 *got_deleted_ = true; 413 *got_deleted_ = true;
414 } 414 }
415 415
416 void ShelfView::Init() { 416 void ShelfView::Init() {
417 model_->AddObserver(this); 417 model_->AddObserver(this);
418 418
419 const ShelfItems& items(model_->items()); 419 const ShelfItems& items(model_->items());
420 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) { 420 for (ShelfItems::const_iterator i = items.begin(); i != items.end(); ++i) {
421 views::View* child = CreateViewForItem(*i); 421 views::View* child = CreateViewForItem(*i);
422 child->SetPaintToLayer(true); 422 child->SetPaintToLayer(true);
423 view_model_->Add(child, static_cast<int>(i - items.begin())); 423 view_model_->Add(child, static_cast<int>(i - items.begin()));
424 AddChildView(child); 424 AddChildView(child);
425 } 425 }
426 overflow_button_ = new OverflowButton(this, shelf_); 426 overflow_button_ = new OverflowButton(this);
427 overflow_button_->set_context_menu_controller(this); 427 overflow_button_->set_context_menu_controller(this);
428 ConfigureChildView(overflow_button_); 428 ConfigureChildView(overflow_button_);
429 AddChildView(overflow_button_); 429 AddChildView(overflow_button_);
430 430
431 // We'll layout when our bounds change. 431 // We'll layout when our bounds change.
432 } 432 }
433 433
434 void ShelfView::OnShelfAlignmentChanged() { 434 void ShelfView::OnShelfAlignmentChanged() {
435 overflow_button_->OnShelfAlignmentChanged(); 435 overflow_button_->OnShelfAlignmentChanged();
436 LayoutToIdealBounds(); 436 LayoutToIdealBounds();
(...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after
711 // to animate back to its correct location. 711 // to animate back to its correct location.
712 AnimateToIdealBounds(); 712 AnimateToIdealBounds();
713 } else { 713 } else {
714 drag_and_drop_view->SetSize(pre_drag_and_drop_size_); 714 drag_and_drop_view->SetSize(pre_drag_and_drop_size_);
715 } 715 }
716 } 716 }
717 717
718 drag_and_drop_shelf_id_ = 0; 718 drag_and_drop_shelf_id_ = 0;
719 } 719 }
720 720
721 bool ShelfView::ShouldIgnoreEventOnButton(View* view, const ui::Event& event) {
722 if (dragging())
723 return true;
724
725 // Ignore if we are already in a pointer event sequence started with a repost
726 // event on the same shelf item. See crbug.com/343005 for more detail.
727 if (is_repost_event_on_same_item_)
728 return true;
729
730 // Don't activate the item twice on double-click. Otherwise the window starts
731 // animating open due to the first click, then immediately minimizes due to
732 // the second click. The user most likely intended to open or minimize the
733 // item once, not do both.
734 if (event.flags() & ui::EF_IS_DOUBLE_CLICK)
735 return true;
736
737 // Ignore if this is a repost event on the last pressed shelf item.
738 int index = view_model_->GetIndexOfView(view);
739 if (index == -1)
740 return true;
741 return IsRepostEvent(event) && (last_pressed_index_ == index);
742 }
743
721 void ShelfView::PointerPressedOnButton(views::View* view, 744 void ShelfView::PointerPressedOnButton(views::View* view,
722 Pointer pointer, 745 Pointer pointer,
723 const ui::LocatedEvent& event) { 746 const ui::LocatedEvent& event) {
724 if (drag_view_) 747 if (drag_view_)
725 return; 748 return;
726 749
727 int index = view_model_->GetIndexOfView(view); 750 int index = view_model_->GetIndexOfView(view);
728 if (index == -1) 751 if (index == -1 || view_model_->view_size() <= 1)
729 return; 752 return; // View is being deleted, ignore request.
730 753
731 ShelfItemDelegate* item_delegate = 754 ShelfItemDelegate* item_delegate =
732 item_manager_->GetShelfItemDelegate(model_->items()[index].id); 755 item_manager_->GetShelfItemDelegate(model_->items()[index].id);
733 if (view_model_->view_size() <= 1 || !item_delegate->IsDraggable()) 756 if (!item_delegate->IsDraggable())
734 return; // View is being deleted or not draggable, ignore request. 757 return; // View is not draggable, ignore request.
735 758
736 // Only when the repost event occurs on the same shelf item, we should ignore 759 // Only when the repost event occurs on the same shelf item, we should ignore
737 // the call in ShelfView::ButtonPressed(...). 760 // the call in ShelfView::ButtonPressed(...).
738 is_repost_event_ = IsRepostEvent(event) && (last_pressed_index_ == index); 761 is_repost_event_on_same_item_ =
762 IsRepostEvent(event) && (last_pressed_index_ == index);
739 763
740 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName()); 764 CHECK_EQ(ShelfButton::kViewClassName, view->GetClassName());
741 drag_view_ = static_cast<ShelfButton*>(view); 765 drag_view_ = static_cast<ShelfButton*>(view);
742 drag_origin_ = gfx::Point(event.x(), event.y()); 766 drag_origin_ = gfx::Point(event.x(), event.y());
743 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentUsage", 767 UMA_HISTOGRAM_ENUMERATION("Ash.ShelfAlignmentUsage",
744 shelf_->SelectValueForShelfAlignment( 768 shelf_->SelectValueForShelfAlignment(
745 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM, 769 SHELF_ALIGNMENT_UMA_ENUM_VALUE_BOTTOM,
746 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT, 770 SHELF_ALIGNMENT_UMA_ENUM_VALUE_LEFT,
747 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT), 771 SHELF_ALIGNMENT_UMA_ENUM_VALUE_RIGHT),
748 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT); 772 SHELF_ALIGNMENT_UMA_ENUM_VALUE_COUNT);
749 } 773 }
750 774
751 void ShelfView::PointerDraggedOnButton(views::View* view, 775 void ShelfView::PointerDraggedOnButton(views::View* view,
752 Pointer pointer, 776 Pointer pointer,
753 const ui::LocatedEvent& event) { 777 const ui::LocatedEvent& event) {
754 // To prepare all drag types (moving an item in the shelf and dragging off), 778 // To prepare all drag types (moving an item in the shelf and dragging off),
755 // we should check the x-axis and y-axis offset. 779 // we should check the x-axis and y-axis offset.
756 if (!dragging() && drag_view_ && 780 if (!dragging() && drag_view_ &&
757 ((std::abs(event.x() - drag_origin_.x()) >= kMinimumDragDistance) || 781 ((std::abs(event.x() - drag_origin_.x()) >= kMinimumDragDistance) ||
758 (std::abs(event.y() - drag_origin_.y()) >= kMinimumDragDistance))) { 782 (std::abs(event.y() - drag_origin_.y()) >= kMinimumDragDistance))) {
759 PrepareForDrag(pointer, event); 783 PrepareForDrag(pointer, event);
760 } 784 }
761 if (drag_pointer_ == pointer) 785 if (drag_pointer_ == pointer)
762 ContinueDrag(event); 786 ContinueDrag(event);
763 } 787 }
764 788
765 void ShelfView::PointerReleasedOnButton(views::View* view, 789 void ShelfView::PointerReleasedOnButton(views::View* view,
766 Pointer pointer, 790 Pointer pointer,
767 bool canceled) { 791 bool canceled) {
768 // Reset |is_repost_event| to false. 792 is_repost_event_on_same_item_ = false;
769 is_repost_event_ = false;
770 793
771 if (canceled) { 794 if (canceled) {
772 CancelDrag(-1); 795 CancelDrag(-1);
773 } else if (drag_pointer_ == pointer) { 796 } else if (drag_pointer_ == pointer) {
774 FinalizeRipOffDrag(false); 797 FinalizeRipOffDrag(false);
775 drag_pointer_ = NONE; 798 drag_pointer_ = NONE;
776 AnimateToIdealBounds(); 799 AnimateToIdealBounds();
777 } 800 }
778 // If the drag pointer is NONE, no drag operation is going on and the 801 // If the drag pointer is NONE, no drag operation is going on and the
779 // drag_view can be released. 802 // drag_view can be released.
(...skipping 262 matching lines...) Expand 10 before | Expand all | Expand 10 after
1042 ShelfItemDelegate* item_delegate = item_manager_->GetShelfItemDelegate( 1065 ShelfItemDelegate* item_delegate = item_manager_->GetShelfItemDelegate(
1043 model_->items()[start_drag_index_].id); 1066 model_->items()[start_drag_index_].id);
1044 if (!item_delegate->IsDraggable()) { 1067 if (!item_delegate->IsDraggable()) {
1045 CancelDrag(-1); 1068 CancelDrag(-1);
1046 return; 1069 return;
1047 } 1070 }
1048 1071
1049 // Move the view to the front so that it appears on top of other views. 1072 // Move the view to the front so that it appears on top of other views.
1050 ReorderChildView(drag_view_, -1); 1073 ReorderChildView(drag_view_, -1);
1051 bounds_animator_->StopAnimatingView(drag_view_); 1074 bounds_animator_->StopAnimatingView(drag_view_);
1075
1076 drag_view_->OnDragStarted();
1052 } 1077 }
1053 1078
1054 void ShelfView::ContinueDrag(const ui::LocatedEvent& event) { 1079 void ShelfView::ContinueDrag(const ui::LocatedEvent& event) {
1055 // Due to a syncing operation the application might have been removed. 1080 // Due to a syncing operation the application might have been removed.
1056 // Bail if it is gone. 1081 // Bail if it is gone.
1057 int current_index = view_model_->GetIndexOfView(drag_view_); 1082 int current_index = view_model_->GetIndexOfView(drag_view_);
1058 DCHECK_NE(-1, current_index); 1083 DCHECK_NE(-1, current_index);
1059 1084
1060 ShelfItemDelegate* item_delegate = 1085 ShelfItemDelegate* item_delegate =
1061 item_manager_->GetShelfItemDelegate(model_->items()[current_index].id); 1086 item_manager_->GetShelfItemDelegate(model_->items()[current_index].id);
(...skipping 604 matching lines...) Expand 10 before | Expand all | Expand 10 after
1666 void ShelfView::ShelfItemMoved(int start_index, int target_index) { 1691 void ShelfView::ShelfItemMoved(int start_index, int target_index) {
1667 view_model_->Move(start_index, target_index); 1692 view_model_->Move(start_index, target_index);
1668 // When cancelling a drag due to a shelf item being added, the currently 1693 // When cancelling a drag due to a shelf item being added, the currently
1669 // dragged item is moved back to its initial position. AnimateToIdealBounds 1694 // dragged item is moved back to its initial position. AnimateToIdealBounds
1670 // will be called again when the new item is added to the |view_model_| but 1695 // will be called again when the new item is added to the |view_model_| but
1671 // at this time the |view_model_| is inconsistent with the |model_|. 1696 // at this time the |view_model_| is inconsistent with the |model_|.
1672 if (!cancelling_drag_model_changed_) 1697 if (!cancelling_drag_model_changed_)
1673 AnimateToIdealBounds(); 1698 AnimateToIdealBounds();
1674 } 1699 }
1675 1700
1676 void ShelfView::ButtonPressed(views::Button* sender, const ui::Event& event) { 1701 void ShelfView::ButtonPressed(views::Button* sender,
1677 // Do not handle mouse release during drag. 1702 const ui::Event& event,
1678 if (dragging()) 1703 views::InkDrop* ink_drop) {
1679 return;
1680
1681 if (sender == overflow_button_) { 1704 if (sender == overflow_button_) {
1682 ToggleOverflowBubble(); 1705 ToggleOverflowBubble();
1683 shelf_button_pressed_metric_tracker_.ButtonPressed( 1706 shelf_button_pressed_metric_tracker_.ButtonPressed(
1684 event, sender, ShelfItemDelegate::kNoAction); 1707 event, sender, ShelfItemDelegate::kNoAction);
1685 return; 1708 return;
1686 } 1709 }
1687 1710
1688 int view_index = view_model_->GetIndexOfView(sender); 1711 // None of the checks in |ShouldIgnoreEventOnButton| affects overflow button.
1689 // May be -1 while in the process of animating closed. 1712 // So, it is safe to be checked after handling overflow button.
1690 if (view_index == -1) 1713 if (ShouldIgnoreEventOnButton(sender, event))
1691 return; 1714 return;
1692 1715
1693 // If the menu was just closed by the same event as this one, we ignore 1716 int view_index = view_model_->GetIndexOfView(sender);
1694 // the call and don't open the menu again. See crbug.com/343005 for more 1717 DCHECK_LT(-1, view_index);
1695 // detail.
1696 if (is_repost_event_)
1697 return;
1698 1718
1699 // Record the index for the last pressed shelf item. 1719 // Record the index for the last pressed shelf item.
1700 last_pressed_index_ = view_index; 1720 last_pressed_index_ = view_index;
1701 1721
1702 // Don't activate the item twice on double-click. Otherwise the window starts
1703 // animating open due to the first click, then immediately minimizes due to
1704 // the second click. The user most likely intended to open or minimize the
1705 // item once, not do both.
1706 if (event.flags() & ui::EF_IS_DOUBLE_CLICK)
1707 return;
1708
1709 { 1722 {
1710 ScopedTargetRootWindow scoped_target( 1723 ScopedTargetRootWindow scoped_target(
1711 sender->GetWidget()->GetNativeView()->GetRootWindow()); 1724 sender->GetWidget()->GetNativeView()->GetRootWindow());
1712 // Slow down activation animations if shift key is pressed. 1725 // Slow down activation animations if shift key is pressed.
1713 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations; 1726 std::unique_ptr<ui::ScopedAnimationDurationScaleMode> slowing_animations;
1714 if (event.IsShiftDown()) { 1727 if (event.IsShiftDown()) {
1715 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode( 1728 slowing_animations.reset(new ui::ScopedAnimationDurationScaleMode(
1716 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION)); 1729 ui::ScopedAnimationDurationScaleMode::SLOW_DURATION));
1717 } 1730 }
1718 1731
1719 // Collect usage statistics before we decide what to do with the click. 1732 // Collect usage statistics before we decide what to do with the click.
1720 switch (model_->items()[view_index].type) { 1733 switch (model_->items()[view_index].type) {
1721 case TYPE_APP_SHORTCUT: 1734 case TYPE_APP_SHORTCUT:
1722 case TYPE_WINDOWED_APP: 1735 case TYPE_WINDOWED_APP:
1723 case TYPE_PLATFORM_APP: 1736 case TYPE_PLATFORM_APP:
1724 case TYPE_BROWSER_SHORTCUT: 1737 case TYPE_BROWSER_SHORTCUT:
1725 Shell::GetInstance()->metrics()->RecordUserMetricsAction( 1738 Shell::GetInstance()->metrics()->RecordUserMetricsAction(
1726 UMA_LAUNCHER_CLICK_ON_APP); 1739 UMA_LAUNCHER_CLICK_ON_APP);
(...skipping 14 matching lines...) Expand all
1741 break; 1754 break;
1742 } 1755 }
1743 1756
1744 ShelfItemDelegate::PerformedAction performed_action = 1757 ShelfItemDelegate::PerformedAction performed_action =
1745 item_manager_->GetShelfItemDelegate(model_->items()[view_index].id) 1758 item_manager_->GetShelfItemDelegate(model_->items()[view_index].id)
1746 ->ItemSelected(event); 1759 ->ItemSelected(event);
1747 1760
1748 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender, 1761 shelf_button_pressed_metric_tracker_.ButtonPressed(event, sender,
1749 performed_action); 1762 performed_action);
1750 1763
1751 if (performed_action != ShelfItemDelegate::kNewWindowCreated) 1764 if (performed_action == ShelfItemDelegate::kNewWindowCreated ||
1752 ShowListMenuForView(model_->items()[view_index], sender, event); 1765 !ShowListMenuForView(model_->items()[view_index], sender, event,
1766 ink_drop)) {
1767 ink_drop->AnimateToState(views::InkDropState::ACTION_TRIGGERED);
1768 }
1753 } 1769 }
1754 } 1770 }
1755 1771
1756 void ShelfView::ShowListMenuForView(const ShelfItem& item, 1772 bool ShelfView::ShowListMenuForView(const ShelfItem& item,
1757 views::View* source, 1773 views::View* source,
1758 const ui::Event& event) { 1774 const ui::Event& event,
1775 views::InkDrop* ink_drop) {
1759 ShelfItemDelegate* item_delegate = 1776 ShelfItemDelegate* item_delegate =
1760 item_manager_->GetShelfItemDelegate(item.id); 1777 item_manager_->GetShelfItemDelegate(item.id);
1761 std::unique_ptr<ui::MenuModel> list_menu_model( 1778 std::unique_ptr<ui::MenuModel> list_menu_model(
1762 item_delegate->CreateApplicationMenu(event.flags())); 1779 item_delegate->CreateApplicationMenu(event.flags()));
1763 1780
1764 // Make sure we have a menu and it has at least two items in addition to the 1781 // Make sure we have a menu and it has at least two items in addition to the
1765 // application title and the 3 spacing separators. 1782 // application title and the 3 spacing separators.
1766 if (!list_menu_model.get() || list_menu_model->GetItemCount() <= 5) 1783 if (!list_menu_model.get() || list_menu_model->GetItemCount() <= 5)
1767 return; 1784 return false;
1768 1785
1786 ink_drop->AnimateToState(views::InkDropState::ACTIVATED);
1769 context_menu_id_ = item.id; 1787 context_menu_id_ = item.id;
1770 ShowMenu(list_menu_model.get(), source, gfx::Point(), false, 1788 ShowMenu(list_menu_model.get(), source, gfx::Point(), false,
1771 ui::GetMenuSourceTypeForEvent(event)); 1789 ui::GetMenuSourceTypeForEvent(event));
1790 // Menu is run synchronously, the menu is closed now and we need to go to
1791 // the deactivated state.
1792 ink_drop->AnimateToState(views::InkDropState::DEACTIVATED);
1793 return true;
1772 } 1794 }
1773 1795
1774 void ShelfView::ShowContextMenuForView(views::View* source, 1796 void ShelfView::ShowContextMenuForView(views::View* source,
1775 const gfx::Point& point, 1797 const gfx::Point& point,
1776 ui::MenuSourceType source_type) { 1798 ui::MenuSourceType source_type) {
1799 last_pressed_index_ = -1;
1800
1777 const ShelfItem* item = ShelfItemForView(source); 1801 const ShelfItem* item = ShelfItemForView(source);
1778 if (!item) { 1802 if (!item) {
1779 Shell::GetInstance()->ShowContextMenu(point, source_type); 1803 Shell::GetInstance()->ShowContextMenu(point, source_type);
1780 return; 1804 return;
1781 } 1805 }
1782 1806
1783 std::unique_ptr<ui::MenuModel> context_menu_model( 1807 std::unique_ptr<ui::MenuModel> context_menu_model(
1784 Shell::GetInstance()->delegate()->CreateContextMenu(wm_shelf_, item)); 1808 Shell::GetInstance()->delegate()->CreateContextMenu(wm_shelf_, item));
1785 if (!context_menu_model) 1809 if (!context_menu_model)
1786 return; 1810 return;
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
1876 } 1900 }
1877 snap_back_from_rip_off_view_ = nullptr; 1901 snap_back_from_rip_off_view_ = nullptr;
1878 } 1902 }
1879 } 1903 }
1880 } 1904 }
1881 1905
1882 bool ShelfView::IsRepostEvent(const ui::Event& event) { 1906 bool ShelfView::IsRepostEvent(const ui::Event& event) {
1883 if (closing_event_time_.is_null()) 1907 if (closing_event_time_.is_null())
1884 return false; 1908 return false;
1885 1909
1886 base::TimeTicks last_closing_event_time = closing_event_time_;
1887 closing_event_time_ = base::TimeTicks();
1888 // If the current (press down) event is a repost event, the time stamp of 1910 // If the current (press down) event is a repost event, the time stamp of
1889 // these two events should be the same. 1911 // these two events should be the same.
1890 return last_closing_event_time == event.time_stamp(); 1912 return closing_event_time_ == event.time_stamp();
1891 } 1913 }
1892 1914
1893 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const { 1915 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const {
1894 const int view_index = view_model_->GetIndexOfView(view); 1916 const int view_index = view_model_->GetIndexOfView(view);
1895 return (view_index < 0) ? nullptr : &(model_->items()[view_index]); 1917 return (view_index < 0) ? nullptr : &(model_->items()[view_index]);
1896 } 1918 }
1897 1919
1898 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1920 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1899 const gfx::Rect bounds = GetBoundsInScreen(); 1921 const gfx::Rect bounds = GetBoundsInScreen();
1900 int distance = shelf_->SelectValueForShelfAlignment( 1922 int distance = shelf_->SelectValueForShelfAlignment(
1901 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1923 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1902 bounds.x() - coordinate.x()); 1924 bounds.x() - coordinate.x());
1903 return distance > 0 ? distance : 0; 1925 return distance > 0 ? distance : 0;
1904 } 1926 }
1905 1927
1906 } // namespace ash 1928 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698