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