OLD | NEW |
---|---|
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/command_line.h" | 10 #include "base/command_line.h" |
(...skipping 420 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
431 } | 431 } |
432 | 432 |
433 void OpaqueBrowserFrameView::Layout() { | 433 void OpaqueBrowserFrameView::Layout() { |
434 LayoutWindowControls(); | 434 LayoutWindowControls(); |
435 LayoutTitleBar(); | 435 LayoutTitleBar(); |
436 LayoutAvatar(); | 436 LayoutAvatar(); |
437 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); | 437 client_view_bounds_ = CalculateClientAreaBounds(width(), height()); |
438 } | 438 } |
439 | 439 |
440 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { | 440 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { |
441 // If |rect| does not intersect the bounds of the client area, claim it. | 441 if (!views::View::HitTestRect(rect)) { |
442 bool in_nonclient = NonClientFrameView::HitTestRect(rect); | 442 // |rect| is outside OpaqueBrowserFrameView's bounds. |
443 if (in_nonclient) | 443 return false; |
444 return in_nonclient; | 444 } |
445 | 445 |
446 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. | 446 // If the rect is outside the bounds of the client area, claim it. |
447 if (!browser_view()->tabstrip()) | 447 gfx::Point rect_in_client_view_coords_origin(rect.origin()); |
448 return false; | 448 View::ConvertPointToTarget(this, frame()->client_view(), |
tdanderson
2013/07/18 20:47:04
Please add a "TODO(tdanderson): Update this once C
| |
449 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 449 &rect_in_client_view_coords_origin); |
450 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 450 gfx::Rect rect_in_client_view_coords( |
451 View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin); | 451 rect_in_client_view_coords_origin, rect.size()); |
452 tabstrip_bounds.set_origin(tabstrip_origin); | 452 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) |
pkotwicz
2013/07/18 14:38:29
I fixed this from the pervious patch set. In the p
James Cook
2013/07/18 18:39:45
Agreed that ConvertRectToTarget both sounds like a
| |
453 if (rect.bottom() > tabstrip_bounds.bottom()) | 453 return true; |
454 | |
455 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in | |
456 // a non-tab portion. | |
457 TabStrip* tabstrip = browser_view()->tabstrip(); | |
458 if (!tabstrip || !browser_view()->IsTabStripVisible()) | |
454 return false; | 459 return false; |
455 | 460 |
456 // We convert from our parent's coordinates since we assume we fill its bounds | 461 gfx::Point rect_in_tabstrip_coords_origin(rect.origin()); |
457 // completely. We need to do this since we're not a parent of the tabstrip, | 462 View::ConvertPointToTarget(this, tabstrip, |
tdanderson
2013/07/18 20:47:04
Also add a TODO for me here.
| |
458 // meaning ConvertPointToTarget would otherwise return something bogus. | 463 &rect_in_tabstrip_coords_origin); |
459 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of | 464 gfx::Rect rect_in_tabstrip_coords( |
460 // its center point once GetEventHandlerForRect() is implemented. | 465 rect_in_tabstrip_coords_origin, rect.size()); |
461 gfx::Point browser_view_point(rect.CenterPoint()); | 466 |
462 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point); | 467 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { |
463 return browser_view()->IsPositionInWindowCaption(browser_view_point); | 468 // |rect| is below the tabstrip. |
469 return false; | |
tdanderson
2013/07/18 20:47:04
Have you tested that this return is hit at the rig
| |
470 } | |
471 | |
472 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | |
473 // Claim |rect| if it is in a non-tab portion of the tabstrip. | |
474 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center | |
475 // point to TabStrip::IsPositionInWindowCaption() once | |
476 // GetEventHandlerForRect() is implemented. | |
477 return tabstrip->IsPositionInWindowCaption( | |
478 rect_in_tabstrip_coords.CenterPoint()); | |
479 } | |
480 | |
481 // The window switcher button is to the right of the tabstrip but is | |
482 // part of the client view. | |
483 views::View* window_switcher_button = | |
484 browser_view()->window_switcher_button(); | |
485 if (window_switcher_button && window_switcher_button->visible()) { | |
486 gfx::Point rect_in_window_switcher_coords_origin(rect.origin()); | |
487 View::ConvertPointToTarget(this, window_switcher_button, | |
tdanderson
2013/07/18 20:47:04
Also add a TODO for me here.
| |
488 &rect_in_window_switcher_coords_origin); | |
489 gfx::Rect rect_in_window_switcher_coords( | |
490 rect_in_window_switcher_coords_origin, rect.size()); | |
491 | |
492 if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords)) | |
493 return false; | |
494 } | |
495 | |
496 // We claim |rect| because it is above the bottom of the tabstrip, but | |
497 // neither in the tabstrip nor in the window switcher button. In particular, | |
498 // the avatar label/button is left of the tabstrip and the window controls | |
499 // are right of the tabstrip. | |
500 return true; | |
464 } | 501 } |
465 | 502 |
466 void OpaqueBrowserFrameView::GetAccessibleState( | 503 void OpaqueBrowserFrameView::GetAccessibleState( |
467 ui::AccessibleViewState* state) { | 504 ui::AccessibleViewState* state) { |
468 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; | 505 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; |
469 } | 506 } |
470 | 507 |
471 /////////////////////////////////////////////////////////////////////////////// | 508 /////////////////////////////////////////////////////////////////////////////// |
472 // OpaqueBrowserFrameView, views::ButtonListener implementation: | 509 // OpaqueBrowserFrameView, views::ButtonListener implementation: |
473 | 510 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 | 1089 |
1053 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1090 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
1054 int height) const { | 1091 int height) const { |
1055 int top_height = NonClientTopBorderHeight(false); | 1092 int top_height = NonClientTopBorderHeight(false); |
1056 int border_thickness = NonClientBorderThickness(); | 1093 int border_thickness = NonClientBorderThickness(); |
1057 return gfx::Rect(border_thickness, top_height, | 1094 return gfx::Rect(border_thickness, top_height, |
1058 std::max(0, width - (2 * border_thickness)), | 1095 std::max(0, width - (2 * border_thickness)), |
1059 std::max(0, height - GetReservedHeight() - | 1096 std::max(0, height - GetReservedHeight() - |
1060 top_height - border_thickness)); | 1097 top_height - border_thickness)); |
1061 } | 1098 } |
OLD | NEW |