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

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

Issue 2594533003: Revert of [views] Changes iteration over |children_| to use range-based for loops (Closed)
Patch Set: 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"
15 #include "base/logging.h" 14 #include "base/logging.h"
16 #include "base/macros.h" 15 #include "base/macros.h"
17 #include "base/memory/ptr_util.h" 16 #include "base/memory/ptr_util.h"
18 #include "base/message_loop/message_loop.h" 17 #include "base/message_loop/message_loop.h"
19 #include "base/stl_util.h" 18 #include "base/stl_util.h"
20 #include "base/strings/stringprintf.h" 19 #include "base/strings/stringprintf.h"
21 #include "base/strings/utf_string_conversions.h" 20 #include "base/strings/utf_string_conversions.h"
22 #include "base/trace_event/trace_event.h" 21 #include "base/trace_event/trace_event.h"
23 #include "build/build_config.h" 22 #include "build/build_config.h"
24 #include "third_party/skia/include/core/SkRect.h" 23 #include "third_party/skia/include/core/SkRect.h"
(...skipping 523 matching lines...) Expand 10 before | Expand all | Expand 10 after
548 // If we have a layout manager, let it handle the layout for us. 547 // If we have a layout manager, let it handle the layout for us.
549 if (layout_manager_.get()) 548 if (layout_manager_.get())
550 layout_manager_->Layout(this); 549 layout_manager_->Layout(this);
551 550
552 // Make sure to propagate the Layout() call to any children that haven't 551 // Make sure to propagate the Layout() call to any children that haven't
553 // received it yet through the layout manager and need to be laid out. This 552 // received it yet through the layout manager and need to be laid out. This
554 // is needed for the case when the child requires a layout but its bounds 553 // is needed for the case when the child requires a layout but its bounds
555 // weren't changed by the layout manager. If there is no layout manager, we 554 // weren't changed by the layout manager. If there is no layout manager, we
556 // just propagate the Layout() call down the hierarchy, so whoever receives 555 // just propagate the Layout() call down the hierarchy, so whoever receives
557 // the call can take appropriate action. 556 // the call can take appropriate action.
558 for (auto* child : children_) { 557 for (int i = 0, count = child_count(); i < count; ++i) {
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 (auto* child : children_) { 624 for (int i = 0, count = child_count(); i < count; ++i) {
625 const View* view = child->GetViewByID(id); 625 const View* view = child_at(i)->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 (auto* child : children_) 654 for (int i = 0, count = child_count(); i < count; ++i)
655 child->GetViewsInGroup(group, views); 655 child_at(i)->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 (auto* child : base::Reversed(children_)) { 920 for (int i = child_count() - 1; i >= 0; --i) {
921 View* child = child_at(i);
921 if (!child->visible()) 922 if (!child->visible())
922 continue; 923 continue;
923 924
924 gfx::Point point_in_child_coords(point); 925 gfx::Point point_in_child_coords(point);
925 ConvertPointToTarget(this, child, &point_in_child_coords); 926 ConvertPointToTarget(this, child, &point_in_child_coords);
926 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords); 927 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords);
927 if (handler) 928 if (handler)
928 return handler; 929 return handler;
929 } 930 }
930 return this; 931 return this;
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1429 1430
1430 if (focus_manager) 1431 if (focus_manager)
1431 RegisterPendingAccelerators(); 1432 RegisterPendingAccelerators();
1432 } 1433 }
1433 } 1434 }
1434 1435
1435 // Painting -------------------------------------------------------------------- 1436 // Painting --------------------------------------------------------------------
1436 1437
1437 void View::PaintChildren(const ui::PaintContext& context) { 1438 void View::PaintChildren(const ui::PaintContext& context) {
1438 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); 1439 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName());
1439 for (auto* child : children_) { 1440 for (int i = 0, count = child_count(); i < count; ++i)
1440 if (!child->layer()) 1441 if (!child_at(i)->layer())
1441 child->Paint(context); 1442 child_at(i)->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 (auto* child : children_) 1508 for (int i = 0, count = child_count(); i < count; ++i)
1509 child->MoveLayerToParent(parent_layer, local_point); 1509 child_at(i)->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 (auto* child : children_) 1525 for (int i = 0, count = child_count(); i < count; ++i)
1526 child->UpdateChildLayerVisibility(ancestor_visible && visible_); 1526 child_at(i)->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 (auto* child : children_) { 1534 for (int i = 0, count = child_count(); i < count; ++i) {
1535 View* child = child_at(i);
1535 child->UpdateChildLayerBounds( 1536 child->UpdateChildLayerBounds(
1536 offset + gfx::Vector2d(child->GetMirroredX(), child->y())); 1537 offset + gfx::Vector2d(child->GetMirroredX(), child->y()));
1537 } 1538 }
1538 } 1539 }
1539 } 1540 }
1540 1541
1541 void View::OnPaintLayer(const ui::PaintContext& context) { 1542 void View::OnPaintLayer(const ui::PaintContext& context) {
1542 Paint(context); 1543 Paint(context);
1543 } 1544 }
1544 1545
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after
1757 1758
1758 base::snprintf(pp, kMaxPointerStringLength, "%p", parent_); 1759 base::snprintf(pp, kMaxPointerStringLength, "%p", parent_);
1759 result.append(" N"); 1760 result.append(" N");
1760 result.append(pp + 2); 1761 result.append(pp + 2);
1761 result.append(" -> N"); 1762 result.append(" -> N");
1762 result.append(p + 2); 1763 result.append(p + 2);
1763 result.append("\n"); 1764 result.append("\n");
1764 } 1765 }
1765 1766
1766 // Children. 1767 // Children.
1767 for (auto* child : view_with_children->children_) 1768 for (int i = 0, count = view_with_children->child_count(); i < count; ++i)
1768 result.append(child->PrintViewGraph(false)); 1769 result.append(view_with_children->child_at(i)->PrintViewGraph(false));
1769 1770
1770 if (first) 1771 if (first)
1771 result.append("}\n"); 1772 result.append("}\n");
1772 1773
1773 return result; 1774 return result;
1774 } 1775 }
1775 #endif 1776 #endif
1776 1777
1777 //////////////////////////////////////////////////////////////////////////////// 1778 ////////////////////////////////////////////////////////////////////////////////
1778 // View, private: 1779 // View, private:
(...skipping 88 matching lines...) Expand 10 before | Expand all | Expand 10 after
1867 UpdateTooltip(); 1868 UpdateTooltip();
1868 1869
1869 if (layout_manager_) 1870 if (layout_manager_)
1870 layout_manager_->ViewRemoved(this, view); 1871 layout_manager_->ViewRemoved(this, view);
1871 1872
1872 for (ViewObserver& observer : observers_) 1873 for (ViewObserver& observer : observers_)
1873 observer.OnChildViewRemoved(view, this); 1874 observer.OnChildViewRemoved(view, this);
1874 } 1875 }
1875 1876
1876 void View::PropagateRemoveNotifications(View* old_parent, View* new_parent) { 1877 void View::PropagateRemoveNotifications(View* old_parent, View* new_parent) {
1877 for (auto* child : children_) 1878 for (int i = 0, count = child_count(); i < count; ++i)
1878 child->PropagateRemoveNotifications(old_parent, new_parent); 1879 child_at(i)->PropagateRemoveNotifications(old_parent, new_parent);
1879 1880
1880 ViewHierarchyChangedDetails details(false, old_parent, this, new_parent); 1881 ViewHierarchyChangedDetails details(false, old_parent, this, new_parent);
1881 for (View* v = this; v; v = v->parent_) 1882 for (View* v = this; v; v = v->parent_)
1882 v->ViewHierarchyChangedImpl(true, details); 1883 v->ViewHierarchyChangedImpl(true, details);
1883 } 1884 }
1884 1885
1885 void View::PropagateAddNotifications( 1886 void View::PropagateAddNotifications(
1886 const ViewHierarchyChangedDetails& details) { 1887 const ViewHierarchyChangedDetails& details) {
1887 for (auto* child : children_) 1888 for (int i = 0, count = child_count(); i < count; ++i)
1888 child->PropagateAddNotifications(details); 1889 child_at(i)->PropagateAddNotifications(details);
1889 ViewHierarchyChangedImpl(true, details); 1890 ViewHierarchyChangedImpl(true, details);
1890 } 1891 }
1891 1892
1892 void View::PropagateNativeViewHierarchyChanged() { 1893 void View::PropagateNativeViewHierarchyChanged() {
1893 for (auto* child : children_) 1894 for (int i = 0, count = child_count(); i < count; ++i)
1894 child->PropagateNativeViewHierarchyChanged(); 1895 child_at(i)->PropagateNativeViewHierarchyChanged();
1895 NativeViewHierarchyChanged(); 1896 NativeViewHierarchyChanged();
1896 } 1897 }
1897 1898
1898 void View::ViewHierarchyChangedImpl( 1899 void View::ViewHierarchyChangedImpl(
1899 bool register_accelerators, 1900 bool register_accelerators,
1900 const ViewHierarchyChangedDetails& details) { 1901 const ViewHierarchyChangedDetails& details) {
1901 if (register_accelerators) { 1902 if (register_accelerators) {
1902 if (details.is_add) { 1903 if (details.is_add) {
1903 // If you get this registration, you are part of a subtree that has been 1904 // If you get this registration, you are part of a subtree that has been
1904 // added to the view hierarchy. 1905 // added to the view hierarchy.
1905 if (GetFocusManager()) 1906 if (GetFocusManager())
1906 RegisterPendingAccelerators(); 1907 RegisterPendingAccelerators();
1907 } else { 1908 } else {
1908 if (details.child == this) 1909 if (details.child == this)
1909 UnregisterAccelerators(true); 1910 UnregisterAccelerators(true);
1910 } 1911 }
1911 } 1912 }
1912 1913
1913 ViewHierarchyChanged(details); 1914 ViewHierarchyChanged(details);
1914 details.parent->needs_layout_ = true; 1915 details.parent->needs_layout_ = true;
1915 } 1916 }
1916 1917
1917 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) { 1918 void View::PropagateNativeThemeChanged(const ui::NativeTheme* theme) {
1918 for (auto* child : children_) 1919 for (int i = 0, count = child_count(); i < count; ++i)
1919 child->PropagateNativeThemeChanged(theme); 1920 child_at(i)->PropagateNativeThemeChanged(theme);
1920 OnNativeThemeChanged(theme); 1921 OnNativeThemeChanged(theme);
1921 } 1922 }
1922 1923
1923 // Size and disposition -------------------------------------------------------- 1924 // Size and disposition --------------------------------------------------------
1924 1925
1925 void View::PropagateVisibilityNotifications(View* start, bool is_visible) { 1926 void View::PropagateVisibilityNotifications(View* start, bool is_visible) {
1926 for (auto* child : children_) 1927 for (int i = 0, count = child_count(); i < count; ++i)
1927 child->PropagateVisibilityNotifications(start, is_visible); 1928 child_at(i)->PropagateVisibilityNotifications(start, is_visible);
1928 VisibilityChangedImpl(start, is_visible); 1929 VisibilityChangedImpl(start, is_visible);
1929 } 1930 }
1930 1931
1931 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { 1932 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) {
1932 VisibilityChanged(starting_from, is_visible); 1933 VisibilityChanged(starting_from, is_visible);
1933 } 1934 }
1934 1935
1935 void View::BoundsChanged(const gfx::Rect& previous_bounds) { 1936 void View::BoundsChanged(const gfx::Rect& previous_bounds) {
1936 if (visible_) { 1937 if (visible_) {
1937 // Paint the new bounds. 1938 // Paint the new bounds.
(...skipping 160 matching lines...) Expand 10 before | Expand all | Expand 10 after
2098 bool result = GetTransformRelativeTo(ancestor, &trans); 2099 bool result = GetTransformRelativeTo(ancestor, &trans);
2099 trans.TransformRectReverse(rect); 2100 trans.TransformRectReverse(rect);
2100 return result; 2101 return result;
2101 } 2102 }
2102 2103
2103 // Accelerated painting -------------------------------------------------------- 2104 // Accelerated painting --------------------------------------------------------
2104 2105
2105 void View::CreateLayer() { 2106 void View::CreateLayer() {
2106 // A new layer is being created for the view. So all the layers of the 2107 // A new layer is being created for the view. So all the layers of the
2107 // sub-tree can inherit the visibility of the corresponding view. 2108 // sub-tree can inherit the visibility of the corresponding view.
2108 for (auto* child : children_) 2109 for (int i = 0, count = child_count(); i < count; ++i)
2109 child->UpdateChildLayerVisibility(true); 2110 child_at(i)->UpdateChildLayerVisibility(true);
2110 2111
2111 SetLayer(base::MakeUnique<ui::Layer>()); 2112 SetLayer(base::MakeUnique<ui::Layer>());
2112 layer()->set_delegate(this); 2113 layer()->set_delegate(this);
2113 layer()->set_name(GetClassName()); 2114 layer()->set_name(GetClassName());
2114 2115
2115 UpdateParentLayers(); 2116 UpdateParentLayers();
2116 UpdateLayerVisibility(); 2117 UpdateLayerVisibility();
2117 2118
2118 // The new layer needs to be ordered in the layer tree according 2119 // The new layer needs to be ordered in the layer tree according
2119 // to the view tree. Children of this layer were added in order 2120 // to the view tree. Children of this layer were added in order
(...skipping 17 matching lines...) Expand all
2137 if (layer()) { 2138 if (layer()) {
2138 if (!layer()->parent()) { 2139 if (!layer()->parent()) {
2139 UpdateParentLayer(); 2140 UpdateParentLayer();
2140 return true; 2141 return true;
2141 } 2142 }
2142 // The layers of any child views are already in place, so we can stop 2143 // The layers of any child views are already in place, so we can stop
2143 // iterating here. 2144 // iterating here.
2144 return false; 2145 return false;
2145 } 2146 }
2146 bool result = false; 2147 bool result = false;
2147 for (auto* child : children_) { 2148 for (int i = 0, count = child_count(); i < count; ++i) {
2148 if (child->UpdateParentLayers()) 2149 if (child_at(i)->UpdateParentLayers())
2149 result = true; 2150 result = true;
2150 } 2151 }
2151 return result; 2152 return result;
2152 } 2153 }
2153 2154
2154 void View::OrphanLayers() { 2155 void View::OrphanLayers() {
2155 if (layer()) { 2156 if (layer()) {
2156 if (layer()->parent()) 2157 if (layer()->parent())
2157 layer()->parent()->Remove(layer()); 2158 layer()->parent()->Remove(layer());
2158 2159
2159 // The layer belonging to this View has already been orphaned. It is not 2160 // The layer belonging to this View has already been orphaned. It is not
2160 // necessary to orphan the child layers. 2161 // necessary to orphan the child layers.
2161 return; 2162 return;
2162 } 2163 }
2163 for (auto* child : children_) 2164 for (int i = 0, count = child_count(); i < count; ++i)
2164 child->OrphanLayers(); 2165 child_at(i)->OrphanLayers();
2165 } 2166 }
2166 2167
2167 void View::ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer) { 2168 void View::ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer) {
2168 layer()->SetBounds(GetLocalBounds() + offset); 2169 layer()->SetBounds(GetLocalBounds() + offset);
2169 DCHECK_NE(layer(), parent_layer); 2170 DCHECK_NE(layer(), parent_layer);
2170 if (parent_layer) 2171 if (parent_layer)
2171 parent_layer->Add(layer()); 2172 parent_layer->Add(layer());
2172 layer()->SchedulePaint(GetLocalBounds()); 2173 layer()->SchedulePaint(GetLocalBounds());
2173 MoveLayerToParent(layer(), gfx::Point()); 2174 MoveLayerToParent(layer(), gfx::Point());
2174 } 2175 }
(...skipping 208 matching lines...) Expand 10 before | Expand all | Expand 10 after
2383 return; 2384 return;
2384 2385
2385 FocusManager* focus_manager = GetFocusManager(); 2386 FocusManager* focus_manager = GetFocusManager();
2386 if (focus_manager) 2387 if (focus_manager)
2387 focus_manager->AdvanceFocusIfNecessary(); 2388 focus_manager->AdvanceFocusIfNecessary();
2388 } 2389 }
2389 2390
2390 // System events --------------------------------------------------------------- 2391 // System events ---------------------------------------------------------------
2391 2392
2392 void View::PropagateThemeChanged() { 2393 void View::PropagateThemeChanged() {
2393 for (auto* child : base::Reversed(children_)) 2394 for (int i = child_count() - 1; i >= 0; --i)
2394 child->PropagateThemeChanged(); 2395 child_at(i)->PropagateThemeChanged();
2395 OnThemeChanged(); 2396 OnThemeChanged();
2396 } 2397 }
2397 2398
2398 void View::PropagateLocaleChanged() { 2399 void View::PropagateLocaleChanged() {
2399 for (auto* child : base::Reversed(children_)) 2400 for (int i = child_count() - 1; i >= 0; --i)
2400 child->PropagateLocaleChanged(); 2401 child_at(i)->PropagateLocaleChanged();
2401 OnLocaleChanged(); 2402 OnLocaleChanged();
2402 } 2403 }
2403 2404
2404 void View::PropagateDeviceScaleFactorChanged(float device_scale_factor) { 2405 void View::PropagateDeviceScaleFactorChanged(float device_scale_factor) {
2405 for (auto* child : base::Reversed(children_)) 2406 for (int i = child_count() - 1; i >= 0; --i)
2406 child->PropagateDeviceScaleFactorChanged(device_scale_factor); 2407 child_at(i)->PropagateDeviceScaleFactorChanged(device_scale_factor);
2407 2408
2408 // If the view is drawing to the layer, OnDeviceScaleFactorChanged() is called 2409 // If the view is drawing to the layer, OnDeviceScaleFactorChanged() is called
2409 // through LayerDelegate callback. 2410 // through LayerDelegate callback.
2410 if (!layer()) 2411 if (!layer())
2411 OnDeviceScaleFactorChanged(device_scale_factor); 2412 OnDeviceScaleFactorChanged(device_scale_factor);
2412 } 2413 }
2413 2414
2414 // Tooltips -------------------------------------------------------------------- 2415 // Tooltips --------------------------------------------------------------------
2415 2416
2416 void View::UpdateTooltip() { 2417 void View::UpdateTooltip() {
(...skipping 30 matching lines...) Expand all
2447 // Message the RootView to do the drag and drop. That way if we're removed 2448 // Message the RootView to do the drag and drop. That way if we're removed
2448 // the RootView can detect it and avoid calling us back. 2449 // the RootView can detect it and avoid calling us back.
2449 gfx::Point widget_location(event.location()); 2450 gfx::Point widget_location(event.location());
2450 ConvertPointToWidget(this, &widget_location); 2451 ConvertPointToWidget(this, &widget_location);
2451 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2452 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2452 // WARNING: we may have been deleted. 2453 // WARNING: we may have been deleted.
2453 return true; 2454 return true;
2454 } 2455 }
2455 2456
2456 } // namespace views 2457 } // 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