Diff
Modified: trunk/Source/WebCore/ChangeLog (198982 => 198983)
--- trunk/Source/WebCore/ChangeLog 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/ChangeLog 2016-04-03 10:50:11 UTC (rev 198983)
@@ -1,3 +1,42 @@
+2016-04-03 Carlos Garcia Campos <cgar...@igalia.com>
+
+ Replace all RenderTheme::popupInternalPadding methods with a single one returning a LengthBox
+ https://bugs.webkit.org/show_bug.cgi?id=156098
+
+ Reviewed by Darin Adler.
+
+ The caller always wants all padding sides, so we can simplify both the caller and the implementations by using a
+ single method. It's also more efficient for the GTK+ port that creates and destroys the same style contexts on
+ every call.
+
+ * rendering/RenderMenuList.cpp:
+ (WebCore::RenderMenuList::adjustInnerStyle):
+ * rendering/RenderTheme.h:
+ (WebCore::RenderTheme::popupInternalPaddingBox):
+ (WebCore::RenderTheme::popupInternalPaddingLeft): Deleted.
+ (WebCore::RenderTheme::popupInternalPaddingRight): Deleted.
+ (WebCore::RenderTheme::popupInternalPaddingTop): Deleted.
+ (WebCore::RenderTheme::popupInternalPaddingBottom): Deleted.
+ * rendering/RenderThemeGtk.cpp:
+ (WebCore::RenderThemeGtk::popupInternalPaddingBox):
+ (WebCore::getComboBoxMetrics): Deleted.
+ (WebCore::RenderThemeGtk::popupInternalPaddingLeft): Deleted.
+ (WebCore::RenderThemeGtk::popupInternalPaddingRight): Deleted.
+ (WebCore::RenderThemeGtk::popupInternalPaddingTop): Deleted.
+ (WebCore::RenderThemeGtk::popupInternalPaddingBottom): Deleted.
+ * rendering/RenderThemeGtk.h:
+ * rendering/RenderThemeIOS.h:
+ * rendering/RenderThemeIOS.mm:
+ (WebCore::RenderThemeIOS::popupInternalPaddingBox):
+ (WebCore::RenderThemeIOS::popupInternalPaddingRight): Deleted.
+ * rendering/RenderThemeMac.h:
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::popupInternalPaddingBox):
+ (WebCore::RenderThemeMac::popupInternalPaddingLeft): Deleted.
+ (WebCore::RenderThemeMac::popupInternalPaddingRight): Deleted.
+ (WebCore::RenderThemeMac::popupInternalPaddingTop): Deleted.
+ (WebCore::RenderThemeMac::popupInternalPaddingBottom): Deleted.
+
2016-04-02 Sam Weinig <s...@webkit.org>
Cleanup DataDetection.mm a little bit
Modified: trunk/Source/WebCore/rendering/RenderMenuList.cpp (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderMenuList.cpp 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderMenuList.cpp 2016-04-03 10:50:11 UTC (rev 198983)
@@ -123,10 +123,7 @@
innerStyle.setAlignSelfPosition(ItemPositionFlexStart);
}
- innerStyle.setPaddingLeft(Length(theme().popupInternalPaddingLeft(style()), Fixed));
- innerStyle.setPaddingRight(Length(theme().popupInternalPaddingRight(style()), Fixed));
- innerStyle.setPaddingTop(Length(theme().popupInternalPaddingTop(style()), Fixed));
- innerStyle.setPaddingBottom(Length(theme().popupInternalPaddingBottom(style()), Fixed));
+ innerStyle.setPaddingBox(theme().popupInternalPaddingBox(style()));
if (document().page()->chrome().selectItemWritingDirectionIsNatural()) {
// Items in the popup will not respect the CSS text-align and direction properties,
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2016-04-03 10:50:11 UTC (rev 198983)
@@ -184,10 +184,7 @@
virtual void adjustSliderThumbSize(RenderStyle&, Element*) const;
- virtual int popupInternalPaddingLeft(const RenderStyle&) const { return 0; }
- virtual int popupInternalPaddingRight(const RenderStyle&) const { return 0; }
- virtual int popupInternalPaddingTop(const RenderStyle&) const { return 0; }
- virtual int popupInternalPaddingBottom(const RenderStyle&) const { return 0; }
+ virtual LengthBox popupInternalPaddingBox(const RenderStyle&) const { return { 0, 0, 0, 0 }; }
virtual bool popupOptionSupportsTextIndent() const { return false; }
virtual PopupMenuStyle::PopupMenuSize popupMenuSize(const RenderStyle&, IntRect&) const { return PopupMenuStyle::PopupMenuSizeNormal; }
Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.cpp (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderThemeGtk.cpp 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.cpp 2016-04-03 10:50:11 UTC (rev 198983)
@@ -761,63 +761,27 @@
adjustMenuListStyle(styleResolver, style, e);
}
-static void getComboBoxMetrics(const RenderStyle& style, GtkBorder& border, int& focus)
+LengthBox RenderThemeGtk::popupInternalPaddingBox(const RenderStyle& style) const
{
- // If this menu list button isn't drawn using the native theme, we
- // don't add any extra padding beyond what WebCore already uses.
if (style.appearance() == NoControlPart)
- return;
+ return { 0, 0, 0, 0 };
GRefPtr<GtkStyleContext> parentContext = createStyleContext(ComboBox);
GRefPtr<GtkStyleContext> context = createStyleContext(ComboBoxButton, parentContext.get());
gtk_style_context_set_direction(context.get(), static_cast<GtkTextDirection>(gtkTextDirection(style.direction())));
gtk_style_context_set_state(context.get(), static_cast<GtkStateFlags>(0));
- gtk_style_context_get_border(context.get(), gtk_style_context_get_state(context.get()), &border);
+ GtkBorder borderWidth = { 0, 0, 0, 0 };
+ gtk_style_context_get_border(context.get(), gtk_style_context_get_state(context.get()), &borderWidth);
gboolean interiorFocus;
gint focusWidth, focusPad;
gtk_style_context_get_style(context.get(), "interior-focus", &interiorFocus, "focus-line-width", &focusWidth, "focus-padding", &focusPad, nullptr);
- focus = interiorFocus ? focusWidth + focusPad : 0;
-}
+ focusWidth = interiorFocus ? focusWidth + focusPad : 0;
-int RenderThemeGtk::popupInternalPaddingLeft(const RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth);
- int left = borderWidth.left + focusWidth;
- if (style.direction() == RTL)
- left += minArrowSize;
- return left;
+ return { borderWidth.top + focusWidth, borderWidth.right + focusWidth + (style.direction() == LTR ? minArrowSize : 0),
+ borderWidth.bottom + focusWidth, borderWidth.left + focusWidth + (style.direction() == RTL ? minArrowSize : 0) };
}
-int RenderThemeGtk::popupInternalPaddingRight(const RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth);
- int right = borderWidth.right + focusWidth;
- if (style.direction() == LTR)
- right += minArrowSize;
- return right;
-}
-
-int RenderThemeGtk::popupInternalPaddingTop(const RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth);
- return borderWidth.top + focusWidth;
-}
-
-int RenderThemeGtk::popupInternalPaddingBottom(const RenderStyle& style) const
-{
- GtkBorder borderWidth = { 0, 0, 0, 0 };
- int focusWidth = 0;
- getComboBoxMetrics(style, borderWidth, focusWidth);
- return borderWidth.bottom + focusWidth;
-}
-
bool RenderThemeGtk::paintMenuList(const RenderObject& renderObject, const PaintInfo& paintInfo, const FloatRect& r)
{
// FIXME: adopt subpixel themes.
Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.h (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderThemeGtk.h 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.h 2016-04-03 10:50:11 UTC (rev 198983)
@@ -119,10 +119,7 @@
bool paintTextField(const RenderObject&, const PaintInfo&, const FloatRect&) override;
bool paintTextArea(const RenderObject&, const PaintInfo&, const FloatRect&) override;
- int popupInternalPaddingLeft(const RenderStyle&) const override;
- int popupInternalPaddingRight(const RenderStyle&) const override;
- int popupInternalPaddingTop(const RenderStyle&) const override;
- int popupInternalPaddingBottom(const RenderStyle&) const override;
+ LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
// The Mac port differentiates between the "menu list" and the "menu list button."
// The former is used when a menu list button has been styled. This is used to ensure
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2016-04-03 10:50:11 UTC (rev 198983)
@@ -40,7 +40,7 @@
public:
static Ref<RenderTheme> create();
- int popupInternalPaddingRight(const RenderStyle&) const override;
+ LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
static void adjustRoundBorderRadius(RenderStyle&, RenderBox&);
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2016-04-03 10:50:11 UTC (rev 198983)
@@ -528,11 +528,11 @@
const float MenuListArrowHeight = 6;
const float MenuListButtonPaddingRight = 19;
-int RenderThemeIOS::popupInternalPaddingRight(const RenderStyle& style) const
+LengthBox RenderThemeIOS::popupInternalPaddingBox(const RenderStyle& style) const
{
if (style.appearance() == MenulistButtonPart)
- return MenuListButtonPaddingRight + style.borderTopWidth();
- return 0;
+ return { 0, static_cast<int>(MenuListButtonPaddingRight + style.borderTopWidth()), 0, 0 };
+ return { 0, 0, 0, 0 };
}
void RenderThemeIOS::adjustRoundBorderRadius(RenderStyle& style, RenderBox& box)
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2016-04-03 10:50:11 UTC (rev 198983)
@@ -75,10 +75,7 @@
int sliderTickOffsetFromTrackCenter() const override;
#endif
- int popupInternalPaddingLeft(const RenderStyle&) const override;
- int popupInternalPaddingRight(const RenderStyle&) const override;
- int popupInternalPaddingTop(const RenderStyle&) const override;
- int popupInternalPaddingBottom(const RenderStyle&) const override;
+ LengthBox popupInternalPaddingBox(const RenderStyle&) const override;
PopupMenuStyle::PopupMenuSize popupMenuSize(const RenderStyle&, IntRect&) const override;
bool popsMenuByArrowKeys() const override { return true; }
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (198982 => 198983)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2016-04-03 09:56:44 UTC (rev 198982)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2016-04-03 10:50:11 UTC (rev 198983)
@@ -1365,45 +1365,25 @@
style.setBoxShadow(nullptr);
}
-int RenderThemeMac::popupInternalPaddingLeft(const RenderStyle& style) const
+LengthBox RenderThemeMac::popupInternalPaddingBox(const RenderStyle& style) const
{
- if (style.appearance() == MenulistPart)
- return popupButtonPadding(controlSizeForFont(style))[leftPadding] * style.effectiveZoom();
- if (style.appearance() == MenulistButtonPart)
- return styledPopupPaddingLeft * style.effectiveZoom();
- return 0;
-}
+ if (style.appearance() == MenulistPart) {
+ return { static_cast<int>(popupButtonPadding(controlSizeForFont(style))[topPadding] * style.effectiveZoom()),
+ static_cast<int>(popupButtonPadding(controlSizeForFont(style))[rightPadding] * style.effectiveZoom()),
+ static_cast<int>(popupButtonPadding(controlSizeForFont(style))[bottomPadding] * style.effectiveZoom()),
+ static_cast<int>(popupButtonPadding(controlSizeForFont(style))[leftPadding] * style.effectiveZoom()) };
+ }
-int RenderThemeMac::popupInternalPaddingRight(const RenderStyle& style) const
-{
- if (style.appearance() == MenulistPart)
- return popupButtonPadding(controlSizeForFont(style))[rightPadding] * style.effectiveZoom();
if (style.appearance() == MenulistButtonPart) {
- float fontScale = style.fontSize() / baseFontSize;
- float arrowWidth = baseArrowWidth * fontScale;
- return static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPaddingRight + paddingBeforeSeparator) * style.effectiveZoom()));
+ float arrowWidth = baseArrowWidth * (style.fontSize() / baseFontSize);
+ return { static_cast<int>(styledPopupPaddingTop * style.effectiveZoom()),
+ static_cast<int>(ceilf(arrowWidth + (arrowPaddingLeft + arrowPaddingRight + paddingBeforeSeparator) * style.effectiveZoom())),
+ static_cast<int>(styledPopupPaddingBottom * style.effectiveZoom()), static_cast<int>(styledPopupPaddingLeft * style.effectiveZoom()) };
}
- return 0;
-}
-int RenderThemeMac::popupInternalPaddingTop(const RenderStyle& style) const
-{
- if (style.appearance() == MenulistPart)
- return popupButtonPadding(controlSizeForFont(style))[topPadding] * style.effectiveZoom();
- if (style.appearance() == MenulistButtonPart)
- return styledPopupPaddingTop * style.effectiveZoom();
- return 0;
+ return { 0, 0, 0, 0 };
}
-int RenderThemeMac::popupInternalPaddingBottom(const RenderStyle& style) const
-{
- if (style.appearance() == MenulistPart)
- return popupButtonPadding(controlSizeForFont(style))[bottomPadding] * style.effectiveZoom();
- if (style.appearance() == MenulistButtonPart)
- return styledPopupPaddingBottom * style.effectiveZoom();
- return 0;
-}
-
PopupMenuStyle::PopupMenuSize RenderThemeMac::popupMenuSize(const RenderStyle& style, IntRect& rect) const
{
NSPopUpButtonCell* popupButton = this->popupButton();