| OLD | NEW | 
|---|
| 1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 #ifndef NDEBUG | 8 #ifndef NDEBUG | 
| 9 #include <iostream> | 9 #include <iostream> | 
| 10 #endif | 10 #endif | 
| (...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 125 | 125 | 
| 126   if (size_changed || position_changed) { | 126   if (size_changed || position_changed) { | 
| 127     DidChangeBounds(prev, bounds_); | 127     DidChangeBounds(prev, bounds_); | 
| 128 | 128 | 
| 129     RootView* root = GetRootView(); | 129     RootView* root = GetRootView(); | 
| 130     if (root) | 130     if (root) | 
| 131       root->ViewBoundsChanged(this, size_changed, position_changed); | 131       root->ViewBoundsChanged(this, size_changed, position_changed); | 
| 132   } | 132   } | 
| 133 } | 133 } | 
| 134 | 134 | 
|  | 135 void View::RegisterForMouseNearEvents(const gfx::Insets& insets) { | 
|  | 136   RootView* root = GetRootView(); | 
|  | 137   if (insets.empty()) { | 
|  | 138     near_insets_.reset(NULL); | 
|  | 139     if (root) | 
|  | 140       root->UnregisterViewForNearNotification(this); | 
|  | 141   } else { | 
|  | 142     near_insets_.reset( | 
|  | 143         new gfx::Insets(insets.top(), insets.left(), insets.bottom(), | 
|  | 144                         insets.right())); | 
|  | 145     if (root) | 
|  | 146       root->RegisterViewForNearNotification(this); | 
|  | 147   } | 
|  | 148 } | 
|  | 149 | 
| 135 gfx::Rect View::GetLocalBounds(bool include_border) const { | 150 gfx::Rect View::GetLocalBounds(bool include_border) const { | 
| 136   if (include_border || !border_.get()) | 151   if (include_border || !border_.get()) | 
| 137     return gfx::Rect(0, 0, width(), height()); | 152     return gfx::Rect(0, 0, width(), height()); | 
| 138 | 153 | 
| 139   gfx::Insets insets; | 154   gfx::Insets insets; | 
| 140   border_->GetInsets(&insets); | 155   border_->GetInsets(&insets); | 
| 141   return gfx::Rect(insets.left(), insets.top(), | 156   return gfx::Rect(insets.left(), insets.top(), | 
| 142                    std::max(0, width() - insets.width()), | 157                    std::max(0, width() - insets.width()), | 
| 143                    std::max(0, height() - insets.height())); | 158                    std::max(0, height() - insets.height())); | 
| 144 } | 159 } | 
| (...skipping 385 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 530   child_views_.insert(child_views_.begin() + index, v); | 545   child_views_.insert(child_views_.begin() + index, v); | 
| 531   v->SetParent(this); | 546   v->SetParent(this); | 
| 532 | 547 | 
| 533   for (View* p = this; p; p = p->GetParent()) | 548   for (View* p = this; p; p = p->GetParent()) | 
| 534     p->ViewHierarchyChangedImpl(false, true, this, v); | 549     p->ViewHierarchyChangedImpl(false, true, this, v); | 
| 535 | 550 | 
| 536   v->PropagateAddNotifications(this, v); | 551   v->PropagateAddNotifications(this, v); | 
| 537   UpdateTooltip(); | 552   UpdateTooltip(); | 
| 538   RootView* root = GetRootView(); | 553   RootView* root = GetRootView(); | 
| 539   if (root) | 554   if (root) | 
| 540     RegisterChildrenForVisibleBoundsNotification(root, v); | 555     RegisterChildrenForRootNotifications(root, v); | 
| 541 | 556 | 
| 542   if (layout_manager_.get()) | 557   if (layout_manager_.get()) | 
| 543     layout_manager_->ViewAdded(this, v); | 558     layout_manager_->ViewAdded(this, v); | 
| 544 } | 559 } | 
| 545 | 560 | 
| 546 View* View::GetChildViewAt(int index) const { | 561 View* View::GetChildViewAt(int index) const { | 
| 547   return index < GetChildViewCount() ? child_views_[index] : NULL; | 562   return index < GetChildViewCount() ? child_views_[index] : NULL; | 
| 548 } | 563 } | 
| 549 | 564 | 
| 550 int View::GetChildViewCount() const { | 565 int View::GetChildViewCount() const { | 
| (...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 602       View* next_focusable = a_view->next_focusable_view_; | 617       View* next_focusable = a_view->next_focusable_view_; | 
| 603       View* prev_focusable = a_view->previous_focusable_view_; | 618       View* prev_focusable = a_view->previous_focusable_view_; | 
| 604       if (prev_focusable) | 619       if (prev_focusable) | 
| 605         prev_focusable->next_focusable_view_ = next_focusable; | 620         prev_focusable->next_focusable_view_ = next_focusable; | 
| 606       if (next_focusable) | 621       if (next_focusable) | 
| 607         next_focusable->previous_focusable_view_ = prev_focusable; | 622         next_focusable->previous_focusable_view_ = prev_focusable; | 
| 608     } | 623     } | 
| 609 | 624 | 
| 610     RootView* root = GetRootView(); | 625     RootView* root = GetRootView(); | 
| 611     if (root) | 626     if (root) | 
| 612       UnregisterChildrenForVisibleBoundsNotification(root, a_view); | 627       UnregisterChildrenForRootNotifications(root, a_view); | 
| 613     a_view->PropagateRemoveNotifications(this); | 628     a_view->PropagateRemoveNotifications(this); | 
| 614     a_view->SetParent(NULL); | 629     a_view->SetParent(NULL); | 
| 615 | 630 | 
| 616     if (delete_removed_view && a_view->IsParentOwned()) | 631     if (delete_removed_view && a_view->IsParentOwned()) | 
| 617       delete a_view; | 632       delete a_view; | 
| 618 | 633 | 
| 619     child_views_.erase(i); | 634     child_views_.erase(i); | 
| 620   } | 635   } | 
| 621 | 636 | 
| 622   if (update_tool_tip) | 637   if (update_tool_tip) | 
| (...skipping 810 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1433                                  bool is_horizontal, bool is_positive) { | 1448                                  bool is_horizontal, bool is_positive) { | 
| 1434   return 0; | 1449   return 0; | 
| 1435 } | 1450 } | 
| 1436 | 1451 | 
| 1437 ThemeProvider* View::GetThemeProvider() const { | 1452 ThemeProvider* View::GetThemeProvider() const { | 
| 1438   Widget* widget = GetWidget(); | 1453   Widget* widget = GetWidget(); | 
| 1439   return widget ? widget->GetThemeProvider() : NULL; | 1454   return widget ? widget->GetThemeProvider() : NULL; | 
| 1440 } | 1455 } | 
| 1441 | 1456 | 
| 1442 // static | 1457 // static | 
| 1443 void View::RegisterChildrenForVisibleBoundsNotification( | 1458 void View::RegisterChildrenForRootNotifications(RootView* root, View* view) { | 
| 1444     RootView* root, View* view) { |  | 
| 1445   DCHECK(root && view); | 1459   DCHECK(root && view); | 
| 1446   if (view->GetNotifyWhenVisibleBoundsInRootChanges()) | 1460   if (view->GetNotifyWhenVisibleBoundsInRootChanges()) | 
| 1447     root->RegisterViewForVisibleBoundsNotification(view); | 1461     root->RegisterViewForVisibleBoundsNotification(view); | 
|  | 1462   if (view->near_insets_.get()) | 
|  | 1463     root->RegisterViewForNearNotification(view); | 
| 1448   for (int i = 0; i < view->GetChildViewCount(); ++i) | 1464   for (int i = 0; i < view->GetChildViewCount(); ++i) | 
| 1449     RegisterChildrenForVisibleBoundsNotification(root, view->GetChildViewAt(i)); | 1465     RegisterChildrenForRootNotifications(root, view->GetChildViewAt(i)); | 
| 1450 } | 1466 } | 
| 1451 | 1467 | 
| 1452 // static | 1468 // static | 
| 1453 void View::UnregisterChildrenForVisibleBoundsNotification( | 1469 void View::UnregisterChildrenForRootNotifications( | 
| 1454     RootView* root, View* view) { | 1470     RootView* root, View* view) { | 
| 1455   DCHECK(root && view); | 1471   DCHECK(root && view); | 
| 1456   if (view->GetNotifyWhenVisibleBoundsInRootChanges()) | 1472   if (view->GetNotifyWhenVisibleBoundsInRootChanges()) | 
| 1457     root->UnregisterViewForVisibleBoundsNotification(view); | 1473     root->UnregisterViewForVisibleBoundsNotification(view); | 
|  | 1474   if (view->near_insets_.get()) | 
|  | 1475     root->UnregisterViewForNearNotification(view); | 
| 1458   for (int i = 0; i < view->GetChildViewCount(); ++i) | 1476   for (int i = 0; i < view->GetChildViewCount(); ++i) | 
| 1459     UnregisterChildrenForVisibleBoundsNotification(root, | 1477     UnregisterChildrenForRootNotifications(root, view->GetChildViewAt(i)); | 
| 1460                                                    view->GetChildViewAt(i)); |  | 
| 1461 } | 1478 } | 
| 1462 | 1479 | 
| 1463 void View::AddDescendantToNotify(View* view) { | 1480 void View::AddDescendantToNotify(View* view) { | 
| 1464   DCHECK(view); | 1481   DCHECK(view); | 
| 1465   if (!descendants_to_notify_.get()) | 1482   if (!descendants_to_notify_.get()) | 
| 1466     descendants_to_notify_.reset(new ViewList()); | 1483     descendants_to_notify_.reset(new ViewList()); | 
| 1467   descendants_to_notify_->push_back(view); | 1484   descendants_to_notify_->push_back(view); | 
| 1468 } | 1485 } | 
| 1469 | 1486 | 
| 1470 void View::RemoveDescendantToNotify(View* view) { | 1487 void View::RemoveDescendantToNotify(View* view) { | 
| (...skipping 13 matching lines...) Expand all  Loading... | 
| 1484   possible_drag = false; | 1501   possible_drag = false; | 
| 1485   start_pt = gfx::Point(); | 1502   start_pt = gfx::Point(); | 
| 1486 } | 1503 } | 
| 1487 | 1504 | 
| 1488 void View::DragInfo::PossibleDrag(const gfx::Point& p) { | 1505 void View::DragInfo::PossibleDrag(const gfx::Point& p) { | 
| 1489   possible_drag = true; | 1506   possible_drag = true; | 
| 1490   start_pt = p; | 1507   start_pt = p; | 
| 1491 } | 1508 } | 
| 1492 | 1509 | 
| 1493 }  // namespace | 1510 }  // namespace | 
| OLD | NEW | 
|---|