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 <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "ash/ash_switches.h" | 9 #include "ash/ash_switches.h" |
10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" | 10 #include "ash/frame/caption_buttons/frame_caption_button_container_view.h" |
(...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
239 void BrowserNonClientFrameViewAsh::UpdateWindowIcon() { | 239 void BrowserNonClientFrameViewAsh::UpdateWindowIcon() { |
240 if (window_icon_) | 240 if (window_icon_) |
241 window_icon_->SchedulePaint(); | 241 window_icon_->SchedulePaint(); |
242 } | 242 } |
243 | 243 |
244 void BrowserNonClientFrameViewAsh::UpdateWindowTitle() { | 244 void BrowserNonClientFrameViewAsh::UpdateWindowTitle() { |
245 if (!frame()->IsFullscreen()) | 245 if (!frame()->IsFullscreen()) |
246 header_painter_->SchedulePaintForTitle(); | 246 header_painter_->SchedulePaintForTitle(); |
247 } | 247 } |
248 | 248 |
| 249 bool BrowserNonClientFrameViewAsh::DoesIntersectRect( |
| 250 const views::View* target, |
| 251 const gfx::Rect& rect) const { |
| 252 CHECK_EQ(target, this); |
| 253 if (!views::ViewTargeterDelegate::DoesIntersectRect(this, rect)) { |
| 254 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. |
| 255 return false; |
| 256 } |
| 257 |
| 258 TabStrip* tabstrip = browser_view()->tabstrip(); |
| 259 if (tabstrip && browser_view()->IsTabStripVisible()) { |
| 260 // Claim |rect| only if it is above the bottom of the tabstrip in a non-tab |
| 261 // portion. |
| 262 gfx::RectF rect_in_tabstrip_coords_f(rect); |
| 263 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); |
| 264 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect( |
| 265 rect_in_tabstrip_coords_f); |
| 266 |
| 267 if (rect_in_tabstrip_coords.y() > tabstrip->height()) |
| 268 return false; |
| 269 |
| 270 return !tabstrip->HitTestRect(rect_in_tabstrip_coords) || |
| 271 tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); |
| 272 } |
| 273 |
| 274 // Claim |rect| if it is above the top of the topmost view in the client area. |
| 275 return rect.y() < GetTopInset(); |
| 276 } |
| 277 |
249 /////////////////////////////////////////////////////////////////////////////// | 278 /////////////////////////////////////////////////////////////////////////////// |
250 // views::View: | 279 // views::View: |
251 | 280 |
252 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { | 281 void BrowserNonClientFrameViewAsh::OnPaint(gfx::Canvas* canvas) { |
253 if (!ShouldPaint()) | 282 if (!ShouldPaint()) |
254 return; | 283 return; |
255 | 284 |
256 if (UseImmersiveLightbarHeaderStyle()) { | 285 if (UseImmersiveLightbarHeaderStyle()) { |
257 PaintImmersiveLightbarStyleHeader(canvas); | 286 PaintImmersiveLightbarStyleHeader(canvas); |
258 return; | 287 return; |
(...skipping 30 matching lines...) Expand all Loading... |
289 header_painter_->SetHeaderHeightForPainting(painted_height); | 318 header_painter_->SetHeaderHeightForPainting(painted_height); |
290 if (avatar_button()) | 319 if (avatar_button()) |
291 LayoutAvatar(); | 320 LayoutAvatar(); |
292 BrowserNonClientFrameView::Layout(); | 321 BrowserNonClientFrameView::Layout(); |
293 } | 322 } |
294 | 323 |
295 const char* BrowserNonClientFrameViewAsh::GetClassName() const { | 324 const char* BrowserNonClientFrameViewAsh::GetClassName() const { |
296 return kViewClassName; | 325 return kViewClassName; |
297 } | 326 } |
298 | 327 |
299 bool BrowserNonClientFrameViewAsh::HitTestRect(const gfx::Rect& rect) const { | |
300 if (!views::View::HitTestRect(rect)) { | |
301 // |rect| is outside BrowserNonClientFrameViewAsh's bounds. | |
302 return false; | |
303 } | |
304 | |
305 TabStrip* tabstrip = browser_view()->tabstrip(); | |
306 if (tabstrip && browser_view()->IsTabStripVisible()) { | |
307 // Claim |rect| only if it is above the bottom of the tabstrip in a non-tab | |
308 // portion. | |
309 gfx::RectF rect_in_tabstrip_coords_f(rect); | |
310 View::ConvertRectToTarget(this, tabstrip, &rect_in_tabstrip_coords_f); | |
311 gfx::Rect rect_in_tabstrip_coords = gfx::ToEnclosingRect( | |
312 rect_in_tabstrip_coords_f); | |
313 | |
314 if (rect_in_tabstrip_coords.y() > tabstrip->height()) | |
315 return false; | |
316 | |
317 return !tabstrip->HitTestRect(rect_in_tabstrip_coords) || | |
318 tabstrip->IsRectInWindowCaption(rect_in_tabstrip_coords); | |
319 } | |
320 | |
321 // Claim |rect| if it is above the top of the topmost view in the client area. | |
322 return rect.y() < GetTopInset(); | |
323 } | |
324 | |
325 void BrowserNonClientFrameViewAsh::GetAccessibleState( | 328 void BrowserNonClientFrameViewAsh::GetAccessibleState( |
326 ui::AXViewState* state) { | 329 ui::AXViewState* state) { |
327 state->role = ui::AX_ROLE_TITLE_BAR; | 330 state->role = ui::AX_ROLE_TITLE_BAR; |
328 } | 331 } |
329 | 332 |
330 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() const { | 333 gfx::Size BrowserNonClientFrameViewAsh::GetMinimumSize() const { |
331 gfx::Size min_client_view_size(frame()->client_view()->GetMinimumSize()); | 334 gfx::Size min_client_view_size(frame()->client_view()->GetMinimumSize()); |
332 int min_width = std::max(header_painter_->GetMinimumHeaderWidth(), | 335 int min_width = std::max(header_painter_->GetMinimumHeaderWidth(), |
333 min_client_view_size.width()); | 336 min_client_view_size.width()); |
334 if (browser_view()->IsTabStripVisible()) { | 337 if (browser_view()->IsTabStripVisible()) { |
(...skipping 199 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
534 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 537 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
535 } | 538 } |
536 | 539 |
537 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { | 540 void BrowserNonClientFrameViewAsh::PaintContentEdge(gfx::Canvas* canvas) { |
538 DCHECK(!UsePackagedAppHeaderStyle()); | 541 DCHECK(!UsePackagedAppHeaderStyle()); |
539 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), | 542 canvas->FillRect(gfx::Rect(0, caption_button_container_->bounds().bottom(), |
540 width(), kClientEdgeThickness), | 543 width(), kClientEdgeThickness), |
541 ThemeProperties::GetDefaultColor( | 544 ThemeProperties::GetDefaultColor( |
542 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); | 545 ThemeProperties::COLOR_TOOLBAR_SEPARATOR)); |
543 } | 546 } |
OLD | NEW |