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

Side by Side Diff: views/view.cc

Issue 7349021: Convert some more view methods to the ui/views style. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 5 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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 #include "views/view.h" 5 #include "views/view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 8
9 #include "base/logging.h" 9 #include "base/logging.h"
10 #include "base/memory/scoped_ptr.h" 10 #include "base/memory/scoped_ptr.h"
(...skipping 205 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 void View::RemoveChildView(View* view) { 216 void View::RemoveChildView(View* view) {
217 DoRemoveChildView(view, true, true, false); 217 DoRemoveChildView(view, true, true, false);
218 } 218 }
219 219
220 void View::RemoveAllChildViews(bool delete_children) { 220 void View::RemoveAllChildViews(bool delete_children) {
221 while (!children_.empty()) 221 while (!children_.empty())
222 DoRemoveChildView(children_.front(), false, false, delete_children); 222 DoRemoveChildView(children_.front(), false, false, delete_children);
223 UpdateTooltip(); 223 UpdateTooltip();
224 } 224 }
225 225
226 const View* View::GetChildViewAt(int index) const {
227 return index < child_count() ? children_[index] : NULL;
228 }
229
230 View* View::GetChildViewAt(int index) {
231 return
232 const_cast<View*>(const_cast<const View*>(this)->GetChildViewAt(index));
233 }
234
235 bool View::Contains(const View* view) const { 226 bool View::Contains(const View* view) const {
236 for (const View* v = view; v; v = v->parent_) { 227 for (const View* v = view; v; v = v->parent_) {
237 if (v == this) 228 if (v == this)
238 return true; 229 return true;
239 } 230 }
240 return false; 231 return false;
241 } 232 }
242 233
243 int View::GetIndexOf(const View* view) const { 234 int View::GetIndexOf(const View* view) const {
244 Views::const_iterator i(std::find(children_.begin(), children_.end(), view)); 235 Views::const_iterator i(std::find(children_.begin(), children_.end(), view));
(...skipping 288 matching lines...) Expand 10 before | Expand all | Expand 10 after
533 if (layout_manager_.get()) 524 if (layout_manager_.get())
534 layout_manager_->Layout(this); 525 layout_manager_->Layout(this);
535 526
536 // Make sure to propagate the Layout() call to any children that haven't 527 // Make sure to propagate the Layout() call to any children that haven't
537 // received it yet through the layout manager and need to be laid out. This 528 // received it yet through the layout manager and need to be laid out. This
538 // is needed for the case when the child requires a layout but its bounds 529 // is needed for the case when the child requires a layout but its bounds
539 // weren't changed by the layout manager. If there is no layout manager, we 530 // weren't changed by the layout manager. If there is no layout manager, we
540 // just propagate the Layout() call down the hierarchy, so whoever receives 531 // just propagate the Layout() call down the hierarchy, so whoever receives
541 // the call can take appropriate action. 532 // the call can take appropriate action.
542 for (int i = 0, count = child_count(); i < count; ++i) { 533 for (int i = 0, count = child_count(); i < count; ++i) {
543 View* child = GetChildViewAt(i); 534 View* child = child_at(i);
544 if (child->needs_layout_ || !layout_manager_.get()) { 535 if (child->needs_layout_ || !layout_manager_.get()) {
545 child->needs_layout_ = false; 536 child->needs_layout_ = false;
546 child->Layout(); 537 child->Layout();
547 } 538 }
548 } 539 }
549 } 540 }
550 541
551 void View::InvalidateLayout() { 542 void View::InvalidateLayout() {
552 // Always invalidate up. This is needed to handle the case of us already being 543 // Always invalidate up. This is needed to handle the case of us already being
553 // valid, but not our parent. 544 // valid, but not our parent.
(...skipping 27 matching lines...) Expand all
581 return view; 572 return view;
582 } 573 }
583 return NULL; 574 return NULL;
584 } 575 }
585 576
586 const View* View::GetViewByID(int id) const { 577 const View* View::GetViewByID(int id) const {
587 if (id == id_) 578 if (id == id_)
588 return const_cast<View*>(this); 579 return const_cast<View*>(this);
589 580
590 for (int i = 0, count = child_count(); i < count; ++i) { 581 for (int i = 0, count = child_count(); i < count; ++i) {
591 const View* view = GetChildViewAt(i)->GetViewByID(id); 582 const View* view = child_at(i)->GetViewByID(id);
592 if (view) 583 if (view)
593 return view; 584 return view;
594 } 585 }
595 return NULL; 586 return NULL;
596 } 587 }
597 588
598 View* View::GetViewByID(int id) { 589 View* View::GetViewByID(int id) {
599 return const_cast<View*>(const_cast<const View*>(this)->GetViewByID(id)); 590 return const_cast<View*>(const_cast<const View*>(this)->GetViewByID(id));
600 } 591 }
601 592
602 void View::SetGroup(int gid) { 593 void View::SetGroup(int gid) {
603 // Don't change the group id once it's set. 594 // Don't change the group id once it's set.
604 DCHECK(group_ == -1 || group_ == gid); 595 DCHECK(group_ == -1 || group_ == gid);
605 group_ = gid; 596 group_ = gid;
606 } 597 }
607 598
608 int View::GetGroup() const { 599 int View::GetGroup() const {
609 return group_; 600 return group_;
610 } 601 }
611 602
612 bool View::IsGroupFocusTraversable() const { 603 bool View::IsGroupFocusTraversable() const {
613 return true; 604 return true;
614 } 605 }
615 606
616 void View::GetViewsWithGroup(int group_id, Views* out) { 607 void View::GetViewsWithGroup(int group_id, Views* out) {
617 if (group_ == group_id) 608 if (group_ == group_id)
618 out->push_back(this); 609 out->push_back(this);
619 610
620 for (int i = 0, count = child_count(); i < count; ++i) 611 for (int i = 0, count = child_count(); i < count; ++i)
621 GetChildViewAt(i)->GetViewsWithGroup(group_id, out); 612 child_at(i)->GetViewsWithGroup(group_id, out);
622 } 613 }
623 614
624 View* View::GetSelectedViewForGroup(int group_id) { 615 View* View::GetSelectedViewForGroup(int group_id) {
625 Views views; 616 Views views;
626 GetWidget()->GetRootView()->GetViewsWithGroup(group_id, &views); 617 GetWidget()->GetRootView()->GetViewsWithGroup(group_id, &views);
627 return views.empty() ? NULL : views[0]; 618 return views.empty() ? NULL : views[0];
628 } 619 }
629 620
630 // Coordinate conversion ------------------------------------------------------- 621 // Coordinate conversion -------------------------------------------------------
631 622
(...skipping 162 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 bool View::get_use_acceleration_when_possible() { 785 bool View::get_use_acceleration_when_possible() {
795 return use_acceleration_when_possible; 786 return use_acceleration_when_possible;
796 } 787 }
797 788
798 // Input ----------------------------------------------------------------------- 789 // Input -----------------------------------------------------------------------
799 790
800 View* View::GetEventHandlerForPoint(const gfx::Point& point) { 791 View* View::GetEventHandlerForPoint(const gfx::Point& point) {
801 // Walk the child Views recursively looking for the View that most 792 // Walk the child Views recursively looking for the View that most
802 // tightly encloses the specified point. 793 // tightly encloses the specified point.
803 for (int i = child_count() - 1; i >= 0; --i) { 794 for (int i = child_count() - 1; i >= 0; --i) {
804 View* child = GetChildViewAt(i); 795 View* child = child_at(i);
805 if (!child->IsVisible()) 796 if (!child->IsVisible())
806 continue; 797 continue;
807 798
808 gfx::Point point_in_child_coords(point); 799 gfx::Point point_in_child_coords(point);
809 View::ConvertPointToView(this, child, &point_in_child_coords); 800 View::ConvertPointToView(this, child, &point_in_child_coords);
810 if (child->HitTest(point_in_child_coords)) 801 if (child->HitTest(point_in_child_coords))
811 return child->GetEventHandlerForPoint(point_in_child_coords); 802 return child->GetEventHandlerForPoint(point_in_child_coords);
812 } 803 }
813 return this; 804 return this;
814 } 805 }
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
1131 RegisterPendingAccelerators(); 1122 RegisterPendingAccelerators();
1132 accelerator_registration_delayed_ = false; 1123 accelerator_registration_delayed_ = false;
1133 } 1124 }
1134 } 1125 }
1135 } 1126 }
1136 1127
1137 // Painting -------------------------------------------------------------------- 1128 // Painting --------------------------------------------------------------------
1138 1129
1139 void View::PaintChildren(gfx::Canvas* canvas) { 1130 void View::PaintChildren(gfx::Canvas* canvas) {
1140 for (int i = 0, count = child_count(); i < count; ++i) { 1131 for (int i = 0, count = child_count(); i < count; ++i) {
1141 View* child = GetChildViewAt(i); 1132 View* child = child_at(i);
1142 if (!child) { 1133 if (!child) {
sky 2011/07/13 23:54:52 This 'if' no longer makes sense after your change.
1143 NOTREACHED() << "Should not have a NULL child View for index in bounds"; 1134 NOTREACHED() << "Should not have a NULL child View for index in bounds";
1144 continue; 1135 continue;
1145 } 1136 }
1146 child->Paint(canvas); 1137 child->Paint(canvas);
1147 } 1138 }
1148 } 1139 }
1149 1140
1150 void View::OnPaint(gfx::Canvas* canvas) { 1141 void View::OnPaint(gfx::Canvas* canvas) {
1151 OnPaintBackground(canvas); 1142 OnPaintBackground(canvas);
1152 OnPaintFocusBorder(canvas); 1143 OnPaintFocusBorder(canvas);
(...skipping 20 matching lines...) Expand all
1173 void View::PaintComposite() { 1164 void View::PaintComposite() {
1174 if (!IsVisible()) 1165 if (!IsVisible())
1175 return; 1166 return;
1176 1167
1177 if (layer()) { 1168 if (layer()) {
1178 OnWillCompositeLayer(); 1169 OnWillCompositeLayer();
1179 layer()->Draw(); 1170 layer()->Draw();
1180 } 1171 }
1181 1172
1182 for (int i = 0, count = child_count(); i < count; ++i) 1173 for (int i = 0, count = child_count(); i < count; ++i)
1183 GetChildViewAt(i)->PaintComposite(); 1174 child_at(i)->PaintComposite();
1184 } 1175 }
1185 1176
1186 void View::SchedulePaintInternal(const gfx::Rect& rect) { 1177 void View::SchedulePaintInternal(const gfx::Rect& rect) {
1187 if (parent_) { 1178 if (parent_) {
1188 // Translate the requested paint rect to the parent's coordinate system 1179 // Translate the requested paint rect to the parent's coordinate system
1189 // then pass this notification up to the parent. 1180 // then pass this notification up to the parent.
1190 parent_->SchedulePaintInternal(ConvertRectToParent(rect)); 1181 parent_->SchedulePaintInternal(ConvertRectToParent(rect));
1191 } 1182 }
1192 } 1183 }
1193 1184
1194 void View::PaintToLayer(const gfx::Rect& dirty_region) { 1185 void View::PaintToLayer(const gfx::Rect& dirty_region) {
1195 if (!IsVisible()) 1186 if (!IsVisible())
1196 return; 1187 return;
1197 1188
1198 if (layer() && layer_helper_->bitmap_needs_updating()) { 1189 if (layer() && layer_helper_->bitmap_needs_updating()) {
1199 if (!layer_helper_->needs_paint_all()) 1190 if (!layer_helper_->needs_paint_all())
1200 layer_helper_->set_clip_rect(dirty_region); 1191 layer_helper_->set_clip_rect(dirty_region);
1201 else 1192 else
1202 layer_helper_->set_needs_paint_all(false); 1193 layer_helper_->set_needs_paint_all(false);
1203 Paint(NULL); 1194 Paint(NULL);
1204 layer_helper_->set_clip_rect(gfx::Rect()); 1195 layer_helper_->set_clip_rect(gfx::Rect());
1205 } else { 1196 } else {
1206 // Forward to all children as a descendant may be dirty and have a layer. 1197 // Forward to all children as a descendant may be dirty and have a layer.
1207 for (int i = child_count() - 1; i >= 0; --i) { 1198 for (int i = child_count() - 1; i >= 0; --i) {
1208 View* child_view = GetChildViewAt(i); 1199 View* child_view = child_at(i);
1209 1200
1210 gfx::Rect child_dirty_rect = dirty_region; 1201 gfx::Rect child_dirty_rect = dirty_region;
1211 child_dirty_rect.Offset(-child_view->GetMirroredX(), -child_view->y()); 1202 child_dirty_rect.Offset(-child_view->GetMirroredX(), -child_view->y());
1212 child_view->GetTransform().TransformRectReverse(&child_dirty_rect); 1203 child_view->GetTransform().TransformRectReverse(&child_dirty_rect);
1213 child_dirty_rect = gfx::Rect(gfx::Point(), child_view->size()).Intersect( 1204 child_dirty_rect = gfx::Rect(gfx::Point(), child_view->size()).Intersect(
1214 child_dirty_rect); 1205 child_dirty_rect);
1215 1206
1216 if (!child_dirty_rect.IsEmpty()) 1207 if (!child_dirty_rect.IsEmpty())
1217 GetChildViewAt(i)->PaintToLayer(child_dirty_rect); 1208 child_at(i)->PaintToLayer(child_dirty_rect);
1218 } 1209 }
1219 } 1210 }
1220 } 1211 }
1221 1212
1222 void View::OnWillCompositeLayer() { 1213 void View::OnWillCompositeLayer() {
1223 } 1214 }
1224 1215
1225 bool View::SetExternalTexture(ui::Texture* texture) { 1216 bool View::SetExternalTexture(ui::Texture* texture) {
1226 // A little heavy-handed -- it should be that each child has it's own layer. 1217 // A little heavy-handed -- it should be that each child has it's own layer.
1227 // The desired use case is where there are no children. 1218 // The desired use case is where there are no children.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
1285 1276
1286 offset->Offset(x(), y()); 1277 offset->Offset(x(), y());
1287 parent_->CalculateOffsetToAncestorWithLayer(offset, ancestor); 1278 parent_->CalculateOffsetToAncestorWithLayer(offset, ancestor);
1288 } 1279 }
1289 1280
1290 void View::CreateLayerIfNecessary() { 1281 void View::CreateLayerIfNecessary() {
1291 if (ShouldPaintToLayer()) 1282 if (ShouldPaintToLayer())
1292 CreateLayer(); 1283 CreateLayer();
1293 1284
1294 for (int i = 0, count = child_count(); i < count; ++i) 1285 for (int i = 0, count = child_count(); i < count; ++i)
1295 GetChildViewAt(i)->CreateLayerIfNecessary(); 1286 child_at(i)->CreateLayerIfNecessary();
1296 } 1287 }
1297 1288
1298 void View::MoveLayerToParent(ui::Layer* parent_layer, 1289 void View::MoveLayerToParent(ui::Layer* parent_layer,
1299 const gfx::Point& point) { 1290 const gfx::Point& point) {
1300 gfx::Point local_point(point); 1291 gfx::Point local_point(point);
1301 if (parent_layer != layer()) 1292 if (parent_layer != layer())
1302 local_point.Offset(x(), y()); 1293 local_point.Offset(x(), y());
1303 if (layer() && parent_layer != layer()) { 1294 if (layer() && parent_layer != layer()) {
1304 parent_layer->Add(layer()); 1295 parent_layer->Add(layer());
1305 layer()->set_bounds( 1296 layer()->set_bounds(
1306 gfx::Rect(local_point.x(), local_point.y(), width(), height())); 1297 gfx::Rect(local_point.x(), local_point.y(), width(), height()));
1307 } else { 1298 } else {
1308 for (int i = 0, count = child_count(); i < count; ++i) 1299 for (int i = 0, count = child_count(); i < count; ++i)
1309 GetChildViewAt(i)->MoveLayerToParent(parent_layer, local_point); 1300 child_at(i)->MoveLayerToParent(parent_layer, local_point);
1310 } 1301 }
1311 } 1302 }
1312 1303
1313 void View::DestroyLayerRecurse() { 1304 void View::DestroyLayerRecurse() {
1314 for (int i = child_count() - 1; i >= 0; --i) 1305 for (int i = child_count() - 1; i >= 0; --i)
1315 GetChildViewAt(i)->DestroyLayerRecurse(); 1306 child_at(i)->DestroyLayerRecurse();
1316 DestroyLayer(); 1307 DestroyLayer();
1317 } 1308 }
1318 1309
1319 void View::UpdateLayerBounds(const gfx::Point& offset) { 1310 void View::UpdateLayerBounds(const gfx::Point& offset) {
1320 if (layer()) { 1311 if (layer()) {
1321 layer_helper_->property_setter()->SetBounds( 1312 layer_helper_->property_setter()->SetBounds(
1322 layer(), 1313 layer(),
1323 gfx::Rect(offset.x() + x(), offset.y() + y(), width(), height())); 1314 gfx::Rect(offset.x() + x(), offset.y() + y(), width(), height()));
1324 } else { 1315 } else {
1325 gfx::Point new_offset(offset.x() + x(), offset.y() + y()); 1316 gfx::Point new_offset(offset.x() + x(), offset.y() + y());
1326 for (int i = 0, count = child_count(); i < count; ++i) 1317 for (int i = 0, count = child_count(); i < count; ++i)
1327 GetChildViewAt(i)->UpdateLayerBounds(new_offset); 1318 child_at(i)->UpdateLayerBounds(new_offset);
1328 } 1319 }
1329 } 1320 }
1330 1321
1331 // Input ----------------------------------------------------------------------- 1322 // Input -----------------------------------------------------------------------
1332 1323
1333 bool View::HasHitTestMask() const { 1324 bool View::HasHitTestMask() const {
1334 return false; 1325 return false;
1335 } 1326 }
1336 1327
1337 void View::GetHitTestMask(gfx::Path* mask) const { 1328 void View::GetHitTestMask(gfx::Path* mask) const {
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after
1475 1466
1476 if (update_tool_tip) 1467 if (update_tool_tip)
1477 UpdateTooltip(); 1468 UpdateTooltip();
1478 1469
1479 if (layout_manager_.get()) 1470 if (layout_manager_.get())
1480 layout_manager_->ViewRemoved(this, view); 1471 layout_manager_->ViewRemoved(this, view);
1481 } 1472 }
1482 1473
1483 void View::PropagateRemoveNotifications(View* parent) { 1474 void View::PropagateRemoveNotifications(View* parent) {
1484 for (int i = 0, count = child_count(); i < count; ++i) 1475 for (int i = 0, count = child_count(); i < count; ++i)
1485 GetChildViewAt(i)->PropagateRemoveNotifications(parent); 1476 child_at(i)->PropagateRemoveNotifications(parent);
1486 1477
1487 for (View* v = this; v; v = v->parent_) 1478 for (View* v = this; v; v = v->parent_)
1488 v->ViewHierarchyChangedImpl(true, false, parent, this); 1479 v->ViewHierarchyChangedImpl(true, false, parent, this);
1489 } 1480 }
1490 1481
1491 void View::PropagateAddNotifications(View* parent, View* child) { 1482 void View::PropagateAddNotifications(View* parent, View* child) {
1492 for (int i = 0, count = child_count(); i < count; ++i) 1483 for (int i = 0, count = child_count(); i < count; ++i)
1493 GetChildViewAt(i)->PropagateAddNotifications(parent, child); 1484 child_at(i)->PropagateAddNotifications(parent, child);
1494 ViewHierarchyChangedImpl(true, true, parent, child); 1485 ViewHierarchyChangedImpl(true, true, parent, child);
1495 } 1486 }
1496 1487
1497 void View::PropagateNativeViewHierarchyChanged(bool attached, 1488 void View::PropagateNativeViewHierarchyChanged(bool attached,
1498 gfx::NativeView native_view, 1489 gfx::NativeView native_view,
1499 internal::RootView* root_view) { 1490 internal::RootView* root_view) {
1500 for (int i = 0, count = child_count(); i < count; ++i) 1491 for (int i = 0, count = child_count(); i < count; ++i)
1501 GetChildViewAt(i)->PropagateNativeViewHierarchyChanged(attached, 1492 child_at(i)->PropagateNativeViewHierarchyChanged(attached,
1502 native_view, 1493 native_view,
1503 root_view); 1494 root_view);
1504 NativeViewHierarchyChanged(attached, native_view, root_view); 1495 NativeViewHierarchyChanged(attached, native_view, root_view);
1505 } 1496 }
1506 1497
1507 void View::ViewHierarchyChangedImpl(bool register_accelerators, 1498 void View::ViewHierarchyChangedImpl(bool register_accelerators,
1508 bool is_add, 1499 bool is_add,
1509 View* parent, 1500 View* parent,
1510 View* child) { 1501 View* child) {
1511 if (register_accelerators) { 1502 if (register_accelerators) {
(...skipping 14 matching lines...) Expand all
1526 } 1517 }
1527 1518
1528 ViewHierarchyChanged(is_add, parent, child); 1519 ViewHierarchyChanged(is_add, parent, child);
1529 parent->needs_layout_ = true; 1520 parent->needs_layout_ = true;
1530 } 1521 }
1531 1522
1532 // Size and disposition -------------------------------------------------------- 1523 // Size and disposition --------------------------------------------------------
1533 1524
1534 void View::PropagateVisibilityNotifications(View* start, bool is_visible) { 1525 void View::PropagateVisibilityNotifications(View* start, bool is_visible) {
1535 for (int i = 0, count = child_count(); i < count; ++i) 1526 for (int i = 0, count = child_count(); i < count; ++i)
1536 GetChildViewAt(i)->PropagateVisibilityNotifications(start, is_visible); 1527 child_at(i)->PropagateVisibilityNotifications(start, is_visible);
1537 VisibilityChangedImpl(start, is_visible); 1528 VisibilityChangedImpl(start, is_visible);
1538 } 1529 }
1539 1530
1540 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { 1531 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) {
1541 if (is_visible) 1532 if (is_visible)
1542 RegisterPendingAccelerators(); 1533 RegisterPendingAccelerators();
1543 else 1534 else
1544 UnregisterAccelerators(true); 1535 UnregisterAccelerators(true);
1545 VisibilityChanged(starting_from, is_visible); 1536 VisibilityChanged(starting_from, is_visible);
1546 } 1537 }
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after
1601 (*i)->OnVisibleBoundsChanged(); 1592 (*i)->OnVisibleBoundsChanged();
1602 } 1593 }
1603 } 1594 }
1604 } 1595 }
1605 1596
1606 // static 1597 // static
1607 void View::RegisterChildrenForVisibleBoundsNotification(View* view) { 1598 void View::RegisterChildrenForVisibleBoundsNotification(View* view) {
1608 if (view->NeedsNotificationWhenVisibleBoundsChange()) 1599 if (view->NeedsNotificationWhenVisibleBoundsChange())
1609 view->RegisterForVisibleBoundsNotification(); 1600 view->RegisterForVisibleBoundsNotification();
1610 for (int i = 0; i < view->child_count(); ++i) 1601 for (int i = 0; i < view->child_count(); ++i)
1611 RegisterChildrenForVisibleBoundsNotification(view->GetChildViewAt(i)); 1602 RegisterChildrenForVisibleBoundsNotification(view->child_at(i));
1612 } 1603 }
1613 1604
1614 // static 1605 // static
1615 void View::UnregisterChildrenForVisibleBoundsNotification(View* view) { 1606 void View::UnregisterChildrenForVisibleBoundsNotification(View* view) {
1616 if (view->NeedsNotificationWhenVisibleBoundsChange()) 1607 if (view->NeedsNotificationWhenVisibleBoundsChange())
1617 view->UnregisterForVisibleBoundsNotification(); 1608 view->UnregisterForVisibleBoundsNotification();
1618 for (int i = 0; i < view->child_count(); ++i) 1609 for (int i = 0; i < view->child_count(); ++i)
1619 UnregisterChildrenForVisibleBoundsNotification(view->GetChildViewAt(i)); 1610 UnregisterChildrenForVisibleBoundsNotification(view->child_at(i));
1620 } 1611 }
1621 1612
1622 void View::RegisterForVisibleBoundsNotification() { 1613 void View::RegisterForVisibleBoundsNotification() {
1623 if (registered_for_visible_bounds_notification_) 1614 if (registered_for_visible_bounds_notification_)
1624 return; 1615 return;
1625 1616
1626 registered_for_visible_bounds_notification_ = true; 1617 registered_for_visible_bounds_notification_ = true;
1627 for (View* ancestor = parent_; ancestor; ancestor = ancestor->parent_) 1618 for (View* ancestor = parent_; ancestor; ancestor = ancestor->parent_)
1628 ancestor->AddDescendantToNotify(this); 1619 ancestor->AddDescendantToNotify(this);
1629 } 1620 }
(...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after
1951 prev->next_focusable_view_ = v; 1942 prev->next_focusable_view_ = v;
1952 children_[index]->previous_focusable_view_ = v; 1943 children_[index]->previous_focusable_view_ = v;
1953 } 1944 }
1954 } 1945 }
1955 } 1946 }
1956 1947
1957 // System events --------------------------------------------------------------- 1948 // System events ---------------------------------------------------------------
1958 1949
1959 void View::PropagateThemeChanged() { 1950 void View::PropagateThemeChanged() {
1960 for (int i = child_count() - 1; i >= 0; --i) 1951 for (int i = child_count() - 1; i >= 0; --i)
1961 GetChildViewAt(i)->PropagateThemeChanged(); 1952 child_at(i)->PropagateThemeChanged();
1962 OnThemeChanged(); 1953 OnThemeChanged();
1963 } 1954 }
1964 1955
1965 void View::PropagateLocaleChanged() { 1956 void View::PropagateLocaleChanged() {
1966 for (int i = child_count() - 1; i >= 0; --i) 1957 for (int i = child_count() - 1; i >= 0; --i)
1967 GetChildViewAt(i)->PropagateLocaleChanged(); 1958 child_at(i)->PropagateLocaleChanged();
1968 OnLocaleChanged(); 1959 OnLocaleChanged();
1969 } 1960 }
1970 1961
1971 // Tooltips -------------------------------------------------------------------- 1962 // Tooltips --------------------------------------------------------------------
1972 1963
1973 void View::UpdateTooltip() { 1964 void View::UpdateTooltip() {
1974 Widget* widget = GetWidget(); 1965 Widget* widget = GetWidget();
1975 // TODO(beng): The TooltipManager NULL check can be removed when we 1966 // TODO(beng): The TooltipManager NULL check can be removed when we
1976 // consolidate Init() methods and make views_unittests Init() all 1967 // consolidate Init() methods and make views_unittests Init() all
1977 // Widgets that it uses. 1968 // Widgets that it uses.
(...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after
2035 snprintf(pp, kMaxPointerStringLength, "%p", parent_); 2026 snprintf(pp, kMaxPointerStringLength, "%p", parent_);
2036 result.append(" N"); 2027 result.append(" N");
2037 result.append(pp+2); 2028 result.append(pp+2);
2038 result.append(" -> N"); 2029 result.append(" -> N");
2039 result.append(p+2); 2030 result.append(p+2);
2040 result.append("\n"); 2031 result.append("\n");
2041 } 2032 }
2042 2033
2043 // Children. 2034 // Children.
2044 for (int i = 0, count = child_count(); i < count; ++i) 2035 for (int i = 0, count = child_count(); i < count; ++i)
2045 result.append(GetChildViewAt(i)->PrintViewGraph(false)); 2036 result.append(child_at(i)->PrintViewGraph(false));
2046 2037
2047 if (first) 2038 if (first)
2048 result.append("}\n"); 2039 result.append("}\n");
2049 2040
2050 return result; 2041 return result;
2051 } 2042 }
2052 #endif 2043 #endif
2053 2044
2054 } // namespace views 2045 } // namespace views
OLDNEW
« views/view.h ('K') | « views/view.h ('k') | views/widget/root_view.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698