| OLD | NEW |
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 "views/controls/scroll_view.h" | 5 #include "views/controls/scroll_view.h" |
| 6 | 6 |
| 7 #include "base/logging.h" | 7 #include "base/logging.h" |
| 8 #include "views/controls/scrollbar/native_scroll_bar.h" | 8 #include "views/controls/scrollbar/native_scroll_bar.h" |
| 9 #include "views/widget/root_view.h" | 9 #include "views/widget/root_view.h" |
| 10 | 10 |
| 11 namespace views { | 11 namespace views { |
| 12 | 12 |
| 13 const char* const ScrollView::kViewClassName = "views/ScrollView"; | 13 const char* const ScrollView::kViewClassName = "views/ScrollView"; |
| 14 | 14 |
| 15 // Viewport contains the contents View of the ScrollView. | 15 // Viewport contains the contents View of the ScrollView. |
| 16 class Viewport : public View { | 16 class Viewport : public View { |
| 17 public: | 17 public: |
| 18 Viewport() {} | 18 Viewport() {} |
| 19 virtual ~Viewport() {} | 19 virtual ~Viewport() {} |
| 20 | 20 |
| 21 virtual void ScrollRectToVisible(const gfx::Rect& rect) { | 21 virtual void ScrollRectToVisible(const gfx::Rect& rect) { |
| 22 if (!has_children() || !parent()) | 22 if (!has_children() || !parent()) |
| 23 return; | 23 return; |
| 24 | 24 |
| 25 View* contents = GetChildViewAt(0); | 25 View* contents = child_at(0); |
| 26 gfx::Rect scroll_rect(rect); | 26 gfx::Rect scroll_rect(rect); |
| 27 scroll_rect.Offset(-contents->x(), -contents->y()); | 27 scroll_rect.Offset(-contents->x(), -contents->y()); |
| 28 static_cast<ScrollView*>(parent())->ScrollContentsRegionToBeVisible( | 28 static_cast<ScrollView*>(parent())->ScrollContentsRegionToBeVisible( |
| 29 scroll_rect); | 29 scroll_rect); |
| 30 } | 30 } |
| 31 | 31 |
| 32 private: | 32 private: |
| 33 DISALLOW_COPY_AND_ASSIGN(Viewport); | 33 DISALLOW_COPY_AND_ASSIGN(Viewport); |
| 34 }; | 34 }; |
| 35 | 35 |
| (...skipping 452 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 488 | 488 |
| 489 VariableRowHeightScrollHelper::RowInfo | 489 VariableRowHeightScrollHelper::RowInfo |
| 490 FixedRowHeightScrollHelper::GetRowInfo(int y) { | 490 FixedRowHeightScrollHelper::GetRowInfo(int y) { |
| 491 if (y < top_margin_) | 491 if (y < top_margin_) |
| 492 return RowInfo(0, top_margin_); | 492 return RowInfo(0, top_margin_); |
| 493 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, | 493 return RowInfo((y - top_margin_) / row_height_ * row_height_ + top_margin_, |
| 494 row_height_); | 494 row_height_); |
| 495 } | 495 } |
| 496 | 496 |
| 497 } // namespace views | 497 } // namespace views |
| OLD | NEW |