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 517 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
528 DestroyLayer(); | 528 DestroyLayer(); |
529 } | 529 } |
530 } | 530 } |
531 | 531 |
532 ui::Layer* View::RecreateLayer() { | 532 ui::Layer* View::RecreateLayer() { |
533 ui::Layer* layer = AcquireLayer(); | 533 ui::Layer* layer = AcquireLayer(); |
534 if (!layer) | 534 if (!layer) |
535 return NULL; | 535 return NULL; |
536 | 536 |
537 CreateLayer(); | 537 CreateLayer(); |
538 | |
539 // TODO(pkotwicz): Remove this once ReorderLayers() stacks layers not attached | |
540 // to a view above layers attached to a view. | |
541 if (layer->parent()) | |
542 layer->parent()->StackAtTop(layer); | |
543 | |
544 layer_->set_scale_content(layer->scale_content()); | 538 layer_->set_scale_content(layer->scale_content()); |
545 return layer; | 539 return layer; |
546 } | 540 } |
547 | 541 |
548 // RTL positioning ------------------------------------------------------------- | 542 // RTL positioning ------------------------------------------------------------- |
549 | 543 |
550 gfx::Rect View::GetMirroredBounds() const { | 544 gfx::Rect View::GetMirroredBounds() const { |
551 gfx::Rect bounds(bounds_); | 545 gfx::Rect bounds(bounds_); |
552 bounds.set_x(GetMirroredX()); | 546 bounds.set_x(GetMirroredX()); |
553 return bounds; | 547 return bounds; |
(...skipping 897 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1451 | 1445 |
1452 base::Closure View::PrepareForLayerBoundsChange() { | 1446 base::Closure View::PrepareForLayerBoundsChange() { |
1453 return base::Closure(); | 1447 return base::Closure(); |
1454 } | 1448 } |
1455 | 1449 |
1456 void View::ReorderLayers() { | 1450 void View::ReorderLayers() { |
1457 View* v = this; | 1451 View* v = this; |
1458 while (v && !v->layer()) | 1452 while (v && !v->layer()) |
1459 v = v->parent(); | 1453 v = v->parent(); |
1460 | 1454 |
1455 Widget* widget = GetWidget(); | |
1461 if (!v) { | 1456 if (!v) { |
1462 Widget* widget = GetWidget(); | |
1463 if (widget) { | 1457 if (widget) { |
1464 ui::Layer* layer = widget->GetLayer(); | 1458 ui::Layer* layer = widget->GetLayer(); |
1465 if (layer) | 1459 if (layer) |
1466 widget->GetRootView()->ReorderChildLayers(layer); | 1460 widget->GetRootView()->ReorderChildLayers(layer); |
1467 } | 1461 } |
1468 } else { | 1462 } else { |
1469 v->ReorderChildLayers(v->layer()); | 1463 v->ReorderChildLayers(v->layer()); |
1470 } | 1464 } |
1465 | |
1466 if (widget) { | |
1467 // Reorder layers for NativeViews attached to a view (eg via a | |
1468 // NativeViewHost). Always do the reordering because the attached | |
1469 // NativeView's layer is parented to the widget's layer regardless of | |
1470 // whether the host view has an ancestor with a layer. | |
1471 widget->ReorderLayersForAttachedNativeViews(); | |
1472 } | |
1471 } | 1473 } |
1472 | 1474 |
1473 void View::ReorderChildLayers(ui::Layer* parent_layer) { | 1475 void View::ReorderChildLayers(ui::Layer* parent_layer) { |
1474 if (layer() && layer() != parent_layer) { | 1476 if (layer() && layer() != parent_layer) { |
sky
2013/05/24 15:57:26
It's subtle that we iterate backward. And subtle c
pkotwicz
2013/05/26 04:12:15
Done.
| |
1475 DCHECK_EQ(parent_layer, layer()->parent()); | 1477 DCHECK_EQ(parent_layer, layer()->parent()); |
1476 parent_layer->StackAtTop(layer()); | 1478 parent_layer->StackAtBottom(layer()); |
1477 } else { | 1479 } else { |
1478 for (Views::const_iterator i(children_.begin()); i != children_.end(); ++i) | 1480 for (Views::const_reverse_iterator it(children_.rbegin()); |
1479 (*i)->ReorderChildLayers(parent_layer); | 1481 it != children_.rend(); ++it) { |
1482 (*it)->ReorderChildLayers(parent_layer); | |
1483 } | |
1480 } | 1484 } |
1481 } | 1485 } |
1482 | 1486 |
1483 // Input ----------------------------------------------------------------------- | 1487 // Input ----------------------------------------------------------------------- |
1484 | 1488 |
1485 bool View::HasHitTestMask() const { | 1489 bool View::HasHitTestMask() const { |
1486 return false; | 1490 return false; |
1487 } | 1491 } |
1488 | 1492 |
1489 void View::GetHitTestMask(gfx::Path* mask) const { | 1493 void View::GetHitTestMask(gfx::Path* mask) const { |
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
2299 ConvertPointToWidget(this, &widget_location); | 2303 ConvertPointToWidget(this, &widget_location); |
2300 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, | 2304 GetWidget()->RunShellDrag(this, data, widget_location, drag_operations, |
2301 source); | 2305 source); |
2302 return true; | 2306 return true; |
2303 #else | 2307 #else |
2304 return false; | 2308 return false; |
2305 #endif // !defined(OS_MACOSX) | 2309 #endif // !defined(OS_MACOSX) |
2306 } | 2310 } |
2307 | 2311 |
2308 } // namespace views | 2312 } // namespace views |
OLD | NEW |