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

Unified Diff: ui/gfx/compositor/layer.cc

Issue 8510076: Fix stale compositor references from ui::Layer (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 9 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: ui/gfx/compositor/layer.cc
diff --git a/ui/gfx/compositor/layer.cc b/ui/gfx/compositor/layer.cc
index 2b98d44e7a61015df987bcbf31fb4d9513761a49..e3b4395048f91a97477c4a82245f2422e6b4ba95 100644
--- a/ui/gfx/compositor/layer.cc
+++ b/ui/gfx/compositor/layer.cc
@@ -32,13 +32,17 @@ bool IsApproximateMultilpleOf(float value, float base) {
return remainder < EPSILON || base - remainder < EPSILON;
}
+const ui::Layer* GetRoot(const ui::Layer* layer) {
+ return layer->parent() ? GetRoot(layer->parent()) : layer;
+}
+
} // namespace
namespace ui {
-Layer::Layer(Compositor* compositor)
+Layer::Layer()
: type_(LAYER_HAS_TEXTURE),
- compositor_(compositor),
+ compositor_(NULL),
parent_(NULL),
visible_(true),
fills_bounds_opaquely_(true),
@@ -50,9 +54,9 @@ Layer::Layer(Compositor* compositor)
#endif
}
-Layer::Layer(Compositor* compositor, LayerType type)
+Layer::Layer(LayerType type)
: type_(type),
- compositor_(compositor),
+ compositor_(NULL),
parent_(NULL),
visible_(true),
fills_bounds_opaquely_(true),
@@ -79,11 +83,10 @@ Compositor* Layer::GetCompositor() {
}
void Layer::SetCompositor(Compositor* compositor) {
- // This function must only be called once, with a valid compositor, and only
- // for the compositor's root layer.
- DCHECK(!compositor_);
- DCHECK(compositor);
- DCHECK_EQ(compositor->root_layer(), this);
+ // This function must only be called to set the compositor on the root layer,
+ // or to reset it.
+ DCHECK(!compositor || !compositor_);
+ DCHECK(!compositor || compositor->root_layer() == this);
compositor_ = compositor;
}
@@ -230,8 +233,8 @@ void Layer::ConvertPointToLayer(const Layer* source,
if (source == target)
return;
- const Layer* root_layer = source->compositor()->root_layer();
- CHECK_EQ(root_layer, target->compositor()->root_layer());
+ const Layer* root_layer = GetRoot(source);
+ CHECK_EQ(root_layer, GetRoot(target));
if (source != root_layer)
source->ConvertPointForAncestor(root_layer, point);

Powered by Google App Engine
This is Rietveld 408576698