Fix stale compositor references from ui::Layer

This is needed to fix some issues in tests exposed by the WebKit compositor. The
problem is that sometimes during the teardown paths, some layers have stale a
pointer to the compositor that has already been destroyed. The WebKit layer
(rightfully) calls ScheduleDraw when the layer hierarchy is changed, exposing
the issue.

We now always walk back to the root layer to find the compositor, and reset the
pointer when the compositor's root changes (or it gets destroyed).

BUG=99524
TEST=views_unittest, aura_unittest, compositor_unittests with (and without) use_webkit_compositor=1


Review URL: http://codereview.chromium.org/8510076

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@110223 0039d316-1c4b-4281-b951-d872f2087c98
diff --git a/ui/gfx/compositor/layer.h b/ui/gfx/compositor/layer.h
index d8cb66c..76fef3e 100644
--- a/ui/gfx/compositor/layer.h
+++ b/ui/gfx/compositor/layer.h
@@ -48,10 +48,8 @@
     LAYER_HAS_TEXTURE = 1
   };
 
-  // |compositor| can be NULL, and will be set later when the Layer is added to
-  // a Compositor.
-  explicit Layer(Compositor* compositor);
-  Layer(Compositor* compositor, LayerType type);
+  Layer();
+  explicit Layer(LayerType type);
   virtual ~Layer();
 
   // Retrieves the Layer's compositor. The Layer will walk up its parent chain
@@ -152,10 +150,6 @@
 
   const gfx::Rect& hole_rect() const {  return hole_rect_; }
 
-  // The compositor.
-  const Compositor* compositor() const { return compositor_; }
-  Compositor* compositor() { return compositor_; }
-
   const ui::Texture* texture() const { return texture_.get(); }
 
   // |texture| cannot be NULL, and this function cannot be called more than