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