| OLD | NEW |
| 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/gtk/gtk_util.h" | 5 #include "chrome/browser/ui/gtk/gtk_util.h" |
| 6 | 6 |
| 7 #include <cairo/cairo.h> | 7 #include <cairo/cairo.h> |
| 8 | 8 |
| 9 #include <algorithm> | 9 #include <algorithm> |
| 10 #include <cstdarg> | 10 #include <cstdarg> |
| (...skipping 746 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 757 GTK_STATE_NORMAL, GTK_SHADOW_NONE, dirty_rec, | 757 GTK_STATE_NORMAL, GTK_SHADOW_NONE, dirty_rec, |
| 758 widget_to_draw_on, "entry_bg", | 758 widget_to_draw_on, "entry_bg", |
| 759 rec->x + xborder, rec->y + yborder, | 759 rec->x + xborder, rec->y + yborder, |
| 760 width, height); | 760 width, height); |
| 761 } | 761 } |
| 762 | 762 |
| 763 gtk_style_detach(our_style); | 763 gtk_style_detach(our_style); |
| 764 g_object_unref(our_style); | 764 g_object_unref(our_style); |
| 765 } | 765 } |
| 766 | 766 |
| 767 void SetLayoutText(PangoLayout* layout, const string16& text) { |
| 768 // Pango is really easy to overflow and send into a computational death |
| 769 // spiral that can corrupt the screen. Assume that we'll never have more than |
| 770 // 2000 characters, which should be a safe assumption until we all get robot |
| 771 // eyes. http://crbug.com/66576 |
| 772 std::string text_utf8 = UTF16ToUTF8(text); |
| 773 if (text_utf8.length() > 2000) |
| 774 text_utf8 = text_utf8.substr(0, 2000); |
| 775 |
| 776 pango_layout_set_text(layout, text_utf8.data(), text_utf8.length()); |
| 777 } |
| 778 |
| 767 void DrawThemedToolbarBackground(GtkWidget* widget, | 779 void DrawThemedToolbarBackground(GtkWidget* widget, |
| 768 cairo_t* cr, | 780 cairo_t* cr, |
| 769 GdkEventExpose* event, | 781 GdkEventExpose* event, |
| 770 const gfx::Point& tabstrip_origin, | 782 const gfx::Point& tabstrip_origin, |
| 771 GtkThemeService* theme_service) { | 783 GtkThemeService* theme_service) { |
| 772 // Fill the entire region with the toolbar color. | 784 // Fill the entire region with the toolbar color. |
| 773 GdkColor color = theme_service->GetGdkColor( | 785 GdkColor color = theme_service->GetGdkColor( |
| 774 ThemeService::COLOR_TOOLBAR); | 786 ThemeService::COLOR_TOOLBAR); |
| 775 gdk_cairo_set_source_color(cr, &color); | 787 gdk_cairo_set_source_color(cr, &color); |
| 776 cairo_fill(cr); | 788 cairo_fill(cr); |
| (...skipping 398 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1175 | 1187 |
| 1176 void DoCopy(BrowserWindow* window) { | 1188 void DoCopy(BrowserWindow* window) { |
| 1177 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); | 1189 DoCutCopyPaste(window, &RenderViewHost::Copy, "copy-clipboard"); |
| 1178 } | 1190 } |
| 1179 | 1191 |
| 1180 void DoPaste(BrowserWindow* window) { | 1192 void DoPaste(BrowserWindow* window) { |
| 1181 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); | 1193 DoCutCopyPaste(window, &RenderViewHost::Paste, "paste-clipboard"); |
| 1182 } | 1194 } |
| 1183 | 1195 |
| 1184 } // namespace gtk_util | 1196 } // namespace gtk_util |
| OLD | NEW |