summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--app/gfx/canvas_linux.cc7
-rw-r--r--chrome/browser/gtk/tabs/tab_gtk.cc8
-rw-r--r--chrome/browser/gtk/tabs/tab_renderer_gtk.h2
3 files changed, 13 insertions, 4 deletions
diff --git a/app/gfx/canvas_linux.cc b/app/gfx/canvas_linux.cc
index d1d391b..5d644ad 100644
--- a/app/gfx/canvas_linux.cc
+++ b/app/gfx/canvas_linux.cc
@@ -196,6 +196,7 @@ void Canvas::DrawStringInt(const std::wstring& text,
pango_layout_set_width(layout, w * PANGO_SCALE);
pango_layout_set_height(layout, h * PANGO_SCALE);
+ cairo_save(cr);
cairo_set_source_rgb(cr,
SkColorGetR(color) / 255.0,
SkColorGetG(color) / 255.0,
@@ -217,7 +218,13 @@ void Canvas::DrawStringInt(const std::wstring& text,
}
cairo_move_to(cr, x, y);
+ cairo_rectangle(cr, x, y, x + w, y + h);
+ // We use cairo_clip_preserve so that we can reset the clip region with
+ // cairo_restore; otherwise, any further drawing operations on this context
+ // will be clipped to this region.
+ cairo_clip_preserve(cr);
pango_cairo_show_layout(cr, layout);
+ cairo_restore(cr);
g_object_unref(layout);
// NOTE: beginPlatformPaint returned its surface, we shouldn't destroy it.
diff --git a/chrome/browser/gtk/tabs/tab_gtk.cc b/chrome/browser/gtk/tabs/tab_gtk.cc
index 547c655..ee7789a 100644
--- a/chrome/browser/gtk/tabs/tab_gtk.cc
+++ b/chrome/browser/gtk/tabs/tab_gtk.cc
@@ -24,10 +24,10 @@ void SetEmptyDragIcon(GtkWidget* widget) {
}
// Returns the width of the title for the current font, in pixels.
-int GetTitleWidth(std::wstring title) {
+int GetTitleWidth(gfx::Font* font, std::wstring title) {
+ DCHECK(font);
if (!title.empty()) {
- gfx::Font font;
- return font.GetStringWidth(title);
+ return font->GetStringWidth(title);
}
return 0;
}
@@ -290,7 +290,7 @@ void TabGtk::UpdateData(TabContents* contents, bool loading_only) {
TabRendererGtk::UpdateData(contents, loading_only);
// Cache the title width so we don't recalculate it every time the tab is
// resized.
- title_width_ = GetTitleWidth(GetTitle());
+ title_width_ = GetTitleWidth(title_font(), GetTitle());
UpdateTooltipState();
}
diff --git a/chrome/browser/gtk/tabs/tab_renderer_gtk.h b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
index b996f5d..7029f7e 100644
--- a/chrome/browser/gtk/tabs/tab_renderer_gtk.h
+++ b/chrome/browser/gtk/tabs/tab_renderer_gtk.h
@@ -157,6 +157,8 @@ class TabRendererGtk : public AnimationDelegate {
static void SetSelectedTitleColor(SkColor color);
static void SetUnselectedTitleColor(SkColor color);
+ static gfx::Font* title_font() { return title_font_; }
+
// Returns the bounds of the Tab.
int x() const { return bounds_.x(); }
int y() const { return bounds_.y(); }