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/resource_bundle.h" | 10 #include "app/resource_bundle.h" |
11 #include "app/slide_animation.h" | 11 #include "app/slide_animation.h" |
12 #include "base/compiler_specific.h" | 12 #include "base/compiler_specific.h" |
13 #include "base/stl_util-inl.h" | 13 #include "base/stl_util-inl.h" |
14 #include "chrome/browser/browser.h" | 14 #include "chrome/browser/browser.h" |
15 #include "chrome/browser/browser_theme_provider.h" | 15 #include "chrome/browser/browser_theme_provider.h" |
16 #include "chrome/browser/defaults.h" | 16 #include "chrome/browser/defaults.h" |
17 #include "chrome/browser/view_ids.h" | 17 #include "chrome/browser/view_ids.h" |
18 #include "chrome/browser/views/tabs/tab.h" | 18 #include "chrome/browser/views/tabs/tab.h" |
19 #include "chrome/browser/views/tabs/tab_strip_controller.h" | 19 #include "chrome/browser/views/tabs/tab_strip_controller.h" |
20 #include "chrome/common/pref_names.h" | 20 #include "chrome/common/pref_names.h" |
21 #include "gfx/canvas.h" | 21 #include "gfx/canvas_skia.h" |
22 #include "gfx/path.h" | 22 #include "gfx/path.h" |
23 #include "gfx/size.h" | 23 #include "gfx/size.h" |
24 #include "grit/generated_resources.h" | 24 #include "grit/generated_resources.h" |
25 #include "grit/theme_resources.h" | 25 #include "grit/theme_resources.h" |
26 #include "views/controls/image_view.h" | 26 #include "views/controls/image_view.h" |
27 #include "views/widget/default_theme_provider.h" | 27 #include "views/widget/default_theme_provider.h" |
28 #include "views/window/non_client_view.h" | 28 #include "views/window/non_client_view.h" |
29 #include "views/window/window.h" | 29 #include "views/window/window.h" |
30 | 30 |
31 #if defined(OS_WIN) | 31 #if defined(OS_WIN) |
(...skipping 255 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
287 /////////////////////////////////////////////////////////////////////////////// | 287 /////////////////////////////////////////////////////////////////////////////// |
288 // TabStrip, views::View overrides: | 288 // TabStrip, views::View overrides: |
289 | 289 |
290 void TabStrip::PaintChildren(gfx::Canvas* canvas) { | 290 void TabStrip::PaintChildren(gfx::Canvas* canvas) { |
291 // Tabs are painted in reverse order, so they stack to the left. | 291 // Tabs are painted in reverse order, so they stack to the left. |
292 // Phantom tabs appear behind all other tabs and are rendered first. To make | 292 // Phantom tabs appear behind all other tabs and are rendered first. To make |
293 // them slightly transparent we render them to a different layer. | 293 // them slightly transparent we render them to a different layer. |
294 if (HasPhantomTabs()) { | 294 if (HasPhantomTabs()) { |
295 SkRect bounds; | 295 SkRect bounds; |
296 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); | 296 bounds.set(0, 0, SkIntToScalar(width()), SkIntToScalar(height())); |
297 canvas->saveLayerAlpha(&bounds, kPhantomTabAlpha, | 297 canvas->AsCanvasSkia()->saveLayerAlpha( |
298 SkCanvas::kARGB_ClipLayer_SaveFlag); | 298 &bounds, kPhantomTabAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag); |
299 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 299 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
300 for (int i = tab_count() - 1; i >= 0; --i) { | 300 for (int i = tab_count() - 1; i >= 0; --i) { |
301 Tab* tab = GetTabAtTabDataIndex(i); | 301 Tab* tab = GetTabAtTabDataIndex(i); |
302 if (tab->data().phantom) | 302 if (tab->data().phantom) |
303 tab->ProcessPaint(canvas); | 303 tab->ProcessPaint(canvas); |
304 } | 304 } |
305 canvas->restore(); | 305 canvas->AsCanvasSkia()->restore(); |
306 | 306 |
307 canvas->saveLayerAlpha(&bounds, kPhantomTabIconAlpha, | 307 canvas->AsCanvasSkia()->saveLayerAlpha( |
308 SkCanvas::kARGB_ClipLayer_SaveFlag); | 308 &bounds, kPhantomTabIconAlpha, SkCanvas::kARGB_ClipLayer_SaveFlag); |
309 canvas->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); | 309 canvas->AsCanvasSkia()->drawARGB(0, 255, 255, 255, SkXfermode::kClear_Mode); |
310 for (int i = tab_count() - 1; i >= 0; --i) { | 310 for (int i = tab_count() - 1; i >= 0; --i) { |
311 Tab* tab = GetTabAtTabDataIndex(i); | 311 Tab* tab = GetTabAtTabDataIndex(i); |
312 if (tab->data().phantom) { | 312 if (tab->data().phantom) { |
313 canvas->save(); | 313 canvas->AsCanvasSkia()->save(); |
314 canvas->ClipRectInt(tab->MirroredX(), tab->y(), tab->width(), | 314 canvas->ClipRectInt(tab->MirroredX(), tab->y(), tab->width(), |
315 tab->height()); | 315 tab->height()); |
316 canvas->TranslateInt(tab->MirroredX(), tab->y()); | 316 canvas->TranslateInt(tab->MirroredX(), tab->y()); |
317 tab->PaintIcon(canvas); | 317 tab->PaintIcon(canvas); |
318 canvas->restore(); | 318 canvas->AsCanvasSkia()->restore(); |
319 } | 319 } |
320 } | 320 } |
321 canvas->restore(); | 321 canvas->AsCanvasSkia()->restore(); |
322 } | 322 } |
323 | 323 |
324 Tab* selected_tab = NULL; | 324 Tab* selected_tab = NULL; |
325 | 325 |
326 Tab* dragging_tab = NULL; | 326 Tab* dragging_tab = NULL; |
327 | 327 |
328 for (int i = tab_count() - 1; i >= 0; --i) { | 328 for (int i = tab_count() - 1; i >= 0; --i) { |
329 Tab* tab = GetTabAtTabDataIndex(i); | 329 Tab* tab = GetTabAtTabDataIndex(i); |
330 // We must ask the _Tab's_ model, not ourselves, because in some situations | 330 // We must ask the _Tab's_ model, not ourselves, because in some situations |
331 // the model will be different to this object, e.g. when a Tab is being | 331 // the model will be different to this object, e.g. when a Tab is being |
(...skipping 829 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1161 } | 1161 } |
1162 } | 1162 } |
1163 | 1163 |
1164 bool TabStrip::HasPhantomTabs() const { | 1164 bool TabStrip::HasPhantomTabs() const { |
1165 for (int i = 0; i < tab_count(); ++i) { | 1165 for (int i = 0; i < tab_count(); ++i) { |
1166 if (GetTabAtTabDataIndex(i)->data().phantom) | 1166 if (GetTabAtTabDataIndex(i)->data().phantom) |
1167 return true; | 1167 return true; |
1168 } | 1168 } |
1169 return false; | 1169 return false; |
1170 } | 1170 } |
OLD | NEW |