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

Side by Side Diff: chrome/browser/ui/views/tabs/tab_strip.cc

Issue 1393193002: Paint tab-loading throbbers into a ui::Layer. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix clipping on the right, and animations Created 5 years, 2 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
OLDNEW
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/tabs/tab_strip.h" 5 #include "chrome/browser/ui/views/tabs/tab_strip.h"
6 6
7 #include <algorithm> 7 #include <algorithm>
8 #include <iterator> 8 #include <iterator>
9 #include <string> 9 #include <string>
10 #include <vector> 10 #include <vector>
(...skipping 1160 matching lines...) Expand 10 before | Expand all | Expand 10 after
1171 1171
1172 return view && view->id() == VIEW_ID_TAB ? static_cast<Tab*>(view) : NULL; 1172 return view && view->id() == VIEW_ID_TAB ? static_cast<Tab*>(view) : NULL;
1173 } 1173 }
1174 1174
1175 void TabStrip::OnMouseEventInTab(views::View* source, 1175 void TabStrip::OnMouseEventInTab(views::View* source,
1176 const ui::MouseEvent& event) { 1176 const ui::MouseEvent& event) {
1177 UpdateStackedLayoutFromMouseEvent(source, event); 1177 UpdateStackedLayoutFromMouseEvent(source, event);
1178 } 1178 }
1179 1179
1180 bool TabStrip::ShouldPaintTab(const Tab* tab, gfx::Rect* clip) { 1180 bool TabStrip::ShouldPaintTab(const Tab* tab, gfx::Rect* clip) {
1181 const bool dragging = drag_controller_ && drag_controller_->started_drag();
1181 // Only touch layout needs to restrict the clip. 1182 // Only touch layout needs to restrict the clip.
1182 if (!touch_layout_ && !IsStackingDraggedTabs()) 1183 if (!touch_layout_ && !dragging)
1183 return true; 1184 return true;
1184 1185
1185 int index = GetModelIndexOfTab(tab); 1186 int index = GetModelIndexOfTab(tab);
1186 if (index == -1) 1187 if (index == -1)
1187 return true; // Tab is closing, paint it all. 1188 return true; // Tab is closing, paint it all.
1188 1189
1189 int active_index = IsStackingDraggedTabs() ? 1190 int active_index =
1190 controller_->GetActiveIndex() : touch_layout_->active_index(); 1191 dragging ? controller_->GetActiveIndex() : touch_layout_->active_index();
1191 if (active_index == tab_count()) 1192 if (active_index == tab_count())
1192 active_index--; 1193 active_index--;
1193 1194
1194 if (index < active_index) { 1195 if (index < active_index) {
1195 if (tab_at(index)->x() == tab_at(index + 1)->x()) 1196 if (tab_at(index)->x() == tab_at(index + 1)->x())
1196 return false; 1197 return false;
1197 1198
1198 if (tab_at(index)->x() > tab_at(index + 1)->x()) 1199 if (tab_at(index)->x() > tab_at(index + 1)->x()) {
1199 return true; // Can happen during dragging. 1200 // Can happen during dragging.
1200 1201 int x = tab_at(index)->x() - tab_at(index + 1)->x();
1201 clip->SetRect( 1202 clip->SetRect(x, 0, tab_at(index)->width() - x, tab_at(index)->height());
1202 0, 0, tab_at(index + 1)->x() - tab_at(index)->x() + kStackedTabLeftClip, 1203 } else {
1203 tab_at(index)->height()); 1204 clip->SetRect(0, 0, tab_at(index + 1)->x() - tab_at(index)->x() +
1205 kStackedTabLeftClip,
1206 tab_at(index)->height());
1207 }
1204 } else if (index > active_index && index > 0) { 1208 } else if (index > active_index && index > 0) {
1205 const gfx::Rect& tab_bounds(tab_at(index)->bounds()); 1209 const gfx::Rect& tab_bounds(tab_at(index)->bounds());
1206 const gfx::Rect& previous_tab_bounds(tab_at(index - 1)->bounds()); 1210 const gfx::Rect& previous_tab_bounds(tab_at(index - 1)->bounds());
1207 if (tab_bounds.x() == previous_tab_bounds.x()) 1211 if (tab_bounds.x() == previous_tab_bounds.x())
1208 return false; 1212 return false;
1209 1213
1210 if (tab_bounds.x() < previous_tab_bounds.x()) 1214 if (tab_bounds.x() < previous_tab_bounds.x()) {
1211 return true; // Can happen during dragging. 1215 // Can happen during dragging.
1212 1216 int x = previous_tab_bounds.x() - tab_bounds.x();
1213 if (previous_tab_bounds.right() - GetLayoutConstant(TABSTRIP_TAB_OVERLAP) != 1217 clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height());
1214 tab_bounds.x()) { 1218 } else if (previous_tab_bounds.right() -
1219 GetLayoutConstant(TABSTRIP_TAB_OVERLAP) !=
1220 tab_bounds.x()) {
1215 int x = previous_tab_bounds.right() - tab_bounds.x() - 1221 int x = previous_tab_bounds.right() - tab_bounds.x() -
1216 kStackedTabRightClip; 1222 kStackedTabRightClip;
1217 clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height()); 1223 clip->SetRect(x, 0, tab_bounds.width() - x, tab_bounds.height());
1218 } 1224 }
1219 } 1225 }
1220 return true; 1226 return true;
1221 } 1227 }
1222 1228
1223 bool TabStrip::IsImmersiveStyle() const { 1229 bool TabStrip::IsImmersiveStyle() const {
1224 return immersive_style_; 1230 return immersive_style_;
(...skipping 519 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 new_bounds.set_x(std::min(min_x, new_bounds.x() + delta)); 1750 new_bounds.set_x(std::min(min_x, new_bounds.x() + delta));
1745 tabs_.set_ideal_bounds(i, new_bounds); 1751 tabs_.set_ideal_bounds(i, new_bounds);
1746 } 1752 }
1747 if (ideal_bounds(tab_count() - 1).right() >= newtab_button_->x()) 1753 if (ideal_bounds(tab_count() - 1).right() >= newtab_button_->x())
1748 newtab_button_->SetVisible(false); 1754 newtab_button_->SetVisible(false);
1749 } 1755 }
1750 views::ViewModelUtils::SetViewBoundsToIdealBounds(tabs_); 1756 views::ViewModelUtils::SetViewBoundsToIdealBounds(tabs_);
1751 SchedulePaint(); 1757 SchedulePaint();
1752 } 1758 }
1753 1759
1754 bool TabStrip::IsStackingDraggedTabs() const {
1755 return drag_controller_.get() && drag_controller_->started_drag() &&
1756 (drag_controller_->move_behavior() ==
1757 TabDragController::MOVE_VISIBILE_TABS);
1758 }
1759
1760 void TabStrip::LayoutDraggedTabsAt(const Tabs& tabs, 1760 void TabStrip::LayoutDraggedTabsAt(const Tabs& tabs,
1761 Tab* active_tab, 1761 Tab* active_tab,
1762 const gfx::Point& location, 1762 const gfx::Point& location,
1763 bool initial_drag) { 1763 bool initial_drag) {
1764 // Immediately hide the new tab button if the last tab is being dragged. 1764 // Immediately hide the new tab button if the last tab is being dragged.
1765 const Tab* last_visible_tab = GetLastVisibleTab(); 1765 const Tab* last_visible_tab = GetLastVisibleTab();
1766 if (last_visible_tab && last_visible_tab->dragging()) 1766 if (last_visible_tab && last_visible_tab->dragging())
1767 newtab_button_->SetVisible(false); 1767 newtab_button_->SetVisible(false);
1768 std::vector<gfx::Rect> bounds; 1768 std::vector<gfx::Rect> bounds;
1769 CalculateBoundsForDraggedTabs(tabs, &bounds); 1769 CalculateBoundsForDraggedTabs(tabs, &bounds);
(...skipping 918 matching lines...) Expand 10 before | Expand all | Expand 10 after
2688 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point); 2688 ConvertPointToViewAndGetEventHandler(this, newtab_button_, point);
2689 if (view) 2689 if (view)
2690 return view; 2690 return view;
2691 } 2691 }
2692 Tab* tab = FindTabForEvent(point); 2692 Tab* tab = FindTabForEvent(point);
2693 if (tab) 2693 if (tab)
2694 return ConvertPointToViewAndGetEventHandler(this, tab, point); 2694 return ConvertPointToViewAndGetEventHandler(this, tab, point);
2695 } 2695 }
2696 return this; 2696 return this;
2697 } 2697 }
OLDNEW
« chrome/browser/ui/views/tabs/tab.cc ('K') | « chrome/browser/ui/views/tabs/tab_strip.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698