https://bugs.webkit.org/show_bug.cgi?id=144234
Reviewed by Antti Koivisto.
Source/WebCore:
Test: fast/forms/button-line-height.html
* platform/Theme.h: Changed controlFont to return an Optional so we can tell
when the theme is overriding the font. Otherwise if the font from the user-agent
style sheet and the font from the theme are the same, we will think we are not
overriding the font when we actually are.
* platform/mac/ThemeMac.h: Updated controlFont to return Optional.
* platform/mac/ThemeMac.mm:
(WebCore::ThemeMac::controlFont): Ditto.
* rendering/RenderTheme.cpp:
(WebCore::RenderTheme::adjustStyle): Set line height only if the font is
overriden by the theme, all the time for PushButtonPart on Mac, and not at all
for other parts. Also tightened up the logic a little since RenderStyle's
setFontDescription already does an "==" comparison; we don't have to do
that twice.
LayoutTests:
* fast/forms/button-line-height-expected.html: Added.
* fast/forms/button-line-height.html: Added.
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@183366
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-04-26 Darin Adler <darin@apple.com>
+
+ REGRESSION (r176751): line-height ignored in <button> elements
+ https://bugs.webkit.org/show_bug.cgi?id=144234
+
+ Reviewed by Antti Koivisto.
+
+ * fast/forms/button-line-height-expected.html: Added.
+ * fast/forms/button-line-height.html: Added.
+
2015-04-26 Darin Adler <darin@apple.com>
REGRESSION (r173801): Use after free in WebCore::NotificationCenter::~NotificationCenter
--- /dev/null
+<button style="height:24px; margin:0">Button with line-height</button>
+<button style="height:24px; margin:0">Button with height</button>
+<button style="height:124px; margin:0">Button with line-height</button>
+<button style="height:124px; margin:0">Button with height</button>
--- /dev/null
+<button style="line-height:19px; margin:0">Button with line-height</button>
+<button style="height:24px; margin:0">Button with height</button>
+<button style="line-height:119px; margin:0">Button with line-height</button>
+<button style="height:124px; margin:0">Button with height</button>
+2015-04-26 Darin Adler <darin@apple.com>
+
+ REGRESSION (r176751): line-height ignored in <button> elements
+ https://bugs.webkit.org/show_bug.cgi?id=144234
+
+ Reviewed by Antti Koivisto.
+
+ Test: fast/forms/button-line-height.html
+
+ * platform/Theme.h: Changed controlFont to return an Optional so we can tell
+ when the theme is overriding the font. Otherwise if the font from the user-agent
+ style sheet and the font from the theme are the same, we will think we are not
+ overriding the font when we actually are.
+
+ * platform/mac/ThemeMac.h: Updated controlFont to return Optional.
+ * platform/mac/ThemeMac.mm:
+ (WebCore::ThemeMac::controlFont): Ditto.
+
+ * rendering/RenderTheme.cpp:
+ (WebCore::RenderTheme::adjustStyle): Set line height only if the font is
+ overriden by the theme, all the time for PushButtonPart on Mac, and not at all
+ for other parts. Also tightened up the logic a little since RenderStyle's
+ setFontDescription already does an "==" comparison; we don't have to do
+ that twice.
+
2015-04-26 Darin Adler <darin@apple.com>
REGRESSION (r173801): Use after free in WebCore::NotificationCenter::~NotificationCenter
#include "LengthSize.h"
#include "ThemeTypes.h"
#include <wtf/Forward.h>
+#include <wtf/Optional.h>
namespace WebCore {
// Methods used to adjust the RenderStyles of controls.
// The font description result should have a zoomed font size.
- virtual FontDescription controlFont(ControlPart, const FontCascade& font, float /*zoomFactor*/) const { return font.fontDescription(); }
+ virtual Optional<FontDescription> controlFont(ControlPart, const FontCascade&, float /*zoomFactor*/) const { return Nullopt; }
- // The size here is in zoomed coordinates already. If a new size is returned, it also needs to be in zoomed coordinates.
+ // The size here is in zoomed coordinates already. If a new size is returned, it also needs to be in zoomed coordinates.
virtual LengthSize controlSize(ControlPart, const FontCascade&, const LengthSize& zoomedSize, float /*zoomFactor*/) const { return zoomedSize; }
// Returns the minimum size for a control in zoomed coordinates.
virtual int baselinePositionAdjustment(ControlPart) const;
- virtual FontDescription controlFont(ControlPart, const FontCascade&, float zoomFactor) const;
+ virtual Optional<FontDescription> controlFont(ControlPart, const FontCascade&, float zoomFactor) const;
virtual LengthSize controlSize(ControlPart, const FontCascade&, const LengthSize&, float zoomFactor) const;
virtual LengthSize minimumControlSize(ControlPart, const FontCascade&, float zoomFactor) const;
return Theme::baselinePositionAdjustment(part);
}
-FontDescription ThemeMac::controlFont(ControlPart part, const FontCascade& font, float zoomFactor) const
+Optional<FontDescription> ThemeMac::controlFont(ControlPart part, const FontCascade& font, float zoomFactor) const
{
switch (part) {
case PushButtonPart: {
style.setMinHeight(minControlSize.height());
// Font
- FontDescription controlFont = m_theme->controlFont(part, style.fontCascade(), style.effectiveZoom());
- if (controlFont != style.fontCascade().fontDescription()) {
- // Now update our font.
- if (style.setFontDescription(controlFont))
- style.fontCascade().update(0);
+ if (auto themeFont = m_theme->controlFont(part, style.fontCascade(), style.effectiveZoom())) {
+ // If overriding the specified font with the theme font, also override the line height with the standard line height.
+ style.setLineHeight(RenderStyle::initialLineHeight());
+ if (style.setFontDescription(themeFont.value()))
+ style.fontCascade().update(nullptr);
}
- // Reset our line-height
- style.setLineHeight(RenderStyle::initialLineHeight());
style.setInsideDefaultButton(part == DefaultButtonPart);
}
break;