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

Side by Side Diff: ui/views/window/non_client_view.cc

Issue 403963002: Remove remaining overrides of View::GetEventHandlerForRect() (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 5 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 | Annotate | Revision Log
« no previous file with comments | « ui/views/window/non_client_view.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2012 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/views/window/non_client_view.h" 5 #include "ui/views/window/non_client_view.h"
6 6
7 #include "ui/accessibility/ax_view_state.h" 7 #include "ui/accessibility/ax_view_state.h"
8 #include "ui/base/hit_test.h" 8 #include "ui/base/hit_test.h"
9 #include "ui/gfx/rect_conversions.h" 9 #include "ui/gfx/rect_conversions.h"
10 #include "ui/views/rect_based_targeting_utils.h" 10 #include "ui/views/rect_based_targeting_utils.h"
(...skipping 18 matching lines...) Expand all
29 static const int kFrameViewIndex = 0; 29 static const int kFrameViewIndex = 0;
30 static const int kClientViewIndex = 1; 30 static const int kClientViewIndex = 1;
31 // The overlay view is always on top (index == child_count() - 1). 31 // The overlay view is always on top (index == child_count() - 1).
32 32
33 //////////////////////////////////////////////////////////////////////////////// 33 ////////////////////////////////////////////////////////////////////////////////
34 // NonClientView, public: 34 // NonClientView, public:
35 35
36 NonClientView::NonClientView() 36 NonClientView::NonClientView()
37 : client_view_(NULL), 37 : client_view_(NULL),
38 overlay_view_(NULL) { 38 overlay_view_(NULL) {
39 SetEventTargeter(
40 scoped_ptr<views::ViewTargeter>(new views::ViewTargeter(this)));
39 } 41 }
40 42
41 NonClientView::~NonClientView() { 43 NonClientView::~NonClientView() {
42 // This value may have been reset before the window hierarchy shuts down, 44 // This value may have been reset before the window hierarchy shuts down,
43 // so we need to manually remove it. 45 // so we need to manually remove it.
44 RemoveChildView(frame_view_.get()); 46 RemoveChildView(frame_view_.get());
45 } 47 }
46 48
47 void NonClientView::SetFrameView(NonClientFrameView* frame_view) { 49 void NonClientView::SetFrameView(NonClientFrameView* frame_view) {
48 // See comment in header about ownership. 50 // See comment in header about ownership.
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
180 182
181 void NonClientView::GetAccessibleState(ui::AXViewState* state) { 183 void NonClientView::GetAccessibleState(ui::AXViewState* state) {
182 state->role = ui::AX_ROLE_CLIENT; 184 state->role = ui::AX_ROLE_CLIENT;
183 state->name = accessible_name_; 185 state->name = accessible_name_;
184 } 186 }
185 187
186 const char* NonClientView::GetClassName() const { 188 const char* NonClientView::GetClassName() const {
187 return kViewClassName; 189 return kViewClassName;
188 } 190 }
189 191
190 View* NonClientView::GetEventHandlerForRect(const gfx::Rect& rect) { 192 View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) {
193 // The same logic as for |TargetForRect()| applies here.
194 if (frame_view_->parent() == this) {
195 // During the reset of the frame_view_ it's possible to be in this code
196 // after it's been removed from the view hierarchy but before it's been
197 // removed from the NonClientView.
198 gfx::Point point_in_child_coords(point);
199 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords);
200 View* handler =
201 frame_view_->GetTooltipHandlerForPoint(point_in_child_coords);
202 if (handler)
203 return handler;
204 }
205
206 return View::GetTooltipHandlerForPoint(point);
207 }
208
209 View* NonClientView::TargetForRect(View* root, const gfx::Rect& rect) {
210 CHECK_EQ(root, this);
211
191 if (!UsePointBasedTargeting(rect)) 212 if (!UsePointBasedTargeting(rect))
192 return View::GetEventHandlerForRect(rect); 213 return ViewTargeterDelegate::TargetForRect(root, rect);
193 214
194 // Because of the z-ordering of our child views (the client view is positioned 215 // Because of the z-ordering of our child views (the client view is positioned
195 // over the non-client frame view, if the client view ever overlaps the frame 216 // over the non-client frame view, if the client view ever overlaps the frame
196 // view visually (as it does for the browser window), then it will eat 217 // view visually (as it does for the browser window), then it will eat
197 // events for the window controls. We override this method here so that we can 218 // events for the window controls. We override this method here so that we can
198 // detect this condition and re-route the events to the non-client frame view. 219 // detect this condition and re-route the events to the non-client frame view.
199 // The assumption is that the frame view's implementation of HitTest will only 220 // The assumption is that the frame view's implementation of HitTest will only
200 // return true for area not occupied by the client view. 221 // return true for area not occupied by the client view.
201 if (frame_view_->parent() == this) { 222 if (frame_view_->parent() == this) {
202 // During the reset of the frame_view_ it's possible to be in this code 223 // During the reset of the frame_view_ it's possible to be in this code
203 // after it's been removed from the view hierarchy but before it's been 224 // after it's been removed from the view hierarchy but before it's been
204 // removed from the NonClientView. 225 // removed from the NonClientView.
205 gfx::RectF rect_in_child_coords_f(rect); 226 gfx::RectF rect_in_child_coords_f(rect);
206 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords_f); 227 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords_f);
207 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect( 228 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect(
208 rect_in_child_coords_f); 229 rect_in_child_coords_f);
209 if (frame_view_->HitTestRect(rect_in_child_coords)) 230 if (frame_view_->HitTestRect(rect_in_child_coords))
210 return frame_view_->GetEventHandlerForRect(rect_in_child_coords); 231 return frame_view_->GetEventHandlerForRect(rect_in_child_coords);
211 } 232 }
212 233
213 return View::GetEventHandlerForRect(rect); 234 return ViewTargeterDelegate::TargetForRect(root, rect);
214 }
215
216 View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) {
217 // The same logic as for |GetEventHandlerForRect()| applies here.
218 if (frame_view_->parent() == this) {
219 // During the reset of the frame_view_ it's possible to be in this code
220 // after it's been removed from the view hierarchy but before it's been
221 // removed from the NonClientView.
222 gfx::Point point_in_child_coords(point);
223 View::ConvertPointToTarget(this, frame_view_.get(), &point_in_child_coords);
224 View* handler =
225 frame_view_->GetTooltipHandlerForPoint(point_in_child_coords);
226 if (handler)
227 return handler;
228 }
229
230 return View::GetTooltipHandlerForPoint(point);
231 } 235 }
232 236
233 //////////////////////////////////////////////////////////////////////////////// 237 ////////////////////////////////////////////////////////////////////////////////
234 // NonClientFrameView, public: 238 // NonClientFrameView, public:
235 239
236 NonClientFrameView::~NonClientFrameView() { 240 NonClientFrameView::~NonClientFrameView() {
237 } 241 }
238 242
239 void NonClientFrameView::SetInactiveRenderingDisabled(bool disable) { 243 void NonClientFrameView::SetInactiveRenderingDisabled(bool disable) {
240 if (inactive_rendering_disabled_ == disable) 244 if (inactive_rendering_disabled_ == disable)
(...skipping 85 matching lines...) Expand 10 before | Expand all | Expand 10 after
326 bool NonClientFrameView::DoesIntersectRect(const View* target, 330 bool NonClientFrameView::DoesIntersectRect(const View* target,
327 const gfx::Rect& rect) const { 331 const gfx::Rect& rect) const {
328 CHECK_EQ(target, this); 332 CHECK_EQ(target, this);
329 333
330 // For the default case, we assume the non-client frame view never overlaps 334 // For the default case, we assume the non-client frame view never overlaps
331 // the client view. 335 // the client view.
332 return !GetWidget()->client_view()->bounds().Intersects(rect); 336 return !GetWidget()->client_view()->bounds().Intersects(rect);
333 } 337 }
334 338
335 } // namespace views 339 } // namespace views
OLDNEW
« no previous file with comments | « ui/views/window/non_client_view.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698