OLD | NEW |
1 // Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2006-2008 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/tabs/tab_strip_model.h" | 5 #include "chrome/browser/tabs/tab_strip_model.h" |
6 | 6 |
7 #include <algorithm> | 7 #include <algorithm> |
8 | 8 |
9 #include "base/command_line.h" | 9 #include "base/command_line.h" |
10 #include "base/stl_util-inl.h" | 10 #include "base/stl_util-inl.h" |
(...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
392 // Ensure that the new TabContentsView begins at the same size as the | 392 // Ensure that the new TabContentsView begins at the same size as the |
393 // previous TabContentsView if it existed. Otherwise, the initial WebKit | 393 // previous TabContentsView if it existed. Otherwise, the initial WebKit |
394 // layout will be performed based on a width of 0 pixels, causing a | 394 // layout will be performed based on a width of 0 pixels, causing a |
395 // very long, narrow, inaccurate layout. Because some scripts on pages (as | 395 // very long, narrow, inaccurate layout. Because some scripts on pages (as |
396 // well as WebKit's anchor link location calculation) are run on the | 396 // well as WebKit's anchor link location calculation) are run on the |
397 // initial layout and not recalculated later, we need to ensure the first | 397 // initial layout and not recalculated later, we need to ensure the first |
398 // layout is performed with sane view dimensions even when we're opening a | 398 // layout is performed with sane view dimensions even when we're opening a |
399 // new background tab. | 399 // new background tab. |
400 if (TabContents* old_contents = GetSelectedTabContents()) { | 400 if (TabContents* old_contents = GetSelectedTabContents()) { |
401 if (!foreground) { | 401 if (!foreground) { |
402 contents->HideContents(); | |
403 contents->view()->SizeContents(old_contents->view()->GetContainerSize()); | 402 contents->view()->SizeContents(old_contents->view()->GetContainerSize()); |
404 // We need to hide the contents or else we get and execute paints for | 403 // We need to hide the contents or else we get and execute paints for |
405 // background tabs. With enough background tabs they will steal the | 404 // background tabs. With enough background tabs they will steal the |
406 // backing store of the visible tab causing flashing. See bug 20831. | 405 // backing store of the visible tab causing flashing. See bug 20831. |
407 | 406 contents->HideContents(); |
408 } | 407 } |
409 } | 408 } |
410 } | 409 } |
411 | 410 |
412 void TabStripModel::CloseSelectedTab() { | 411 void TabStripModel::CloseSelectedTab() { |
413 CloseTabContentsAt(selected_index_); | 412 CloseTabContentsAt(selected_index_); |
414 } | 413 } |
415 | 414 |
416 void TabStripModel::SelectNextTab() { | 415 void TabStripModel::SelectNextTab() { |
417 // This may happen during automated testing or if a user somehow buffers | 416 // This may happen during automated testing or if a user somehow buffers |
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
671 int index = GetIndexOfTabContents(contents); | 670 int index = GetIndexOfTabContents(contents); |
672 contents_data_.at(index)->opener = &opener->controller(); | 671 contents_data_.at(index)->opener = &opener->controller(); |
673 } | 672 } |
674 | 673 |
675 // static | 674 // static |
676 bool TabStripModel::OpenerMatches(const TabContentsData* data, | 675 bool TabStripModel::OpenerMatches(const TabContentsData* data, |
677 const NavigationController* opener, | 676 const NavigationController* opener, |
678 bool use_group) { | 677 bool use_group) { |
679 return data->opener == opener || (use_group && data->group == opener); | 678 return data->opener == opener || (use_group && data->group == opener); |
680 } | 679 } |
OLD | NEW |