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

Side by Side Diff: ui/views/controls/menu/menu_controller.cc

Issue 10417035: Add 'base::' to Time::Now() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 8 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | no next file » | 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 "ui/views/controls/menu/menu_controller.h" 5 #include "ui/views/controls/menu/menu_controller.h"
6 6
7 #include "base/i18n/case_conversion.h" 7 #include "base/i18n/case_conversion.h"
8 #include "base/i18n/rtl.h" 8 #include "base/i18n/rtl.h"
9 #include "base/time.h" 9 #include "base/time.h"
10 #include "base/utf_string_conversions.h" 10 #include "base/utf_string_conversions.h"
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after
156 if (!part.is_scroll()) { 156 if (!part.is_scroll()) {
157 StopScrolling(); 157 StopScrolling();
158 return; 158 return;
159 } 159 }
160 DCHECK(part.submenu); 160 DCHECK(part.submenu);
161 SubmenuView* new_menu = part.submenu; 161 SubmenuView* new_menu = part.submenu;
162 bool new_is_up = (part.type == MenuController::MenuPart::SCROLL_UP); 162 bool new_is_up = (part.type == MenuController::MenuPart::SCROLL_UP);
163 if (new_menu == submenu_ && is_scrolling_up_ == new_is_up) 163 if (new_menu == submenu_ && is_scrolling_up_ == new_is_up)
164 return; 164 return;
165 165
166 start_scroll_time_ = Time::Now(); 166 start_scroll_time_ = base::Time::Now();
167 start_y_ = part.submenu->GetVisibleBounds().y(); 167 start_y_ = part.submenu->GetVisibleBounds().y();
168 submenu_ = new_menu; 168 submenu_ = new_menu;
169 is_scrolling_up_ = new_is_up; 169 is_scrolling_up_ = new_is_up;
170 170
171 if (!scrolling_timer_.IsRunning()) { 171 if (!scrolling_timer_.IsRunning()) {
172 scrolling_timer_.Start(FROM_HERE, 172 scrolling_timer_.Start(FROM_HERE,
173 TimeDelta::FromMilliseconds(kScrollTimerMS), 173 TimeDelta::FromMilliseconds(kScrollTimerMS),
174 this, &MenuScrollTask::Run); 174 this, &MenuScrollTask::Run);
175 } 175 }
176 } 176 }
177 177
178 void StopScrolling() { 178 void StopScrolling() {
179 if (scrolling_timer_.IsRunning()) { 179 if (scrolling_timer_.IsRunning()) {
180 scrolling_timer_.Stop(); 180 scrolling_timer_.Stop();
181 submenu_ = NULL; 181 submenu_ = NULL;
182 } 182 }
183 } 183 }
184 184
185 // The menu being scrolled. Returns null if not scrolling. 185 // The menu being scrolled. Returns null if not scrolling.
186 SubmenuView* submenu() const { return submenu_; } 186 SubmenuView* submenu() const { return submenu_; }
187 187
188 private: 188 private:
189 void Run() { 189 void Run() {
190 DCHECK(submenu_); 190 DCHECK(submenu_);
191 gfx::Rect vis_rect = submenu_->GetVisibleBounds(); 191 gfx::Rect vis_rect = submenu_->GetVisibleBounds();
192 const int delta_y = static_cast<int>( 192 const int delta_y = static_cast<int>(
193 (Time::Now() - start_scroll_time_).InMilliseconds() * 193 (base::Time::Now() - start_scroll_time_).InMilliseconds() *
194 pixels_per_second_ / 1000); 194 pixels_per_second_ / 1000);
195 vis_rect.set_y(is_scrolling_up_ ? 195 vis_rect.set_y(is_scrolling_up_ ?
196 std::max(0, start_y_ - delta_y) : 196 std::max(0, start_y_ - delta_y) :
197 std::min(submenu_->height() - vis_rect.height(), start_y_ + delta_y)); 197 std::min(submenu_->height() - vis_rect.height(), start_y_ + delta_y));
198 submenu_->ScrollRectToVisible(vis_rect); 198 submenu_->ScrollRectToVisible(vis_rect);
199 } 199 }
200 200
201 // SubmenuView being scrolled. 201 // SubmenuView being scrolled.
202 SubmenuView* submenu_; 202 SubmenuView* submenu_;
203 203
(...skipping 1844 matching lines...) Expand 10 before | Expand all | Expand 10 after
2048 (!pending_state_.item->HasSubmenu() || 2048 (!pending_state_.item->HasSubmenu() ||
2049 !pending_state_.item->GetSubmenu()->IsShowing())) { 2049 !pending_state_.item->GetSubmenu()->IsShowing())) {
2050 // On exit if the user hasn't selected an item with a submenu, move the 2050 // On exit if the user hasn't selected an item with a submenu, move the
2051 // selection back to the parent menu item. 2051 // selection back to the parent menu item.
2052 SetSelection(pending_state_.item->GetParentMenuItem(), 2052 SetSelection(pending_state_.item->GetParentMenuItem(),
2053 SELECTION_OPEN_SUBMENU); 2053 SELECTION_OPEN_SUBMENU);
2054 } 2054 }
2055 } 2055 }
2056 2056
2057 } // namespace views 2057 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698