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 // TODO(tdanderson): Implement View::ConvertRectToTarget(). |
448 return false; | 448 gfx::Point rect_in_client_view_coords_origin(rect.origin()); |
449 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 449 View::ConvertPointToTarget(this, frame()->client_view(), |
450 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 450 &rect_in_client_view_coords_origin); |
451 View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin); | 451 gfx::Rect rect_in_client_view_coords( |
452 tabstrip_bounds.set_origin(tabstrip_origin); | 452 rect_in_client_view_coords_origin, rect.size()); |
453 if (rect.bottom() > tabstrip_bounds.bottom()) | 453 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) |
| 454 return true; |
| 455 |
| 456 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
| 457 // a non-tab portion. |
| 458 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 459 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
454 return false; | 460 return false; |
455 | 461 |
456 // We convert from our parent's coordinates since we assume we fill its bounds | 462 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, | 463 View::ConvertPointToTarget(this, tabstrip, |
458 // meaning ConvertPointToTarget would otherwise return something bogus. | 464 &rect_in_tabstrip_coords_origin); |
459 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of | 465 gfx::Rect rect_in_tabstrip_coords( |
460 // its center point once GetEventHandlerForRect() is implemented. | 466 rect_in_tabstrip_coords_origin, rect.size()); |
461 gfx::Point browser_view_point(rect.CenterPoint()); | 467 |
462 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point); | 468 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { |
463 return browser_view()->IsPositionInWindowCaption(browser_view_point); | 469 // |rect| is below the tabstrip. |
| 470 return false; |
| 471 } |
| 472 |
| 473 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
| 474 // Claim |rect| if it is in a non-tab portion of the tabstrip. |
| 475 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center |
| 476 // point to TabStrip::IsPositionInWindowCaption() once |
| 477 // GetEventHandlerForRect() is implemented. |
| 478 return tabstrip->IsPositionInWindowCaption( |
| 479 rect_in_tabstrip_coords.CenterPoint()); |
| 480 } |
| 481 |
| 482 // The window switcher button is to the right of the tabstrip but is |
| 483 // part of the client view. |
| 484 views::View* window_switcher_button = |
| 485 browser_view()->window_switcher_button(); |
| 486 if (window_switcher_button && window_switcher_button->visible()) { |
| 487 gfx::Point rect_in_window_switcher_coords_origin(rect.origin()); |
| 488 View::ConvertPointToTarget(this, window_switcher_button, |
| 489 &rect_in_window_switcher_coords_origin); |
| 490 gfx::Rect rect_in_window_switcher_coords( |
| 491 rect_in_window_switcher_coords_origin, rect.size()); |
| 492 |
| 493 if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords)) |
| 494 return false; |
| 495 } |
| 496 |
| 497 // We claim |rect| because it is above the bottom of the tabstrip, but |
| 498 // neither in the tabstrip nor in the window switcher button. In particular, |
| 499 // the avatar label/button is left of the tabstrip and the window controls |
| 500 // are right of the tabstrip. |
| 501 return true; |
464 } | 502 } |
465 | 503 |
466 void OpaqueBrowserFrameView::GetAccessibleState( | 504 void OpaqueBrowserFrameView::GetAccessibleState( |
467 ui::AccessibleViewState* state) { | 505 ui::AccessibleViewState* state) { |
468 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; | 506 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; |
469 } | 507 } |
470 | 508 |
471 /////////////////////////////////////////////////////////////////////////////// | 509 /////////////////////////////////////////////////////////////////////////////// |
472 // OpaqueBrowserFrameView, views::ButtonListener implementation: | 510 // OpaqueBrowserFrameView, views::ButtonListener implementation: |
473 | 511 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1052 | 1090 |
1053 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1091 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
1054 int height) const { | 1092 int height) const { |
1055 int top_height = NonClientTopBorderHeight(false); | 1093 int top_height = NonClientTopBorderHeight(false); |
1056 int border_thickness = NonClientBorderThickness(); | 1094 int border_thickness = NonClientBorderThickness(); |
1057 return gfx::Rect(border_thickness, top_height, | 1095 return gfx::Rect(border_thickness, top_height, |
1058 std::max(0, width - (2 * border_thickness)), | 1096 std::max(0, width - (2 * border_thickness)), |
1059 std::max(0, height - GetReservedHeight() - | 1097 std::max(0, height - GetReservedHeight() - |
1060 top_height - border_thickness)); | 1098 top_height - border_thickness)); |
1061 } | 1099 } |
OLD | NEW |