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

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

Issue 2813353002: Ensure that the focus ring in the bookmarks bar does not paint outside the parent view. (Closed)
Patch Set: Remove newline and global variable Created 3 years, 8 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 | « no previous file | ui/views/controls/scroll_view.cc » ('j') | ui/views/controls/scroll_view.cc » ('J')
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 #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"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 // Returns the ScrollView for which |contents| is its contents, or null if 49 // Returns the ScrollView for which |contents| is its contents, or null if
50 // |contents| is not in a ScrollView. 50 // |contents| is not in a ScrollView.
51 static ScrollView* GetScrollViewForContents(View* contents); 51 static ScrollView* GetScrollViewForContents(View* contents);
52 52
53 // Set the contents. Any previous contents will be deleted. The contents 53 // Set the contents. Any previous contents will be deleted. The contents
54 // is the view that needs to scroll. 54 // is the view that needs to scroll.
55 void SetContents(View* a_view); 55 void SetContents(View* a_view);
56 const View* contents() const { return contents_; } 56 const View* contents() const { return contents_; }
57 View* contents() { return contents_; } 57 View* contents() { return contents_; }
58 58
59 const View* contents_viewport() const { return contents_viewport_; }
sky 2017/04/18 15:35:48 I would prefer not to expose this. Can you friend
ananta 2017/04/18 22:22:39 Done.
60
59 // Sets the header, deleting the previous header. 61 // Sets the header, deleting the previous header.
60 void SetHeader(View* header); 62 void SetHeader(View* header);
61 63
62 // Sets the background color. The default is white when scrolling with layers, 64 // Sets the background color. The default is white when scrolling with layers,
63 // otherwise transparent. An opaque color when scrolling with layers ensures 65 // otherwise transparent. An opaque color when scrolling with layers ensures
64 // fonts can be drawn with subpixel antialiasing. 66 // fonts can be drawn with subpixel antialiasing.
65 void SetBackgroundColor(SkColor color); 67 void SetBackgroundColor(SkColor color);
66 68
67 // Returns the visible region of the content View. 69 // Returns the visible region of the content View.
68 gfx::Rect GetVisibleRect() const; 70 gfx::Rect GetVisibleRect() const;
(...skipping 29 matching lines...) Expand all
98 // View overrides: 100 // View overrides:
99 gfx::Size GetPreferredSize() const override; 101 gfx::Size GetPreferredSize() const override;
100 int GetHeightForWidth(int width) const override; 102 int GetHeightForWidth(int width) const override;
101 void Layout() override; 103 void Layout() override;
102 bool OnKeyPressed(const ui::KeyEvent& event) override; 104 bool OnKeyPressed(const ui::KeyEvent& event) override;
103 bool OnMouseWheel(const ui::MouseWheelEvent& e) override; 105 bool OnMouseWheel(const ui::MouseWheelEvent& e) override;
104 void OnScrollEvent(ui::ScrollEvent* event) override; 106 void OnScrollEvent(ui::ScrollEvent* event) override;
105 void OnGestureEvent(ui::GestureEvent* event) override; 107 void OnGestureEvent(ui::GestureEvent* event) override;
106 const char* GetClassName() const override; 108 const char* GetClassName() const override;
107 void OnNativeThemeChanged(const ui::NativeTheme* theme) override; 109 void OnNativeThemeChanged(const ui::NativeTheme* theme) override;
110 void ViewHierarchyChanged(
111 const ViewHierarchyChangedDetails& details) override;
112 void OnChildLayerChanged(View* child) override;
108 113
109 // ScrollBarController overrides: 114 // ScrollBarController overrides:
110 void ScrollToPosition(ScrollBar* source, int position) override; 115 void ScrollToPosition(ScrollBar* source, int position) override;
111 int GetScrollIncrement(ScrollBar* source, 116 int GetScrollIncrement(ScrollBar* source,
112 bool is_page, 117 bool is_page,
113 bool is_positive) override; 118 bool is_positive) override;
114 119
115 // TODO(djacobo): Remove this method when http://crbug.com/656198 is closed. 120 // TODO(djacobo): Remove this method when http://crbug.com/656198 is closed.
sky 2017/04/18 15:35:48 This is the bug you are fixing, and you should be
ananta 2017/04/18 22:22:39 Will do this in a later patch. Will ask QA to test
116 // Force |contents_viewport_| to enable a Layer(). 121 // Force |contents_viewport_| to enable a Layer().
117 void EnableViewPortLayer(); 122 void EnableViewPortLayer();
118 123
119 private: 124 private:
120 friend class test::ScrollViewTestApi; 125 friend class test::ScrollViewTestApi;
121 126
122 class Viewport; 127 class Viewport;
123 128
124 // Used internally by SetHeader() and SetContents() to reset the view. Sets 129 // Used internally by SetHeader() and SetContents() to reset the view. Sets
125 // |member| to |new_view|. If |new_view| is non-null it is added to |parent|. 130 // |member| to |new_view|. If |new_view| is non-null it is added to |parent|.
(...skipping 29 matching lines...) Expand all
155 160
156 // Callback entrypoint when hosted Layers are scrolled by the Compositor. 161 // Callback entrypoint when hosted Layers are scrolled by the Compositor.
157 void OnLayerScrolled(const gfx::ScrollOffset& offset); 162 void OnLayerScrolled(const gfx::ScrollOffset& offset);
158 163
159 // Horizontally scrolls the header (if any) to match the contents. 164 // Horizontally scrolls the header (if any) to match the contents.
160 void ScrollHeader(); 165 void ScrollHeader();
161 166
162 void AddBorder(); 167 void AddBorder();
163 void UpdateBorder(); 168 void UpdateBorder();
164 169
170 // Enables view port layering if layering is enabled for the |child| or any
sky 2017/04/18 15:35:47 'layering is enabled' -> |child| has a layer
ananta 2017/04/18 22:22:39 Done.
171 // of its descendants. Returns true if yes. We short circuit the recursion
172 // if we enabled layering.
173 bool EnableLayeringRecursivelyForChild(View* child);
174
165 // The current contents and its viewport. |contents_| is contained in 175 // The current contents and its viewport. |contents_| is contained in
166 // |contents_viewport_|. 176 // |contents_viewport_|.
167 View* contents_; 177 View* contents_;
168 View* contents_viewport_; 178 View* contents_viewport_;
169 179
170 // The current header and its viewport. |header_| is contained in 180 // The current header and its viewport. |header_| is contained in
171 // |header_viewport_|. 181 // |header_viewport_|.
172 View* header_; 182 View* header_;
173 View* header_viewport_; 183 View* header_viewport_;
174 184
(...skipping 22 matching lines...) Expand all
197 // In Harmony, the indicator is a focus ring. Pre-Harmony, the indicator is a 207 // In Harmony, the indicator is a focus ring. Pre-Harmony, the indicator is a
198 // different border painter. 208 // different border painter.
199 bool draw_focus_indicator_ = false; 209 bool draw_focus_indicator_ = false;
200 210
201 // Only needed for pre-Harmony. Remove when Harmony is default. 211 // Only needed for pre-Harmony. Remove when Harmony is default.
202 bool draw_border_ = false; 212 bool draw_border_ = false;
203 213
204 // Focus ring, if one is installed. 214 // Focus ring, if one is installed.
205 View* focus_ring_ = nullptr; 215 View* focus_ring_ = nullptr;
206 216
217 // Set to true if we enabled layering for the viewport.
218 bool viewport_layer_enabled_ = false;
219
220 // Set to true if the scroll with layers feature is enabled.
221 bool scroll_with_layers_enabled_ = false;
sky 2017/04/18 15:35:47 Make const
ananta 2017/04/18 22:22:39 We cannot do that as this is set based on the expe
sky 2017/04/19 00:03:04 If you move scroll_with_layers_enabled_ = b
ananta 2017/04/19 00:53:17 Thanks. done
222
207 DISALLOW_COPY_AND_ASSIGN(ScrollView); 223 DISALLOW_COPY_AND_ASSIGN(ScrollView);
208 }; 224 };
209 225
210 // VariableRowHeightScrollHelper is intended for views that contain rows of 226 // VariableRowHeightScrollHelper is intended for views that contain rows of
211 // varying height. To use a VariableRowHeightScrollHelper create one supplying 227 // varying height. To use a VariableRowHeightScrollHelper create one supplying
212 // a Controller and delegate GetPageScrollIncrement and GetLineScrollIncrement 228 // a Controller and delegate GetPageScrollIncrement and GetLineScrollIncrement
213 // to the helper. VariableRowHeightScrollHelper calls back to the 229 // to the helper. VariableRowHeightScrollHelper calls back to the
214 // Controller to determine row boundaries. 230 // Controller to determine row boundaries.
215 class VariableRowHeightScrollHelper { 231 class VariableRowHeightScrollHelper {
216 public: 232 public:
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
273 private: 289 private:
274 int top_margin_; 290 int top_margin_;
275 int row_height_; 291 int row_height_;
276 292
277 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper); 293 DISALLOW_COPY_AND_ASSIGN(FixedRowHeightScrollHelper);
278 }; 294 };
279 295
280 } // namespace views 296 } // namespace views
281 297
282 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_ 298 #endif // UI_VIEWS_CONTROLS_SCROLL_VIEW_H_
OLDNEW
« no previous file with comments | « no previous file | ui/views/controls/scroll_view.cc » ('j') | ui/views/controls/scroll_view.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698