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

Side by Side 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: reduced diff 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 unified diff | Download patch
OLDNEW
1 // Copyright (c) 2013 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2013 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #include "ui/aura/window_targeter.h" 5 #include "ui/aura/window_targeter.h"
6 6
7 #include "ui/aura/client/capture_client.h" 7 #include "ui/aura/client/capture_client.h"
8 #include "ui/aura/client/event_client.h" 8 #include "ui/aura/client/event_client.h"
9 #include "ui/aura/client/focus_client.h" 9 #include "ui/aura/client/focus_client.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
52 52
53 bool WindowTargeter::EventLocationInsideBounds( 53 bool WindowTargeter::EventLocationInsideBounds(
54 Window* window, 54 Window* window,
55 const ui::LocatedEvent& event) const { 55 const ui::LocatedEvent& event) const {
56 gfx::Point point = event.location(); 56 gfx::Point point = event.location();
57 if (window->parent()) 57 if (window->parent())
58 Window::ConvertPointToTarget(window->parent(), window, &point); 58 Window::ConvertPointToTarget(window->parent(), window, &point);
59 return gfx::Rect(window->bounds().size()).Contains(point); 59 return gfx::Rect(window->bounds().size()).Contains(point);
60 } 60 }
61 61
62 bool WindowTargeter::EventLocationInsideBoundsRecursive(
63 Window* window,
64 gfx::Point point, gfx::Point location) {
65 Window* parent = window->parent();
66 bool canAccept = true;
67 if (parent){
68 if (parent->delegate_ && !parent->delegate_->
69 ShouldDescendIntoChildForEventHandling(window, location)) {
70 canAccept = false;
71 }
72 Window::ConvertPointToTarget(window->parent(), window, &point);
73 }
74
75 bool inBounds = gfx::Rect(window->bounds().size()).Contains(point);
76 canAccept = canAccept && (window->IsVisible() && !window->ignore_events());
77 client::EventClient* client = client::GetEventClient(window->GetRootWindow());
78 if (client && !client->CanProcessEventsWithinSubtree(window))
79 canAccept = false;
80 if (inBounds && canAccept){
81 return true;
82 }
83 std::unique_ptr<ui::EventTargetIterator> iter =
84 window->GetChildIterator();
85 if (iter) {
86 for (ui::EventTarget* child = iter->GetNextTarget(); child;
87 child = iter->GetNextTarget()) {
88 if (EventLocationInsideBoundsRecursive(static_cast<Window*>(child),
89 point, location))
90 return true;
91 }
92 }
93 return false;
94 }
95
62 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root, 96 ui::EventTarget* WindowTargeter::FindTargetForEvent(ui::EventTarget* root,
63 ui::Event* event) { 97 ui::Event* event) {
64 Window* window = static_cast<Window*>(root); 98 Window* window = static_cast<Window*>(root);
65 Window* target = event->IsKeyEvent() 99 Window* target = event->IsKeyEvent()
66 ? FindTargetForKeyEvent(window, *event->AsKeyEvent()) 100 ? FindTargetForKeyEvent(window, *event->AsKeyEvent())
67 : FindTargetForNonKeyEvent(window, event); 101 : FindTargetForNonKeyEvent(window, event);
68 if (target && !window->parent() && !window->Contains(target)) { 102 if (target && !window->parent() && !window->Contains(target)) {
69 // |window| is the root window, but |target| is not a descendent of 103 // |window| is the root window, but |target| is not a descendent of
70 // |window|. So do not allow dispatching from here. Instead, dispatch the 104 // |window|. So do not allow dispatching from here. Instead, dispatch the
71 // event through the WindowEventDispatcher that owns |target|. 105 // event through the WindowEventDispatcher that owns |target|.
(...skipping 21 matching lines...) Expand all
93 ui::EventTarget* WindowTargeter::FindNextBestTarget( 127 ui::EventTarget* WindowTargeter::FindNextBestTarget(
94 ui::EventTarget* previous_target, 128 ui::EventTarget* previous_target,
95 ui::Event* event) { 129 ui::Event* event) {
96 return nullptr; 130 return nullptr;
97 } 131 }
98 132
99 bool WindowTargeter::SubtreeShouldBeExploredForEvent( 133 bool WindowTargeter::SubtreeShouldBeExploredForEvent(
100 Window* window, 134 Window* window,
101 const ui::LocatedEvent& event) { 135 const ui::LocatedEvent& event) {
102 return SubtreeCanAcceptEvent(window, event) && 136 return SubtreeCanAcceptEvent(window, event) &&
103 EventLocationInsideBounds(window, event); 137 EventLocationInsideBoundsRecursive(window, event.location(),
rbpotter 2016/07/25 18:53:28 Should a flag be added to the aura::Window class t
138 event.location());
104 } 139 }
105 140
106 Window* WindowTargeter::FindTargetForKeyEvent(Window* window, 141 Window* WindowTargeter::FindTargetForKeyEvent(Window* window,
107 const ui::KeyEvent& key) { 142 const ui::KeyEvent& key) {
108 Window* root_window = window->GetRootWindow(); 143 Window* root_window = window->GetRootWindow();
109 client::FocusClient* focus_client = client::GetFocusClient(root_window); 144 client::FocusClient* focus_client = client::GetFocusClient(root_window);
110 Window* focused_window = focus_client->GetFocusedWindow(); 145 Window* focused_window = focus_client->GetFocusedWindow();
111 if (!focused_window) 146 if (!focused_window)
112 return window; 147 return window;
113 148
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
188 static_cast<Window*>(targeter->FindTargetForEvent(child, event)); 223 static_cast<Window*>(targeter->FindTargetForEvent(child, event));
189 if (child_target_window) 224 if (child_target_window)
190 return child_target_window; 225 return child_target_window;
191 } 226 }
192 target->ConvertEventToTarget(root_window, event); 227 target->ConvertEventToTarget(root_window, event);
193 } 228 }
194 return root_window->CanAcceptEvent(*event) ? root_window : nullptr; 229 return root_window->CanAcceptEvent(*event) ? root_window : nullptr;
195 } 230 }
196 231
197 } // namespace aura 232 } // namespace aura
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698