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

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

Issue 1975533002: Change ui::Event::time_stamp from TimeDelta to TimeTicks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: merge master 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 361 matching lines...) Expand 10 before | Expand all | Expand 10 after
372 overflow_button_(nullptr), 372 overflow_button_(nullptr),
373 owner_overflow_bubble_(nullptr), 373 owner_overflow_bubble_(nullptr),
374 tooltip_(this), 374 tooltip_(this),
375 drag_pointer_(NONE), 375 drag_pointer_(NONE),
376 drag_view_(nullptr), 376 drag_view_(nullptr),
377 start_drag_index_(-1), 377 start_drag_index_(-1),
378 context_menu_id_(0), 378 context_menu_id_(0),
379 leading_inset_(kDefaultLeadingInset), 379 leading_inset_(kDefaultLeadingInset),
380 cancelling_drag_model_changed_(false), 380 cancelling_drag_model_changed_(false),
381 last_hidden_index_(0), 381 last_hidden_index_(0),
382 closing_event_time_(base::TimeDelta()), 382 closing_event_time_(base::TimeTicks()),
383 got_deleted_(nullptr), 383 got_deleted_(nullptr),
384 drag_and_drop_item_pinned_(false), 384 drag_and_drop_item_pinned_(false),
385 drag_and_drop_shelf_id_(0), 385 drag_and_drop_shelf_id_(0),
386 drag_replaced_view_(nullptr), 386 drag_replaced_view_(nullptr),
387 dragged_off_shelf_(false), 387 dragged_off_shelf_(false),
388 snap_back_from_rip_off_view_(nullptr), 388 snap_back_from_rip_off_view_(nullptr),
389 item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()), 389 item_manager_(Shell::GetInstance()->shelf_item_delegate_manager()),
390 overflow_mode_(false), 390 overflow_mode_(false),
391 main_shelf_(nullptr), 391 main_shelf_(nullptr),
392 dragged_off_from_overflow_to_shelf_(false), 392 dragged_off_from_overflow_to_shelf_(false),
(...skipping 1388 matching lines...) Expand 10 before | Expand all | Expand 10 after
1781 1781
1782 context_menu_id_ = item ? item->id : 0; 1782 context_menu_id_ = item ? item->id : 0;
1783 ShowMenu(context_menu_model.get(), source, point, true, source_type); 1783 ShowMenu(context_menu_model.get(), source, point, true, source_type);
1784 } 1784 }
1785 1785
1786 void ShelfView::ShowMenu(ui::MenuModel* menu_model, 1786 void ShelfView::ShowMenu(ui::MenuModel* menu_model,
1787 views::View* source, 1787 views::View* source,
1788 const gfx::Point& click_point, 1788 const gfx::Point& click_point,
1789 bool context_menu, 1789 bool context_menu,
1790 ui::MenuSourceType source_type) { 1790 ui::MenuSourceType source_type) {
1791 closing_event_time_ = base::TimeDelta(); 1791 closing_event_time_ = base::TimeTicks();
1792 launcher_menu_runner_.reset(new views::MenuRunner( 1792 launcher_menu_runner_.reset(new views::MenuRunner(
1793 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0)); 1793 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0));
1794 1794
1795 aura::Window* window = source->GetWidget()->GetNativeWindow(); 1795 aura::Window* window = source->GetWidget()->GetNativeWindow();
1796 ScopedTargetRootWindow scoped_target(window->GetRootWindow()); 1796 ScopedTargetRootWindow scoped_target(window->GetRootWindow());
1797 1797
1798 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; 1798 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT;
1799 gfx::Rect anchor = gfx::Rect(click_point, gfx::Size()); 1799 gfx::Rect anchor = gfx::Rect(click_point, gfx::Size());
1800 1800
1801 if (!context_menu) { 1801 if (!context_menu) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1834 got_deleted_ = nullptr; 1834 got_deleted_ = nullptr;
1835 context_menu_id_ = 0; 1835 context_menu_id_ = 0;
1836 shelf_widget->ForceUndimming(false); 1836 shelf_widget->ForceUndimming(false);
1837 1837
1838 // Hide the hide overflow bubble after showing a context menu for its items. 1838 // Hide the hide overflow bubble after showing a context menu for its items.
1839 if (owner_overflow_bubble_) 1839 if (owner_overflow_bubble_)
1840 owner_overflow_bubble_->HideBubbleAndRefreshButton(); 1840 owner_overflow_bubble_->HideBubbleAndRefreshButton();
1841 1841
1842 // Unpinning an item will reset |launcher_menu_runner_| before coming here. 1842 // Unpinning an item will reset |launcher_menu_runner_| before coming here.
1843 if (launcher_menu_runner_) 1843 if (launcher_menu_runner_)
1844 closing_event_time_ = launcher_menu_runner_->closing_event_time(); 1844 closing_event_time_ =
1845 base::TimeTicks() + launcher_menu_runner_->closing_event_time();
1845 Shell::GetInstance()->UpdateShelfVisibility(); 1846 Shell::GetInstance()->UpdateShelfVisibility();
1846 } 1847 }
1847 1848
1848 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { 1849 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) {
1849 FOR_EACH_OBSERVER(ShelfIconObserver, observers_, 1850 FOR_EACH_OBSERVER(ShelfIconObserver, observers_,
1850 OnShelfIconPositionsChanged()); 1851 OnShelfIconPositionsChanged());
1851 PreferredSizeChanged(); 1852 PreferredSizeChanged();
1852 } 1853 }
1853 1854
1854 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { 1855 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
(...skipping 11 matching lines...) Expand all
1866 button->ClearState(ShelfButton::STATE_HIDDEN); 1867 button->ClearState(ShelfButton::STATE_HIDDEN);
1867 break; 1868 break;
1868 } 1869 }
1869 } 1870 }
1870 snap_back_from_rip_off_view_ = nullptr; 1871 snap_back_from_rip_off_view_ = nullptr;
1871 } 1872 }
1872 } 1873 }
1873 } 1874 }
1874 1875
1875 bool ShelfView::IsRepostEvent(const ui::Event& event) { 1876 bool ShelfView::IsRepostEvent(const ui::Event& event) {
1876 if (closing_event_time_.is_zero()) 1877 if (closing_event_time_.is_null())
1877 return false; 1878 return false;
1878 1879
1879 base::TimeDelta delta = 1880 base::TimeTicks last_closing_event_time = closing_event_time_;
1880 base::TimeDelta(event.time_stamp() - closing_event_time_); 1881 closing_event_time_ = base::TimeTicks();
1881 closing_event_time_ = base::TimeDelta();
1882 // If the current (press down) event is a repost event, the time stamp of 1882 // If the current (press down) event is a repost event, the time stamp of
1883 // these two events should be the same. 1883 // these two events should be the same.
1884 return (delta.InMilliseconds() == 0); 1884 return last_closing_event_time == event.time_stamp();
1885 } 1885 }
1886 1886
1887 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const { 1887 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const {
1888 const int view_index = view_model_->GetIndexOfView(view); 1888 const int view_index = view_model_->GetIndexOfView(view);
1889 return (view_index < 0) ? nullptr : &(model_->items()[view_index]); 1889 return (view_index < 0) ? nullptr : &(model_->items()[view_index]);
1890 } 1890 }
1891 1891
1892 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1892 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1893 const gfx::Rect bounds = GetBoundsInScreen(); 1893 const gfx::Rect bounds = GetBoundsInScreen();
1894 int distance = shelf_->SelectValueForShelfAlignment( 1894 int distance = shelf_->SelectValueForShelfAlignment(
1895 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1895 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1896 bounds.x() - coordinate.x()); 1896 bounds.x() - coordinate.x());
1897 return distance > 0 ? distance : 0; 1897 return distance > 0 ? distance : 0;
1898 } 1898 }
1899 1899
1900 } // namespace ash 1900 } // namespace ash
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698