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

Unified Diff: ui/aura/window_targeter.cc

Issue 2172363002: Created min size for print preview dialog and modified to allow the Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix Mac compile error. Created 4 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
« ui/aura/window_targeter.h ('K') | « ui/aura/window_targeter.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: ui/aura/window_targeter.cc
diff --git a/ui/aura/window_targeter.cc b/ui/aura/window_targeter.cc
index 9853585d3cda3a6a0dddb1503f668abb4b34c7d5..9cccc949cfeb77c6daabd1289c42b3cb7c97e29e 100644
--- a/ui/aura/window_targeter.cc
+++ b/ui/aura/window_targeter.cc
@@ -4,6 +4,8 @@
#include "ui/aura/window_targeter.h"
+#include <memory>
+
#include "ui/aura/client/capture_client.h"
#include "ui/aura/client/event_client.h"
#include "ui/aura/client/focus_client.h"
@@ -15,6 +17,7 @@
#include "ui/events/event_target_iterator.h"
namespace aura {
+const char kHasIndependentBoundsKey[] = "__INDEPENDENT_BOUNDS__";
WindowTargeter::WindowTargeter() {}
WindowTargeter::~WindowTargeter() {}
@@ -59,6 +62,49 @@ bool WindowTargeter::EventLocationInsideBounds(
return gfx::Rect(window->bounds().size()).Contains(point);
}
+bool WindowTargeter::ChildHasBoundsOutsideParent(Window* parent,
+ Window* child) {
+ if (!parent || !child)
+ return false;
+ return
+ child->GetNativeWindowProperty(aura::kHasIndependentBoundsKey) != nullptr;
Lei Zhang 2016/08/19 03:28:47 Or !!foo is you want it to fit on one line again.
rbpotter 2016/08/19 16:59:42 Done.
+}
+
+bool WindowTargeter::HasIndependentChildWithEvent(Window* window,
+ const gfx::Point& event_point,
+ bool in_parent_coordinates) {
+ gfx::Point point(event_point);
+ Window* parent = window->parent();
+ bool can_accept = true;
+ if (parent) {
+ if (!in_parent_coordinates)
+ Window::ConvertPointToTarget(window, parent, &point);
+ if (parent->delegate_ &&
+ !parent->delegate_->ShouldDescendIntoChildForEventHandling(window,
+ point)) {
+ can_accept = false;
+ }
+ Window::ConvertPointToTarget(parent, window, &point);
+ }
+ bool in_bounds = gfx::Rect(window->bounds().size()).Contains(point);
+ can_accept = can_accept && (window->IsVisible() && !window->ignore_events());
+ client::EventClient* client = client::GetEventClient(window->GetRootWindow());
+ if (client && !client->CanProcessEventsWithinSubtree(window))
+ can_accept = false;
+ if (in_bounds && can_accept && ChildHasBoundsOutsideParent(parent, window))
+ return true;
+ std::unique_ptr<ui::EventTargetIterator> iter = window->GetChildIterator();
+ if (iter) {
+ for (ui::EventTarget* child = iter->GetNextTarget(); child;
+ child = iter->GetNextTarget()) {
+ if (HasIndependentChildWithEvent(static_cast<Window*>(child), point,
+ true))
+ return true;
+ }
Lei Zhang 2016/08/19 03:28:47 bad indent
rbpotter 2016/08/19 16:59:42 Done.
+ }
+ return false;
+}
+
ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root,
ui::Event* event) {
Window* window = static_cast<Window*>(root);
@@ -99,8 +145,9 @@ ui::EventTarget* WindowTargeter::FindNextBestTarget(
bool WindowTargeter::SubtreeShouldBeExploredForEvent(
Window* window,
const ui::LocatedEvent& event) {
- return SubtreeCanAcceptEvent(window, event) &&
- EventLocationInsideBounds(window, event);
+ return (SubtreeCanAcceptEvent(window, event) &&
+ EventLocationInsideBounds(window, event)) ||
+ HasIndependentChildWithEvent(window, event.location(), true);
}
Window* WindowTargeter::FindTargetForKeyEvent(Window* window,
« ui/aura/window_targeter.h ('K') | « ui/aura/window_targeter.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698