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 1434 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1445 | 1445 |
1446 base::Closure View::PrepareForLayerBoundsChange() { | 1446 base::Closure View::PrepareForLayerBoundsChange() { |
1447 return base::Closure(); | 1447 return base::Closure(); |
1448 } | 1448 } |
1449 | 1449 |
1450 void View::ReorderLayers() { | 1450 void View::ReorderLayers() { |
1451 View* v = this; | 1451 View* v = this; |
1452 while (v && !v->layer()) | 1452 while (v && !v->layer()) |
1453 v = v->parent(); | 1453 v = v->parent(); |
1454 | 1454 |
| 1455 Widget* widget = GetWidget(); |
1455 if (!v) { | 1456 if (!v) { |
1456 Widget* widget = GetWidget(); | |
1457 if (widget) { | 1457 if (widget) { |
1458 ui::Layer* layer = widget->GetLayer(); | 1458 ui::Layer* layer = widget->GetLayer(); |
1459 if (layer) | 1459 if (layer) |
1460 widget->GetRootView()->ReorderChildLayers(layer); | 1460 widget->GetRootView()->ReorderChildLayers(layer); |
1461 } | 1461 } |
1462 } else { | 1462 } else { |
1463 v->ReorderChildLayers(v->layer()); | 1463 v->ReorderChildLayers(v->layer()); |
1464 } | 1464 } |
| 1465 |
| 1466 if (widget) { |
| 1467 // Reorder the widget's child NativeViews in case a child NativeView is |
| 1468 // associated with a view (eg via a NativeViewHost). Always do the |
| 1469 // reordering because the associated NativeView's layer (if it has one) |
| 1470 // is parented to the widget's layer regardless of whether the host view has |
| 1471 // an ancestor with a layer. |
| 1472 widget->ReorderNativeViews(); |
| 1473 } |
1465 } | 1474 } |
1466 | 1475 |
1467 void View::ReorderChildLayers(ui::Layer* parent_layer) { | 1476 void View::ReorderChildLayers(ui::Layer* parent_layer) { |
1468 if (layer() && layer() != parent_layer) { | 1477 if (layer() && layer() != parent_layer) { |
1469 DCHECK_EQ(parent_layer, layer()->parent()); | 1478 DCHECK_EQ(parent_layer, layer()->parent()); |
1470 parent_layer->StackAtTop(layer()); | 1479 parent_layer->StackAtBottom(layer()); |
1471 } else { | 1480 } else { |
1472 for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i) | 1481 // Iterate backwards through the children so that a child with a layer |
1473 (*i)->ReorderChildLayers(parent_layer); | 1482 // which is further to the back is stacked above one which is further to |
| 1483 // the front. |
| 1484 for (Views::const_reverse_iterator it(children_.rbegin()); |
| 1485 it != children_.rend(); ++it) { |
| 1486 (*it)->ReorderChildLayers(parent_layer); |
| 1487 } |
1474 } | 1488 } |
1475 } | 1489 } |
1476 | 1490 |
1477 // Input ----------------------------------------------------------------------- | 1491 // Input ----------------------------------------------------------------------- |
1478 | 1492 |
1479 bool View::HasHitTestMask() const { | 1493 bool View::HasHitTestMask() const { |
1480 return false; | 1494 return false; |
1481 } | 1495 } |
1482 | 1496 |
1483 void View::GetHitTestMask(gfx::Path* mask) const { | 1497 void View::GetHitTestMask(gfx::Path* mask) const { |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2293 ConvertPointToWidget(this, &widget_location); | 2307 ConvertPointToWidget(this, &widget_location); |
2294 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, | 2308 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, |
2295 source); | 2309 source); |
2296 return true; | 2310 return true; |
2297 #else | 2311 #else |
2298 return false; | 2312 return false; |
2299 #endif // !defined(OS_MACOSX) | 2313 #endif // !defined(OS_MACOSX) |
2300 } | 2314 } |
2301 | 2315 |
2302 } // namespace views | 2316 } // namespace views |
OLD | NEW |