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

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

Issue 265713007: views: Update event-related API to use PointF/RectF instead of Point/Rect. Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Created 6 years, 7 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
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 168 matching lines...) Expand 10 before | Expand all | Expand 10 after
179 179
180 void NonClientView::GetAccessibleState(ui::AXViewState* state) { 180 void NonClientView::GetAccessibleState(ui::AXViewState* state) {
181 state->role = ui::AX_ROLE_CLIENT; 181 state->role = ui::AX_ROLE_CLIENT;
182 state->name = accessible_name_; 182 state->name = accessible_name_;
183 } 183 }
184 184
185 const char* NonClientView::GetClassName() const { 185 const char* NonClientView::GetClassName() const {
186 return kViewClassName; 186 return kViewClassName;
187 } 187 }
188 188
189 View* NonClientView::GetEventHandlerForRect(const gfx::Rect& rect) { 189 View* NonClientView::GetEventHandlerForRect(const gfx::RectF& rect) {
190 if (!UsePointBasedTargeting(rect)) 190 if (!UsePointBasedTargeting(rect))
191 return View::GetEventHandlerForRect(rect); 191 return View::GetEventHandlerForRect(rect);
192 192
193 // Because of the z-ordering of our child views (the client view is positioned 193 // Because of the z-ordering of our child views (the client view is positioned
194 // over the non-client frame view, if the client view ever overlaps the frame 194 // over the non-client frame view, if the client view ever overlaps the frame
195 // view visually (as it does for the browser window), then it will eat 195 // view visually (as it does for the browser window), then it will eat
196 // events for the window controls. We override this method here so that we can 196 // events for the window controls. We override this method here so that we can
197 // detect this condition and re-route the events to the non-client frame view. 197 // detect this condition and re-route the events to the non-client frame view.
198 // The assumption is that the frame view's implementation of HitTest will only 198 // The assumption is that the frame view's implementation of HitTest will only
199 // return true for area not occupied by the client view. 199 // return true for area not occupied by the client view.
200 if (frame_view_->parent() == this) { 200 if (frame_view_->parent() == this) {
201 // During the reset of the frame_view_ it's possible to be in this code 201 // During the reset of the frame_view_ it's possible to be in this code
202 // after it's been removed from the view hierarchy but before it's been 202 // after it's been removed from the view hierarchy but before it's been
203 // removed from the NonClientView. 203 // removed from the NonClientView.
204 gfx::RectF rect_in_child_coords_f(rect); 204 gfx::RectF rect_in_child_coords(rect);
205 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords_f); 205 View::ConvertRectToTarget(this, frame_view_.get(), &rect_in_child_coords);
206 gfx::Rect rect_in_child_coords = gfx::ToEnclosingRect(
207 rect_in_child_coords_f);
208 if (frame_view_->HitTestRect(rect_in_child_coords)) 206 if (frame_view_->HitTestRect(rect_in_child_coords))
209 return frame_view_->GetEventHandlerForRect(rect_in_child_coords); 207 return frame_view_->GetEventHandlerForRect(rect_in_child_coords);
210 } 208 }
211 209
212 return View::GetEventHandlerForRect(rect); 210 return View::GetEventHandlerForRect(rect);
213 } 211 }
214 212
215 View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) { 213 View* NonClientView::GetTooltipHandlerForPoint(const gfx::Point& point) {
216 // The same logic as for |GetEventHandlerForRect()| applies here. 214 // The same logic as for |GetEventHandlerForRect()| applies here.
217 if (frame_view_->parent() == this) { 215 if (frame_view_->parent() == this) {
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after
296 } 294 }
297 295
298 // If the window can't be resized, there are no resize boundaries, just 296 // If the window can't be resized, there are no resize boundaries, just
299 // window borders. 297 // window borders.
300 return can_resize ? component : HTBORDER; 298 return can_resize ? component : HTBORDER;
301 } 299 }
302 300
303 //////////////////////////////////////////////////////////////////////////////// 301 ////////////////////////////////////////////////////////////////////////////////
304 // NonClientFrameView, View overrides: 302 // NonClientFrameView, View overrides:
305 303
306 bool NonClientFrameView::HitTestRect(const gfx::Rect& rect) const { 304 bool NonClientFrameView::HitTestRect(const gfx::RectF& rect) const {
307 // For the default case, we assume the non-client frame view never overlaps 305 // For the default case, we assume the non-client frame view never overlaps
308 // the client view. 306 // the client view.
309 return !GetWidget()->client_view()->bounds().Intersects(rect); 307 gfx::RectF bounds(GetWidget()->client_view()->bounds());
308 return bounds.Intersects(rect);
310 } 309 }
311 310
312 //////////////////////////////////////////////////////////////////////////////// 311 ////////////////////////////////////////////////////////////////////////////////
313 // NonClientFrameView, protected: 312 // NonClientFrameView, protected:
314 313
315 void NonClientFrameView::GetAccessibleState(ui::AXViewState* state) { 314 void NonClientFrameView::GetAccessibleState(ui::AXViewState* state) {
316 state->role = ui::AX_ROLE_CLIENT; 315 state->role = ui::AX_ROLE_CLIENT;
317 } 316 }
318 317
319 const char* NonClientFrameView::GetClassName() const { 318 const char* NonClientFrameView::GetClassName() const {
320 return kViewClassName; 319 return kViewClassName;
321 } 320 }
322 321
323 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) { 322 void NonClientFrameView::OnBoundsChanged(const gfx::Rect& previous_bounds) {
324 // Overridden to do nothing. The NonClientView manually calls Layout on the 323 // Overridden to do nothing. The NonClientView manually calls Layout on the
325 // FrameView when it is itself laid out, see comment in NonClientView::Layout. 324 // FrameView when it is itself laid out, see comment in NonClientView::Layout.
326 } 325 }
327 326
328 NonClientFrameView::NonClientFrameView() : inactive_rendering_disabled_(false) { 327 NonClientFrameView::NonClientFrameView() : inactive_rendering_disabled_(false) {
329 } 328 }
330 329
331 } // namespace views 330 } // namespace views
OLDNEW
« ui/views/rect_based_targeting_utils.cc ('K') | « 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