Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(254)

Side by Side Diff: ui/views/view.cc

Issue 2561253002: [ash-md] Adds support for Z-order iteration in views::View (Closed)
Patch Set: [ash-md] Adds support for Z-order iteration in views::View (rebased) Created 3 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 478 matching lines...) Expand 10 before | Expand all | Expand 10 after
489 489
490 for (ViewObserver& observer : observers_) 490 for (ViewObserver& observer : observers_)
491 observer.OnViewEnabledChanged(this); 491 observer.OnViewEnabledChanged(this);
492 } 492 }
493 } 493 }
494 494
495 void View::OnEnabledChanged() { 495 void View::OnEnabledChanged() {
496 SchedulePaint(); 496 SchedulePaint();
497 } 497 }
498 498
499 View::Views View::GetChildrenInZOrder() {
500 return children_;
501 }
502
499 // Transformations ------------------------------------------------------------- 503 // Transformations -------------------------------------------------------------
500 504
501 gfx::Transform View::GetTransform() const { 505 gfx::Transform View::GetTransform() const {
502 if (!layer()) 506 if (!layer())
503 return gfx::Transform(); 507 return gfx::Transform();
504 508
505 gfx::Transform transform = layer()->transform(); 509 gfx::Transform transform = layer()->transform();
506 gfx::ScrollOffset scroll_offset = layer()->CurrentScrollOffset(); 510 gfx::ScrollOffset scroll_offset = layer()->CurrentScrollOffset();
507 transform.Translate(-scroll_offset.x(), -scroll_offset.y()); 511 transform.Translate(-scroll_offset.x(), -scroll_offset.y());
508 return transform; 512 return transform;
(...skipping 438 matching lines...) Expand 10 before | Expand all | Expand 10 after
947 return true; 951 return true;
948 } 952 }
949 953
950 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) { 954 View* View::GetTooltipHandlerForPoint(const gfx::Point& point) {
951 // TODO(tdanderson): Move this implementation into ViewTargetDelegate. 955 // TODO(tdanderson): Move this implementation into ViewTargetDelegate.
952 if (!HitTestPoint(point) || !CanProcessEventsWithinSubtree()) 956 if (!HitTestPoint(point) || !CanProcessEventsWithinSubtree())
953 return NULL; 957 return NULL;
954 958
955 // Walk the child Views recursively looking for the View that most 959 // Walk the child Views recursively looking for the View that most
956 // tightly encloses the specified point. 960 // tightly encloses the specified point.
957 for (auto* child : base::Reversed(children_)) { 961 View::Views children = GetChildrenInZOrder();
962 DCHECK_EQ(child_count(), static_cast<int>(children.size()));
963 for (auto* child : base::Reversed(children)) {
958 if (!child->visible()) 964 if (!child->visible())
959 continue; 965 continue;
960 966
961 gfx::Point point_in_child_coords(point); 967 gfx::Point point_in_child_coords(point);
962 ConvertPointToTarget(this, child, &point_in_child_coords); 968 ConvertPointToTarget(this, child, &point_in_child_coords);
963 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords); 969 View* handler = child->GetTooltipHandlerForPoint(point_in_child_coords);
964 if (handler) 970 if (handler)
965 return handler; 971 return handler;
966 } 972 }
967 return this; 973 return this;
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
1466 1472
1467 if (focus_manager) 1473 if (focus_manager)
1468 RegisterPendingAccelerators(); 1474 RegisterPendingAccelerators();
1469 } 1475 }
1470 } 1476 }
1471 1477
1472 // Painting -------------------------------------------------------------------- 1478 // Painting --------------------------------------------------------------------
1473 1479
1474 void View::PaintChildren(const ui::PaintContext& context) { 1480 void View::PaintChildren(const ui::PaintContext& context) {
1475 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName()); 1481 TRACE_EVENT1("views", "View::PaintChildren", "class", GetClassName());
1476 internal::ScopedChildrenLock lock(this); 1482 View::Views children = GetChildrenInZOrder();
1477 for (auto* child : children_) { 1483 DCHECK_EQ(child_count(), static_cast<int>(children.size()));
1484 for (auto* child : children) {
1478 if (!child->layer()) 1485 if (!child->layer())
1479 child->Paint(context); 1486 child->Paint(context);
1480 } 1487 }
1481 } 1488 }
1482 1489
1483 void View::OnPaint(gfx::Canvas* canvas) { 1490 void View::OnPaint(gfx::Canvas* canvas) {
1484 TRACE_EVENT1("views", "View::OnPaint", "class", GetClassName()); 1491 TRACE_EVENT1("views", "View::OnPaint", "class", GetClassName());
1485 OnPaintBackground(canvas); 1492 OnPaintBackground(canvas);
1486 OnPaintBorder(canvas); 1493 OnPaintBorder(canvas);
1487 } 1494 }
(...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after
1621 } 1628 }
1622 1629
1623 void View::ReorderChildLayers(ui::Layer* parent_layer) { 1630 void View::ReorderChildLayers(ui::Layer* parent_layer) {
1624 if (layer() && layer() != parent_layer) { 1631 if (layer() && layer() != parent_layer) {
1625 DCHECK_EQ(parent_layer, layer()->parent()); 1632 DCHECK_EQ(parent_layer, layer()->parent());
1626 parent_layer->StackAtBottom(layer()); 1633 parent_layer->StackAtBottom(layer());
1627 } else { 1634 } else {
1628 // Iterate backwards through the children so that a child with a layer 1635 // Iterate backwards through the children so that a child with a layer
1629 // which is further to the back is stacked above one which is further to 1636 // which is further to the back is stacked above one which is further to
1630 // the front. 1637 // the front.
1631 internal::ScopedChildrenLock lock(this); 1638 View::Views children = GetChildrenInZOrder();
1632 for (auto* child : base::Reversed(children_)) { 1639 DCHECK_EQ(child_count(), static_cast<int>(children.size()));
1640 for (auto* child : base::Reversed(children))
1633 child->ReorderChildLayers(parent_layer); 1641 child->ReorderChildLayers(parent_layer);
1634 }
1635 } 1642 }
1636 } 1643 }
1637 1644
1638 // Input ----------------------------------------------------------------------- 1645 // Input -----------------------------------------------------------------------
1639 1646
1640 View::DragInfo* View::GetDragInfo() { 1647 View::DragInfo* View::GetDragInfo() {
1641 return parent_ ? parent_->GetDragInfo() : NULL; 1648 return parent_ ? parent_->GetDragInfo() : NULL;
1642 } 1649 }
1643 1650
1644 // Focus ----------------------------------------------------------------------- 1651 // Focus -----------------------------------------------------------------------
(...skipping 878 matching lines...) Expand 10 before | Expand all | Expand 10 after
2523 // Message the RootView to do the drag and drop. That way if we're removed 2530 // Message the RootView to do the drag and drop. That way if we're removed
2524 // the RootView can detect it and avoid calling us back. 2531 // the RootView can detect it and avoid calling us back.
2525 gfx::Point widget_location(event.location()); 2532 gfx::Point widget_location(event.location());
2526 ConvertPointToWidget(this, &widget_location); 2533 ConvertPointToWidget(this, &widget_location);
2527 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2534 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2528 // WARNING: we may have been deleted. 2535 // WARNING: we may have been deleted.
2529 return true; 2536 return true;
2530 } 2537 }
2531 2538
2532 } // namespace views 2539 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/view.h ('k') | ui/views/view_targeter_delegate.cc » ('j') | ui/views/view_unittest.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698