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

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

Issue 184983005: Remove Views dependency from window_animations.cc (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: . Created 6 years, 9 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/corewm/window_animations.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 501 matching lines...) Expand 10 before | Expand all | Expand 10 after
512 void View::SetPaintToLayer(bool paint_to_layer) { 512 void View::SetPaintToLayer(bool paint_to_layer) {
513 paint_to_layer_ = paint_to_layer; 513 paint_to_layer_ = paint_to_layer;
514 if (paint_to_layer_ && !layer()) { 514 if (paint_to_layer_ && !layer()) {
515 CreateLayer(); 515 CreateLayer();
516 } else if (!paint_to_layer_ && layer()) { 516 } else if (!paint_to_layer_ && layer()) {
517 DestroyLayer(); 517 DestroyLayer();
518 } 518 }
519 } 519 }
520 520
521 ui::Layer* View::RecreateLayer() { 521 ui::Layer* View::RecreateLayer() {
522 ui::Layer* layer = AcquireLayer(); 522 ui::Layer* acquired = AcquireLayer();
523 if (!layer) 523 if (!acquired)
524 return NULL; 524 return NULL;
525 525
526 CreateLayer(); 526 CreateLayer();
527 layer_->set_scale_content(layer->scale_content()); 527 layer()->set_scale_content(acquired->scale_content());
528 return layer; 528 return acquired;
529 } 529 }
530 530
531 // RTL positioning ------------------------------------------------------------- 531 // RTL positioning -------------------------------------------------------------
532 532
533 gfx::Rect View::GetMirroredBounds() const { 533 gfx::Rect View::GetMirroredBounds() const {
534 gfx::Rect bounds(bounds_); 534 gfx::Rect bounds(bounds_);
535 bounds.set_x(GetMirroredX()); 535 bounds.set_x(GetMirroredX());
536 return bounds; 536 return bounds;
537 } 537 }
538 538
(...skipping 1552 matching lines...) Expand 10 before | Expand all | Expand 10 after
2091 } 2091 }
2092 2092
2093 // Accelerated painting -------------------------------------------------------- 2093 // Accelerated painting --------------------------------------------------------
2094 2094
2095 void View::CreateLayer() { 2095 void View::CreateLayer() {
2096 // A new layer is being created for the view. So all the layers of the 2096 // A new layer is being created for the view. So all the layers of the
2097 // sub-tree can inherit the visibility of the corresponding view. 2097 // sub-tree can inherit the visibility of the corresponding view.
2098 for (int i = 0, count = child_count(); i < count; ++i) 2098 for (int i = 0, count = child_count(); i < count; ++i)
2099 child_at(i)->UpdateChildLayerVisibility(true); 2099 child_at(i)->UpdateChildLayerVisibility(true);
2100 2100
2101 layer_ = new ui::Layer(); 2101 SetLayer(new ui::Layer());
2102 layer_owner_.reset(layer_); 2102 layer()->set_delegate(this);
2103 layer_->set_delegate(this);
2104 #if !defined(NDEBUG) 2103 #if !defined(NDEBUG)
2105 layer_->set_name(GetClassName()); 2104 layer()->set_name(GetClassName());
2106 #endif 2105 #endif
2107 2106
2108 UpdateParentLayers(); 2107 UpdateParentLayers();
2109 UpdateLayerVisibility(); 2108 UpdateLayerVisibility();
2110 2109
2111 // The new layer needs to be ordered in the layer tree according 2110 // The new layer needs to be ordered in the layer tree according
2112 // to the view tree. Children of this layer were added in order 2111 // to the view tree. Children of this layer were added in order
2113 // in UpdateParentLayers(). 2112 // in UpdateParentLayers().
2114 if (parent()) 2113 if (parent())
2115 parent()->ReorderLayers(); 2114 parent()->ReorderLayers();
(...skipping 20 matching lines...) Expand all
2136 2135
2137 // The layer belonging to this View has already been orphaned. It is not 2136 // The layer belonging to this View has already been orphaned. It is not
2138 // necessary to orphan the child layers. 2137 // necessary to orphan the child layers.
2139 return; 2138 return;
2140 } 2139 }
2141 for (int i = 0, count = child_count(); i < count; ++i) 2140 for (int i = 0, count = child_count(); i < count; ++i)
2142 child_at(i)->OrphanLayers(); 2141 child_at(i)->OrphanLayers();
2143 } 2142 }
2144 2143
2145 void View::ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer) { 2144 void View::ReparentLayer(const gfx::Vector2d& offset, ui::Layer* parent_layer) {
2146 layer_->SetBounds(GetLocalBounds() + offset); 2145 layer()->SetBounds(GetLocalBounds() + offset);
2147 DCHECK_NE(layer(), parent_layer); 2146 DCHECK_NE(layer(), parent_layer);
2148 if (parent_layer) 2147 if (parent_layer)
2149 parent_layer->Add(layer()); 2148 parent_layer->Add(layer());
2150 layer_->SchedulePaint(GetLocalBounds()); 2149 layer()->SchedulePaint(GetLocalBounds());
2151 MoveLayerToParent(layer(), gfx::Point()); 2150 MoveLayerToParent(layer(), gfx::Point());
2152 } 2151 }
2153 2152
2154 void View::DestroyLayer() { 2153 void View::DestroyLayer() {
2155 ui::Layer* new_parent = layer()->parent(); 2154 ui::Layer* new_parent = layer()->parent();
2156 std::vector<ui::Layer*> children = layer()->children(); 2155 std::vector<ui::Layer*> children = layer()->children();
2157 for (size_t i = 0; i < children.size(); ++i) { 2156 for (size_t i = 0; i < children.size(); ++i) {
2158 layer()->Remove(children[i]); 2157 layer()->Remove(children[i]);
2159 if (new_parent) 2158 if (new_parent)
2160 new_parent->Add(children[i]); 2159 new_parent->Add(children[i]);
2161 } 2160 }
2162 2161
2163 layer_ = NULL; 2162 LayerOwner::DestroyLayer();
2164 layer_owner_.reset();
2165 2163
2166 if (new_parent) 2164 if (new_parent)
2167 ReorderLayers(); 2165 ReorderLayers();
2168 2166
2169 UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL)); 2167 UpdateChildLayerBounds(CalculateOffsetToAncestorWithLayer(NULL));
2170 2168
2171 SchedulePaint(); 2169 SchedulePaint();
2172 2170
2173 Widget* widget = GetWidget(); 2171 Widget* widget = GetWidget();
2174 if (widget) 2172 if (widget)
(...skipping 217 matching lines...) Expand 10 before | Expand all | Expand 10 after
2392 // Message the RootView to do the drag and drop. That way if we're removed 2390 // Message the RootView to do the drag and drop. That way if we're removed
2393 // the RootView can detect it and avoid calling us back. 2391 // the RootView can detect it and avoid calling us back.
2394 gfx::Point widget_location(event.location()); 2392 gfx::Point widget_location(event.location());
2395 ConvertPointToWidget(this, &widget_location); 2393 ConvertPointToWidget(this, &widget_location);
2396 widget->RunShellDrag(this, data, widget_location, drag_operations, source); 2394 widget->RunShellDrag(this, data, widget_location, drag_operations, source);
2397 // WARNING: we may have been deleted. 2395 // WARNING: we may have been deleted.
2398 return true; 2396 return true;
2399 } 2397 }
2400 2398
2401 } // namespace views 2399 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/corewm/window_animations.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698