diff options
author | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 16:38:14 +0000 |
---|---|---|
committer | sky@chromium.org <sky@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2012-06-16 16:38:14 +0000 |
commit | 334b8189916a733965999d766aebc7a698ec06cd (patch) | |
tree | bc3cda855f9e0a09b2b2356d8788843644ddc1d9 /ui/views/widget/native_widget_aura.cc | |
parent | 514a2ba9c0651a76f15978a8af9eb1fea1234537 (diff) | |
download | chromium_src-334b8189916a733965999d766aebc7a698ec06cd.zip chromium_src-334b8189916a733965999d766aebc7a698ec06cd.tar.gz chromium_src-334b8189916a733965999d766aebc7a698ec06cd.tar.bz2 |
Provides a way for a window to stop events from propagating to a
child. Wires it up for the situation of a child view with a layer
being stacked on top of a child control's window.
BUG=none
TEST=covered by unit test
R=ben@chromium.org
Review URL: https://chromiumcodereview.appspot.com/10554015
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@142601 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'ui/views/widget/native_widget_aura.cc')
-rw-r--r-- | ui/views/widget/native_widget_aura.cc | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/ui/views/widget/native_widget_aura.cc b/ui/views/widget/native_widget_aura.cc index 774585a..70e63a2 100644 --- a/ui/views/widget/native_widget_aura.cc +++ b/ui/views/widget/native_widget_aura.cc @@ -741,6 +741,36 @@ int NativeWidgetAura::GetNonClientComponent(const gfx::Point& point) const { return delegate_->GetNonClientComponent(point); } +bool NativeWidgetAura::ShouldDescendIntoChildForEventHandling( + aura::Window* child, + const gfx::Point& location) { + // Don't descend into |child| if there is a view with a Layer that contains + // the point and is stacked above |child|s layer. + typedef std::vector<ui::Layer*> Layers; + const Layers& root_layers(delegate_->GetRootLayers()); + if (root_layers.empty()) + return true; + + Layers::const_iterator child_layer_iter( + std::find(window_->layer()->children().begin(), + window_->layer()->children().end(), child->layer())); + if (child_layer_iter == window_->layer()->children().end()) + return true; + + for (std::vector<ui::Layer*>::const_reverse_iterator i = root_layers.rbegin(); + i != root_layers.rend(); ++i) { + ui::Layer* layer = *i; + if (layer->visible() && layer->bounds().Contains(location)) { + Layers::const_iterator root_layer_iter( + std::find(window_->layer()->children().begin(), + window_->layer()->children().end(), layer)); + if (root_layer_iter > child_layer_iter) + return false; + } + } + return true; +} + bool NativeWidgetAura::OnMouseEvent(aura::MouseEvent* event) { DCHECK(window_->IsVisible()); if (event->type() == ui::ET_MOUSEWHEEL) { |