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

Side by Side Diff: ash/wm/resize_handle_window_targeter.cc

Issue 1119423003: Refactors away method implementations in ui::EventTargeter (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Refactors ui::EventTargeter (rebased) Created 5 years, 6 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 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 "ash/wm/resize_handle_window_targeter.h" 5 #include "ash/wm/resize_handle_window_targeter.h"
6 6
7 #include "ash/ash_constants.h" 7 #include "ash/ash_constants.h"
8 #include "ash/wm/immersive_fullscreen_controller.h" 8 #include "ash/wm/immersive_fullscreen_controller.h"
9 #include "ash/wm/window_state.h" 9 #include "ash/wm/window_state.h"
10 #include "ui/aura/window.h" 10 #include "ui/aura/window.h"
11 #include "ui/events/event.h"
11 12
12 namespace ash { 13 namespace ash {
13 14
14 ResizeHandleWindowTargeter::ResizeHandleWindowTargeter( 15 ResizeHandleWindowTargeter::ResizeHandleWindowTargeter(
15 aura::Window* window, 16 aura::Window* window,
16 ImmersiveFullscreenController* controller) 17 ImmersiveFullscreenController* controller)
17 : window_(window), 18 : window_(window),
18 immersive_controller_(controller) { 19 immersive_controller_(controller) {
19 wm::WindowState* window_state = wm::GetWindowState(window_); 20 wm::WindowState* window_state = wm::GetWindowState(window_);
20 OnPostWindowStateTypeChange(window_state, wm::WINDOW_STATE_TYPE_DEFAULT); 21 OnPostWindowStateTypeChange(window_state, wm::WINDOW_STATE_TYPE_DEFAULT);
(...skipping 20 matching lines...) Expand all
41 kResizeInsideBoundsSize); 42 kResizeInsideBoundsSize);
42 } 43 }
43 } 44 }
44 45
45 void ResizeHandleWindowTargeter::OnWindowDestroying(aura::Window* window) { 46 void ResizeHandleWindowTargeter::OnWindowDestroying(aura::Window* window) {
46 CHECK_EQ(window_, window); 47 CHECK_EQ(window_, window);
47 wm::GetWindowState(window_)->RemoveObserver(this); 48 wm::GetWindowState(window_)->RemoveObserver(this);
48 window_ = NULL; 49 window_ = NULL;
49 } 50 }
50 51
51 ui::EventTarget* ResizeHandleWindowTargeter::FindTargetForLocatedEvent( 52 aura::Window* ResizeHandleWindowTargeter::FindTargetForLocatedEvent(
52 ui::EventTarget* root, 53 aura::Window* window,
53 ui::LocatedEvent* event) { 54 ui::LocatedEvent* event) {
54 aura::Window* window = static_cast<aura::Window*>(root);
55 if (window == window_) { 55 if (window == window_) {
56 gfx::Insets insets; 56 gfx::Insets insets;
57 if (immersive_controller_ && immersive_controller_->IsEnabled() && 57 if (immersive_controller_ && immersive_controller_->IsEnabled() &&
58 !immersive_controller_->IsRevealed() && 58 !immersive_controller_->IsRevealed() &&
59 event->IsTouchEvent()) { 59 event->IsTouchEvent()) {
60 // If the window is in immersive fullscreen, and top-of-window views are 60 // If the window is in immersive fullscreen, and top-of-window views are
61 // not revealed, then touch events towards the top of the window 61 // not revealed, then touch events towards the top of the window
62 // should not reach the child window so that touch gestures can be used to 62 // should not reach the child window so that touch gestures can be used to
63 // reveal the top-of-windows views. This is needed because the child 63 // reveal the top-of-windows views. This is needed because the child
64 // window may consume touch events and prevent touch-scroll gesture from 64 // window may consume touch events and prevent touch-scroll gesture from
65 // being generated. 65 // being generated.
66 insets = gfx::Insets(kImmersiveFullscreenTopEdgeInset, 0, 0, 0); 66 insets = gfx::Insets(kImmersiveFullscreenTopEdgeInset, 0, 0, 0);
67 } else { 67 } else {
68 // If the event falls very close to the inside of the frame border, then 68 // If the event falls very close to the inside of the frame border, then
69 // target the window itself, so that the window can be resized easily. 69 // target the window itself, so that the window can be resized easily.
70 insets = frame_border_inset_; 70 insets = frame_border_inset_;
71 } 71 }
72 72
73 if (!insets.empty()) { 73 if (!insets.empty()) {
74 gfx::Rect bounds = gfx::Rect(window_->bounds().size()); 74 gfx::Rect bounds = gfx::Rect(window_->bounds().size());
75 bounds.Inset(insets); 75 bounds.Inset(insets);
76 if (!bounds.Contains(event->location())) 76 if (!bounds.Contains(event->location()))
77 return window_; 77 return window_;
78 } 78 }
79 } 79 }
80 return aura::WindowTargeter::FindTargetForLocatedEvent(root, event); 80 return aura::WindowTargeter::FindTargetForLocatedEvent(window, event);
81 } 81 }
82 82
83 bool ResizeHandleWindowTargeter::SubtreeShouldBeExploredForEvent( 83 bool ResizeHandleWindowTargeter::SubtreeShouldBeExploredForEvent(
84 ui::EventTarget* target, 84 aura::Window* window,
85 const ui::LocatedEvent& event) { 85 const ui::LocatedEvent& event) {
86 if (target == window_) { 86 if (window == window_) {
87 // Defer to the parent's targeter on whether |window_| should be able to 87 // Defer to the parent's targeter on whether |window_| should be able to
88 // receive the event. 88 // receive the event.
89 ui::EventTarget* parent = target->GetParentTarget(); 89 ui::EventTarget* parent =
90 static_cast<ui::EventTarget*>(window)->GetParentTarget();
90 if (parent) { 91 if (parent) {
91 ui::EventTargeter* targeter = parent->GetEventTargeter(); 92 aura::WindowTargeter* targeter =
93 static_cast<aura::WindowTargeter*>(parent->GetEventTargeter());
92 if (targeter) 94 if (targeter)
93 return targeter->SubtreeShouldBeExploredForEvent(target, event); 95 return targeter->SubtreeShouldBeExploredForEvent(window, event);
94 } 96 }
95 } 97 }
96 return aura::WindowTargeter::SubtreeShouldBeExploredForEvent(target, event); 98 return aura::WindowTargeter::SubtreeShouldBeExploredForEvent(window, event);
97 } 99 }
98 100
99 } // namespace ash 101 } // namespace ash
OLDNEW
« no previous file with comments | « ash/wm/resize_handle_window_targeter.h ('k') | chrome/browser/ui/views/apps/app_window_easy_resize_window_targeter.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698