Chromium Code Reviews| Index: ui/views/view.cc |
| diff --git a/ui/views/view.cc b/ui/views/view.cc |
| index 92223157d4c8671aaa2c55aab4c006d1ee25b265..b1f3125281e1723fd40c341c7b9b70c1d3030b18 100644 |
| --- a/ui/views/view.cc |
| +++ b/ui/views/view.cc |
| @@ -461,6 +461,10 @@ void View::OnEnabledChanged() { |
| SchedulePaint(); |
| } |
| +View::Views View::GetChildrenOrderedByVisualOrder() { |
| + return children_; |
| +} |
| + |
| // Transformations ------------------------------------------------------------- |
| gfx::Transform View::GetTransform() const { |
| @@ -917,8 +921,10 @@ View* View::GetTooltipHandlerForPoint(const gfx::Point& point) { |
| // Walk the child Views recursively looking for the View that most |
| // tightly encloses the specified point. |
| - for (int i = child_count() - 1; i >= 0; --i) { |
| - View* child = child_at(i); |
| + View::Views children = GetChildrenOrderedByVisualOrder(); |
| + DCHECK_EQ(child_count(), static_cast<int>(children.size())); |
| + for (int i = children.size() - 1; i >= 0; --i) { |
| + View* child = children[i]; |
| if (!child->visible()) |
| continue; |
| @@ -1437,9 +1443,13 @@ void View::NativeViewHierarchyChanged() { |
| void View::PaintChildren(const ui::PaintContext& context) { |
| TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); |
| - for (int i = 0, count = child_count(); i < count; ++i) |
| - if (!child_at(i)->layer()) |
| - child_at(i)->Paint(context); |
| + View::Views children = GetChildrenOrderedByVisualOrder(); |
| + DCHECK_EQ(child_count(), static_cast<int>(children.size())); |
| + for (int i = 0, count = children.size(); i < count; ++i) { |
|
sky
2016/12/13 23:40:56
Use range based for-loop?
varkha
2016/12/19 20:35:44
Done. I will try to get the rest of the similar it
varkha
2016/12/19 20:56:15
Posted https://codereview.chromium.org/2583343003
|
| + View* child = children[i]; |
| + if (!child->layer()) |
| + child->Paint(context); |
| + } |
| } |
| void View::OnPaint(gfx::Canvas* canvas) { |
| @@ -1588,10 +1598,10 @@ void View::ReorderChildLayers(ui::Layer* parent_layer) { |
| // Iterate backwards through the children so that a child with a layer |
| // which is further to the back is stacked above one which is further to |
| // the front. |
| - for (Views::reverse_iterator it(children_.rbegin()); |
| - it != children_.rend(); ++it) { |
| - (*it)->ReorderChildLayers(parent_layer); |
| - } |
| + View::Views children = GetChildrenOrderedByVisualOrder(); |
| + DCHECK_EQ(child_count(), static_cast<int>(children.size())); |
| + for (int i = children.size() - 1; i >= 0; --i) |
|
sky
2016/12/13 23:40:56
I think a reverse iterator is safer here.
varkha
2016/12/19 20:35:44
Done.
|
| + children[i]->ReorderChildLayers(parent_layer); |
| } |
| } |