| 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/browser_non_client_frame_view_ash.h" | 5 #include "chrome/browser/ui/views/frame/browser_non_client_frame_view_ash.h" |
| 6 | 6 |
| 7 #include "ash/ash_switches.h" | 7 #include "ash/ash_switches.h" |
| 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" | 8 #include "ash/wm/caption_buttons/frame_caption_button_container_view.h" |
| 9 #include "ash/wm/frame_painter.h" | 9 #include "ash/wm/frame_painter.h" |
| 10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 285 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 285 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 286 return kViewClassName; | 286 return kViewClassName; |
| 287 } | 287 } |
| 288 | 288 |
| 289 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { | 289 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { |
| 290 if (!views::View::HitTestRect(rect)) { | 290 if (!views::View::HitTestRect(rect)) { |
| 291 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | 291 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 292 return false; | 292 return false; |
| 293 } | 293 } |
| 294 // If the rect is outside the bounds of the client area, claim it. | 294 // If the rect is outside the bounds of the client area, claim it. |
| 295 // TODO(tdanderson): Implement View::ConvertRectToTarget(). | 295 gfx::Rect rect_in_client_view_coords(rect); |
| 296 gfx::Point rect_in_client_view_coords_origin(rect.origin()); | 296 View::ConvertRectToTarget(this, frame()->client_view(), |
| 297 View::ConvertPointToTarget(this, frame()->client_view(), | 297 &rect_in_client_view_coords); |
| 298 &rect_in_client_view_coords_origin); | |
| 299 gfx::Rect rect_in_client_view_coords( | |
| 300 rect_in_client_view_coords_origin, rect.size()); | |
| 301 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) | 298 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) |
| 302 return true; | 299 return true; |
| 303 | 300 |
| 304 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in | 301 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
| 305 // a non-tab portion. | 302 // a non-tab portion. |
| 306 TabStrip* tabstrip = browser_view()->tabstrip(); | 303 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 307 if (!tabstrip || !browser_view()->IsTabStripVisible()) | 304 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
| 308 return false; | 305 return false; |
| 309 | 306 |
| 310 gfx::Point rect_in_tabstrip_coords_origin(rect.origin()); | 307 gfx::Rect rect_in_tabstrip_coords(rect); |
| 311 View::ConvertPointToTarget(this, tabstrip, | 308 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords); |
| 312 &rect_in_tabstrip_coords_origin); | |
| 313 gfx::Rect rect_in_tabstrip_coords(rect_in_tabstrip_coords_origin, | |
| 314 rect.size()); | |
| 315 | 309 |
| 316 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { | 310 if (rect_in_tabstrip_coords.y() > tabstrip->GetLocalBounds().bottom()) { |
| 317 // |rect| is below the tabstrip. | 311 // |rect| is below the tabstrip. |
| 318 return false; | 312 return false; |
| 319 } | 313 } |
| 320 | 314 |
| 321 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | 315 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
| 322 // Claim |rect| if it is in a non-tab portion of the tabstrip. | 316 // Claim |rect| if it is in a non-tab portion of the tabstrip. |
| 323 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center | 317 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); |
| 324 // point to TabStrip::IsPositionInWindowCaption() once | |
| 325 // GetEventHandlerForRect() is implemented. | |
| 326 return tabstrip->IsPositionInWindowCaption( | |
| 327 rect_in_tabstrip_coords.CenterPoint()); | |
| 328 } | 318 } |
| 329 | 319 |
| 330 // We claim |rect| because it is above the bottom of the tabstrip, but | 320 // We claim |rect| because it is above the bottom of the tabstrip, but |
| 331 // not in the tabstrip. In particular, the window controls are right of | 321 // not in the tabstrip. In particular, the window controls are right of |
| 332 // the tabstrip. | 322 // the tabstrip. |
| 333 return true; | 323 return true; |
| 334 } | 324 } |
| 335 | 325 |
| 336 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 326 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 337 ui::AccessibleViewState* state) { | 327 ui::AccessibleViewState* state) { |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 556 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { | 546 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { |
| 557 ui::ThemeProvider* tp = GetThemeProvider(); | 547 ui::ThemeProvider* tp = GetThemeProvider(); |
| 558 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 548 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 559 browser_view()->IsBrowserTypeNormal() && | 549 browser_view()->IsBrowserTypeNormal() && |
| 560 !browser_view()->IsOffTheRecord()) { | 550 !browser_view()->IsOffTheRecord()) { |
| 561 return ShouldPaintAsActive() ? | 551 return ShouldPaintAsActive() ? |
| 562 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; | 552 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; |
| 563 } | 553 } |
| 564 return 0; | 554 return 0; |
| 565 } | 555 } |
| OLD | NEW |