Chromium Code Reviews| 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/shell_delegate.h" | 7 #include "ash/shell_delegate.h" |
| 8 #include "ash/wm/frame_painter.h" | 8 #include "ash/wm/frame_painter.h" |
| 9 #include "ash/wm/workspace/frame_maximize_button.h" | 9 #include "ash/wm/workspace/frame_maximize_button.h" |
| 10 #include "chrome/browser/themes/theme_properties.h" | 10 #include "chrome/browser/themes/theme_properties.h" |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 257 if (avatar_button()) | 257 if (avatar_button()) |
| 258 LayoutAvatar(); | 258 LayoutAvatar(); |
| 259 BrowserNonClientFrameView::Layout(); | 259 BrowserNonClientFrameView::Layout(); |
| 260 } | 260 } |
| 261 | 261 |
| 262 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 262 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
| 263 return kViewClassName; | 263 return kViewClassName; |
| 264 } | 264 } |
| 265 | 265 |
| 266 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { | 266 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { |
| 267 if (!views::View::HitTestRect(rect)) { | |
| 268 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | |
| 269 return false; | |
| 270 } | |
| 267 // If the rect is outside the bounds of the client area, claim it. | 271 // If the rect is outside the bounds of the client area, claim it. |
| 268 if (NonClientFrameView::HitTestRect(rect)) | 272 gfx::Point rect_in_client_view_coords_origin(rect.origin()); |
| 273 View::ConvertPointToTarget(this, frame()->client_view(), | |
|
tdanderson
2013/07/18 20:47:04
Also add a TODO for me here.
| |
| 274 &rect_in_client_view_coords_origin); | |
| 275 gfx::Rect rect_in_client_view_coords( | |
| 276 rect_in_client_view_coords_origin, rect.size()); | |
| 277 if (!frame()->client_view()->HitTestRect(rect_in_client_view_coords)) | |
| 269 return true; | 278 return true; |
| 270 | 279 |
| 271 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. | 280 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
| 272 if (!browser_view()->tabstrip()) | 281 // a non-tab portion. |
| 273 return false; | 282 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 274 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 283 if (!tabstrip || !browser_view()->IsTabStripVisible()) |
| 275 gfx::Point tabstrip_origin(tabstrip_bounds.origin()); | |
| 276 View::ConvertPointToTarget(frame()->client_view(), this, &tabstrip_origin); | |
| 277 tabstrip_bounds.set_origin(tabstrip_origin); | |
| 278 if (rect.bottom() > tabstrip_bounds.bottom()) | |
| 279 return false; | 284 return false; |
| 280 | 285 |
| 281 // We convert from our parent's coordinates since we assume we fill its bounds | 286 gfx::Point rect_in_tabstrip_coords_origin(rect.origin()); |
| 282 // completely. We need to do this since we're not a parent of the tabstrip, | 287 View::ConvertPointToTarget(this, tabstrip, |
|
tdanderson
2013/07/18 20:47:04
Also add a TODO for me here.
| |
| 283 // meaning ConvertPointToTarget would otherwise return something bogus. | 288 &rect_in_tabstrip_coords_origin); |
| 284 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of | 289 gfx::Rect rect_in_tabstrip_coords(rect_in_tabstrip_coords_origin, |
| 285 // its center point once GetEventHandlerForRect() is implemented. | 290 rect.size()); |
| 286 gfx::Point browser_view_point(rect.CenterPoint()); | 291 |
| 287 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point); | 292 if (rect_in_tabstrip_coords.bottom() > tabstrip->GetLocalBounds().bottom()) { |
| 288 return browser_view()->IsPositionInWindowCaption(browser_view_point); | 293 // |rect| is below the tabstrip. |
| 294 return false; | |
| 295 } | |
| 296 | |
| 297 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { | |
| 298 // Claim |rect| if it is in a non-tab portion of the tabstrip. | |
| 299 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center | |
| 300 // point to TabStrip::IsPositionInWindowCaption() once | |
| 301 // GetEventHandlerForRect() is implemented. | |
| 302 return tabstrip->IsPositionInWindowCaption( | |
| 303 rect_in_tabstrip_coords.CenterPoint()); | |
| 304 } | |
| 305 | |
| 306 // We claim |rect| because it is above the bottom of the tabstrip, but | |
| 307 // not in the tabstrip. In particular, the window controls are right of | |
| 308 // the tabstrip. | |
| 309 return true; | |
| 289 } | 310 } |
| 290 | 311 |
| 291 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 312 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
| 292 ui::AccessibleViewState* state) { | 313 ui::AccessibleViewState* state) { |
| 293 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; | 314 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; |
| 294 } | 315 } |
| 295 | 316 |
| 296 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() { | 317 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() { |
| 297 return frame_painter_->GetMinimumSize(this); | 318 return frame_painter_->GetMinimumSize(this); |
| 298 } | 319 } |
| (...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 543 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { | 564 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { |
| 544 ui::ThemeProvider* tp = GetThemeProvider(); | 565 ui::ThemeProvider* tp = GetThemeProvider(); |
| 545 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 566 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
| 546 browser_view()->IsBrowserTypeNormal() && | 567 browser_view()->IsBrowserTypeNormal() && |
| 547 !browser_view()->IsOffTheRecord()) { | 568 !browser_view()->IsOffTheRecord()) { |
| 548 return ShouldPaintAsActive() ? | 569 return ShouldPaintAsActive() ? |
| 549 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; | 570 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; |
| 550 } | 571 } |
| 551 return 0; | 572 return 0; |
| 552 } | 573 } |
| OLD | NEW |