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

Side by Side Diff: chrome/browser/ui/gtk/tabs/dragged_view_gtk.cc

Issue 8392011: GTK: Step 1 of tab strip refresh. (Closed) Base URL: http://git.chromium.org/chromium/src.git@master
Patch Set: Rebase to ToT again. Created 9 years, 1 month 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
« no previous file with comments | « chrome/browser/ui/gtk/tabs/dragged_view_gtk.h ('k') | chrome/browser/ui/gtk/tabs/tab_gtk.h » ('j') | 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) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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/gtk/tabs/dragged_view_gtk.h" 5 #include "chrome/browser/ui/gtk/tabs/dragged_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 8
9 #include <algorithm> 9 #include <algorithm>
10 10
11 #include "base/i18n/rtl.h" 11 #include "base/i18n/rtl.h"
12 #include "base/stl_util.h" 12 #include "base/stl_util.h"
13 #include "chrome/browser/extensions/extension_tab_helper.h" 13 #include "chrome/browser/extensions/extension_tab_helper.h"
14 #include "chrome/browser/profiles/profile.h" 14 #include "chrome/browser/profiles/profile.h"
15 #include "chrome/browser/tabs/tab_strip_model.h" 15 #include "chrome/browser/tabs/tab_strip_model.h"
16 #include "chrome/browser/themes/theme_service.h" 16 #include "chrome/browser/themes/theme_service.h"
17 #include "chrome/browser/themes/theme_service_factory.h" 17 #include "chrome/browser/themes/theme_service_factory.h"
18 #include "chrome/browser/ui/gtk/gtk_theme_service.h"
18 #include "chrome/browser/ui/gtk/gtk_util.h" 19 #include "chrome/browser/ui/gtk/gtk_util.h"
19 #include "chrome/browser/ui/gtk/tabs/drag_data.h" 20 #include "chrome/browser/ui/gtk/tabs/drag_data.h"
20 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h" 21 #include "chrome/browser/ui/gtk/tabs/tab_renderer_gtk.h"
21 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" 22 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h"
22 #include "content/browser/renderer_host/backing_store_gtk.h" 23 #include "content/browser/renderer_host/backing_store_gtk.h"
23 #include "content/browser/renderer_host/render_view_host.h" 24 #include "content/browser/renderer_host/render_view_host.h"
24 #include "content/browser/tab_contents/tab_contents.h" 25 #include "content/browser/tab_contents/tab_contents.h"
25 #include "third_party/skia/include/core/SkShader.h" 26 #include "third_party/skia/include/core/SkShader.h"
26 #include "ui/base/gtk/gtk_screen_utils.h" 27 #include "ui/base/gtk/gtk_screen_utils.h"
27 #include "ui/base/x/x11_util.h" 28 #include "ui/base/x/x11_util.h"
(...skipping 28 matching lines...) Expand all
56 mini_width_(-1), 57 mini_width_(-1),
57 normal_width_(-1), 58 normal_width_(-1),
58 attached_(false), 59 attached_(false),
59 parent_window_width_(-1), 60 parent_window_width_(-1),
60 mouse_tab_offset_(mouse_tab_offset), 61 mouse_tab_offset_(mouse_tab_offset),
61 attached_tab_size_(TabRendererGtk::GetMinimumSelectedSize()), 62 attached_tab_size_(TabRendererGtk::GetMinimumSelectedSize()),
62 contents_size_(contents_size), 63 contents_size_(contents_size),
63 close_animation_(this) { 64 close_animation_(this) {
64 std::vector<TabContents*> data_sources(drag_data_->GetDraggedTabsContents()); 65 std::vector<TabContents*> data_sources(drag_data_->GetDraggedTabsContents());
65 for (size_t i = 0; i < data_sources.size(); i++) { 66 for (size_t i = 0; i < data_sources.size(); i++) {
66 renderers_.push_back(new TabRendererGtk(ThemeServiceFactory::GetForProfile( 67 renderers_.push_back(new TabRendererGtk(GtkThemeService::GetFrom(
67 Profile::FromBrowserContext(data_sources[i]->browser_context())))); 68 Profile::FromBrowserContext(data_sources[i]->browser_context()))));
68 } 69 }
69 70
70 for (size_t i = 0; i < drag_data_->size(); i++) { 71 for (size_t i = 0; i < drag_data_->size(); i++) {
71 TabContentsWrapper* wrapper = 72 TabContentsWrapper* wrapper =
72 TabContentsWrapper::GetCurrentWrapperForContents( 73 TabContentsWrapper::GetCurrentWrapperForContents(
73 drag_data_->get(i)->contents_->tab_contents()); 74 drag_data_->get(i)->contents_->tab_contents());
74 renderers_[i]->UpdateData( 75 renderers_[i]->UpdateData(
75 drag_data_->get(i)->contents_->tab_contents(), 76 drag_data_->get(i)->contents_->tab_contents(),
76 wrapper->extension_tab_helper()->is_app(), 77 wrapper->extension_tab_helper()->is_app(),
(...skipping 258 matching lines...) Expand 10 before | Expand all | Expand 10 after
335 336
336 // Blit the rendered bitmap into a pixmap. Any pixel set in the pixmap will 337 // Blit the rendered bitmap into a pixmap. Any pixel set in the pixmap will
337 // be opaque in the container window. 338 // be opaque in the container window.
338 if (!attached_) 339 if (!attached_)
339 cairo_scale(cairo_context, kScalingFactor, kScalingFactor); 340 cairo_scale(cairo_context, kScalingFactor, kScalingFactor);
340 for (size_t i = 0; i < renderers_.size(); i++) { 341 for (size_t i = 0; i < renderers_.size(); i++) {
341 if (static_cast<int>(i) == 0) 342 if (static_cast<int>(i) == 0)
342 cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE); 343 cairo_set_operator(cairo_context, CAIRO_OPERATOR_SOURCE);
343 else 344 else
344 cairo_set_operator(cairo_context, CAIRO_OPERATOR_OVER); 345 cairo_set_operator(cairo_context, CAIRO_OPERATOR_OVER);
345 PaintTab(i, cairo_context, container_->allocation.width); 346 PaintTab(i, container_, cairo_context, container_->allocation.width);
346 } 347 }
347 348
348 if (!attached_) { 349 if (!attached_) {
349 // Make the render area depiction opaque (leaving enough room for the 350 // Make the render area depiction opaque (leaving enough room for the
350 // border). 351 // border).
351 cairo_identity_matrix(cairo_context); 352 cairo_identity_matrix(cairo_context);
352 // On Lucid running VNC, the X server will reject RGBA (1,1,1,1) as an 353 // On Lucid running VNC, the X server will reject RGBA (1,1,1,1) as an
353 // invalid value below in gdk_window_shape_combine_mask(). Using (0,0,0,1) 354 // invalid value below in gdk_window_shape_combine_mask(). Using (0,0,0,1)
354 // instead. The value doesn't really matter, as long as the alpha is not 0. 355 // instead. The value doesn't really matter, as long as the alpha is not 0.
355 cairo_set_source_rgba(cairo_context, 0.0f, 0.0f, 0.0f, 1.0f); 356 cairo_set_source_rgba(cairo_context, 0.0f, 0.0f, 0.0f, 1.0f);
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
415 cairo_stroke(cr); 416 cairo_stroke(cr);
416 } 417 }
417 418
418 // Draw the tab. 419 // Draw the tab.
419 if (!attached_) 420 if (!attached_)
420 cairo_scale(cr, kScalingFactor, kScalingFactor); 421 cairo_scale(cr, kScalingFactor, kScalingFactor);
421 // Painting all but the active tab first, from last to first. 422 // Painting all but the active tab first, from last to first.
422 for (int i = renderers_.size() - 1; i >= 0; i--) { 423 for (int i = renderers_.size() - 1; i >= 0; i--) {
423 if (i == drag_data_->source_tab_index()) 424 if (i == drag_data_->source_tab_index())
424 continue; 425 continue;
425 PaintTab(i, cr, widget->allocation.width); 426 PaintTab(i, widget, cr, widget->allocation.width);
426 } 427 }
427 // Painting the active tab last, so that it appears on top. 428 // Painting the active tab last, so that it appears on top.
428 PaintTab(drag_data_->source_tab_index(), cr, widget->allocation.width); 429 PaintTab(drag_data_->source_tab_index(), widget, cr,
430 widget->allocation.width);
429 431
430 cairo_destroy(cr); 432 cairo_destroy(cr);
431 433
432 // We've already drawn the tab, so don't propagate the expose-event signal. 434 // We've already drawn the tab, so don't propagate the expose-event signal.
433 return TRUE; 435 return TRUE;
434 } 436 }
435 437
436 void DraggedViewGtk::PaintTab(int index, cairo_t* cr, int widget_width) { 438 void DraggedViewGtk::PaintTab(int index, GtkWidget* widget, cairo_t* cr,
439 int widget_width) {
dpapad 2011/10/28 16:56:52 Drive by comment. |widget_width| argument can now
437 renderers_[index]->set_mini(drag_data_->get(index)->mini_); 440 renderers_[index]->set_mini(drag_data_->get(index)->mini_);
438 cairo_surface_t* surface = renderers_[index]->PaintToSurface(); 441 cairo_surface_t* surface = renderers_[index]->PaintToSurface(widget, cr);
439 442
440 int paint_at = 0; 443 int paint_at = 0;
441 if (!base::i18n::IsRTL()) { 444 if (!base::i18n::IsRTL()) {
442 paint_at = std::max(GetWidthInTabStripFromTo(0, index) - 16, 0); 445 paint_at = std::max(GetWidthInTabStripFromTo(0, index) - 16, 0);
443 } else { 446 } else {
444 paint_at = GetTotalWidthInTabStrip() - 447 paint_at = GetTotalWidthInTabStrip() -
445 GetWidthInTabStripFromTo(0, index + 1); 448 GetWidthInTabStripFromTo(0, index + 1);
446 if (!attached_) { 449 if (!attached_) {
447 paint_at = widget_width / kScalingFactor - 450 paint_at = widget_width / kScalingFactor -
448 GetWidthInTabStripFromTo(0, index + 1); 451 GetWidthInTabStripFromTo(0, index + 1);
449 } 452 }
450 } 453 }
451 454
452 cairo_set_source_surface(cr, surface, paint_at, 0); 455 cairo_set_source_surface(cr, surface, paint_at, 0);
453 cairo_paint(cr); 456 cairo_paint(cr);
454 cairo_surface_destroy(surface); 457 cairo_surface_destroy(surface);
455 } 458 }
OLDNEW
« no previous file with comments | « chrome/browser/ui/gtk/tabs/dragged_view_gtk.h ('k') | chrome/browser/ui/gtk/tabs/tab_gtk.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698