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

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: rebase 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
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 365 matching lines...) Expand 10 before | Expand all | Expand 10 after
376 overflow_button_(nullptr), 376 overflow_button_(nullptr),
377 owner_overflow_bubble_(nullptr), 377 owner_overflow_bubble_(nullptr),
378 tooltip_(this), 378 tooltip_(this),
379 drag_pointer_(NONE), 379 drag_pointer_(NONE),
380 drag_view_(nullptr), 380 drag_view_(nullptr),
381 start_drag_index_(-1), 381 start_drag_index_(-1),
382 context_menu_id_(0), 382 context_menu_id_(0),
383 leading_inset_(kDefaultLeadingInset), 383 leading_inset_(kDefaultLeadingInset),
384 cancelling_drag_model_changed_(false), 384 cancelling_drag_model_changed_(false),
385 last_hidden_index_(0), 385 last_hidden_index_(0),
386 closing_event_time_(base::TimeDelta()), 386 closing_event_time_(base::TimeTicks()),
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),
(...skipping 1390 matching lines...) Expand 10 before | Expand all | Expand 10 after
1787 1787
1788 context_menu_id_ = item ? item->id : 0; 1788 context_menu_id_ = item ? item->id : 0;
1789 ShowMenu(context_menu_model.get(), source, point, true, source_type); 1789 ShowMenu(context_menu_model.get(), source, point, true, source_type);
1790 } 1790 }
1791 1791
1792 void ShelfView::ShowMenu(ui::MenuModel* menu_model, 1792 void ShelfView::ShowMenu(ui::MenuModel* menu_model,
1793 views::View* source, 1793 views::View* source,
1794 const gfx::Point& click_point, 1794 const gfx::Point& click_point,
1795 bool context_menu, 1795 bool context_menu,
1796 ui::MenuSourceType source_type) { 1796 ui::MenuSourceType source_type) {
1797 closing_event_time_ = base::TimeDelta(); 1797 closing_event_time_ = base::TimeTicks();
1798 launcher_menu_runner_.reset(new views::MenuRunner( 1798 launcher_menu_runner_.reset(new views::MenuRunner(
1799 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0)); 1799 menu_model, context_menu ? views::MenuRunner::CONTEXT_MENU : 0));
1800 1800
1801 aura::Window* window = source->GetWidget()->GetNativeWindow(); 1801 aura::Window* window = source->GetWidget()->GetNativeWindow();
1802 ScopedTargetRootWindow scoped_target(window->GetRootWindow()); 1802 ScopedTargetRootWindow scoped_target(window->GetRootWindow());
1803 1803
1804 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT; 1804 views::MenuAnchorPosition menu_alignment = views::MENU_ANCHOR_TOPLEFT;
1805 gfx::Rect anchor = gfx::Rect(click_point, gfx::Size()); 1805 gfx::Rect anchor = gfx::Rect(click_point, gfx::Size());
1806 1806
1807 if (!context_menu) { 1807 if (!context_menu) {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
1840 got_deleted_ = nullptr; 1840 got_deleted_ = nullptr;
1841 context_menu_id_ = 0; 1841 context_menu_id_ = 0;
1842 shelf_widget->ForceUndimming(false); 1842 shelf_widget->ForceUndimming(false);
1843 1843
1844 // Hide the hide overflow bubble after showing a context menu for its items. 1844 // Hide the hide overflow bubble after showing a context menu for its items.
1845 if (owner_overflow_bubble_) 1845 if (owner_overflow_bubble_)
1846 owner_overflow_bubble_->HideBubbleAndRefreshButton(); 1846 owner_overflow_bubble_->HideBubbleAndRefreshButton();
1847 1847
1848 // Unpinning an item will reset |launcher_menu_runner_| before coming here. 1848 // Unpinning an item will reset |launcher_menu_runner_| before coming here.
1849 if (launcher_menu_runner_) 1849 if (launcher_menu_runner_)
1850 closing_event_time_ = launcher_menu_runner_->closing_event_time(); 1850 closing_event_time_ =
1851 base::TimeTicks() + launcher_menu_runner_->closing_event_time();
1851 Shell::GetInstance()->UpdateShelfVisibility(); 1852 Shell::GetInstance()->UpdateShelfVisibility();
1852 } 1853 }
1853 1854
1854 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) { 1855 void ShelfView::OnBoundsAnimatorProgressed(views::BoundsAnimator* animator) {
1855 FOR_EACH_OBSERVER(ShelfIconObserver, observers_, 1856 FOR_EACH_OBSERVER(ShelfIconObserver, observers_,
1856 OnShelfIconPositionsChanged()); 1857 OnShelfIconPositionsChanged());
1857 PreferredSizeChanged(); 1858 PreferredSizeChanged();
1858 } 1859 }
1859 1860
1860 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) { 1861 void ShelfView::OnBoundsAnimatorDone(views::BoundsAnimator* animator) {
(...skipping 11 matching lines...) Expand all
1872 button->ClearState(ShelfButton::STATE_HIDDEN); 1873 button->ClearState(ShelfButton::STATE_HIDDEN);
1873 break; 1874 break;
1874 } 1875 }
1875 } 1876 }
1876 snap_back_from_rip_off_view_ = nullptr; 1877 snap_back_from_rip_off_view_ = nullptr;
1877 } 1878 }
1878 } 1879 }
1879 } 1880 }
1880 1881
1881 bool ShelfView::IsRepostEvent(const ui::Event& event) { 1882 bool ShelfView::IsRepostEvent(const ui::Event& event) {
1882 if (closing_event_time_.is_zero()) 1883 if (closing_event_time_.is_null())
1883 return false; 1884 return false;
1884 1885
1885 base::TimeDelta delta = 1886 base::TimeTicks last_closing_event_time = closing_event_time_;
1886 base::TimeDelta(event.time_stamp() - closing_event_time_); 1887 closing_event_time_ = base::TimeTicks();
1887 closing_event_time_ = base::TimeDelta();
1888 // If the current (press down) event is a repost event, the time stamp of 1888 // If the current (press down) event is a repost event, the time stamp of
1889 // these two events should be the same. 1889 // these two events should be the same.
1890 return (delta.InMilliseconds() == 0); 1890 return last_closing_event_time == event.time_stamp();
1891 } 1891 }
1892 1892
1893 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const { 1893 const ShelfItem* ShelfView::ShelfItemForView(const views::View* view) const {
1894 const int view_index = view_model_->GetIndexOfView(view); 1894 const int view_index = view_model_->GetIndexOfView(view);
1895 return (view_index < 0) ? nullptr : &(model_->items()[view_index]); 1895 return (view_index < 0) ? nullptr : &(model_->items()[view_index]);
1896 } 1896 }
1897 1897
1898 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const { 1898 int ShelfView::CalculateShelfDistance(const gfx::Point& coordinate) const {
1899 const gfx::Rect bounds = GetBoundsInScreen(); 1899 const gfx::Rect bounds = GetBoundsInScreen();
1900 int distance = shelf_->SelectValueForShelfAlignment( 1900 int distance = shelf_->SelectValueForShelfAlignment(
1901 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(), 1901 bounds.y() - coordinate.y(), coordinate.x() - bounds.right(),
1902 bounds.x() - coordinate.x()); 1902 bounds.x() - coordinate.x());
1903 return distance > 0 ? distance : 0; 1903 return distance > 0 ? distance : 0;
1904 } 1904 }
1905 1905
1906 } // namespace ash 1906 } // namespace ash
OLDNEW
« no previous file with comments | « ash/shelf/shelf_view.h ('k') | ash/system/chromeos/rotation/tray_rotation_lock_unittest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698