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

Side by Side Diff: ui/views/controls/scrollbar/base_scroll_bar.cc

Issue 2454323002: MacViews: Reveal scrollbars when resting on the trackpad. (Closed)
Patch Set: rebase for r432358 Created 4 years, 1 month 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 "ui/views/controls/scrollbar/base_scroll_bar.h" 5 #include "ui/views/controls/scrollbar/base_scroll_bar.h"
6 6
7 #include "base/bind.h" 7 #include "base/bind.h"
8 #include "base/bind_helpers.h" 8 #include "base/bind_helpers.h"
9 #include "base/callback.h" 9 #include "base/callback.h"
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 397 matching lines...) Expand 10 before | Expand all | Expand 10 after
408 controller()->ScrollToPosition(this, position); 408 controller()->ScrollToPosition(this, position);
409 } 409 }
410 410
411 int BaseScrollBar::GetScrollIncrement(bool is_page, bool is_positive) { 411 int BaseScrollBar::GetScrollIncrement(bool is_page, bool is_positive) {
412 return controller()->GetScrollIncrement(this, is_page, is_positive); 412 return controller()->GetScrollIncrement(this, is_page, is_positive);
413 } 413 }
414 414
415 /////////////////////////////////////////////////////////////////////////////// 415 ///////////////////////////////////////////////////////////////////////////////
416 // BaseScrollBar, private: 416 // BaseScrollBar, private:
417 417
418 #if !defined(OS_MACOSX)
419 // static
420 base::Timer* BaseScrollBar::GetHideTimerForTest(BaseScrollBar* scroll_bar) {
421 return nullptr;
422 }
423 #endif
424
418 int BaseScrollBar::GetThumbSizeForTest() { 425 int BaseScrollBar::GetThumbSizeForTest() {
419 return thumb_->GetSize(); 426 return thumb_->GetSize();
420 } 427 }
421 428
422 void BaseScrollBar::ProcessPressEvent(const ui::LocatedEvent& event) { 429 void BaseScrollBar::ProcessPressEvent(const ui::LocatedEvent& event) {
423 gfx::Rect thumb_bounds = thumb_->bounds(); 430 gfx::Rect thumb_bounds = thumb_->bounds();
424 if (IsHorizontal()) { 431 if (IsHorizontal()) {
425 if (GetMirroredXInView(event.x()) < thumb_bounds.x()) { 432 if (GetMirroredXInView(event.x()) < thumb_bounds.x()) {
426 last_scroll_amount_ = SCROLL_PREV_PAGE; 433 last_scroll_amount_ = SCROLL_PREV_PAGE;
427 } else if (GetMirroredXInView(event.x()) > thumb_bounds.right()) { 434 } else if (GetMirroredXInView(event.x()) > thumb_bounds.right()) {
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
470 int track_size = GetTrackSize(); 477 int track_size = GetTrackSize();
471 if (track_size == thumb_size) 478 if (track_size == thumb_size)
472 return 0; 479 return 0;
473 if (scroll_to_middle) 480 if (scroll_to_middle)
474 thumb_position = thumb_position - (thumb_size / 2); 481 thumb_position = thumb_position - (thumb_size / 2);
475 return (thumb_position * (contents_size_ - viewport_size_)) / 482 return (thumb_position * (contents_size_ - viewport_size_)) /
476 (track_size - thumb_size); 483 (track_size - thumb_size);
477 } 484 }
478 485
479 } // namespace views 486 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/controls/scrollbar/base_scroll_bar.h ('k') | ui/views/controls/scrollbar/cocoa_scroll_bar.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698