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

Side by Side Diff: ui/views/controls/scroll_view.h

Issue 2188133002: Scroll with Layers in views::ScrollView (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@20160728-MacViews-ScrollTrack
Patch Set: DCHECK for no layer Created 4 years, 4 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 #ifndef UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 5 #ifndef UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
6 #define UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 6 #define UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
11 #include "base/gtest_prod_util.h" 11 #include "base/gtest_prod_util.h"
12 #include "base/macros.h" 12 #include "base/macros.h"
13 #include "ui/views/controls/scrollbar/scroll_bar.h" 13 #include "ui/views/controls/scrollbar/scroll_bar.h"
14 14
15 namespace gfx {
16 class ScrollOffset;
17 }
18
15 namespace views { 19 namespace views {
16 namespace test { 20 namespace test {
17 class ScrollViewTestApi; 21 class ScrollViewTestApi;
18 } 22 }
19 23
20 ///////////////////////////////////////////////////////////////////////////// 24 /////////////////////////////////////////////////////////////////////////////
21 // 25 //
22 // ScrollView class 26 // ScrollView class
23 // 27 //
24 // A ScrollView is used to make any View scrollable. The view is added to 28 // A ScrollView is used to make any View scrollable. The view is added to
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
82 // View overrides: 86 // View overrides:
83 gfx::Size GetPreferredSize() const override; 87 gfx::Size GetPreferredSize() const override;
84 int GetHeightForWidth(int width) const override; 88 int GetHeightForWidth(int width) const override;
85 void Layout() override; 89 void Layout() override;
86 bool OnKeyPressed(const ui::KeyEvent& event) override; 90 bool OnKeyPressed(const ui::KeyEvent& event) override;
87 bool OnMouseWheel(const ui::MouseWheelEvent& e) override; 91 bool OnMouseWheel(const ui::MouseWheelEvent& e) override;
88 void OnMouseEntered(const ui::MouseEvent& event) override; 92 void OnMouseEntered(const ui::MouseEvent& event) override;
89 void OnMouseExited(const ui::MouseEvent& event) override; 93 void OnMouseExited(const ui::MouseEvent& event) override;
90 void OnGestureEvent(ui::GestureEvent* event) override; 94 void OnGestureEvent(ui::GestureEvent* event) override;
91 const char* GetClassName() const override; 95 const char* GetClassName() const override;
96 ScrollView* EnclosingScrollView() override;
92 97
93 // ScrollBarController overrides: 98 // ScrollBarController overrides:
94 void ScrollToPosition(ScrollBar* source, int position) override; 99 void ScrollToPosition(ScrollBar* source, int position) override;
95 int GetScrollIncrement(ScrollBar* source, 100 int GetScrollIncrement(ScrollBar* source,
96 bool is_page, 101 bool is_page,
97 bool is_positive) override; 102 bool is_positive) override;
98 103
99 private: 104 private:
100 friend class test::ScrollViewTestApi; 105 friend class test::ScrollViewTestApi;
101 106
(...skipping 16 matching lines...) Expand all
118 bool* horiz_is_shown, 123 bool* horiz_is_shown,
119 bool* vert_is_shown) const; 124 bool* vert_is_shown) const;
120 125
121 // Shows or hides the scrollbar/corner_view based on the value of 126 // Shows or hides the scrollbar/corner_view based on the value of
122 // |should_show|. 127 // |should_show|.
123 void SetControlVisibility(View* control, bool should_show); 128 void SetControlVisibility(View* control, bool should_show);
124 129
125 // Update the scrollbars positions given viewport and content sizes. 130 // Update the scrollbars positions given viewport and content sizes.
126 void UpdateScrollBarPositions(); 131 void UpdateScrollBarPositions();
127 132
128 // The current contents and its viewport. |contents_| is contained in 133 // Helpers to get and set the current scroll offset (either from the ui::Layer
129 // |contents_viewport_|. 134 // or from the |contents_| origin offset).
135 gfx::ScrollOffset CurrentOffset() const;
136 void ScrollToOffset(const gfx::ScrollOffset& offset);
137
138 // Callback entrypoint when hosted Layers are scrolled by the Compositor.
139 void OnLayerScrolled();
140
141 // Horizontally scrolls the header (if any) to match the contents.
142 void ScrollHeader();
143
144 // The current contents and its viewport. |contents_| is contained in the
145 // layer-backed |contents_container_| which guarantees it is at least as high
146 // and wide as the |contents_viewport_|, which does the clipping. If
147 // |contents_container_| is null, the origin of |contents_| is offset to
148 // perform scrolling.
130 View* contents_; 149 View* contents_;
150 View* contents_container_;
131 View* contents_viewport_; 151 View* contents_viewport_;
132 152
133 // The current header and its viewport. |header_| is contained in 153 // The current header and its viewport. |header_| is contained in
134 // |header_viewport_|. 154 // |header_viewport_|.
135 View* header_; 155 View* header_;
136 View* header_viewport_; 156 View* header_viewport_;
137 157
138 // Horizontal scrollbar. 158 // Horizontal scrollbar.
139 ScrollBar* horiz_sb_; 159 ScrollBar* horiz_sb_;
140 160
(...skipping 81 matching lines...) Expand 10 before | Expand all | Expand 10 after
222 private: 242 private:
223 int top_margin_; 243 int top_margin_;
224 int row_height_; 244 int row_height_;
225 245
226 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); 246 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper);
227 }; 247 };
228 248
229 } // namespace views 249 } // namespace views
230 250
231 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 251 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698