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 if (!frame()->client_view()->HitTestRect(rect)) |
269 return true; | 273 return true; |
270 | 274 |
271 // Otherwise claim it only if it's in a non-tab portion of the tabstrip. | 275 // Otherwise, claim |rect| only if it is above the bottom of the tabstrip in |
272 if (!browser_view()->tabstrip()) | 276 // a non-tab portion. |
273 return false; | 277 TabStrip* tabstrip = browser_view()->tabstrip(); |
274 gfx::Rect tabstrip_bounds(browser_view()->tabstrip()->bounds()); | 278 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; | 279 return false; |
280 | 280 |
281 // We convert from our parent's coordinates since we assume we fill its bounds | 281 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, | 282 View::ConvertPointToTarget(this, tabstrip, |
283 // meaning ConvertPointToTarget would otherwise return something bogus. | 283 &rect_in_tabstrip_coords_origin); |
284 // TODO(tdanderson): Initialize |browser_view_point| using |rect| instead of | 284 gfx::Rect rect_in_tabstrip_coords(rect_in_tabstrip_coords_origin, |
285 // its center point once GetEventHandlerForRect() is implemented. | 285 rect.size()); |
286 gfx::Point browser_view_point(rect.CenterPoint()); | 286 |
287 View::ConvertPointToTarget(parent(), browser_view(), &browser_view_point); | 287 if (tabstrip->HitTestRect(rect_in_tabstrip_coords)) { |
288 return browser_view()->IsPositionInWindowCaption(browser_view_point); | 288 // TODO(tdanderson): Pass |rect_in_tabstrip_coords| instead of its center |
289 // point to TabStrip::IsPositionInWindowCaption() once | |
290 // GetEventHandlerForRect() is implemented. | |
291 return tabstrip->IsPositionInWindowCaption( | |
292 rect_in_tabstrip_coords.CenterPoint()); | |
293 } | |
294 | |
295 // Claim |rect| if is to the left or right of the tab strip. In | |
296 // particular, the window controls are there. | |
297 return rect_in_tabstrip_coords.bottom() <= | |
James Cook
2013/07/17 21:44:34
This doesn't seem to match the comment above. Doe
| |
298 tabstrip->GetLocalBounds().bottom(); | |
289 } | 299 } |
290 | 300 |
291 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 301 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
292 ui::AccessibleViewState* state) { | 302 ui::AccessibleViewState* state) { |
293 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; | 303 state->role = ui::AccessibilityTypes::ROLE_TITLEBAR; |
294 } | 304 } |
295 | 305 |
296 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() { | 306 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() { |
297 return frame_painter_->GetMinimumSize(this); | 307 return frame_painter_->GetMinimumSize(this); |
298 } | 308 } |
(...skipping 244 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
543 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { | 553 int BrowserNonClientFrameViewAsh::GetThemeFrameOverlayImageId() const { |
544 ui::ThemeProvider* tp = GetThemeProvider(); | 554 ui::ThemeProvider* tp = GetThemeProvider(); |
545 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && | 555 if (tp->HasCustomImage(IDR_THEME_FRAME_OVERLAY) && |
546 browser_view()->IsBrowserTypeNormal() && | 556 browser_view()->IsBrowserTypeNormal() && |
547 !browser_view()->IsOffTheRecord()) { | 557 !browser_view()->IsOffTheRecord()) { |
548 return ShouldPaintAsActive() ? | 558 return ShouldPaintAsActive() ? |
549 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; | 559 IDR_THEME_FRAME_OVERLAY : IDR_THEME_FRAME_OVERLAY_INACTIVE; |
550 } | 560 } |
551 return 0; | 561 return 0; |
552 } | 562 } |
OLD | NEW |