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

Unified Diff: aura/window.cc

Issue 7791030: Proper MouseEvent targeting. Adds a Window method that locates a Window for a given point. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « aura/window.h ('k') | aura/window_delegate.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: aura/window.cc
===================================================================
--- aura/window.cc (revision 98852)
+++ aura/window.cc (working copy)
@@ -24,6 +24,10 @@
}
Window::~Window() {
+ if (delegate_)
+ delegate_->OnWindowDestroyed();
+ if (parent_)
+ parent_->RemoveChild(this);
}
void Window::Init() {
@@ -70,7 +74,6 @@
UpdateLayerCanvas();
Draw();
- // First pass updates the layer bitmaps.
for (Windows::iterator i = children_.begin(); i != children_.end(); ++i)
(*i)->DrawTree();
}
@@ -91,10 +94,37 @@
children_.erase(i);
}
+// static
+void Window::ConvertPointToWindow(Window* source,
+ Window* target,
+ gfx::Point* point) {
+ ui::Layer::ConvertPointToLayer(source->layer(), target->layer(), point);
+}
+
bool Window::OnMouseEvent(const MouseEvent& event) {
return true;
}
+bool Window::HitTest(const gfx::Point& point) {
+ gfx::Rect local_bounds(gfx::Point(), bounds().size());
+ // TODO(beng): hittest masks.
+ return local_bounds.Contains(point);
+}
+
+Window* Window::GetEventHandlerForPoint(const gfx::Point& point) {
+ Windows::const_reverse_iterator i = children_.rbegin();
+ for (; i != children_.rend(); ++i) {
+ Window* child = *i;
+ if (child->visibility() == Window::VISIBILITY_HIDDEN)
+ continue;
+ gfx::Point point_in_child_coords(point);
+ Window::ConvertPointToWindow(this, child, &point_in_child_coords);
+ if (child->HitTest(point_in_child_coords))
+ return child->GetEventHandlerForPoint(point_in_child_coords);
+ }
+ return this;
+}
+
void Window::UpdateLayerCanvas() {
if (needs_paint_all_) {
needs_paint_all_ = false;
« no previous file with comments | « aura/window.h ('k') | aura/window_delegate.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698