| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 Loading... |
| 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::GetViewsInGroup(int group, Views* views) { | 607 void View::GetViewsInGroup(int group, Views* views) { |
| 617 if (group_ == group) | 608 if (group_ == group) |
| 618 views->push_back(this); | 609 views->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)->GetViewsInGroup(group, views); | 612 child_at(i)->GetViewsInGroup(group, views); |
| 622 } | 613 } |
| 623 | 614 |
| 624 View* View::GetSelectedViewForGroup(int group) { | 615 View* View::GetSelectedViewForGroup(int group) { |
| 625 Views views; | 616 Views views; |
| 626 GetWidget()->GetRootView()->GetViewsInGroup(group, &views); | 617 GetWidget()->GetRootView()->GetViewsInGroup(group, &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 Loading... |
| 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 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1130 if (focus_manager) { | 1121 if (focus_manager) { |
| 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 child_at(i)->Paint(canvas); |
| 1142 if (!child) { | |
| 1143 NOTREACHED() << "Should not have a NULL child View for index in bounds"; | |
| 1144 continue; | |
| 1145 } | |
| 1146 child->Paint(canvas); | |
| 1147 } | |
| 1148 } | 1133 } |
| 1149 | 1134 |
| 1150 void View::OnPaint(gfx::Canvas* canvas) { | 1135 void View::OnPaint(gfx::Canvas* canvas) { |
| 1151 OnPaintBackground(canvas); | 1136 OnPaintBackground(canvas); |
| 1152 OnPaintFocusBorder(canvas); | 1137 OnPaintFocusBorder(canvas); |
| 1153 OnPaintBorder(canvas); | 1138 OnPaintBorder(canvas); |
| 1154 } | 1139 } |
| 1155 | 1140 |
| 1156 void View::OnPaintBackground(gfx::Canvas* canvas) { | 1141 void View::OnPaintBackground(gfx::Canvas* canvas) { |
| 1157 if (background_.get()) | 1142 if (background_.get()) |
| (...skipping 15 matching lines...) Expand all Loading... |
| 1173 void View::PaintComposite() { | 1158 void View::PaintComposite() { |
| 1174 if (!IsVisible()) | 1159 if (!IsVisible()) |
| 1175 return; | 1160 return; |
| 1176 | 1161 |
| 1177 if (layer()) { | 1162 if (layer()) { |
| 1178 OnWillCompositeLayer(); | 1163 OnWillCompositeLayer(); |
| 1179 layer()->Draw(); | 1164 layer()->Draw(); |
| 1180 } | 1165 } |
| 1181 | 1166 |
| 1182 for (int i = 0, count = child_count(); i < count; ++i) | 1167 for (int i = 0, count = child_count(); i < count; ++i) |
| 1183 GetChildViewAt(i)->PaintComposite(); | 1168 child_at(i)->PaintComposite(); |
| 1184 } | 1169 } |
| 1185 | 1170 |
| 1186 void View::SchedulePaintInternal(const gfx::Rect& rect) { | 1171 void View::SchedulePaintInternal(const gfx::Rect& rect) { |
| 1187 if (parent_) { | 1172 if (parent_) { |
| 1188 // Translate the requested paint rect to the parent's coordinate system | 1173 // Translate the requested paint rect to the parent's coordinate system |
| 1189 // then pass this notification up to the parent. | 1174 // then pass this notification up to the parent. |
| 1190 parent_->SchedulePaintInternal(ConvertRectToParent(rect)); | 1175 parent_->SchedulePaintInternal(ConvertRectToParent(rect)); |
| 1191 } | 1176 } |
| 1192 } | 1177 } |
| 1193 | 1178 |
| 1194 void View::PaintToLayer(const gfx::Rect& dirty_region) { | 1179 void View::PaintToLayer(const gfx::Rect& dirty_region) { |
| 1195 if (!IsVisible()) | 1180 if (!IsVisible()) |
| 1196 return; | 1181 return; |
| 1197 | 1182 |
| 1198 if (layer() && layer_helper_->bitmap_needs_updating()) { | 1183 if (layer() && layer_helper_->bitmap_needs_updating()) { |
| 1199 if (!layer_helper_->needs_paint_all()) | 1184 if (!layer_helper_->needs_paint_all()) |
| 1200 layer_helper_->set_clip_rect(dirty_region); | 1185 layer_helper_->set_clip_rect(dirty_region); |
| 1201 else | 1186 else |
| 1202 layer_helper_->set_needs_paint_all(false); | 1187 layer_helper_->set_needs_paint_all(false); |
| 1203 Paint(NULL); | 1188 Paint(NULL); |
| 1204 layer_helper_->set_clip_rect(gfx::Rect()); | 1189 layer_helper_->set_clip_rect(gfx::Rect()); |
| 1205 } else { | 1190 } else { |
| 1206 // Forward to all children as a descendant may be dirty and have a layer. | 1191 // Forward to all children as a descendant may be dirty and have a layer. |
| 1207 for (int i = child_count() - 1; i >= 0; --i) { | 1192 for (int i = child_count() - 1; i >= 0; --i) { |
| 1208 View* child_view = GetChildViewAt(i); | 1193 View* child_view = child_at(i); |
| 1209 | 1194 |
| 1210 gfx::Rect child_dirty_rect = dirty_region; | 1195 gfx::Rect child_dirty_rect = dirty_region; |
| 1211 child_dirty_rect.Offset(-child_view->GetMirroredX(), -child_view->y()); | 1196 child_dirty_rect.Offset(-child_view->GetMirroredX(), -child_view->y()); |
| 1212 child_view->GetTransform().TransformRectReverse(&child_dirty_rect); | 1197 child_view->GetTransform().TransformRectReverse(&child_dirty_rect); |
| 1213 child_dirty_rect = gfx::Rect(gfx::Point(), child_view->size()).Intersect( | 1198 child_dirty_rect = gfx::Rect(gfx::Point(), child_view->size()).Intersect( |
| 1214 child_dirty_rect); | 1199 child_dirty_rect); |
| 1215 | 1200 |
| 1216 if (!child_dirty_rect.IsEmpty()) | 1201 if (!child_dirty_rect.IsEmpty()) |
| 1217 GetChildViewAt(i)->PaintToLayer(child_dirty_rect); | 1202 child_at(i)->PaintToLayer(child_dirty_rect); |
| 1218 } | 1203 } |
| 1219 } | 1204 } |
| 1220 } | 1205 } |
| 1221 | 1206 |
| 1222 void View::OnWillCompositeLayer() { | 1207 void View::OnWillCompositeLayer() { |
| 1223 } | 1208 } |
| 1224 | 1209 |
| 1225 bool View::SetExternalTexture(ui::Texture* texture) { | 1210 bool View::SetExternalTexture(ui::Texture* texture) { |
| 1226 // A little heavy-handed -- it should be that each child has it's own layer. | 1211 // 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. | 1212 // The desired use case is where there are no children. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1285 | 1270 |
| 1286 offset->Offset(x(), y()); | 1271 offset->Offset(x(), y()); |
| 1287 parent_->CalculateOffsetToAncestorWithLayer(offset, ancestor); | 1272 parent_->CalculateOffsetToAncestorWithLayer(offset, ancestor); |
| 1288 } | 1273 } |
| 1289 | 1274 |
| 1290 void View::CreateLayerIfNecessary() { | 1275 void View::CreateLayerIfNecessary() { |
| 1291 if (ShouldPaintToLayer()) | 1276 if (ShouldPaintToLayer()) |
| 1292 CreateLayer(); | 1277 CreateLayer(); |
| 1293 | 1278 |
| 1294 for (int i = 0, count = child_count(); i < count; ++i) | 1279 for (int i = 0, count = child_count(); i < count; ++i) |
| 1295 GetChildViewAt(i)->CreateLayerIfNecessary(); | 1280 child_at(i)->CreateLayerIfNecessary(); |
| 1296 } | 1281 } |
| 1297 | 1282 |
| 1298 void View::MoveLayerToParent(ui::Layer* parent_layer, | 1283 void View::MoveLayerToParent(ui::Layer* parent_layer, |
| 1299 const gfx::Point& point) { | 1284 const gfx::Point& point) { |
| 1300 gfx::Point local_point(point); | 1285 gfx::Point local_point(point); |
| 1301 if (parent_layer != layer()) | 1286 if (parent_layer != layer()) |
| 1302 local_point.Offset(x(), y()); | 1287 local_point.Offset(x(), y()); |
| 1303 if (layer() && parent_layer != layer()) { | 1288 if (layer() && parent_layer != layer()) { |
| 1304 parent_layer->Add(layer()); | 1289 parent_layer->Add(layer()); |
| 1305 layer()->set_bounds( | 1290 layer()->set_bounds( |
| 1306 gfx::Rect(local_point.x(), local_point.y(), width(), height())); | 1291 gfx::Rect(local_point.x(), local_point.y(), width(), height())); |
| 1307 } else { | 1292 } else { |
| 1308 for (int i = 0, count = child_count(); i < count; ++i) | 1293 for (int i = 0, count = child_count(); i < count; ++i) |
| 1309 GetChildViewAt(i)->MoveLayerToParent(parent_layer, local_point); | 1294 child_at(i)->MoveLayerToParent(parent_layer, local_point); |
| 1310 } | 1295 } |
| 1311 } | 1296 } |
| 1312 | 1297 |
| 1313 void View::DestroyLayerRecurse() { | 1298 void View::DestroyLayerRecurse() { |
| 1314 for (int i = child_count() - 1; i >= 0; --i) | 1299 for (int i = child_count() - 1; i >= 0; --i) |
| 1315 GetChildViewAt(i)->DestroyLayerRecurse(); | 1300 child_at(i)->DestroyLayerRecurse(); |
| 1316 DestroyLayer(); | 1301 DestroyLayer(); |
| 1317 } | 1302 } |
| 1318 | 1303 |
| 1319 void View::UpdateLayerBounds(const gfx::Point& offset) { | 1304 void View::UpdateLayerBounds(const gfx::Point& offset) { |
| 1320 if (layer()) { | 1305 if (layer()) { |
| 1321 layer_helper_->property_setter()->SetBounds( | 1306 layer_helper_->property_setter()->SetBounds( |
| 1322 layer(), | 1307 layer(), |
| 1323 gfx::Rect(offset.x() + x(), offset.y() + y(), width(), height())); | 1308 gfx::Rect(offset.x() + x(), offset.y() + y(), width(), height())); |
| 1324 } else { | 1309 } else { |
| 1325 gfx::Point new_offset(offset.x() + x(), offset.y() + y()); | 1310 gfx::Point new_offset(offset.x() + x(), offset.y() + y()); |
| 1326 for (int i = 0, count = child_count(); i < count; ++i) | 1311 for (int i = 0, count = child_count(); i < count; ++i) |
| 1327 GetChildViewAt(i)->UpdateLayerBounds(new_offset); | 1312 child_at(i)->UpdateLayerBounds(new_offset); |
| 1328 } | 1313 } |
| 1329 } | 1314 } |
| 1330 | 1315 |
| 1331 // Input ----------------------------------------------------------------------- | 1316 // Input ----------------------------------------------------------------------- |
| 1332 | 1317 |
| 1333 bool View::HasHitTestMask() const { | 1318 bool View::HasHitTestMask() const { |
| 1334 return false; | 1319 return false; |
| 1335 } | 1320 } |
| 1336 | 1321 |
| 1337 void View::GetHitTestMask(gfx::Path* mask) const { | 1322 void View::GetHitTestMask(gfx::Path* mask) const { |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1475 | 1460 |
| 1476 if (update_tool_tip) | 1461 if (update_tool_tip) |
| 1477 UpdateTooltip(); | 1462 UpdateTooltip(); |
| 1478 | 1463 |
| 1479 if (layout_manager_.get()) | 1464 if (layout_manager_.get()) |
| 1480 layout_manager_->ViewRemoved(this, view); | 1465 layout_manager_->ViewRemoved(this, view); |
| 1481 } | 1466 } |
| 1482 | 1467 |
| 1483 void View::PropagateRemoveNotifications(View* parent) { | 1468 void View::PropagateRemoveNotifications(View* parent) { |
| 1484 for (int i = 0, count = child_count(); i < count; ++i) | 1469 for (int i = 0, count = child_count(); i < count; ++i) |
| 1485 GetChildViewAt(i)->PropagateRemoveNotifications(parent); | 1470 child_at(i)->PropagateRemoveNotifications(parent); |
| 1486 | 1471 |
| 1487 for (View* v = this; v; v = v->parent_) | 1472 for (View* v = this; v; v = v->parent_) |
| 1488 v->ViewHierarchyChangedImpl(true, false, parent, this); | 1473 v->ViewHierarchyChangedImpl(true, false, parent, this); |
| 1489 } | 1474 } |
| 1490 | 1475 |
| 1491 void View::PropagateAddNotifications(View* parent, View* child) { | 1476 void View::PropagateAddNotifications(View* parent, View* child) { |
| 1492 for (int i = 0, count = child_count(); i < count; ++i) | 1477 for (int i = 0, count = child_count(); i < count; ++i) |
| 1493 GetChildViewAt(i)->PropagateAddNotifications(parent, child); | 1478 child_at(i)->PropagateAddNotifications(parent, child); |
| 1494 ViewHierarchyChangedImpl(true, true, parent, child); | 1479 ViewHierarchyChangedImpl(true, true, parent, child); |
| 1495 } | 1480 } |
| 1496 | 1481 |
| 1497 void View::PropagateNativeViewHierarchyChanged(bool attached, | 1482 void View::PropagateNativeViewHierarchyChanged(bool attached, |
| 1498 gfx::NativeView native_view, | 1483 gfx::NativeView native_view, |
| 1499 internal::RootView* root_view) { | 1484 internal::RootView* root_view) { |
| 1500 for (int i = 0, count = child_count(); i < count; ++i) | 1485 for (int i = 0, count = child_count(); i < count; ++i) |
| 1501 GetChildViewAt(i)->PropagateNativeViewHierarchyChanged(attached, | 1486 child_at(i)->PropagateNativeViewHierarchyChanged(attached, |
| 1502 native_view, | 1487 native_view, |
| 1503 root_view); | 1488 root_view); |
| 1504 NativeViewHierarchyChanged(attached, native_view, root_view); | 1489 NativeViewHierarchyChanged(attached, native_view, root_view); |
| 1505 } | 1490 } |
| 1506 | 1491 |
| 1507 void View::ViewHierarchyChangedImpl(bool register_accelerators, | 1492 void View::ViewHierarchyChangedImpl(bool register_accelerators, |
| 1508 bool is_add, | 1493 bool is_add, |
| 1509 View* parent, | 1494 View* parent, |
| 1510 View* child) { | 1495 View* child) { |
| 1511 if (register_accelerators) { | 1496 if (register_accelerators) { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 1526 } | 1511 } |
| 1527 | 1512 |
| 1528 ViewHierarchyChanged(is_add, parent, child); | 1513 ViewHierarchyChanged(is_add, parent, child); |
| 1529 parent->needs_layout_ = true; | 1514 parent->needs_layout_ = true; |
| 1530 } | 1515 } |
| 1531 | 1516 |
| 1532 // Size and disposition -------------------------------------------------------- | 1517 // Size and disposition -------------------------------------------------------- |
| 1533 | 1518 |
| 1534 void View::PropagateVisibilityNotifications(View* start, bool is_visible) { | 1519 void View::PropagateVisibilityNotifications(View* start, bool is_visible) { |
| 1535 for (int i = 0, count = child_count(); i < count; ++i) | 1520 for (int i = 0, count = child_count(); i < count; ++i) |
| 1536 GetChildViewAt(i)->PropagateVisibilityNotifications(start, is_visible); | 1521 child_at(i)->PropagateVisibilityNotifications(start, is_visible); |
| 1537 VisibilityChangedImpl(start, is_visible); | 1522 VisibilityChangedImpl(start, is_visible); |
| 1538 } | 1523 } |
| 1539 | 1524 |
| 1540 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { | 1525 void View::VisibilityChangedImpl(View* starting_from, bool is_visible) { |
| 1541 if (is_visible) | 1526 if (is_visible) |
| 1542 RegisterPendingAccelerators(); | 1527 RegisterPendingAccelerators(); |
| 1543 else | 1528 else |
| 1544 UnregisterAccelerators(true); | 1529 UnregisterAccelerators(true); |
| 1545 VisibilityChanged(starting_from, is_visible); | 1530 VisibilityChanged(starting_from, is_visible); |
| 1546 } | 1531 } |
| (...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1601 (*i)->OnVisibleBoundsChanged(); | 1586 (*i)->OnVisibleBoundsChanged(); |
| 1602 } | 1587 } |
| 1603 } | 1588 } |
| 1604 } | 1589 } |
| 1605 | 1590 |
| 1606 // static | 1591 // static |
| 1607 void View::RegisterChildrenForVisibleBoundsNotification(View* view) { | 1592 void View::RegisterChildrenForVisibleBoundsNotification(View* view) { |
| 1608 if (view->NeedsNotificationWhenVisibleBoundsChange()) | 1593 if (view->NeedsNotificationWhenVisibleBoundsChange()) |
| 1609 view->RegisterForVisibleBoundsNotification(); | 1594 view->RegisterForVisibleBoundsNotification(); |
| 1610 for (int i = 0; i < view->child_count(); ++i) | 1595 for (int i = 0; i < view->child_count(); ++i) |
| 1611 RegisterChildrenForVisibleBoundsNotification(view->GetChildViewAt(i)); | 1596 RegisterChildrenForVisibleBoundsNotification(view->child_at(i)); |
| 1612 } | 1597 } |
| 1613 | 1598 |
| 1614 // static | 1599 // static |
| 1615 void View::UnregisterChildrenForVisibleBoundsNotification(View* view) { | 1600 void View::UnregisterChildrenForVisibleBoundsNotification(View* view) { |
| 1616 if (view->NeedsNotificationWhenVisibleBoundsChange()) | 1601 if (view->NeedsNotificationWhenVisibleBoundsChange()) |
| 1617 view->UnregisterForVisibleBoundsNotification(); | 1602 view->UnregisterForVisibleBoundsNotification(); |
| 1618 for (int i = 0; i < view->child_count(); ++i) | 1603 for (int i = 0; i < view->child_count(); ++i) |
| 1619 UnregisterChildrenForVisibleBoundsNotification(view->GetChildViewAt(i)); | 1604 UnregisterChildrenForVisibleBoundsNotification(view->child_at(i)); |
| 1620 } | 1605 } |
| 1621 | 1606 |
| 1622 void View::RegisterForVisibleBoundsNotification() { | 1607 void View::RegisterForVisibleBoundsNotification() { |
| 1623 if (registered_for_visible_bounds_notification_) | 1608 if (registered_for_visible_bounds_notification_) |
| 1624 return; | 1609 return; |
| 1625 | 1610 |
| 1626 registered_for_visible_bounds_notification_ = true; | 1611 registered_for_visible_bounds_notification_ = true; |
| 1627 for (View* ancestor = parent_; ancestor; ancestor = ancestor->parent_) | 1612 for (View* ancestor = parent_; ancestor; ancestor = ancestor->parent_) |
| 1628 ancestor->AddDescendantToNotify(this); | 1613 ancestor->AddDescendantToNotify(this); |
| 1629 } | 1614 } |
| (...skipping 321 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1951 prev->next_focusable_view_ = v; | 1936 prev->next_focusable_view_ = v; |
| 1952 children_[index]->previous_focusable_view_ = v; | 1937 children_[index]->previous_focusable_view_ = v; |
| 1953 } | 1938 } |
| 1954 } | 1939 } |
| 1955 } | 1940 } |
| 1956 | 1941 |
| 1957 // System events --------------------------------------------------------------- | 1942 // System events --------------------------------------------------------------- |
| 1958 | 1943 |
| 1959 void View::PropagateThemeChanged() { | 1944 void View::PropagateThemeChanged() { |
| 1960 for (int i = child_count() - 1; i >= 0; --i) | 1945 for (int i = child_count() - 1; i >= 0; --i) |
| 1961 GetChildViewAt(i)->PropagateThemeChanged(); | 1946 child_at(i)->PropagateThemeChanged(); |
| 1962 OnThemeChanged(); | 1947 OnThemeChanged(); |
| 1963 } | 1948 } |
| 1964 | 1949 |
| 1965 void View::PropagateLocaleChanged() { | 1950 void View::PropagateLocaleChanged() { |
| 1966 for (int i = child_count() - 1; i >= 0; --i) | 1951 for (int i = child_count() - 1; i >= 0; --i) |
| 1967 GetChildViewAt(i)->PropagateLocaleChanged(); | 1952 child_at(i)->PropagateLocaleChanged(); |
| 1968 OnLocaleChanged(); | 1953 OnLocaleChanged(); |
| 1969 } | 1954 } |
| 1970 | 1955 |
| 1971 // Tooltips -------------------------------------------------------------------- | 1956 // Tooltips -------------------------------------------------------------------- |
| 1972 | 1957 |
| 1973 void View::UpdateTooltip() { | 1958 void View::UpdateTooltip() { |
| 1974 Widget* widget = GetWidget(); | 1959 Widget* widget = GetWidget(); |
| 1975 // TODO(beng): The TooltipManager NULL check can be removed when we | 1960 // TODO(beng): The TooltipManager NULL check can be removed when we |
| 1976 // consolidate Init() methods and make views_unittests Init() all | 1961 // consolidate Init() methods and make views_unittests Init() all |
| 1977 // Widgets that it uses. | 1962 // Widgets that it uses. |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2035 snprintf(pp, kMaxPointerStringLength, "%p", parent_); | 2020 snprintf(pp, kMaxPointerStringLength, "%p", parent_); |
| 2036 result.append(" N"); | 2021 result.append(" N"); |
| 2037 result.append(pp+2); | 2022 result.append(pp+2); |
| 2038 result.append(" -> N"); | 2023 result.append(" -> N"); |
| 2039 result.append(p+2); | 2024 result.append(p+2); |
| 2040 result.append("\n"); | 2025 result.append("\n"); |
| 2041 } | 2026 } |
| 2042 | 2027 |
| 2043 // Children. | 2028 // Children. |
| 2044 for (int i = 0, count = child_count(); i < count; ++i) | 2029 for (int i = 0, count = child_count(); i < count; ++i) |
| 2045 result.append(GetChildViewAt(i)->PrintViewGraph(false)); | 2030 result.append(child_at(i)->PrintViewGraph(false)); |
| 2046 | 2031 |
| 2047 if (first) | 2032 if (first) |
| 2048 result.append("}\n"); | 2033 result.append("}\n"); |
| 2049 | 2034 |
| 2050 return result; | 2035 return result; |
| 2051 } | 2036 } |
| 2052 #endif | 2037 #endif |
| 2053 | 2038 |
| 2054 } // namespace views | 2039 } // namespace views |
| OLD | NEW |