| OLD | NEW |
| 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> |
| (...skipping 201 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 212 DCHECK(!iterating_); | 212 DCHECK(!iterating_); |
| 213 #endif | 213 #endif |
| 214 children_.insert(children_.begin() + index, view); | 214 children_.insert(children_.begin() + index, view); |
| 215 | 215 |
| 216 // Ensure the layer tree matches the view tree before calling to any client | 216 // Ensure the layer tree matches the view tree before calling to any client |
| 217 // code. This way if client code further modifies the view tree we are in a | 217 // code. This way if client code further modifies the view tree we are in a |
| 218 // sane state. | 218 // sane state. |
| 219 const bool did_reparent_any_layers = view->UpdateParentLayers(); | 219 const bool did_reparent_any_layers = view->UpdateParentLayers(); |
| 220 Widget* widget = GetWidget(); | 220 Widget* widget = GetWidget(); |
| 221 if (did_reparent_any_layers && widget) | 221 if (did_reparent_any_layers && widget) |
| 222 widget->UpdateRootLayers(); | 222 widget->LayerTreeChanged(); |
| 223 | 223 |
| 224 ReorderLayers(); | 224 ReorderLayers(); |
| 225 | 225 |
| 226 // Make sure the visibility of the child layers are correct. | 226 // Make sure the visibility of the child layers are correct. |
| 227 // If any of the parent View is hidden, then the layers of the subtree | 227 // If any of the parent View is hidden, then the layers of the subtree |
| 228 // rooted at |this| should be hidden. Otherwise, all the child layers should | 228 // rooted at |this| should be hidden. Otherwise, all the child layers should |
| 229 // inherit the visibility of the owner View. | 229 // inherit the visibility of the owner View. |
| 230 view->UpdateLayerVisibility(); | 230 view->UpdateLayerVisibility(); |
| 231 | 231 |
| 232 if (widget) { | 232 if (widget) { |
| (...skipping 325 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 558 | 558 |
| 559 if (new_parent) | 559 if (new_parent) |
| 560 ReorderLayers(); | 560 ReorderLayers(); |
| 561 | 561 |
| 562 UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL)); | 562 UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL)); |
| 563 | 563 |
| 564 SchedulePaint(); | 564 SchedulePaint(); |
| 565 | 565 |
| 566 Widget* widget = GetWidget(); | 566 Widget* widget = GetWidget(); |
| 567 if (widget) | 567 if (widget) |
| 568 widget->UpdateRootLayers(); | 568 widget->LayerTreeChanged(); |
| 569 } | 569 } |
| 570 | 570 |
| 571 std::unique_ptr<ui::Layer> View::RecreateLayer() { | 571 std::unique_ptr<ui::Layer> View::RecreateLayer() { |
| 572 std::unique_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer(); | 572 std::unique_ptr<ui::Layer> old_layer = LayerOwner::RecreateLayer(); |
| 573 Widget* widget = GetWidget(); | 573 Widget* widget = GetWidget(); |
| 574 if (widget) | 574 if (widget) |
| 575 widget->UpdateRootLayers(); | 575 widget->LayerTreeChanged(); |
| 576 return old_layer; | 576 return old_layer; |
| 577 } | 577 } |
| 578 | 578 |
| 579 // RTL positioning ------------------------------------------------------------- | 579 // RTL positioning ------------------------------------------------------------- |
| 580 | 580 |
| 581 gfx::Rect View::GetMirroredBounds() const { | 581 gfx::Rect View::GetMirroredBounds() const { |
| 582 gfx::Rect bounds(bounds_); | 582 gfx::Rect bounds(bounds_); |
| 583 bounds.set_x(GetMirroredX()); | 583 bounds.set_x(GetMirroredX()); |
| 584 return bounds; | 584 return bounds; |
| 585 } | 585 } |
| (...skipping 1348 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1934 view->SchedulePaint(); | 1934 view->SchedulePaint(); |
| 1935 | 1935 |
| 1936 if (!new_parent || new_parent->GetWidget() != widget) | 1936 if (!new_parent || new_parent->GetWidget() != widget) |
| 1937 widget->NotifyWillRemoveView(view); | 1937 widget->NotifyWillRemoveView(view); |
| 1938 } | 1938 } |
| 1939 | 1939 |
| 1940 // Make sure the layers belonging to the subtree rooted at |view| get | 1940 // Make sure the layers belonging to the subtree rooted at |view| get |
| 1941 // removed. | 1941 // removed. |
| 1942 view->OrphanLayers(); | 1942 view->OrphanLayers(); |
| 1943 if (widget) | 1943 if (widget) |
| 1944 widget->UpdateRootLayers(); | 1944 widget->LayerTreeChanged(); |
| 1945 | 1945 |
| 1946 view->PropagateRemoveNotifications(this, new_parent); | 1946 view->PropagateRemoveNotifications(this, new_parent); |
| 1947 view->parent_ = nullptr; | 1947 view->parent_ = nullptr; |
| 1948 | 1948 |
| 1949 if (delete_removed_view && !view->owned_by_client_) | 1949 if (delete_removed_view && !view->owned_by_client_) |
| 1950 view_to_be_deleted.reset(view); | 1950 view_to_be_deleted.reset(view); |
| 1951 | 1951 |
| 1952 #if DCHECK_IS_ON() | 1952 #if DCHECK_IS_ON() |
| 1953 DCHECK(!iterating_); | 1953 DCHECK(!iterating_); |
| 1954 #endif | 1954 #endif |
| (...skipping 273 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2228 UpdateLayerVisibility(); | 2228 UpdateLayerVisibility(); |
| 2229 | 2229 |
| 2230 // The new layer needs to be ordered in the layer tree according | 2230 // The new layer needs to be ordered in the layer tree according |
| 2231 // to the view tree. Children of this layer were added in order | 2231 // to the view tree. Children of this layer were added in order |
| 2232 // in UpdateParentLayers(). | 2232 // in UpdateParentLayers(). |
| 2233 if (parent()) | 2233 if (parent()) |
| 2234 parent()->ReorderLayers(); | 2234 parent()->ReorderLayers(); |
| 2235 | 2235 |
| 2236 Widget* widget = GetWidget(); | 2236 Widget* widget = GetWidget(); |
| 2237 if (widget) | 2237 if (widget) |
| 2238 widget->UpdateRootLayers(); | 2238 widget->LayerTreeChanged(); |
| 2239 | 2239 |
| 2240 // Before having its own Layer, this View may have painted in to a Layer owned | 2240 // Before having its own Layer, this View may have painted in to a Layer owned |
| 2241 // by an ancestor View. Scheduling a paint on the parent View will erase this | 2241 // by an ancestor View. Scheduling a paint on the parent View will erase this |
| 2242 // View's painting effects on the ancestor View's Layer. | 2242 // View's painting effects on the ancestor View's Layer. |
| 2243 // (See crbug.com/551492) | 2243 // (See crbug.com/551492) |
| 2244 SchedulePaintOnParent(); | 2244 SchedulePaintOnParent(); |
| 2245 } | 2245 } |
| 2246 | 2246 |
| 2247 bool View::UpdateParentLayers() { | 2247 bool View::UpdateParentLayers() { |
| 2248 // Attach all top-level un-parented layers. | 2248 // Attach all top-level un-parented layers. |
| (...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2550 // Message the RootView to do the drag and drop. That way if we're removed | 2550 // Message the RootView to do the drag and drop. That way if we're removed |
| 2551 // the RootView can detect it and avoid calling us back. | 2551 // the RootView can detect it and avoid calling us back. |
| 2552 gfx::Point widget_location(event.location()); | 2552 gfx::Point widget_location(event.location()); |
| 2553 ConvertPointToWidget(this, &widget_location); | 2553 ConvertPointToWidget(this, &widget_location); |
| 2554 widget->RunShellDrag(this, data, widget_location, drag_operations, source); | 2554 widget->RunShellDrag(this, data, widget_location, drag_operations, source); |
| 2555 // WARNING: we may have been deleted. | 2555 // WARNING: we may have been deleted. |
| 2556 return true; | 2556 return true; |
| 2557 } | 2557 } |
| 2558 | 2558 |
| 2559 } // namespace views | 2559 } // namespace views |
| OLD | NEW |