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 if (!frame()->client_view()->HitTestRect(rect)) |
448 return false; | 448 return true; |
449 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 449 |
450 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | 450 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
451 View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin); | 451 // a non-tab portion. |
452 tabstrip_bounds.set_origin(tabstrip_origin); | 452 TabStrip* tabstrip = browser_view()->tabstrip(); |
453 if (rect.bottom() > tabstrip_bounds.bottom()) | 453 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
454 return false; | 454 return false; |
455 | 455 |
456 // We convert from our parent's coordinates since we assume we fill its bounds | 456 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, | 457 View::ConvertPointToTarget(this, tabstrip, |
458 // meaning ConvertPointToTarget would otherwise return something bogus. | 458 &rect_in_tabstrip_coords_origin); |
459 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of | 459 gfx::Rect rect_in_tabstrip_coords( |
460 // its center point once GetEventHandlerForRect() is implemented. | 460 rect_in_tabstrip_coords_origin, rect.size()); |
461 gfx::Point browser_view_point(rect.CenterPoint()); | 461 |
462 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point); | 462 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
463 return browser_view()->IsPositionInWindowCaption(browser_view_point); | 463 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center |
464 // point to TabStrip::IsPositionInWindowCaption() once | |
465 // GetEventHandlerForRect() is implemented. | |
466 return tabstrip->IsPositionInWindowCaption( | |
467 rect_in_tabstrip_coords.CenterPoint()); | |
468 } | |
469 | |
470 // The window switcher button is in the client view. | |
471 views::View* window_switcher_button = | |
472 browser_view()->window_switcher_button(); | |
James Cook
2013/07/17 21:44:34
Does anything with the window switcher button need
pkotwicz
2013/07/18 14:38:29
GlassBrowserFrameView does not need to worry about
| |
473 if (window_switcher_button) { | |
474 gfx::Point rect_in_window_switcher_coords_origin(rect.origin()); | |
475 View::ConvertPointToTarget(this, window_switcher_button, | |
476 &rect_in_window_switcher_coords_origin); | |
477 gfx::Rect rect_in_window_switcher_coords( | |
478 rect_in_window_switcher_coords_origin, rect.size()); | |
479 | |
480 if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords)) | |
481 return false; | |
482 } | |
483 | |
484 // Claim |rect| if is to the left or right of the tab strip. In | |
485 // particular, the window controls and the avatar label/button are there. | |
486 return rect_in_tabstrip_coords.bottom() <= | |
James Cook
2013/07/17 21:44:34
Again, maybe the comment could be clearer?
| |
487 tabstrip->GetLocalBounds().bottom(); | |
464 } | 488 } |
465 | 489 |
466 void OpaqueBrowserFrameView::GetAccessibleState( | 490 void OpaqueBrowserFrameView::GetAccessibleState( |
467 ui::AccessibleViewState* state) { | 491 ui::AccessibleViewState* state) { |
468 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; | 492 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; |
469 } | 493 } |
470 | 494 |
471 /////////////////////////////////////////////////////////////////////////////// | 495 /////////////////////////////////////////////////////////////////////////////// |
472 // OpaqueBrowserFrameView, views::ButtonListener implementation: | 496 // OpaqueBrowserFrameView, views::ButtonListener implementation: |
473 | 497 |
(...skipping 578 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1052 | 1076 |
1053 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, | 1077 gfx::Rect OpaqueBrowserFrameView::CalculateClientAreaBounds(int width, |
1054 int height) const { | 1078 int height) const { |
1055 int top_height = NonClientTopBorderHeight(false); | 1079 int top_height = NonClientTopBorderHeight(false); |
1056 int border_thickness = NonClientBorderThickness(); | 1080 int border_thickness = NonClientBorderThickness(); |
1057 return gfx::Rect(border_thickness, top_height, | 1081 return gfx::Rect(border_thickness, top_height, |
1058 std::max(0, width - (2 * border_thickness)), | 1082 std::max(0, width - (2 * border_thickness)), |
1059 std::max(0, height - GetReservedHeight() - | 1083 std::max(0, height - GetReservedHeight() - |
1060 top_height - border_thickness)); | 1084 top_height - border_thickness)); |
1061 } | 1085 } |
OLD | NEW |