diff options
author | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-27 02:01:44 +0000 |
---|---|---|
committer | deanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2008-11-27 02:01:44 +0000 |
commit | 7e62f16aa5fe23497acdc489db323d2d29773292 (patch) | |
tree | 369ff75766c29345d0cb6b2d48dbf3e49fad235d /webkit/port/platform/chromium/RenderThemeGtk.cpp | |
parent | b6ffa1964afddb6a4ef205d0ab5550fdd004f033 (diff) | |
download | chromium_src-7e62f16aa5fe23497acdc489db323d2d29773292.zip chromium_src-7e62f16aa5fe23497acdc489db323d2d29773292.tar.gz chromium_src-7e62f16aa5fe23497acdc489db323d2d29773292.tar.bz2 |
Match Windows checkbox and radio metrics. We now pass basic-inputs.html.
Review URL: http://codereview.chromium.org/10788
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6095 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/port/platform/chromium/RenderThemeGtk.cpp')
-rw-r--r-- | webkit/port/platform/chromium/RenderThemeGtk.cpp | 63 |
1 files changed, 20 insertions, 43 deletions
diff --git a/webkit/port/platform/chromium/RenderThemeGtk.cpp b/webkit/port/platform/chromium/RenderThemeGtk.cpp index dc09d4d..c3945da 100644 --- a/webkit/port/platform/chromium/RenderThemeGtk.cpp +++ b/webkit/port/platform/chromium/RenderThemeGtk.cpp @@ -86,6 +86,14 @@ static float pointsToPixels(float points) return points / POINTS_PER_INCH * pixelsPerInch; } +static void setSizeIfAuto(RenderStyle* style, const IntSize& size) +{ + if (style->width().isIntrinsicOrAuto()) + style->setWidth(Length(size.width(), Fixed)); + if (style->height().isAuto()) + style->setHeight(Length(size.height(), Fixed)); +} + static bool supportsFocus(ControlPart appearance) { switch (appearance) { @@ -200,38 +208,6 @@ static bool paintMozWidget(RenderTheme* theme, GtkThemeWidgetType type, RenderOb return moz_gtk_widget_paint(type, pcs->gdk_skia(), &gdkRect, &gdkClipRect, &mozState, flags, direction) != MOZ_GTK_SUCCESS; } -static void setToggleSize(RenderStyle* style, ControlPart appearance) -{ - // The width and height are both specified, so we shouldn't change them. - if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) - return; - - // FIXME: This is probably not correct use of indicator_size and indicator_spacing. - gint indicator_size, indicator_spacing; - - switch (appearance) { - case CheckboxPart: - if (moz_gtk_checkbox_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS) - return; - break; - case RadioPart: - if (moz_gtk_radio_get_metrics(&indicator_size, &indicator_spacing) != MOZ_GTK_SUCCESS) - return; - break; - default: - return; - } - - // Other ports hard-code this to 13, but GTK+ users tend to demand the native look. - // It could be made a configuration option values other than 13 actually break site compatibility. - int length = indicator_size + indicator_spacing; - if (style->width().isIntrinsicOrAuto()) - style->setWidth(Length(length, Fixed)); - - if (style->height().isAuto()) - style->setHeight(Length(length, Fixed)); -} - static void gtkStyleSetCallback(GtkWidget* widget, GtkStyle* previous, RenderTheme* renderTheme) { // FIXME: Make sure this function doesn't get called many times for a single GTK+ style change signal. @@ -348,7 +324,16 @@ bool RenderThemeGtk::paintCheckbox(RenderObject* o, const RenderObject::PaintInf void RenderThemeGtk::setCheckboxSize(RenderStyle* style) const { - setToggleSize(style, RadioPart); + // If the width and height are both specified, then we have nothing to do. + if (!style->width().isIntrinsicOrAuto() && !style->height().isAuto()) + return; + + // FIXME: A hard-coded size of 13 is used. This is wrong but necessary for now. It matches Firefox. + // At different DPI settings on Windows, querying the theme gives you a larger size that accounts for + // the higher DPI. Until our entire engine honors a DPI setting other than 96, we can't rely on the theme's + // metrics. + const IntSize size(13, 13); + setSizeIfAuto(style, size); } bool RenderThemeGtk::paintRadio(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) @@ -358,7 +343,8 @@ bool RenderThemeGtk::paintRadio(RenderObject* o, const RenderObject::PaintInfo& void RenderThemeGtk::setRadioSize(RenderStyle* style) const { - setToggleSize(style, RadioPart); + // Use same sizing for radio box as checkbox. + setCheckboxSize(style); } bool RenderThemeGtk::paintButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect) @@ -461,15 +447,6 @@ bool RenderThemeGtk::controlSupportsTints(const RenderObject* o) const return isEnabled(o); } -int RenderThemeGtk::baselinePosition(const RenderObject* o) const -{ - // FIXME: This strategy is possibly incorrect for the GTK+ port. - if (o->style()->appearance() == CheckboxPart|| - o->style()->appearance() == RadioPart) - return o->marginTop() + o->height() - 2; - return RenderTheme::baselinePosition(o); -} - Color RenderThemeGtk::activeListBoxSelectionBackgroundColor() const { GtkWidget* widget = gtkTreeView(); |