Chromium Code Reviews| Index: ui/compositor/layer.cc |
| diff --git a/ui/compositor/layer.cc b/ui/compositor/layer.cc |
| index 9accc1f3ab920799ae5b7c0e3e99037543cf1686..2be4080111b60e2c520e99595ecbf2258bb99ae6 100644 |
| --- a/ui/compositor/layer.cc |
| +++ b/ui/compositor/layer.cc |
| @@ -28,6 +28,7 @@ |
| #include "ui/compositor/compositor_switches.h" |
| #include "ui/compositor/dip_util.h" |
| #include "ui/compositor/layer_animator.h" |
| +#include "ui/compositor/layer_observer.h" |
| #include "ui/compositor/paint_context.h" |
| #include "ui/gfx/animation/animation.h" |
| #include "ui/gfx/canvas.h" |
| @@ -99,6 +100,8 @@ Layer::Layer(LayerType type) |
| } |
| Layer::~Layer() { |
| + FOR_EACH_OBSERVER(LayerObserver, observer_list_, OnLayerDestroyed(this)); |
| + |
| // Destroying the animator may cause observers to use the layer (and |
| // indirectly the WebLayer). Destroy the animator first so that the WebLayer |
| // is still around. |
| @@ -151,6 +154,14 @@ void Layer::ResetCompositor() { |
| } |
| } |
| +void Layer::AddObserver(LayerObserver* observer) { |
| + observer_list_.AddObserver(observer); |
| +} |
| + |
| +void Layer::RemoveObserver(LayerObserver* observer) { |
| + observer_list_.RemoveObserver(observer); |
| +} |
| + |
| void Layer::Add(Layer* child) { |
| DCHECK(!child->compositor_); |
| if (child->parent_) |
| @@ -754,6 +765,11 @@ void Layer::OnDelegatedFrameDamage(const gfx::Rect& damage_rect_in_dip) { |
| if (!delegate_) |
| return; |
| delegate_->OnDelegatedFrameDamage(damage_rect_in_dip); |
| + |
| + for (Layer* ancestor = this; ancestor; ancestor = ancestor->parent()) { |
|
sky
2016/08/18 13:36:21
I would like to avoid having to walk the tree on e
Evan Stade
2016/08/18 15:57:31
This only walks up (as opposed to a full tree trav
|
| + FOR_EACH_OBSERVER(LayerObserver, ancestor->observer_list_, |
| + OnDelegatedFrameDamageInTree()); |
| + } |
| } |
| void Layer::SetScrollable(Layer* parent_clip_layer, |