| 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/wm/frame_painter.h" | 7 #include "ash/wm/frame_painter.h" |
| 8 #include "ash/wm/workspace/frame_caption_button_container_view.h" | 8 #include "ash/wm/workspace/frame_caption_button_container_view.h" |
| 9 #include "chrome/browser/themes/theme_properties.h" | 9 #include "chrome/browser/themes/theme_properties.h" |
| 10 #include "chrome/browser/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
| (...skipping 236 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 247 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 247 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 248 return kViewClassName; | 248 return kViewClassName; |
| 249 } | 249 } |
| 250 | 250 |
| 251 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { | 251 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { |
| 252 if (!views::View::HitTestRect(rect)) { | 252 if (!views::View::HitTestRect(rect)) { |
| 253 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | 253 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 254 return false; | 254 return false; |
| 255 } | 255 } |
| 256 // If the rect is outside the bounds of the client area, claim it. | 256 // If the rect is outside the bounds of the client area, claim it. |
| 257 // TODO(tdanderson): Implement View::ConvertRectToTarget(). | 257 gfx::Rect rect_in_client_view_coords(rect); |
| 258 gfx::Point rect_in_client_view_coords_origin(rect.origin()); | 258 View::ConvertRectToTarget(this, frame()->client_view(), |
| 259 View::ConvertPointToTarget(this, frame()->client_view(), | 259 &rect_in_client_view_coords); |
| 260 &rect_in_client_view_coords_origin); | |
| 261 gfx::Rect rect_in_client_view_coords( | |
| 262 rect_in_client_view_coords_origin, rect.size()); | |
| 263 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) | 260 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) |
| 264 return true; | 261 return true; |
| 265 | 262 |
| 266 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in | 263 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
| 267 // a non-tab portion. | 264 // a non-tab portion. |
| 268 TabStrip* tabstrip = browser_view()->tabstrip(); | 265 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 269 if (!tabstrip || !browser_view()->IsTabStripVisible()) | 266 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
| 270 return false; | 267 return false; |
| 271 | 268 |
| 272 gfx::Point rect_in_tabstrip_coords_origin(rect.origin()); | 269 gfx::Rect rect_in_tabstrip_coords(rect); |
| 273 View::ConvertPointToTarget(this, tabstrip, | 270 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords); |
| 274 &rect_in_tabstrip_coords_origin); | |
| 275 gfx::Rect rect_in_tabstrip_coords(rect_in_tabstrip_coords_origin, | |
| 276 rect.size()); | |
| 277 | 271 |
| 278 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { | 272 if (rect_in_tabstrip_coords.y() > tabstrip->GetLocalBounds().bottom()) { |
| 279 // |rect| is below the tabstrip. | 273 // |rect| is below the tabstrip. |
| 280 return false; | 274 return false; |
| 281 } | 275 } |
| 282 | 276 |
| 283 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | 277 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
| 284 // Claim |rect| if it is in a non-tab portion of the tabstrip. | 278 // Claim |rect| if it is in a non-tab portion of the tabstrip. |
| 285 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center | 279 return tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); |
| 286 // point to TabStrip::IsPositionInWindowCaption() once | |
| 287 // GetEventHandlerForRect() is implemented. | |
| 288 return tabstrip->IsPositionInWindowCaption( | |
| 289 rect_in_tabstrip_coords.CenterPoint()); | |
| 290 } | 280 } |
| 291 | 281 |
| 292 // We claim |rect| because it is above the bottom of the tabstrip, but | 282 // We claim |rect| because it is above the bottom of the tabstrip, but |
| 293 // not in the tabstrip. In particular, the window controls are right of | 283 // not in the tabstrip. In particular, the window controls are right of |
| 294 // the tabstrip. | 284 // the tabstrip. |
| 295 return true; | 285 return true; |
| 296 } | 286 } |
| 297 | 287 |
| 298 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 288 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 299 ui::AccessibleViewState* state) { | 289 ui::AccessibleViewState* state) { |
| (...skipping 229 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 529 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { | 519 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { |
| 530 ui::ThemeProvider* tp = GetThemeProvider(); | 520 ui::ThemeProvider* tp = GetThemeProvider(); |
| 531 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 521 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 532 browser_view()->IsBrowserTypeNormal() && | 522 browser_view()->IsBrowserTypeNormal() && |
| 533 !browser_view()->IsOffTheRecord()) { | 523 !browser_view()->IsOffTheRecord()) { |
| 534 return ShouldPaintAsActive() ? | 524 return ShouldPaintAsActive() ? |
| 535 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; | 525 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; |
| 536 } | 526 } |
| 537 return 0; | 527 return 0; |
| 538 } | 528 } |
| OLD | NEW |