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

Side by Side Diff: chrome/browser/tab_contents/tab_contents_view_gtk.cc

Issue 155787: Make Linux pass users' font settings through to renderer. (Closed)
Patch Set: remove unneeded include Created 11 years, 5 months 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/tab_contents/tab_contents_view_gtk.h ('k') | chrome/common/render_messages.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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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/tab_contents/tab_contents_view_gtk.h" 5 #include "chrome/browser/tab_contents/tab_contents_view_gtk.h"
6 6
7 #include <gdk/gdk.h> 7 #include <gdk/gdk.h>
8 #include <gtk/gtk.h> 8 #include <gtk/gtk.h>
9 9
10 #include "base/mime_util.h" 10 #include "base/mime_util.h"
(...skipping 442 matching lines...) Expand 10 before | Expand all | Expand 10 after
453 return NULL; 453 return NULL;
454 return tab_contents()->render_widget_host_view()->GetNativeView(); 454 return tab_contents()->render_widget_host_view()->GetNativeView();
455 } 455 }
456 456
457 457
458 gfx::NativeWindow TabContentsViewGtk::GetTopLevelNativeWindow() const { 458 gfx::NativeWindow TabContentsViewGtk::GetTopLevelNativeWindow() const {
459 GtkWidget* window = gtk_widget_get_ancestor(GetNativeView(), GTK_TYPE_WINDOW); 459 GtkWidget* window = gtk_widget_get_ancestor(GetNativeView(), GTK_TYPE_WINDOW);
460 return window ? GTK_WINDOW(window) : NULL; 460 return window ? GTK_WINDOW(window) : NULL;
461 } 461 }
462 462
463 void TabContentsViewGtk::InitRendererPrefs(RendererPreferences* prefs) {
464 GtkSettings* gtk_settings = gtk_settings_get_default();
465
466 gint antialias = 0;
467 gint hinting = 0;
468 gchar* hint_style = NULL;
469 gchar* rgba_style = NULL;
470 g_object_get(gtk_settings,
471 "gtk-xft-antialias", &antialias,
472 "gtk-xft-hinting", &hinting,
473 "gtk-xft-hintstyle", &hint_style,
474 "gtk-xft-rgba", &rgba_style,
475 NULL);
476
477 // g_object_get() doesn't tell us whether the properties were present or not,
478 // but if they aren't (because gnome-settings-daemon isn't running), we'll get
479 // NULL values for the strings.
480 if (hint_style && rgba_style) {
481 prefs->should_antialias_text = antialias;
482
483 if (hinting == 0 || strcmp(hint_style, "hintnone") == 0) {
484 prefs->hinting = RENDERER_PREFERENCES_HINTING_NONE;
485 } else if (strcmp(hint_style, "hintslight") == 0) {
486 prefs->hinting = RENDERER_PREFERENCES_HINTING_SLIGHT;
487 } else if (strcmp(hint_style, "hintmedium") == 0) {
488 prefs->hinting = RENDERER_PREFERENCES_HINTING_MEDIUM;
489 } else if (strcmp(hint_style, "hintfull") == 0) {
490 prefs->hinting = RENDERER_PREFERENCES_HINTING_FULL;
491 }
492
493 if (strcmp(rgba_style, "none") == 0) {
494 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_NONE;
495 } else if (strcmp(rgba_style, "rgb") == 0) {
496 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_RGB;
497 } else if (strcmp(rgba_style, "bgr") == 0) {
498 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_BGR;
499 } else if (strcmp(rgba_style, "vrgb") == 0) {
500 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VRGB;
501 } else if (strcmp(rgba_style, "vbgr") == 0) {
502 prefs->subpixel_rendering = RENDERER_PREFERENCES_SUBPIXEL_RENDERING_VBGR;
503 }
504 }
505
506 if (hint_style)
507 g_free(hint_style);
508 if (rgba_style)
509 g_free(rgba_style);
510 }
511
463 void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const { 512 void TabContentsViewGtk::GetContainerBounds(gfx::Rect* out) const {
464 // This is used for positioning the download shelf arrow animation, 513 // This is used for positioning the download shelf arrow animation,
465 // as well as sizing some other widgets in Windows. In GTK the size is 514 // as well as sizing some other widgets in Windows. In GTK the size is
466 // managed for us, so it appears to be only used for the download shelf 515 // managed for us, so it appears to be only used for the download shelf
467 // animation. 516 // animation.
468 int x = 0; 517 int x = 0;
469 int y = 0; 518 int y = 0;
470 if (fixed_->window) 519 if (fixed_->window)
471 gdk_window_get_origin(fixed_->window, &x, &y); 520 gdk_window_get_origin(fixed_->window, &x, &y);
472 out->SetRect(x + fixed_->allocation.x, y + fixed_->allocation.y, 521 out->SetRect(x + fixed_->allocation.x, y + fixed_->allocation.y,
(...skipping 301 matching lines...) Expand 10 before | Expand all | Expand 10 after
774 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 823 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
775 widget, "x", &value); 824 widget, "x", &value);
776 825
777 int child_y = std::max(half_view_height - (requisition.height / 2), 0); 826 int child_y = std::max(half_view_height - (requisition.height / 2), 0);
778 g_value_set_int(&value, child_y); 827 g_value_set_int(&value, child_y);
779 gtk_container_child_set_property(GTK_CONTAINER(floating_container), 828 gtk_container_child_set_property(GTK_CONTAINER(floating_container),
780 widget, "y", &value); 829 widget, "y", &value);
781 g_value_unset(&value); 830 g_value_unset(&value);
782 } 831 }
783 } 832 }
OLDNEW
« no previous file with comments | « chrome/browser/tab_contents/tab_contents_view_gtk.h ('k') | chrome/common/render_messages.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698