OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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/views/tabs/tab_strip.h" | 5 #include "chrome/browser/views/tabs/tab_strip.h" |
6 | 6 |
7 #include "app/animation_container.h" | 7 #include "app/animation_container.h" |
8 #include "app/drag_drop_types.h" | 8 #include "app/drag_drop_types.h" |
9 #include "app/l10n_util.h" | 9 #include "app/l10n_util.h" |
10 #include "app/os_exchange_data.h" | 10 #include "app/os_exchange_data.h" |
11 #include "app/resource_bundle.h" | 11 #include "app/resource_bundle.h" |
12 #include "app/slide_animation.h" | 12 #include "app/slide_animation.h" |
13 #include "base/command_line.h" | 13 #include "base/command_line.h" |
14 #include "base/compiler_specific.h" | 14 #include "base/compiler_specific.h" |
15 #include "base/stl_util-inl.h" | 15 #include "base/stl_util-inl.h" |
16 #include "base/string_util.h" | |
17 #include "chrome/browser/browser.h" | 16 #include "chrome/browser/browser.h" |
18 #include "chrome/browser/browser_theme_provider.h" | 17 #include "chrome/browser/browser_theme_provider.h" |
19 #include "chrome/browser/defaults.h" | 18 #include "chrome/browser/defaults.h" |
20 #include "chrome/browser/metrics/user_metrics.h" | 19 #include "chrome/browser/metrics/user_metrics.h" |
21 #include "chrome/browser/profile.h" | 20 #include "chrome/browser/profile.h" |
22 #include "chrome/browser/renderer_host/render_view_host.h" | 21 #include "chrome/browser/renderer_host/render_view_host.h" |
23 #include "chrome/browser/tab_contents/tab_contents.h" | 22 #include "chrome/browser/tab_contents/tab_contents.h" |
24 #include "chrome/browser/tabs/tab_strip_model.h" | 23 #include "chrome/browser/tabs/tab_strip_model.h" |
25 #include "chrome/browser/view_ids.h" | 24 #include "chrome/browser/view_ids.h" |
26 #include "chrome/browser/views/app_launcher.h" | 25 #include "chrome/browser/views/app_launcher.h" |
(...skipping 1380 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1407 // right edge of the TabStrip's bounds, rather than the right edge of the | 1406 // right edge of the TabStrip's bounds, rather than the right edge of the |
1408 // right-most Tab, otherwise it'll bounce when animating. | 1407 // right-most Tab, otherwise it'll bounce when animating. |
1409 new_tab_x = width() - newtab_button_bounds_.width(); | 1408 new_tab_x = width() - newtab_button_bounds_.width(); |
1410 } else { | 1409 } else { |
1411 new_tab_x = Round(tab_x - kTabHOffset) + kNewTabButtonHOffset; | 1410 new_tab_x = Round(tab_x - kTabHOffset) + kNewTabButtonHOffset; |
1412 } | 1411 } |
1413 newtab_button_bounds_.set_origin(gfx::Point(new_tab_x, new_tab_y)); | 1412 newtab_button_bounds_.set_origin(gfx::Point(new_tab_x, new_tab_y)); |
1414 } | 1413 } |
1415 | 1414 |
1416 void TabStrip::NewTabAnimation1Done() { | 1415 void TabStrip::NewTabAnimation1Done() { |
1417 #if defined(OS_LINUX) | |
1418 std::string details(IntToString(GetTabCount())); | |
1419 | |
1420 for (size_t i = 0; i < tab_data_.size(); ++i) { | |
1421 if (tab_data_[i].tab->closing()) | |
1422 details += " " + IntToString(static_cast<int>(i)); | |
1423 } | |
1424 | |
1425 LOG(ERROR) << " NewTabAnimation1Done details=" << details; | |
1426 #endif | |
1427 | |
1428 int tab_data_index = static_cast<int>(tab_data_.size() - 1); | 1416 int tab_data_index = static_cast<int>(tab_data_.size() - 1); |
1429 Tab* tab = GetTabAtTabDataIndex(tab_data_index); | 1417 Tab* tab = GetTabAtTabDataIndex(tab_data_index); |
1430 | 1418 |
1431 gfx::Rect old_tab_bounds = tab->bounds(); | 1419 gfx::Rect old_tab_bounds = tab->bounds(); |
1432 | 1420 |
1433 GenerateIdealBounds(); | 1421 GenerateIdealBounds(); |
1434 | 1422 |
1435 gfx::Rect& end_bounds = tab_data_[tab_data_index].ideal_bounds; | 1423 gfx::Rect& end_bounds = tab_data_[tab_data_index].ideal_bounds; |
1436 end_bounds.Offset(kNewTabOvershoot, 0); | 1424 end_bounds.Offset(kNewTabOvershoot, 0); |
1437 | 1425 |
(...skipping 174 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1612 ResetAnimationState(false); | 1600 ResetAnimationState(false); |
1613 } | 1601 } |
1614 | 1602 |
1615 DCHECK(!IsAnimating()); | 1603 DCHECK(!IsAnimating()); |
1616 | 1604 |
1617 if (layout) | 1605 if (layout) |
1618 Layout(); | 1606 Layout(); |
1619 } | 1607 } |
1620 | 1608 |
1621 void TabStrip::ResetAnimationState(bool stop_new_tab_timer) { | 1609 void TabStrip::ResetAnimationState(bool stop_new_tab_timer) { |
1622 #if defined(OS_LINUX) | |
1623 LOG(ERROR) << " ResetAnimationState stop=" << stop_new_tab_timer; | |
1624 #endif | |
1625 | |
1626 if (animation_type_ == ANIMATION_NEW_TAB_2) | 1610 if (animation_type_ == ANIMATION_NEW_TAB_2) |
1627 newtab_button_->SchedulePaint(); | 1611 newtab_button_->SchedulePaint(); |
1628 | 1612 |
1629 if (stop_new_tab_timer) | 1613 if (stop_new_tab_timer) |
1630 new_tab_timer_.Stop(); | 1614 new_tab_timer_.Stop(); |
1631 | 1615 |
1632 animation_type_ = ANIMATION_DEFAULT; | 1616 animation_type_ = ANIMATION_DEFAULT; |
1633 | 1617 |
1634 // Reset the animation state of each tab. | 1618 // Reset the animation state of each tab. |
1635 for (int i = 0, count = GetTabCount(); i < count; ++i) { | 1619 for (int i = 0, count = GetTabCount(); i < count; ++i) { |
(...skipping 94 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1730 return tab_data_.size(); | 1714 return tab_data_.size(); |
1731 } | 1715 } |
1732 | 1716 |
1733 int TabStrip::TabDataIndexOfTab(Tab* tab) const { | 1717 int TabStrip::TabDataIndexOfTab(Tab* tab) const { |
1734 for (size_t i = 0; i < tab_data_.size(); ++i) { | 1718 for (size_t i = 0; i < tab_data_.size(); ++i) { |
1735 if (tab_data_[i].tab == tab) | 1719 if (tab_data_[i].tab == tab) |
1736 return i; | 1720 return i; |
1737 } | 1721 } |
1738 return -1; | 1722 return -1; |
1739 } | 1723 } |
OLD | NEW |