| 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/profiles/profile.h" | 7 #include "chrome/browser/profiles/profile.h" |
| 8 #include "chrome/browser/ui/browser_finder.h" | 8 #include "chrome/browser/ui/browser_finder.h" |
| 9 #include "chrome/browser/ui/find_bar/find_bar.h" | 9 #include "chrome/browser/ui/find_bar/find_bar.h" |
| 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" | 10 #include "chrome/browser/ui/find_bar/find_bar_controller.h" |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 253 | 253 |
| 254 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { | 254 void BrowserViewLayout::ViewRemoved(views::View* host, views::View* view) { |
| 255 switch (view->id()) { | 255 switch (view->id()) { |
| 256 case VIEW_ID_BOOKMARK_BAR: | 256 case VIEW_ID_BOOKMARK_BAR: |
| 257 active_bookmark_bar_ = NULL; | 257 active_bookmark_bar_ = NULL; |
| 258 break; | 258 break; |
| 259 } | 259 } |
| 260 } | 260 } |
| 261 | 261 |
| 262 void BrowserViewLayout::Layout(views::View* host) { | 262 void BrowserViewLayout::Layout(views::View* host) { |
| 263 // Showing instant extended suggestions causes us to temporarily hide any | 263 // Showing Instant extended suggestions causes us to temporarily hide any |
| 264 // visible bookmark bar and infobars. In turn, this hiding would normally | 264 // visible bookmark bar and infobars. In turn, this hiding would normally |
| 265 // cause the content below the suggestions to shift upwards, which looks | 265 // cause the content below the suggestions to shift upwards, which looks |
| 266 // surprising (since from the user's perspective, we're "covering" rather than | 266 // surprising (since from the user's perspective, we're "covering" rather than |
| 267 // "removing" the bookmark bar/infobars). To prevent this, we save off the | 267 // "removing" the bookmark bar/infobars). To prevent this, we save off the |
| 268 // content origin here, then once we finish laying things out, force the | 268 // content origin here, then once we finish laying things out, force the |
| 269 // contents to continue to display from that origin. | 269 // contents to continue to display from that origin. |
| 270 const chrome::search::Mode& mode = browser()->search_model()->mode(); | 270 const chrome::search::Mode& mode = browser()->search_model()->mode(); |
| 271 views::WebView* contents = browser_view_->contents_container_; | 271 views::WebView* contents = browser_view_->contents_container_; |
| 272 int preview_height = contents_container_->preview_height(); | 272 int overlay_height = contents_container_->overlay_height(); |
| 273 gfx::Point old_contents_origin; | 273 gfx::Point old_contents_origin; |
| 274 if (preview_height > 0 && mode.is_search_suggestions() && | 274 if (overlay_height > 0 && mode.is_search_suggestions() && |
| 275 mode.is_origin_default()) { | 275 mode.is_origin_default()) { |
| 276 old_contents_origin = contents->bounds().origin(); | 276 old_contents_origin = contents->bounds().origin(); |
| 277 views::View::ConvertPointToTarget(contents->parent(), browser_view_, | 277 views::View::ConvertPointToTarget(contents->parent(), browser_view_, |
| 278 &old_contents_origin); | 278 &old_contents_origin); |
| 279 } | 279 } |
| 280 | 280 |
| 281 vertical_layout_rect_ = browser_view_->GetLocalBounds(); | 281 vertical_layout_rect_ = browser_view_->GetLocalBounds(); |
| 282 int top = LayoutTabStripRegion(); | 282 int top = LayoutTabStripRegion(); |
| 283 if (browser_view_->IsTabStripVisible()) { | 283 if (browser_view_->IsTabStripVisible()) { |
| 284 int x = browser_view_->tabstrip_->GetMirroredX() + | 284 int x = browser_view_->tabstrip_->GetMirroredX() + |
| (...skipping 22 matching lines...) Expand all Loading... |
| 307 if (active_top_margin == 0 && !old_contents_origin.IsOrigin()) { | 307 if (active_top_margin == 0 && !old_contents_origin.IsOrigin()) { |
| 308 gfx::Point new_contents_origin(contents->bounds().origin()); | 308 gfx::Point new_contents_origin(contents->bounds().origin()); |
| 309 views::View::ConvertPointToTarget(contents->parent(), browser_view_, | 309 views::View::ConvertPointToTarget(contents->parent(), browser_view_, |
| 310 &new_contents_origin); | 310 &new_contents_origin); |
| 311 active_top_margin = old_contents_origin.y() - new_contents_origin.y(); | 311 active_top_margin = old_contents_origin.y() - new_contents_origin.y(); |
| 312 // Special case: While normally the suggestions appear to "cover" any | 312 // Special case: While normally the suggestions appear to "cover" any |
| 313 // bookmark/infobars, if the suggestions are very short, they might not | 313 // bookmark/infobars, if the suggestions are very short, they might not |
| 314 // fully cover that gap, and leaving the contents at their original height | 314 // fully cover that gap, and leaving the contents at their original height |
| 315 // would leave an odd-looking blank space. In this case, we allow the | 315 // would leave an odd-looking blank space. In this case, we allow the |
| 316 // contents to go ahead and shift upward. | 316 // contents to go ahead and shift upward. |
| 317 if (active_top_margin > 0 && active_top_margin < preview_height) | 317 if (active_top_margin > 0 && active_top_margin < overlay_height) |
| 318 contents_container_->SetActiveTopMargin(active_top_margin); | 318 contents_container_->SetActiveTopMargin(active_top_margin); |
| 319 } | 319 } |
| 320 | 320 |
| 321 // This must be done _after_ we lay out the WebContents since this | 321 // This must be done _after_ we lay out the WebContents since this |
| 322 // code calls back into us to find the bounding box the find bar | 322 // code calls back into us to find the bounding box the find bar |
| 323 // must be laid out within, and that code depends on the | 323 // must be laid out within, and that code depends on the |
| 324 // TabContentsContainer's bounds being up to date. | 324 // TabContentsContainer's bounds being up to date. |
| 325 if (browser()->HasFindBarController()) { | 325 if (browser()->HasFindBarController()) { |
| 326 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( | 326 browser()->GetFindBarController()->find_bar()->MoveWindowIfNecessary( |
| 327 gfx::Rect(), true); | 327 gfx::Rect(), true); |
| (...skipping 206 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 534 } | 534 } |
| 535 return bottom; | 535 return bottom; |
| 536 } | 536 } |
| 537 | 537 |
| 538 bool BrowserViewLayout::InfobarVisible() const { | 538 bool BrowserViewLayout::InfobarVisible() const { |
| 539 views::View* infobar_container = browser_view_->infobar_container_; | 539 views::View* infobar_container = browser_view_->infobar_container_; |
| 540 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. | 540 // NOTE: Can't check if the size IsEmpty() since it's always 0-width. |
| 541 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && | 541 return browser()->SupportsWindowFeature(Browser::FEATURE_INFOBAR) && |
| 542 (infobar_container->GetPreferredSize().height() != 0); | 542 (infobar_container->GetPreferredSize().height() != 0); |
| 543 } | 543 } |
| OLD | NEW |