summaryrefslogtreecommitdiffstats
path: root/webkit
diff options
context:
space:
mode:
authordeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-28 18:02:47 +0000
committerdeanm@chromium.org <deanm@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2008-11-28 18:02:47 +0000
commit19547f4594d4423380fafc75bdec2e8d01dc0c03 (patch)
treebe7ff6325319e830f9f8f27dcce7938d9d84b927 /webkit
parentdfb87a90e99ba354da063518a9a5cc198fddc5c6 (diff)
downloadchromium_src-19547f4594d4423380fafc75bdec2e8d01dc0c03.zip
chromium_src-19547f4594d4423380fafc75bdec2e8d01dc0c03.tar.gz
chromium_src-19547f4594d4423380fafc75bdec2e8d01dc0c03.tar.bz2
Match Windows select metrics.
We now pass basic-selects.html. Also fix a enum type mismatch (both NoPart and NoControlPart are 0, it was only the type that was wrong). Review URL: http://codereview.chromium.org/10982 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@6115 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit')
-rw-r--r--webkit/port/platform/chromium/RenderThemeGtk.cpp96
-rw-r--r--webkit/port/platform/chromium/RenderThemeGtk.h13
-rw-r--r--webkit/port/rendering/RenderThemeWin.cpp2
3 files changed, 79 insertions, 32 deletions
diff --git a/webkit/port/platform/chromium/RenderThemeGtk.cpp b/webkit/port/platform/chromium/RenderThemeGtk.cpp
index c3945da..1b3f106 100644
--- a/webkit/port/platform/chromium/RenderThemeGtk.cpp
+++ b/webkit/port/platform/chromium/RenderThemeGtk.cpp
@@ -30,6 +30,7 @@
#include "NotImplemented.h"
#include "PlatformContextSkia.h"
#include "RenderObject.h"
+#include "ScrollbarTheme.h"
#include "gtkdrawing.h"
#include "GdkSkia.h"
@@ -37,6 +38,15 @@
namespace {
+enum PaddingType {
+ TopPadding,
+ RightPadding,
+ BottomPadding,
+ LeftPadding
+};
+
+const int kStyledMenuListInternalPadding[4] = { 1, 4, 1, 4 };
+
// The default variable-width font size. We use this as the default font
// size for the "system font", and as a base size (which we then shrink) for
// form control fonts.
@@ -122,26 +132,6 @@ static GtkTextDirection gtkTextDirection(TextDirection direction)
return GTK_TEXT_DIR_NONE;
}
}
-
-static void adjustMozStyle(RenderStyle* style, GtkThemeWidgetType type)
-{
- gint left, top, right, bottom;
- GtkTextDirection direction = gtkTextDirection(style->direction());
- gboolean inhtml = true;
-
- if (moz_gtk_get_widget_border(type, &left, &top, &right, &bottom, direction, inhtml) != MOZ_GTK_SUCCESS)
- return;
-
- // FIXME: This approach is likely to be incorrect. See other ports and layout tests to see the problem.
- const int xpadding = 1;
- const int ypadding = 1;
-
- style->setPaddingLeft(Length(xpadding + left, Fixed));
- style->setPaddingTop(Length(ypadding + top, Fixed));
- style->setPaddingRight(Length(xpadding + right, Fixed));
- style->setPaddingBottom(Length(ypadding + bottom, Fixed));
-}
-
static void setMozState(RenderTheme* theme, GtkWidgetState* state, RenderObject* o)
{
state->active = theme->isPressed(o);
@@ -317,6 +307,11 @@ void RenderThemeGtk::systemFont(int propId, Document* document, FontDescription&
}
}
+int RenderThemeGtk::minimumMenuListSize(RenderStyle* style) const
+{
+ return 0;
+}
+
bool RenderThemeGtk::paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
{
return paintMozWidget(this, MOZ_GTK_CHECKBUTTON, o, i, rect);
@@ -357,11 +352,6 @@ bool RenderThemeGtk::paintTextField(RenderObject* o, const RenderObject::PaintIn
return paintMozWidget(this, MOZ_GTK_ENTRY, o, i, rect);
}
-void RenderThemeGtk::adjustTextAreaStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
-{
- adjustTextFieldStyle(selector, style, e);
-}
-
bool RenderThemeGtk::paintTextArea(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
{
return paintTextField(o, i, r);
@@ -389,11 +379,8 @@ bool RenderThemeGtk::paintSearchFieldCancelButton(RenderObject* o, const RenderO
void RenderThemeGtk::adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, WebCore::Element* e) const
{
- style->resetBorder();
- style->resetPadding();
- style->setHeight(Length(Auto));
- style->setWhiteSpace(PRE);
- adjustMozStyle(style, MOZ_GTK_DROPDOWN);
+ // Height is locked to auto on all browsers.
+ style->setLineHeight(RenderStyle::initialLineHeight());
}
bool RenderThemeGtk::paintMenuList(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& rect)
@@ -401,6 +388,37 @@ bool RenderThemeGtk::paintMenuList(RenderObject* o, const RenderObject::PaintInf
return paintMozWidget(this, MOZ_GTK_DROPDOWN, o, i, rect);
}
+void RenderThemeGtk::adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const
+{
+ adjustMenuListStyle(selector, style, e);
+}
+
+// Used to paint styled menulists (i.e. with a non-default border)
+bool RenderThemeGtk::paintMenuListButton(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r)
+{
+ return paintMenuList(o, i, r);
+}
+
+int RenderThemeGtk::popupInternalPaddingLeft(RenderStyle* style) const
+{
+ return menuListInternalPadding(style, LeftPadding);
+}
+
+int RenderThemeGtk::popupInternalPaddingRight(RenderStyle* style) const
+{
+ return menuListInternalPadding(style, RightPadding);
+}
+
+int RenderThemeGtk::popupInternalPaddingTop(RenderStyle* style) const
+{
+ return menuListInternalPadding(style, TopPadding);
+}
+
+int RenderThemeGtk::popupInternalPaddingBottom(RenderStyle* style) const
+{
+ return menuListInternalPadding(style, BottomPadding);
+}
+
void RenderThemeGtk::adjustButtonInnerStyle(RenderStyle* style) const
{
// This inner padding matches Firefox.
@@ -510,4 +528,22 @@ GtkContainer* RenderThemeGtk::gtkContainer() const
return m_gtkContainer;
}
+int RenderThemeGtk::menuListInternalPadding(RenderStyle* style, int paddingType) const
+{
+ // This internal padding is in addition to the user-supplied padding.
+ // Matches the FF behavior.
+ int padding = kStyledMenuListInternalPadding[paddingType];
+
+ // Reserve the space for right arrow here. The rest of the padding is
+ // set by adjustMenuListStyle, since PopMenuWin.cpp uses the padding from
+ // RenderMenuList to lay out the individual items in the popup.
+ // If the MenuList actually has appearance "NoAppearance", then that means
+ // we don't draw a button, so don't reserve space for it.
+ const int bar_type = style->direction() == LTR ? RightPadding : LeftPadding;
+ if (paddingType == bar_type && style->appearance() != NoControlPart)
+ padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();
+
+ return padding;
+}
+
} // namespace WebCore
diff --git a/webkit/port/platform/chromium/RenderThemeGtk.h b/webkit/port/platform/chromium/RenderThemeGtk.h
index 5df2027..a2b5d53 100644
--- a/webkit/port/platform/chromium/RenderThemeGtk.h
+++ b/webkit/port/platform/chromium/RenderThemeGtk.h
@@ -56,6 +56,8 @@ public:
// System fonts.
virtual void systemFont(int propId, Document*, FontDescription&) const;
+ virtual int minimumMenuListSize(RenderStyle*) const;
+
virtual bool paintCheckbox(RenderObject* o, const RenderObject::PaintInfo& i, const IntRect& r);
virtual void setCheckboxSize(RenderStyle* style) const;
@@ -66,7 +68,6 @@ public:
virtual bool paintTextField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
- virtual void adjustTextAreaStyle(CSSStyleSelector*, RenderStyle*, Element*) const;
virtual bool paintTextArea(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
virtual bool paintSearchField(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
@@ -86,6 +87,14 @@ public:
// entire menulist.
virtual void adjustMenuListStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
virtual bool paintMenuList(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+ virtual void adjustMenuListButtonStyle(CSSStyleSelector* selector, RenderStyle* style, Element* e) const;
+ virtual bool paintMenuListButton(RenderObject*, const RenderObject::PaintInfo&, const IntRect&);
+
+ // These methods define the padding for the MenuList's inner block.
+ virtual int popupInternalPaddingLeft(RenderStyle*) const;
+ virtual int popupInternalPaddingRight(RenderStyle*) const;
+ virtual int popupInternalPaddingTop(RenderStyle*) const;
+ virtual int popupInternalPaddingBottom(RenderStyle*) const;
virtual void adjustButtonInnerStyle(RenderStyle* style) const;
@@ -120,6 +129,8 @@ private:
GtkContainer* gtkContainer() const;
private:
+ int menuListInternalPadding(RenderStyle* style, int paddingType) const;
+
mutable GtkWidget* m_gtkWindow;
mutable GtkContainer* m_gtkContainer;
mutable GtkWidget* m_gtkEntry;
diff --git a/webkit/port/rendering/RenderThemeWin.cpp b/webkit/port/rendering/RenderThemeWin.cpp
index f7b47f0..c9262ee 100644
--- a/webkit/port/rendering/RenderThemeWin.cpp
+++ b/webkit/port/rendering/RenderThemeWin.cpp
@@ -609,7 +609,7 @@ int RenderThemeWin::menuListInternalPadding(RenderStyle* style, int paddingType)
// If the MenuList actually has appearance "NoAppearance", then that means
// we don't draw a button, so don't reserve space for it.
const int bar_type = style->direction() == LTR ? RightPadding : LeftPadding;
- if (paddingType == bar_type && style->appearance() != NoPart)
+ if (paddingType == bar_type && style->appearance() != NoControlPart)
padding += ScrollbarTheme::nativeTheme()->scrollbarThickness();
return padding;