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

Side by Side Diff: chrome/browser/ui/views/frame/opaque_browser_frame_view.cc

Issue 1780333006: Check for null |tabstrip_| in BrowserView::IsTabStripVisible() (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: DoesIntersectRect() implementations Created 4 years, 9 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) 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 466 matching lines...) Expand 10 before | Expand all | Expand 10 after
477 477
478 // views::NonClientFrameView: 478 // views::NonClientFrameView:
479 bool OpaqueBrowserFrameView::DoesIntersectRect(const views::View* target, 479 bool OpaqueBrowserFrameView::DoesIntersectRect(const views::View* target,
480 const gfx::Rect& rect) const { 480 const gfx::Rect& rect) const {
481 CHECK_EQ(target, this); 481 CHECK_EQ(target, this);
482 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { 482 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) {
483 // |rect| is outside OpaqueBrowserFrameView's bounds. 483 // |rect| is outside OpaqueBrowserFrameView's bounds.
484 return false; 484 return false;
485 } 485 }
486 486
487 // If the rect is outside the bounds of the client area, claim it. 487 // If the rect is outside the bounds of the client area, claim it.
tdanderson 2016/03/14 20:38:33 Lines 487-497 differ from Ash/Mus. Would removing
Peter Kasting 2016/03/14 23:04:42 I doubt it. I think the difference may be that th
tdanderson 2016/03/15 15:51:42 Ah, OK. It is true that the Ash/Mus frames do not
488 gfx::RectF rect_in_client_view_coords_f(rect); 488 gfx::RectF rect_in_client_view_coords_f(rect);
489 View::ConvertRectToTarget(this, frame()->client_view(), 489 View::ConvertRectToTarget(this, frame()->client_view(),
490 &rect_in_client_view_coords_f); 490 &rect_in_client_view_coords_f);
491 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect( 491 gfx::Rect rect_in_client_view_coords = gfx::ToEnclosingRect(
492 rect_in_client_view_coords_f); 492 rect_in_client_view_coords_f);
493 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) 493 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords))
494 return true; 494 return true;
495 495
496 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in 496 if (!browser_view()->IsTabStripVisible())
497 // a non-tab portion.
498 TabStrip* tabstrip = browser_view()->tabstrip();
499 if (!tabstrip || !browser_view()->IsTabStripVisible())
500 return false; 497 return false;
501 498
499 // Claim |rect| only if it is above the bottom of the tabstrip in a non-tab
500 // portion. In particular, the avatar label/button is left of the tabstrip and
501 // the window controls are right of the tabstrip.
502 TabStrip* tabstrip = browser_view()->tabstrip();
502 gfx::RectF rect_in_tabstrip_coords_f(rect); 503 gfx::RectF rect_in_tabstrip_coords_f(rect);
503 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); 504 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f);
504 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect( 505 const gfx::Rect rect_in_tabstrip_coords =
505 rect_in_tabstrip_coords_f); 506 gfx::ToEnclosingRect(rect_in_tabstrip_coords_f);
506 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { 507 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) {
tdanderson 2016/03/14 20:38:33 This is different than the corresponding check per
Peter Kasting 2016/03/14 23:04:42 I agree.
tdanderson 2016/03/15 15:51:43 Can address as follow-up.
507 // |rect| is below the tabstrip. 508 // |rect| is below the tabstrip.
508 return false; 509 return false;
509 } 510 }
510 511
511 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { 512 return !tabstrip->HitTestRect(rect_in_tabstrip_coords) ||
512 // Claim |rect| if it is in a non-tab portion of the tabstrip. 513 tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords);
513 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords);
514 }
515
516 // We claim |rect| because it is above the bottom of the tabstrip, but
517 // not in the tabstrip itself. In particular, the avatar label/button is left
518 // of the tabstrip and the window controls are right of the tabstrip.
519 return true;
520 } 514 }
tdanderson 2016/03/14 20:38:33 GlassBFV::DoesIntersectRect() looks very different
Peter Kasting 2016/03/14 23:04:42 I don't know. Maybe. I think I'd want to verify
tdanderson 2016/03/15 15:51:42 OK, I'll leave that alone then.
521 515
522 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton( 516 views::ImageButton* OpaqueBrowserFrameView::InitWindowCaptionButton(
523 int normal_image_id, 517 int normal_image_id,
524 int hot_image_id, 518 int hot_image_id,
525 int pushed_image_id, 519 int pushed_image_id,
526 int mask_image_id, 520 int mask_image_id,
527 int accessibility_string_id, 521 int accessibility_string_id,
528 ViewID view_id) { 522 ViewID view_id) {
529 views::ImageButton* button = new views::ImageButton(this); 523 views::ImageButton* button = new views::ImageButton(this);
530 const ui::ThemeProvider* tp = frame()->GetThemeProvider(); 524 const ui::ThemeProvider* tp = frame()->GetThemeProvider();
(...skipping 298 matching lines...) Expand 10 before | Expand all | Expand 10 after
829 gfx::Rect side(x, y, kClientEdgeThickness, h); 823 gfx::Rect side(x, y, kClientEdgeThickness, h);
830 canvas->FillRect(side, color); 824 canvas->FillRect(side, color);
831 if (draw_bottom) { 825 if (draw_bottom) {
832 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness), 826 canvas->FillRect(gfx::Rect(x, y + h, w + (2 * kClientEdgeThickness),
833 kClientEdgeThickness), 827 kClientEdgeThickness),
834 color); 828 color);
835 } 829 }
836 side.Offset(w + kClientEdgeThickness, 0); 830 side.Offset(w + kClientEdgeThickness, 0);
837 canvas->FillRect(side, color); 831 canvas->FillRect(side, color);
838 } 832 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698