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

Side by Side Diff: ui/views/view.cc

Issue 2583343003: [views] Changes iteration over |children_| to use range-based for loops (Closed)
Patch Set: [views] Changes iteration over |children_| to use range-based for loops (nits) Created 3 years, 12 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 | no next file » | no next file with comments »
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 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first. 5 #define _USE_MATH_DEFINES // For VC++ to get M_PI. This has to be first.
6 6
7 #include "ui/views/view.h" 7 #include "ui/views/view.h"
8 8
9 #include <algorithm> 9 #include <algorithm>
10 #include <cmath> 10 #include <cmath>
11 #include <memory> 11 #include <memory>
12 #include <utility> 12 #include <utility>
13 13
14 #include "base/containers/adapters.h"
14 #include "base/logging.h" 15 #include "base/logging.h"
15 #include "base/macros.h" 16 #include "base/macros.h"
16 #include "base/memory/ptr_util.h" 17 #include "base/memory/ptr_util.h"
17 #include "base/message_loop/message_loop.h" 18 #include "base/message_loop/message_loop.h"
18 #include "base/stl_util.h" 19 #include "base/stl_util.h"
19 #include "base/strings/stringprintf.h" 20 #include "base/strings/stringprintf.h"
20 #include "base/strings/utf_string_conversions.h" 21 #include "base/strings/utf_string_conversions.h"
21 #include "base/trace_event/trace_event.h" 22 #include "base/trace_event/trace_event.h"
22 #include "build/build_config.h" 23 #include "build/build_config.h"
23 #include "third_party/skia/include/core/SkRect.h" 24 #include "third_party/skia/include/core/SkRect.h"
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
547 // If we have a layout manager, let it handle the layout for us. 548 // If we have a layout manager, let it handle the layout for us.
548 if (layout_manager_.get()) 549 if (layout_manager_.get())
549 layout_manager_->Layout(this); 550 layout_manager_->Layout(this);
550 551
551 // Make sure to propagate the Layout() call to any children that haven't 552 // Make sure to propagate the Layout() call to any children that haven't
552 // received it yet through the layout manager and need to be laid out. This 553 // received it yet through the layout manager and need to be laid out. This
553 // is needed for the case when the child requires a layout but its bounds 554 // is needed for the case when the child requires a layout but its bounds
554 // weren't changed by the layout manager. If there is no layout manager, we 555 // weren't changed by the layout manager. If there is no layout manager, we
555 // just propagate the Layout() call down the hierarchy, so whoever receives 556 // just propagate the Layout() call down the hierarchy, so whoever receives
556 // the call can take appropriate action. 557 // the call can take appropriate action.
557 for (int i = 0, count = child_count(); i < count; ++i) { 558 for (auto* child : children_) {
558 View* child = child_at(i);
559 if (child->needs_layout_ || !layout_manager_.get()) { 559 if (child->needs_layout_ || !layout_manager_.get()) {
560 TRACE_EVENT1("views", "View::Layout", "class", child->GetClassName()); 560 TRACE_EVENT1("views", "View::Layout", "class", child->GetClassName());
561 child->needs_layout_ = false; 561 child->needs_layout_ = false;
562 child->Layout(); 562 child->Layout();
563 } 563 }
564 } 564 }
565 } 565 }
566 566
567 void View::InvalidateLayout() { 567 void View::InvalidateLayout() {
568 // Always invalidate up. This is needed to handle the case of us already being 568 // Always invalidate up. This is needed to handle the case of us already being
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
614 614
615 View* View::GetAncestorWithClassName(const std::string& name) { 615 View* View::GetAncestorWithClassName(const std::string& name) {
616 return const_cast<View*>(const_cast<const View*>(this)-> 616 return const_cast<View*>(const_cast<const View*>(this)->
617 GetAncestorWithClassName(name)); 617 GetAncestorWithClassName(name));
618 } 618 }
619 619
620 const View* View::GetViewByID(int id) const { 620 const View* View::GetViewByID(int id) const {
621 if (id == id_) 621 if (id == id_)
622 return const_cast<View*>(this); 622 return const_cast<View*>(this);
623 623
624 for (int i = 0, count = child_count(); i < count; ++i) { 624 for (auto* child : children_) {
625 const View* view = child_at(i)->GetViewByID(id); 625 const View* view = child->GetViewByID(id);
626 if (view) 626 if (view)
627 return view; 627 return view;
628 } 628 }
629 return NULL; 629 return NULL;
630 } 630 }
631 631
632 View* View::GetViewByID(int id) { 632 View* View::GetViewByID(int id) {
633 return const_cast<View*>(const_cast<const View*>(this)->GetViewByID(id)); 633 return const_cast<View*>(const_cast<const View*>(this)->GetViewByID(id));
634 } 634 }
635 635
636 void View::SetGroup(int gid) { 636 void View::SetGroup(int gid) {
637 // Don't change the group id once it's set. 637 // Don't change the group id once it's set.
638 DCHECK(group_ == -1 || group_ == gid); 638 DCHECK(group_ == -1 || group_ == gid);
639 group_ = gid; 639 group_ = gid;
640 } 640 }
641 641
642 int View::GetGroup() const { 642 int View::GetGroup() const {
643 return group_; 643 return group_;
644 } 644 }
645 645
646 bool View::IsGroupFocusTraversable() const { 646 bool View::IsGroupFocusTraversable() const {
647 return true; 647 return true;
648 } 648 }
649 649
650 void View::GetViewsInGroup(int group, Views* views) { 650 void View::GetViewsInGroup(int group, Views* views) {
651 if (group_ == group) 651 if (group_ == group)
652 views->push_back(this); 652 views->push_back(this);
653 653
654 for (int i = 0, count = child_count(); i < count; ++i) 654 for (auto* child : children_)
655 child_at(i)->GetViewsInGroup(group, views); 655 child->GetViewsInGroup(group, views);
656 } 656 }
657 657
658 View* View::GetSelectedViewForGroup(int group) { 658 View* View::GetSelectedViewForGroup(int group) {
659 Views views; 659 Views views;
660 GetWidget()->GetRootView()->GetViewsInGroup(group, &views); 660 GetWidget()->GetRootView()->GetViewsInGroup(group, &views);
661 return views.empty() ? NULL : views[0]; 661 return views.empty() ? NULL : views[0];
662 } 662 }
663 663
664 // Coordinate conversion ------------------------------------------------------- 664 // Coordinate conversion -------------------------------------------------------
665 665
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after
910 return true; 910 return true;
911 } 911 }
912 912
913 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) { 913 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) {
914 // TODO(tdanderson): Move this implementation into ViewTargetDelegate. 914 // TODO(tdanderson): Move this implementation into ViewTargetDelegate.
915 if (!HitTestPoint(point) || !CanProcessEventsWithinSubtree()) 915 if (!HitTestPoint(point) || !CanProcessEventsWithinSubtree())
916 return NULL; 916 return NULL;
917 917
918 // Walk the child Views recursively looking for the View that most 918 // Walk the child Views recursively looking for the View that most
919 // tightly encloses the specified point. 919 // tightly encloses the specified point.
920 for (int i = child_count() - 1; i >= 0; --i) { 920 for (auto* child : base::Reversed(children_)) {
921 View* child = child_at(i);
922 if (!child->visible()) 921 if (!child->visible())
923 continue; 922 continue;
924 923
925 gfx::Point point_in_child_coords(point); 924 gfx::Point point_in_child_coords(point);
926 ConvertPointToTarget(this, child, &point_in_child_coords); 925 ConvertPointToTarget(this, child, &point_in_child_coords);
927 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords); 926 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords);
928 if (handler) 927 if (handler)
929 return handler; 928 return handler;
930 } 929 }
931 return this; 930 return this;
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1430 1429
1431 if (focus_manager) 1430 if (focus_manager)
1432 RegisterPendingAccelerators(); 1431 RegisterPendingAccelerators();
1433 } 1432 }
1434 } 1433 }
1435 1434
1436 // Painting -------------------------------------------------------------------- 1435 // Painting --------------------------------------------------------------------
1437 1436
1438 void View::PaintChildren(const ui::PaintContext& context) { 1437 void View::PaintChildren(const ui::PaintContext& context) {
1439 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); 1438 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName());
1440 for (int i = 0, count = child_count(); i < count; ++i) 1439 for (auto* child : children_) {
1441 if (!child_at(i)->layer()) 1440 if (!child->layer())
1442 child_at(i)->Paint(context); 1441 child->Paint(context);
1442 }
1443 } 1443 }
1444 1444
1445 void View::OnPaint(gfx::Canvas* canvas) { 1445 void View::OnPaint(gfx::Canvas* canvas) {
1446 TRACE_EVENT1("views", "View::OnPaint", "class", GetClassName()); 1446 TRACE_EVENT1("views", "View::OnPaint", "class", GetClassName());
1447 OnPaintBackground(canvas); 1447 OnPaintBackground(canvas);
1448 OnPaintBorder(canvas); 1448 OnPaintBorder(canvas);
1449 } 1449 }
1450 1450
1451 void View::OnPaintBackground(gfx::Canvas* canvas) { 1451 void View::OnPaintBackground(gfx::Canvas* canvas) {
1452 if (background_.get()) { 1452 if (background_.get()) {
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
1498 void View::MoveLayerToParent(ui::Layer* parent_layer, 1498 void View::MoveLayerToParent(ui::Layer* parent_layer,
1499 const gfx::Point& point) { 1499 const gfx::Point& point) {
1500 gfx::Point local_point(point); 1500 gfx::Point local_point(point);
1501 if (parent_layer != layer()) 1501 if (parent_layer != layer())
1502 local_point.Offset(GetMirroredX(), y()); 1502 local_point.Offset(GetMirroredX(), y());
1503 if (layer() && parent_layer != layer()) { 1503 if (layer() && parent_layer != layer()) {
1504 parent_layer->Add(layer()); 1504 parent_layer->Add(layer());
1505 SetLayerBounds(gfx::Rect(local_point.x(), local_point.y(), 1505 SetLayerBounds(gfx::Rect(local_point.x(), local_point.y(),
1506 width(), height())); 1506 width(), height()));
1507 } else { 1507 } else {
1508 for (int i = 0, count = child_count(); i < count; ++i) 1508 for (auto* child : children_)
1509 child_at(i)->MoveLayerToParent(parent_layer, local_point); 1509 child->MoveLayerToParent(parent_layer, local_point);
1510 } 1510 }
1511 } 1511 }
1512 1512
1513 void View::UpdateLayerVisibility() { 1513 void View::UpdateLayerVisibility() {
1514 bool visible = visible_; 1514 bool visible = visible_;
1515 for (const View* v = parent_; visible && v && !v->layer(); v = v->parent_) 1515 for (const View* v = parent_; visible && v && !v->layer(); v = v->parent_)
1516 visible = v->visible(); 1516 visible = v->visible();
1517 1517
1518 UpdateChildLayerVisibility(visible); 1518 UpdateChildLayerVisibility(visible);
1519 } 1519 }
1520 1520
1521 void View::UpdateChildLayerVisibility(bool ancestor_visible) { 1521 void View::UpdateChildLayerVisibility(bool ancestor_visible) {
1522 if (layer()) { 1522 if (layer()) {
1523 layer()->SetVisible(ancestor_visible && visible_); 1523 layer()->SetVisible(ancestor_visible && visible_);
1524 } else { 1524 } else {
1525 for (int i = 0, count = child_count(); i < count; ++i) 1525 for (auto* child : children_)
1526 child_at(i)->UpdateChildLayerVisibility(ancestor_visible && visible_); 1526 child->UpdateChildLayerVisibility(ancestor_visible && visible_);
1527 } 1527 }
1528 } 1528 }
1529 1529
1530 void View::UpdateChildLayerBounds(const gfx::Vector2d& offset) { 1530 void View::UpdateChildLayerBounds(const gfx::Vector2d& offset) {
1531 if (layer()) { 1531 if (layer()) {
1532 SetLayerBounds(GetLocalBounds() + offset); 1532 SetLayerBounds(GetLocalBounds() + offset);
1533 } else { 1533 } else {
1534 for (int i = 0, count = child_count(); i < count; ++i) { 1534 for (auto* child : children_) {
1535 View* child = child_at(i);
1536 child->UpdateChildLayerBounds( 1535 child->UpdateChildLayerBounds(
1537 offset + gfx::Vector2d(child->GetMirroredX(), child->y())); 1536 offset + gfx::Vector2d(child->GetMirroredX(), child->y()));
1538 } 1537 }
1539 } 1538 }
1540 } 1539 }
1541 1540
1542 void View::OnPaintLayer(const ui::PaintContext& context) { 1541 void View::OnPaintLayer(const ui::PaintContext& context) {
1543 Paint(context); 1542 Paint(context);
1544 } 1543 }
1545 1544
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1758 1757
1759 base::snprintf(pp, kMaxPointerStringLength, "%p", parent_); 1758 base::snprintf(pp, kMaxPointerStringLength, "%p", parent_);
1760 result.append(" N"); 1759 result.append(" N");
1761 result.append(pp + 2); 1760 result.append(pp + 2);
1762 result.append(" -> N"); 1761 result.append(" -> N");
1763 result.append(p + 2); 1762 result.append(p + 2);
1764 result.append("\n"); 1763 result.append("\n");
1765 } 1764 }
1766 1765
1767 // Children. 1766 // Children.
1768 for (int i = 0, count = view_with_children->child_count(); i < count; ++i) 1767 for (auto* child : view_with_children->children_)
1769 result.append(view_with_children->child_at(i)->PrintViewGraph(false)); 1768 result.append(child->PrintViewGraph(false));
1770 1769
1771 if (first) 1770 if (first)
1772 result.append("}\n"); 1771 result.append("}\n");
1773 1772
1774 return result; 1773 return result;
1775 } 1774 }
1776 #endif 1775 #endif
1777 1776
1778 //////////////////////////////////////////////////////////////////////////////// 1777 ////////////////////////////////////////////////////////////////////////////////
1779 // View, private: 1778 // View, private:
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 UpdateTooltip(); 1867 UpdateTooltip();
1869 1868
1870 if (layout_manager_) 1869 if (layout_manager_)
1871 layout_manager_->ViewRemoved(this, view); 1870 layout_manager_->ViewRemoved(this, view);
1872 1871
1873 for (ViewObserver& observer : observers_) 1872 for (ViewObserver& observer : observers_)
1874 observer.OnChildViewRemoved(view, this); 1873 observer.OnChildViewRemoved(view, this);
1875 } 1874 }
1876 1875
1877 void View::PropagateRemoveNotifications(View* old_parent, View* new_parent) { 1876 void View::PropagateRemoveNotifications(View* old_parent, View* new_parent) {
1878 for (int i = 0, count = child_count(); i < count; ++i) 1877 for (auto* child : children_)
1879 child_at(i)->PropagateRemoveNotifications(old_parent, new_parent); 1878 child->PropagateRemoveNotifications(old_parent, new_parent);
1880 1879
1881 ViewHierarchyChangedDetails details(false, old_parent, this, new_parent); 1880 ViewHierarchyChangedDetails details(false, old_parent, this, new_parent);
1882 for (View* v = this; v; v = v->parent_) 1881 for (View* v = this; v; v = v->parent_)
1883 v->ViewHierarchyChangedImpl(true, details); 1882 v->ViewHierarchyChangedImpl(true, details);
1884 } 1883 }
1885 1884
1886 void View::PropagateAddNotifications( 1885 void View::PropagateAddNotifications(
1887 const ViewHierarchyChangedDetails& details) { 1886 const ViewHierarchyChangedDetails& details) {
1888 for (int i = 0, count = child_count(); i < count; ++i) 1887 for (auto* child : children_)
1889 child_at(i)->PropagateAddNotifications(details); 1888 child->PropagateAddNotifications(details);
1890 ViewHierarchyChangedImpl(true, details); 1889 ViewHierarchyChangedImpl(true, details);
1891 } 1890 }
1892 1891
1893 void View::PropagateNativeViewHierarchyChanged() { 1892 void View::PropagateNativeViewHierarchyChanged() {
1894 for (int i = 0, count = child_count(); i < count; ++i) 1893 for (auto* child : children_)
1895 child_at(i)->PropagateNativeViewHierarchyChanged(); 1894 child->PropagateNativeViewHierarchyChanged();
1896 NativeViewHierarchyChanged(); 1895 NativeViewHierarchyChanged();
1897 } 1896 }
1898 1897
1899 void View::ViewHierarchyChangedImpl( 1898 void View::ViewHierarchyChangedImpl(
1900 bool register_accelerators, 1899 bool register_accelerators,
1901 const ViewHierarchyChangedDetails& details) { 1900 const ViewHierarchyChangedDetails& details) {
1902 if (register_accelerators) { 1901 if (register_accelerators) {
1903 if (details.is_add) { 1902 if (details.is_add) {
1904 // If you get this registration, you are part of a subtree that has been 1903 // If you get this registration, you are part of a subtree that has been
1905 // added to the view hierarchy. 1904 // added to the view hierarchy.
1906 if (GetFocusManager()) 1905 if (GetFocusManager())
1907 RegisterPendingAccelerators(); 1906 RegisterPendingAccelerators();
1908 } else { 1907 } else {
1909 if (details.child == this) 1908 if (details.child == this)
1910 UnregisterAccelerators(true); 1909 UnregisterAccelerators(true);
1911 } 1910 }
1912 } 1911 }
1913 1912
1914 ViewHierarchyChanged(details); 1913 ViewHierarchyChanged(details);
1915 details.parent->needs_layout_ = true; 1914 details.parent->needs_layout_ = true;
1916 } 1915 }
1917 1916
1918 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) { 1917 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) {
1919 for (int i = 0, count = child_count(); i < count; ++i) 1918 for (auto* child : children_)
1920 child_at(i)->PropagateNativeThemeChanged(theme); 1919 child->PropagateNativeThemeChanged(theme);
1921 OnNativeThemeChanged(theme); 1920 OnNativeThemeChanged(theme);
1922 } 1921 }
1923 1922
1924 // Size and disposition -------------------------------------------------------- 1923 // Size and disposition --------------------------------------------------------
1925 1924
1926 void View::PropagateVisibilityNotifications(View* start, bool is_visible) { 1925 void View::PropagateVisibilityNotifications(View* start, bool is_visible) {
1927 for (int i = 0, count = child_count(); i < count; ++i) 1926 for (auto* child : children_)
1928 child_at(i)->PropagateVisibilityNotifications(start, is_visible); 1927 child->PropagateVisibilityNotifications(start, is_visible);
1929 VisibilityChangedImpl(start, is_visible); 1928 VisibilityChangedImpl(start, is_visible);
1930 } 1929 }
1931 1930
1932 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { 1931 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) {
1933 VisibilityChanged(starting_from, is_visible); 1932 VisibilityChanged(starting_from, is_visible);
1934 } 1933 }
1935 1934
1936 void View::BoundsChanged(const gfx::Rect& previous_bounds) { 1935 void View::BoundsChanged(const gfx::Rect& previous_bounds) {
1937 if (visible_) { 1936 if (visible_) {
1938 // Paint the new bounds. 1937 // Paint the new bounds.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2099 bool result = GetTransformRelativeTo(ancestor, &trans); 2098 bool result = GetTransformRelativeTo(ancestor, &trans);
2100 trans.TransformRectReverse(rect); 2099 trans.TransformRectReverse(rect);
2101 return result; 2100 return result;
2102 } 2101 }
2103 2102
2104 // Accelerated painting -------------------------------------------------------- 2103 // Accelerated painting --------------------------------------------------------
2105 2104
2106 void View::CreateLayer() { 2105 void View::CreateLayer() {
2107 // A new layer is being created for the view. So all the layers of the 2106 // A new layer is being created for the view. So all the layers of the
2108 // sub-tree can inherit the visibility of the corresponding view. 2107 // sub-tree can inherit the visibility of the corresponding view.
2109 for (int i = 0, count = child_count(); i < count; ++i) 2108 for (auto* child : children_)
2110 child_at(i)->UpdateChildLayerVisibility(true); 2109 child->UpdateChildLayerVisibility(true);
2111 2110
2112 SetLayer(base::MakeUnique<ui::Layer>()); 2111 SetLayer(base::MakeUnique<ui::Layer>());
2113 layer()->set_delegate(this); 2112 layer()->set_delegate(this);
2114 layer()->set_name(GetClassName()); 2113 layer()->set_name(GetClassName());
2115 2114
2116 UpdateParentLayers(); 2115 UpdateParentLayers();
2117 UpdateLayerVisibility(); 2116 UpdateLayerVisibility();
2118 2117
2119 // The new layer needs to be ordered in the layer tree according 2118 // The new layer needs to be ordered in the layer tree according
2120 // to the view tree. Children of this layer were added in order 2119 // to the view tree. Children of this layer were added in order
(...skipping 17 matching lines...) Expand all
2138 if (layer()) { 2137 if (layer()) {
2139 if (!layer()->parent()) { 2138 if (!layer()->parent()) {
2140 UpdateParentLayer(); 2139 UpdateParentLayer();
2141 return true; 2140 return true;
2142 } 2141 }
2143 // The layers of any child views are already in place, so we can stop 2142 // The layers of any child views are already in place, so we can stop
2144 // iterating here. 2143 // iterating here.
2145 return false; 2144 return false;
2146 } 2145 }
2147 bool result = false; 2146 bool result = false;
2148 for (int i = 0, count = child_count(); i < count; ++i) { 2147 for (auto* child : children_) {
2149 if (child_at(i)->UpdateParentLayers()) 2148 if (child->UpdateParentLayers())
2150 result = true; 2149 result = true;
2151 } 2150 }
2152 return result; 2151 return result;
2153 } 2152 }
2154 2153
2155 void View::OrphanLayers() { 2154 void View::OrphanLayers() {
2156 if (layer()) { 2155 if (layer()) {
2157 if (layer()->parent()) 2156 if (layer()->parent())
2158 layer()->parent()->Remove(layer()); 2157 layer()->parent()->Remove(layer());
2159 2158
2160 // The layer belonging to this View has already been orphaned. It is not 2159 // The layer belonging to this View has already been orphaned. It is not
2161 // necessary to orphan the child layers. 2160 // necessary to orphan the child layers.
2162 return; 2161 return;
2163 } 2162 }
2164 for (int i = 0, count = child_count(); i < count; ++i) 2163 for (auto* child : children_)
2165 child_at(i)->OrphanLayers(); 2164 child->OrphanLayers();
2166 } 2165 }
2167 2166
2168 void View::ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer) { 2167 void View::ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer) {
2169 layer()->SetBounds(GetLocalBounds() + offset); 2168 layer()->SetBounds(GetLocalBounds() + offset);
2170 DCHECK_NE(layer(), parent_layer); 2169 DCHECK_NE(layer(), parent_layer);
2171 if (parent_layer) 2170 if (parent_layer)
2172 parent_layer->Add(layer()); 2171 parent_layer->Add(layer());
2173 layer()->SchedulePaint(GetLocalBounds()); 2172 layer()->SchedulePaint(GetLocalBounds());
2174 MoveLayerToParent(layer(), gfx::Point()); 2173 MoveLayerToParent(layer(), gfx::Point());
2175 } 2174 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2384 return; 2383 return;
2385 2384
2386 FocusManager* focus_manager = GetFocusManager(); 2385 FocusManager* focus_manager = GetFocusManager();
2387 if (focus_manager) 2386 if (focus_manager)
2388 focus_manager->AdvanceFocusIfNecessary(); 2387 focus_manager->AdvanceFocusIfNecessary();
2389 } 2388 }
2390 2389
2391 // System events --------------------------------------------------------------- 2390 // System events ---------------------------------------------------------------
2392 2391
2393 void View::PropagateThemeChanged() { 2392 void View::PropagateThemeChanged() {
2394 for (int i = child_count() - 1; i >= 0; --i) 2393 for (auto* child : base::Reversed(children_))
2395 child_at(i)->PropagateThemeChanged(); 2394 child->PropagateThemeChanged();
2396 OnThemeChanged(); 2395 OnThemeChanged();
2397 } 2396 }
2398 2397
2399 void View::PropagateLocaleChanged() { 2398 void View::PropagateLocaleChanged() {
2400 for (int i = child_count() - 1; i >= 0; --i) 2399 for (auto* child : base::Reversed(children_))
2401 child_at(i)->PropagateLocaleChanged(); 2400 child->PropagateLocaleChanged();
2402 OnLocaleChanged(); 2401 OnLocaleChanged();
2403 } 2402 }
2404 2403
2405 void View::PropagateDeviceScaleFactorChanged(float device_scale_factor) { 2404 void View::PropagateDeviceScaleFactorChanged(float device_scale_factor) {
2406 for (int i = child_count() - 1; i >= 0; --i) 2405 for (auto* child : base::Reversed(children_))
2407 child_at(i)->PropagateDeviceScaleFactorChanged(device_scale_factor); 2406 child->PropagateDeviceScaleFactorChanged(device_scale_factor);
2408 2407
2409 // If the view is drawing to the layer, OnDeviceScaleFactorChanged() is called 2408 // If the view is drawing to the layer, OnDeviceScaleFactorChanged() is called
2410 // through LayerDelegate callback. 2409 // through LayerDelegate callback.
2411 if (!layer()) 2410 if (!layer())
2412 OnDeviceScaleFactorChanged(device_scale_factor); 2411 OnDeviceScaleFactorChanged(device_scale_factor);
2413 } 2412 }
2414 2413
2415 // Tooltips -------------------------------------------------------------------- 2414 // Tooltips --------------------------------------------------------------------
2416 2415
2417 void View::UpdateTooltip() { 2416 void View::UpdateTooltip() {
(...skipping 30 matching lines...) Expand all
2448 // Message the RootView to do the drag and drop. That way if we're removed 2447 // Message the RootView to do the drag and drop. That way if we're removed
2449 // the RootView can detect it and avoid calling us back. 2448 // the RootView can detect it and avoid calling us back.
2450 gfx::Point widget_location(event.location()); 2449 gfx::Point widget_location(event.location());
2451 ConvertPointToWidget(this, &widget_location); 2450 ConvertPointToWidget(this, &widget_location);
2452 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2451 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2453 // WARNING: we may have been deleted. 2452 // WARNING: we may have been deleted.
2454 return true; 2453 return true;
2455 } 2454 }
2456 2455
2457 } // namespace views 2456 } // namespace views
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698