Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(562)

Side by Side Diff: chrome/browser/tabs/tab_strip_model.cc

Issue 165473: Better location for setting the size of tab contents. This should (Closed)
Patch Set: Created 11 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« chrome/browser/browser.cc ('K') | « chrome/browser/browser.cc ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/string_util.h" 11 #include "base/string_util.h"
12 #include "build/build_config.h" 12 #include "build/build_config.h"
13 #include "chrome/browser/metrics/user_metrics.h" 13 #include "chrome/browser/metrics/user_metrics.h"
14 #include "chrome/browser/profile.h" 14 #include "chrome/browser/profile.h"
15 #include "chrome/browser/sessions/tab_restore_service.h" 15 #include "chrome/browser/sessions/tab_restore_service.h"
16 #include "chrome/browser/tabs/tab_strip_model_order_controller.h" 16 #include "chrome/browser/tabs/tab_strip_model_order_controller.h"
17 #include "chrome/browser/tab_contents/navigation_controller.h" 17 #include "chrome/browser/tab_contents/navigation_controller.h"
18 #include "chrome/browser/tab_contents/tab_contents.h" 18 #include "chrome/browser/tab_contents/tab_contents.h"
19 #include "chrome/browser/tab_contents/tab_contents_view.h"
19 #include "chrome/common/chrome_switches.h" 20 #include "chrome/common/chrome_switches.h"
20 #include "chrome/common/notification_service.h" 21 #include "chrome/common/notification_service.h"
21 #include "chrome/common/url_constants.h" 22 #include "chrome/common/url_constants.h"
22 23
23 namespace { 24 namespace {
24 25
25 // Returns true if the specified transition is one of the types that cause the 26 // Returns true if the specified transition is one of the types that cause the
26 // opener relationships for the tab in which the transition occured to be 27 // opener relationships for the tab in which the transition occured to be
27 // forgotten. This is generally any navigation that isn't a link click (i.e. 28 // forgotten. This is generally any navigation that isn't a link click (i.e.
28 // any navigation that can be considered to be the start of a new task distinct 29 // any navigation that can be considered to be the start of a new task distinct
(...skipping 351 matching lines...) Expand 10 before | Expand all | Expand 10 after
380 // transition inherit group as well. This covers the cases where the user 381 // transition inherit group as well. This covers the cases where the user
381 // creates a New Tab (e.g. Ctrl+T, or clicks the New Tab button), or types 382 // creates a New Tab (e.g. Ctrl+T, or clicks the New Tab button), or types
382 // in the address bar and presses Alt+Enter. This allows for opening a new 383 // in the address bar and presses Alt+Enter. This allows for opening a new
383 // Tab to quickly look up something. When this Tab is closed, the old one 384 // Tab to quickly look up something. When this Tab is closed, the old one
384 // is re-selected, not the next-adjacent. 385 // is re-selected, not the next-adjacent.
385 inherit_group = transition == PageTransition::TYPED && index == count(); 386 inherit_group = transition == PageTransition::TYPED && index == count();
386 } 387 }
387 InsertTabContentsAt(index, contents, foreground, inherit_group); 388 InsertTabContentsAt(index, contents, foreground, inherit_group);
388 if (inherit_group && transition == PageTransition::TYPED) 389 if (inherit_group && transition == PageTransition::TYPED)
389 contents_data_.at(index)->reset_group_on_select = true; 390 contents_data_.at(index)->reset_group_on_select = true;
391
392 // Ensure that the new TabContentsView begins at the same size as the
393 // previous TabContentsView if it existed. Otherwise, the initial WebKit
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
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
398 // layout is performed with sane view dimensions even when we're opening a
399 // new background tab.
400 if (TabContents* old_contents = GetSelectedTabContents()) {
401 if (!foreground)
402 contents->view()->SizeContents(old_contents->view()->GetContainerSize());
403 }
390 } 404 }
391 405
392 void TabStripModel::CloseSelectedTab() { 406 void TabStripModel::CloseSelectedTab() {
393 CloseTabContentsAt(selected_index_); 407 CloseTabContentsAt(selected_index_);
394 } 408 }
395 409
396 void TabStripModel::SelectNextTab() { 410 void TabStripModel::SelectNextTab() {
397 // This may happen during automated testing or if a user somehow buffers 411 // This may happen during automated testing or if a user somehow buffers
398 // many key accelerators. 412 // many key accelerators.
399 if (empty()) 413 if (empty())
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
651 int index = GetIndexOfTabContents(contents); 665 int index = GetIndexOfTabContents(contents);
652 contents_data_.at(index)->opener = &opener->controller(); 666 contents_data_.at(index)->opener = &opener->controller();
653 } 667 }
654 668
655 // static 669 // static
656 bool TabStripModel::OpenerMatches(const TabContentsData* data, 670 bool TabStripModel::OpenerMatches(const TabContentsData* data,
657 const NavigationController* opener, 671 const NavigationController* opener,
658 bool use_group) { 672 bool use_group) {
659 return data->opener == opener || (use_group && data->group == opener); 673 return data->opener == opener || (use_group && data->group == opener);
660 } 674 }
OLDNEW
« chrome/browser/browser.cc ('K') | « chrome/browser/browser.cc ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698