| 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_view_layout.h" | 5 #include "chrome/browser/ui/views/frame/browser_view_layout.h" |
| 6 | 6 |
| 7 #include "chrome/browser/ui/find_bar/find_bar.h" | 7 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 8 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| 9 #include "chrome/browser/ui/view_ids.h" | 9 #include "chrome/browser/ui/view_ids.h" |
| 10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" | 10 #include "chrome/browser/ui/views/bookmarks/bookmark_bar_view.h" |
| (...skipping 364 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 375 int overlapped_top = top - | 375 int overlapped_top = top - |
| 376 static_cast<InfoBarContainerView*>(infobar_container_)-> | 376 static_cast<InfoBarContainerView*>(infobar_container_)-> |
| 377 GetVerticalOverlap(&height); | 377 GetVerticalOverlap(&height); |
| 378 infobar_container_->SetBounds(vertical_layout_rect_.x(), | 378 infobar_container_->SetBounds(vertical_layout_rect_.x(), |
| 379 overlapped_top, | 379 overlapped_top, |
| 380 vertical_layout_rect_.width(), | 380 vertical_layout_rect_.width(), |
| 381 height); | 381 height); |
| 382 return overlapped_top + height; | 382 return overlapped_top + height; |
| 383 } | 383 } |
| 384 | 384 |
| 385 // |browser_reserved_rect| is in browser_view_ coordinates. | |
| 386 // |future_source_bounds| is in |source|'s parent coordinates. | |
| 387 // |future_parent_offset| is required, since parent view is not moved yet. | |
| 388 // Note that |future_parent_offset| is relative to browser_view_, not to | |
| 389 // the parent view. | |
| 390 void BrowserViewLayout::UpdateReservedContentsRect( | |
| 391 const gfx::Rect& browser_reserved_rect, | |
| 392 TabContentsContainer* source, | |
| 393 const gfx::Rect& future_source_bounds, | |
| 394 const gfx::Point& future_parent_offset) { | |
| 395 gfx::Point resize_corner_origin(browser_reserved_rect.origin()); | |
| 396 // Convert |resize_corner_origin| from browser_view_ to source's parent | |
| 397 // coordinates. | |
| 398 views::View::ConvertPointToView(browser_view_, source->parent(), | |
| 399 &resize_corner_origin); | |
| 400 // Create |reserved_rect| in source's parent coordinates. | |
| 401 gfx::Rect reserved_rect(resize_corner_origin, browser_reserved_rect.size()); | |
| 402 // Apply source's parent future offset to it. | |
| 403 reserved_rect.Offset(-future_parent_offset.x(), -future_parent_offset.y()); | |
| 404 if (future_source_bounds.Intersects(reserved_rect)) { | |
| 405 // |source| is not properly positioned yet to use ConvertPointToView, | |
| 406 // so convert it into |source|'s coordinates manually. | |
| 407 reserved_rect.Offset(-future_source_bounds.x(), -future_source_bounds.y()); | |
| 408 } else { | |
| 409 reserved_rect = gfx::Rect(); | |
| 410 } | |
| 411 | |
| 412 source->SetReservedContentsRect(reserved_rect); | |
| 413 } | |
| 414 | |
| 415 void BrowserViewLayout::LayoutTabContents(int top, int bottom) { | 385 void BrowserViewLayout::LayoutTabContents(int top, int bottom) { |
| 416 // The ultimate idea is to calculate bounds and reserved areas for all | 386 // The ultimate idea is to calculate bounds and reserved areas for all |
| 417 // contents views first and then resize them all, so every view | 387 // contents views first and then resize them all, so every view |
| 418 // (and its contents) is resized and laid out only once. | 388 // (and its contents) is resized and laid out only once. |
| 419 | 389 |
| 420 // The views hierarcy (see browser_view.h for more details): | 390 // The views hierarcy (see browser_view.h for more details): |
| 421 // contents_split_ -> [contents_container_ | devtools] | 391 // contents_split_ -> [contents_container_ | devtools] |
| 422 | 392 |
| 423 gfx::Rect contents_bounds; | 393 gfx::Rect contents_bounds; |
| 424 gfx::Rect devtools_bounds; | 394 gfx::Rect devtools_bounds; |
| (...skipping 15 matching lines...) Expand all Loading... |
| 440 if (!resize_corner_size.IsEmpty()) { | 410 if (!resize_corner_size.IsEmpty()) { |
| 441 gfx::Rect bounds = browser_view_->GetContentsBounds(); | 411 gfx::Rect bounds = browser_view_->GetContentsBounds(); |
| 442 gfx::Point resize_corner_origin( | 412 gfx::Point resize_corner_origin( |
| 443 bounds.right() - resize_corner_size.width(), | 413 bounds.right() - resize_corner_size.width(), |
| 444 bounds.bottom() - resize_corner_size.height()); | 414 bounds.bottom() - resize_corner_size.height()); |
| 445 browser_reserved_rect = | 415 browser_reserved_rect = |
| 446 gfx::Rect(resize_corner_origin, resize_corner_size); | 416 gfx::Rect(resize_corner_origin, resize_corner_size); |
| 447 } | 417 } |
| 448 } | 418 } |
| 449 | 419 |
| 450 UpdateReservedContentsRect(browser_reserved_rect, | |
| 451 browser_view_->contents_container_, | |
| 452 contents_bounds, | |
| 453 contents_split_offset); | |
| 454 UpdateReservedContentsRect(browser_reserved_rect, | |
| 455 browser_view_->devtools_container_, | |
| 456 devtools_bounds, | |
| 457 contents_split_offset); | |
| 458 | |
| 459 // Now it's safe to actually resize all contents views in the hierarchy. | 420 // Now it's safe to actually resize all contents views in the hierarchy. |
| 460 contents_split_->SetBoundsRect(contents_split_bounds); | 421 contents_split_->SetBoundsRect(contents_split_bounds); |
| 461 } | 422 } |
| 462 | 423 |
| 463 int BrowserViewLayout::GetTopMarginForActiveContent() { | 424 int BrowserViewLayout::GetTopMarginForActiveContent() { |
| 464 if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() || | 425 if (!active_bookmark_bar_ || !browser_view_->IsBookmarkBarVisible() || |
| 465 !active_bookmark_bar_->IsDetached()) { | 426 !active_bookmark_bar_->IsDetached()) { |
| 466 return 0; | 427 return 0; |
| 467 } | 428 } |
| 468 | 429 |
| (...skipping 24 matching lines...) Expand all Loading... |
| 493 } | 454 } |
| 494 #endif | 455 #endif |
| 495 return bottom; | 456 return bottom; |
| 496 } | 457 } |
| 497 | 458 |
| 498 bool BrowserViewLayout::InfobarVisible() const { | 459 bool BrowserViewLayout::InfobarVisible() const { |
| 499 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 460 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
| 500 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 461 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
| 501 (infobar_container_->GetPreferredSize().height() != 0); | 462 (infobar_container_->GetPreferredSize().height() != 0); |
| 502 } | 463 } |
| OLD | NEW |