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

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_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 "chrome/browser/ui/views/frame/opaque_browser_frame_view.h" 5 #include "chrome/browser/ui/views/frame/opaque_browser_frame_view.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <string> 8 #include <string>
9 9
10 #include "base/compiler_specific.h" 10 #include "base/compiler_specific.h"
(...skipping 272 matching lines...) Expand 10 before | Expand all | Expand 10 after
283 } 283 }
284 284
285 void OpaqueBrowserFrameView::UpdateWindowTitle() { 285 void OpaqueBrowserFrameView::UpdateWindowTitle() {
286 if (!frame()->IsFullscreen()) 286 if (!frame()->IsFullscreen())
287 window_title_->SchedulePaint(); 287 window_title_->SchedulePaint();
288 } 288 }
289 289
290 /////////////////////////////////////////////////////////////////////////////// 290 ///////////////////////////////////////////////////////////////////////////////
291 // OpaqueBrowserFrameView, views::View overrides: 291 // OpaqueBrowserFrameView, views::View overrides:
292 292
293 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { 293 bool OpaqueBrowserFrameView::HitTestRect(const gfx::RectF& rect) const {
294 if (!views::View::HitTestRect(rect)) { 294 if (!views::View::HitTestRect(rect)) {
295 // |rect| is outside OpaqueBrowserFrameView's bounds. 295 // |rect| is outside OpaqueBrowserFrameView's bounds.
296 return false; 296 return false;
297 } 297 }
298 298
299 // If the rect is outside the bounds of the client area, claim it. 299 // If the rect is outside the bounds of the client area, claim it.
300 gfx::RectF rect_in_client_view_coords_f(rect); 300 gfx::RectF rect_in_client_view_coords_f(rect);
301 View::ConvertRectToTarget(this, frame()->client_view(), 301 View::ConvertRectToTarget(this, frame()->client_view(),
302 &rect_in_client_view_coords_f); 302 &rect_in_client_view_coords_f);
303 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect( 303 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect(
304 rect_in_client_view_coords_f); 304 rect_in_client_view_coords_f);
305 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) 305 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords))
306 return true; 306 return true;
307 307
308 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in 308 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in
309 // a non-tab portion. 309 // a non-tab portion.
310 TabStrip* tabstrip = browser_view()->tabstrip(); 310 TabStrip* tabstrip = browser_view()->tabstrip();
311 if (!tabstrip || !browser_view()->IsTabStripVisible()) 311 if (!tabstrip || !browser_view()->IsTabStripVisible())
312 return false; 312 return false;
313 313
314 gfx::RectF rect_in_tabstrip_coords_f(rect); 314 gfx::RectF rect_in_tabstrip_coords(rect);
315 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); 315 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords);
316 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect(
317 rect_in_tabstrip_coords_f);
318 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { 316 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) {
319 // |rect| is below the tabstrip. 317 // |rect| is below the tabstrip.
320 return false; 318 return false;
321 } 319 }
322 320
323 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { 321 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) {
324 // Claim |rect| if it is in a non-tab portion of the tabstrip. 322 // Claim |rect| if it is in a non-tab portion of the tabstrip.
325 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); 323 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords);
326 } 324 }
327 325
328 // The window switcher button is to the right of the tabstrip but is 326 // The window switcher button is to the right of the tabstrip but is
329 // part of the client view. 327 // part of the client view.
330 views::View* window_switcher_button = 328 views::View* window_switcher_button =
331 browser_view()->window_switcher_button(); 329 browser_view()->window_switcher_button();
332 if (window_switcher_button && window_switcher_button->visible()) { 330 if (window_switcher_button && window_switcher_button->visible()) {
333 gfx::RectF rect_in_window_switcher_coords_f(rect); 331 gfx::RectF rect_in_window_switcher_coords_f(rect);
tdresser 2014/05/02 13:19:06 |rect_in_window_switcher_coords_f| should probably
334 View::ConvertRectToTarget(this, window_switcher_button, 332 View::ConvertRectToTarget(this, window_switcher_button,
335 &rect_in_window_switcher_coords_f); 333 &rect_in_window_switcher_coords_f);
336 gfx::Rect rect_in_window_switcher_coords = gfx::ToEnclosingRect( 334 if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords_f))
337 rect_in_window_switcher_coords_f);
338
339 if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords))
340 return false; 335 return false;
341 } 336 }
342 337
343 // We claim |rect| because it is above the bottom of the tabstrip, but 338 // We claim |rect| because it is above the bottom of the tabstrip, but
344 // neither in the tabstrip nor in the window switcher button. In particular, 339 // neither in the tabstrip nor in the window switcher button. In particular,
345 // the avatar label/button is left of the tabstrip and the window controls 340 // the avatar label/button is left of the tabstrip and the window controls
346 // are right of the tabstrip. 341 // are right of the tabstrip.
347 return true; 342 return true;
348 } 343 }
349 344
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
921 916
922 int OpaqueBrowserFrameView::GetTopAreaHeight() const { 917 int OpaqueBrowserFrameView::GetTopAreaHeight() const {
923 gfx::ImageSkia* frame_image = GetFrameImage(); 918 gfx::ImageSkia* frame_image = GetFrameImage();
924 int top_area_height = frame_image->height(); 919 int top_area_height = frame_image->height();
925 if (browser_view()->IsTabStripVisible()) { 920 if (browser_view()->IsTabStripVisible()) {
926 top_area_height = std::max(top_area_height, 921 top_area_height = std::max(top_area_height,
927 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); 922 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom());
928 } 923 }
929 return top_area_height; 924 return top_area_height;
930 } 925 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698