| 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 297 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 308 PaintRestoredClientEdge(canvas); | 308 PaintRestoredClientEdge(canvas); |
| 309 } | 309 } |
| 310 | 310 |
| 311 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { | 311 bool OpaqueBrowserFrameView::HitTestRect(const gfx::Rect& rect) const { |
| 312 if (!views::View::HitTestRect(rect)) { | 312 if (!views::View::HitTestRect(rect)) { |
| 313 // |rect| is outside OpaqueBrowserFrameView's bounds. | 313 // |rect| is outside OpaqueBrowserFrameView's bounds. |
| 314 return false; | 314 return false; |
| 315 } | 315 } |
| 316 | 316 |
| 317 // If the rect is outside the bounds of the client area, claim it. | 317 // If the rect is outside the bounds of the client area, claim it. |
| 318 // TODO(tdanderson): Implement View::ConvertRectToTarget(). | 318 gfx::Rect rect_in_client_view_coords(rect); |
| 319 gfx::Point rect_in_client_view_coords_origin(rect.origin()); | 319 View::ConvertRectToTarget(this, frame()->client_view(), |
| 320 View::ConvertPointToTarget(this, frame()->client_view(), | 320 &rect_in_client_view_coords); |
| 321 &rect_in_client_view_coords_origin); | |
| 322 gfx::Rect rect_in_client_view_coords( | |
| 323 rect_in_client_view_coords_origin, rect.size()); | |
| 324 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) | 321 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) |
| 325 return true; | 322 return true; |
| 326 | 323 |
| 327 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in | 324 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
| 328 // a non-tab portion. | 325 // a non-tab portion. |
| 329 TabStrip* tabstrip = browser_view()->tabstrip(); | 326 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 330 if (!tabstrip || !browser_view()->IsTabStripVisible()) | 327 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
| 331 return false; | 328 return false; |
| 332 | 329 |
| 333 gfx::Point rect_in_tabstrip_coords_origin(rect.origin()); | 330 gfx::Rect rect_in_tabstrip_coords(rect); |
| 334 View::ConvertPointToTarget(this, tabstrip, | 331 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords); |
| 335 &rect_in_tabstrip_coords_origin); | |
| 336 gfx::Rect rect_in_tabstrip_coords( | |
| 337 rect_in_tabstrip_coords_origin, rect.size()); | |
| 338 | |
| 339 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { | 332 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { |
| 340 // |rect| is below the tabstrip. | 333 // |rect| is below the tabstrip. |
| 341 return false; | 334 return false; |
| 342 } | 335 } |
| 343 | 336 |
| 344 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | 337 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
| 345 // Claim |rect| if it is in a non-tab portion of the tabstrip. | 338 // Claim |rect| if it is in a non-tab portion of the tabstrip. |
| 346 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center | 339 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); |
| 347 // point to TabStrip::IsPositionInWindowCaption() once | |
| 348 // GetEventHandlerForRect() is implemented. | |
| 349 return tabstrip->IsPositionInWindowCaption( | |
| 350 rect_in_tabstrip_coords.CenterPoint()); | |
| 351 } | 340 } |
| 352 | 341 |
| 353 // The window switcher button is to the right of the tabstrip but is | 342 // The window switcher button is to the right of the tabstrip but is |
| 354 // part of the client view. | 343 // part of the client view. |
| 355 views::View* window_switcher_button = | 344 views::View* window_switcher_button = |
| 356 browser_view()->window_switcher_button(); | 345 browser_view()->window_switcher_button(); |
| 357 if (window_switcher_button && window_switcher_button->visible()) { | 346 if (window_switcher_button && window_switcher_button->visible()) { |
| 358 gfx::Point rect_in_window_switcher_coords_origin(rect.origin()); | 347 gfx::Rect rect_in_window_switcher_coords(rect); |
| 359 View::ConvertPointToTarget(this, window_switcher_button, | 348 View::ConvertRectToTarget(this, window_switcher_button, |
| 360 &rect_in_window_switcher_coords_origin); | 349 &rect_in_window_switcher_coords); |
| 361 gfx::Rect rect_in_window_switcher_coords( | |
| 362 rect_in_window_switcher_coords_origin, rect.size()); | |
| 363 | 350 |
| 364 if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords)) | 351 if (window_switcher_button->HitTestRect(rect_in_window_switcher_coords)) |
| 365 return false; | 352 return false; |
| 366 } | 353 } |
| 367 | 354 |
| 368 // We claim |rect| because it is above the bottom of the tabstrip, but | 355 // We claim |rect| because it is above the bottom of the tabstrip, but |
| 369 // neither in the tabstrip nor in the window switcher button. In particular, | 356 // neither in the tabstrip nor in the window switcher button. In particular, |
| 370 // the avatar label/button is left of the tabstrip and the window controls | 357 // the avatar label/button is left of the tabstrip and the window controls |
| 371 // are right of the tabstrip. | 358 // are right of the tabstrip. |
| 372 return true; | 359 return true; |
| (...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 860 | 847 |
| 861 int OpaqueBrowserFrameView::GetTopAreaHeight() const { | 848 int OpaqueBrowserFrameView::GetTopAreaHeight() const { |
| 862 gfx::ImageSkia* frame_image = GetFrameImage(); | 849 gfx::ImageSkia* frame_image = GetFrameImage(); |
| 863 int top_area_height = frame_image->height(); | 850 int top_area_height = frame_image->height(); |
| 864 if (browser_view()->IsTabStripVisible()) { | 851 if (browser_view()->IsTabStripVisible()) { |
| 865 top_area_height = std::max(top_area_height, | 852 top_area_height = std::max(top_area_height, |
| 866 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); | 853 GetBoundsForTabStrip(browser_view()->tabstrip()).bottom()); |
| 867 } | 854 } |
| 868 return top_area_height; | 855 return top_area_height; |
| 869 } | 856 } |
| OLD | NEW |