Diff
Modified: trunk/Source/WebCore/ChangeLog (179049 => 179050)
--- trunk/Source/WebCore/ChangeLog 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/ChangeLog 2015-01-24 01:41:30 UTC (rev 179050)
@@ -1,3 +1,26 @@
+2015-01-23 Chris Dumez <[email protected]>
+
+ Implement system fonts FontDescription caching at RenderTheme level
+ https://bugs.webkit.org/show_bug.cgi?id=140840
+
+ Reviewed by Andreas Kling.
+
+ Implement system fonts FontDescription caching at RenderTheme level
+ instead of duplicating the logic in its subclasses for each platform.
+ This reduces code / logic duplication and reduces the amount of
+ platform-specific code. This will also make the refactoring at
+ Bug 140577 a lot easier.
+
+ The caching logic remains in RenderThemeIOS class for iOS because:
+ - It supports different system font values than all other platforms
+ - It requires cache invalidation in some cases while other platforms
+ do not.
+
+ This patch is inspired by the following Blink revision:
+ https://src.chromium.org/viewvc/blink?view=rev&revision=184449
+
+ Test: fast/css/css2-system-fonts.html
+
2015-01-23 Zalan Bujtas <[email protected]>
Simple line layout: Refactor line wrapping logic.
Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp (179049 => 179050)
--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.cpp 2015-01-24 01:41:30 UTC (rev 179050)
@@ -984,7 +984,7 @@
defaultFontSize = size;
}
-void RenderThemeEfl::systemFont(CSSValueID, FontDescription& fontDescription) const
+void RenderThemeEfl::updateCachedSystemFontDescription(CSSValueID, FontDescription& fontDescription) const
{
// It was called by RenderEmbeddedObject::paintReplaced to render alternative string.
// To avoid cairo_error while rendering, fontDescription should be passed.
Modified: trunk/Source/WebCore/platform/efl/RenderThemeEfl.h (179049 => 179050)
--- trunk/Source/WebCore/platform/efl/RenderThemeEfl.h 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/platform/efl/RenderThemeEfl.h 2015-01-24 01:41:30 UTC (rev 179050)
@@ -104,9 +104,6 @@
void adjustSizeConstraints(RenderStyle&, FormType) const;
- // System fonts.
- virtual void systemFont(CSSValueID, FontDescription&) const override;
-
virtual void adjustCheckboxStyle(StyleResolver&, RenderStyle&, Element*) const override;
virtual bool paintCheckbox(const RenderObject&, const PaintInfo&, const IntRect&) override;
@@ -189,6 +186,9 @@
return m_edje || (!m_themePath.isEmpty() && const_cast<RenderThemeEfl*>(this)->loadTheme());
}
+ // System fonts.
+ virtual void updateCachedSystemFontDescription(CSSValueID, FontDescription&) const override;
+
ALWAYS_INLINE Ecore_Evas* canvas() const { return m_canvas.get(); }
ALWAYS_INLINE Evas_Object* edje() const { return m_edje.get(); }
Modified: trunk/Source/WebCore/rendering/RenderTheme.cpp (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderTheme.cpp 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderTheme.cpp 2015-01-24 01:41:30 UTC (rev 179050)
@@ -1,7 +1,8 @@
-/**
+/*
* This file is part of the theme implementation for form controls in WebCore.
*
- * Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2012 Apple Inc.
+ * Copyright (C) 2005-2010, 2012, 2015 Apple Inc. All rights reserved.
+ * Copyright (C) 2014 Google Inc. All rights reserved.
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
@@ -45,6 +46,7 @@
#include "SpinButtonElement.h"
#include "StringTruncator.h"
#include "TextControlInnerElements.h"
+#include <wtf/NeverDestroyed.h>
#if ENABLE(METER_ELEMENT)
#include "HTMLMeterElement.h"
@@ -1130,6 +1132,55 @@
Page::updateStyleForAllPagesAfterGlobalChangeInEnvironment();
}
+FontDescription& RenderTheme::cachedSystemFontDescription(CSSValueID systemFontID) const
+{
+ static NeverDestroyed<FontDescription> caption;
+ static NeverDestroyed<FontDescription> icon;
+ static NeverDestroyed<FontDescription> menu;
+ static NeverDestroyed<FontDescription> messageBox;
+ static NeverDestroyed<FontDescription> smallCaption;
+ static NeverDestroyed<FontDescription> statusBar;
+ static NeverDestroyed<FontDescription> webkitMiniControl;
+ static NeverDestroyed<FontDescription> webkitSmallControl;
+ static NeverDestroyed<FontDescription> webkitControl;
+ static NeverDestroyed<FontDescription> defaultDescription;
+
+ switch (systemFontID) {
+ case CSSValueCaption:
+ return caption;
+ case CSSValueIcon:
+ return icon;
+ case CSSValueMenu:
+ return menu;
+ case CSSValueMessageBox:
+ return messageBox;
+ case CSSValueSmallCaption:
+ return smallCaption;
+ case CSSValueStatusBar:
+ return statusBar;
+ case CSSValueWebkitMiniControl:
+ return webkitMiniControl;
+ case CSSValueWebkitSmallControl:
+ return webkitSmallControl;
+ case CSSValueWebkitControl:
+ return webkitControl;
+ case CSSValueNone:
+ return defaultDescription;
+ default:
+ ASSERT_NOT_REACHED();
+ return defaultDescription;
+ }
+}
+
+void RenderTheme::systemFont(CSSValueID systemFontID, FontDescription& fontDescription) const
+{
+ fontDescription = cachedSystemFontDescription(systemFontID);
+ if (fontDescription.isAbsoluteSize())
+ return;
+
+ updateCachedSystemFontDescription(systemFontID, fontDescription);
+}
+
Color RenderTheme::systemColor(CSSValueID cssValueId) const
{
switch (cssValueId) {
Modified: trunk/Source/WebCore/rendering/RenderTheme.h (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderTheme.h 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderTheme.h 2015-01-24 01:41:30 UTC (rev 179050)
@@ -172,7 +172,7 @@
virtual double caretBlinkInterval() const { return 0.5; }
// System fonts and colors for CSS.
- virtual void systemFont(CSSValueID, FontDescription&) const = 0;
+ void systemFont(CSSValueID, FontDescription&) const;
virtual Color systemColor(CSSValueID) const;
virtual int minimumMenuListSize(RenderStyle&) const { return 0; }
@@ -252,6 +252,9 @@
virtual bool defaultButtonHasAnimation() const { return false; }
protected:
+ virtual FontDescription& cachedSystemFontDescription(CSSValueID systemFontID) const;
+ virtual void updateCachedSystemFontDescription(CSSValueID systemFontID, FontDescription&) const = 0;
+
// The platform selection color.
virtual Color platformActiveSelectionBackgroundColor() const;
virtual Color platformInactiveSelectionBackgroundColor() const;
Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.cpp (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeGtk.cpp 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.cpp 2015-01-24 01:41:30 UTC (rev 179050)
@@ -84,7 +84,7 @@
return dpi;
}
-void RenderThemeGtk::systemFont(CSSValueID, FontDescription& fontDescription) const
+void RenderThemeGtk::updateCachedSystemFontDescription(CSSValueID, FontDescription& fontDescription) const
{
GtkSettings* settings = gtk_settings_get_default();
if (!settings)
Modified: trunk/Source/WebCore/rendering/RenderThemeGtk.h (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeGtk.h 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeGtk.h 2015-01-24 01:41:30 UTC (rev 179050)
@@ -36,9 +36,6 @@
public:
static PassRefPtr<RenderTheme> create();
- // System fonts.
- virtual void systemFont(CSSValueID, FontDescription&) const override;
-
#if ENABLE(DATALIST_ELEMENT)
// Returns size of one slider tick mark for a horizontal track.
// For vertical tracks we rotate it and use it. i.e. Width is always length along the track.
@@ -47,6 +44,11 @@
virtual int sliderTickOffsetFromTrackCenter() const override;
#endif
+private:
+ // System fonts.
+ virtual void updateCachedSystemFontDescription(CSSValueID, FontDescription&) const override;
+
+public:
#ifndef GTK_API_VERSION_2
// A method asking if the theme's controls actually care about redrawing when hovered.
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.h (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.h 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.h 2015-01-24 01:41:30 UTC (rev 179050)
@@ -43,13 +43,13 @@
static void adjustRoundBorderRadius(RenderStyle&, RenderBox&);
- virtual void systemFont(CSSValueID, FontDescription&) const override;
-
static CFStringRef contentSizeCategory();
WEBCORE_EXPORT static void setContentSizeCategory(const String&);
protected:
+ virtual FontDescription& cachedSystemFontDescription(CSSValueID systemFontID) const override;
+ virtual void updateCachedSystemFontDescription(CSSValueID, FontDescription&) const override;
virtual int baselinePosition(const RenderObject&) const override;
virtual bool isControlStyled(const RenderStyle&, const BorderData&, const FillLayer& background, const Color& backgroundColor) const override;
Modified: trunk/Source/WebCore/rendering/RenderThemeIOS.mm (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeIOS.mm 2015-01-24 01:41:30 UTC (rev 179050)
@@ -1103,7 +1103,7 @@
return FontWeightNormal;
}
-void RenderThemeIOS::systemFont(CSSValueID valueID, FontDescription& fontDescription) const
+FontDescription& RenderThemeIOS::cachedSystemFontDescription(CSSValueID valueID) const
{
static NeverDestroyed<FontDescription> systemFont;
static NeverDestroyed<FontDescription> headlineFont;
@@ -1143,123 +1143,130 @@
tallBodyFont.get().setIsAbsoluteSize(false);
}
- FontDescription* cachedDesc;
+ switch (valueID) {
+ case CSSValueAppleSystemHeadline:
+ return headlineFont;
+ case CSSValueAppleSystemBody:
+ return bodyFont;
+#if __IPHONE_OS_VERSION_MIN_REQUIRED > 80200
+ case CSSValueAppleSystemTitle1:
+ return title1Font;
+ case CSSValueAppleSystemTitle2:
+ return title2Font;
+ case CSSValueAppleSystemTitle3:
+ return title3Font;
+#endif
+ case CSSValueAppleSystemSubheadline:
+ return subheadlineFont;
+ case CSSValueAppleSystemFootnote:
+ return footnoteFont;
+ case CSSValueAppleSystemCaption1:
+ return caption1Font;
+ case CSSValueAppleSystemCaption2:
+ return caption2Font;
+ // Short version.
+ case CSSValueAppleSystemShortHeadline:
+ return shortHeadlineFont;
+ case CSSValueAppleSystemShortBody:
+ return shortBodyFont;
+ case CSSValueAppleSystemShortSubheadline:
+ return shortSubheadlineFont;
+ case CSSValueAppleSystemShortFootnote:
+ return shortFootnoteFont;
+ case CSSValueAppleSystemShortCaption1:
+ return shortCaption1Font;
+ // Tall version.
+ case CSSValueAppleSystemTallBody:
+ return tallBodyFont;
+ default:
+ return systemFont;
+ }
+}
+
+void RenderThemeIOS::updateCachedSystemFontDescription(CSSValueID valueID, FontDescription& fontDescription) const
+{
RetainPtr<CTFontDescriptorRef> fontDescriptor;
CFStringRef textStyle;
switch (valueID) {
case CSSValueAppleSystemHeadline:
- cachedDesc = &headlineFont.get();
textStyle = kCTUIFontTextStyleHeadline;
- if (!headlineFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemBody:
- cachedDesc = &bodyFont.get();
textStyle = kCTUIFontTextStyleBody;
- if (!bodyFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
#if __IPHONE_OS_VERSION_MIN_REQUIRED > 80200
case CSSValueAppleSystemTitle1:
- cachedDesc = &title1Font.get();
textStyle = kCTUIFontTextStyleTitle1;
- if (!title1Font.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemTitle2:
- cachedDesc = &title2Font.get();
textStyle = kCTUIFontTextStyleTitle2;
- if (!title2Font.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemTitle3:
- cachedDesc = &title3Font.get();
textStyle = kCTUIFontTextStyleTitle3;
- if (!title3Font.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
#endif
case CSSValueAppleSystemSubheadline:
- cachedDesc = &subheadlineFont.get();
textStyle = kCTUIFontTextStyleSubhead;
- if (!subheadlineFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemFootnote:
- cachedDesc = &footnoteFont.get();
textStyle = kCTUIFontTextStyleFootnote;
- if (!footnoteFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemCaption1:
- cachedDesc = &caption1Font.get();
textStyle = kCTUIFontTextStyleCaption1;
- if (!caption1Font.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemCaption2:
- cachedDesc = &caption2Font.get();
textStyle = kCTUIFontTextStyleCaption2;
- if (!caption2Font.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
// Short version.
case CSSValueAppleSystemShortHeadline:
- cachedDesc = &shortHeadlineFont.get();
textStyle = kCTUIFontTextStyleShortHeadline;
- if (!shortHeadlineFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemShortBody:
- cachedDesc = &shortBodyFont.get();
textStyle = kCTUIFontTextStyleShortBody;
- if (!shortBodyFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemShortSubheadline:
- cachedDesc = &shortSubheadlineFont.get();
textStyle = kCTUIFontTextStyleShortSubhead;
- if (!shortSubheadlineFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemShortFootnote:
- cachedDesc = &shortFootnoteFont.get();
textStyle = kCTUIFontTextStyleShortFootnote;
- if (!shortFootnoteFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
case CSSValueAppleSystemShortCaption1:
- cachedDesc = &shortCaption1Font.get();
textStyle = kCTUIFontTextStyleShortCaption1;
- if (!shortCaption1Font.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
// Tall version.
case CSSValueAppleSystemTallBody:
- cachedDesc = &tallBodyFont.get();
textStyle = kCTUIFontTextStyleTallBody;
- if (!tallBodyFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, userTextSize, 0));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateWithTextStyle(textStyle, contentSizeCategory(), 0));
break;
default:
textStyle = kCTFontDescriptorTextStyleEmphasized;
- cachedDesc = &systemFont.get();
- if (!systemFont.get().isAbsoluteSize())
- fontDescriptor = adoptCF(CTFontDescriptorCreateForUIType(kCTFontSystemFontType, 0, nullptr));
+ fontDescriptor = adoptCF(CTFontDescriptorCreateForUIType(kCTFontSystemFontType, 0, nullptr));
}
- if (fontDescriptor) {
- RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
- cachedDesc->setIsAbsoluteSize(true);
- cachedDesc->setOneFamily(textStyle);
- cachedDesc->setSpecifiedSize(CTFontGetSize(font.get()));
- cachedDesc->setWeight(fromCTFontWeight(FontCache::weightOfCTFont(font.get())));
- cachedDesc->setItalic(FontItalicOff);
- }
- fontDescription = *cachedDesc;
+ ASSERT(fontDescriptor);
+ RetainPtr<CTFontRef> font = adoptCF(CTFontCreateWithFontDescriptor(fontDescriptor.get(), 0, nullptr));
+ fontDescription.setIsAbsoluteSize(true);
+ fontDescription.setOneFamily(textStyle);
+ fontDescription.setSpecifiedSize(CTFontGetSize(font.get()));
+ fontDescription.setWeight(fromCTFontWeight(FontCache::weightOfCTFont(font.get())));
+ fontDescription.setItalic(FontItalicOff);
}
#if ENABLE(VIDEO)
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.h (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeMac.h 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.h 2015-01-24 01:41:30 UTC (rev 179050)
@@ -66,9 +66,6 @@
virtual void platformColorsDidChange() override;
- // System fonts.
- virtual void systemFont(CSSValueID, FontDescription&) const override;
-
virtual int minimumMenuListSize(RenderStyle&) const override;
virtual void adjustSliderThumbSize(RenderStyle&, Element*) const override;
@@ -112,6 +109,9 @@
RenderThemeMac();
virtual ~RenderThemeMac();
+ // System fonts.
+ virtual void updateCachedSystemFontDescription(CSSValueID, FontDescription&) const override;
+
#if ENABLE(VIDEO)
// Media controls
virtual String mediaControlsStyleSheet() override;
Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeMac.mm 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm 2015-01-24 01:41:30 UTC (rev 179050)
@@ -338,64 +338,41 @@
return fontWeights[appKitFontWeight - 1];
}
-void RenderThemeMac::systemFont(CSSValueID cssValueId, FontDescription& fontDescription) const
+void RenderThemeMac::updateCachedSystemFontDescription(CSSValueID cssValueId, FontDescription& fontDescription) const
{
- DEPRECATED_DEFINE_STATIC_LOCAL(FontDescription, systemFont, ());
- DEPRECATED_DEFINE_STATIC_LOCAL(FontDescription, smallSystemFont, ());
- DEPRECATED_DEFINE_STATIC_LOCAL(FontDescription, menuFont, ());
- DEPRECATED_DEFINE_STATIC_LOCAL(FontDescription, labelFont, ());
- DEPRECATED_DEFINE_STATIC_LOCAL(FontDescription, miniControlFont, ());
- DEPRECATED_DEFINE_STATIC_LOCAL(FontDescription, smallControlFont, ());
- DEPRECATED_DEFINE_STATIC_LOCAL(FontDescription, controlFont, ());
-
- FontDescription* cachedDesc;
- NSFont* font = nil;
+ NSFont* font;
switch (cssValueId) {
case CSSValueSmallCaption:
- cachedDesc = &smallSystemFont;
- if (!smallSystemFont.isAbsoluteSize())
- font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
+ font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
break;
case CSSValueMenu:
- cachedDesc = &menuFont;
- if (!menuFont.isAbsoluteSize())
- font = [NSFont menuFontOfSize:[NSFont systemFontSize]];
+ font = [NSFont menuFontOfSize:[NSFont systemFontSize]];
break;
case CSSValueStatusBar:
- cachedDesc = &labelFont;
- if (!labelFont.isAbsoluteSize())
- font = [NSFont labelFontOfSize:[NSFont labelFontSize]];
+ font = [NSFont labelFontOfSize:[NSFont labelFontSize]];
break;
case CSSValueWebkitMiniControl:
- cachedDesc = &miniControlFont;
- if (!miniControlFont.isAbsoluteSize())
- font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
+ font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
break;
case CSSValueWebkitSmallControl:
- cachedDesc = &smallControlFont;
- if (!smallControlFont.isAbsoluteSize())
- font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
+ font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSSmallControlSize]];
break;
case CSSValueWebkitControl:
- cachedDesc = &controlFont;
- if (!controlFont.isAbsoluteSize())
- font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
+ font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSRegularControlSize]];
break;
default:
- cachedDesc = &systemFont;
- if (!systemFont.isAbsoluteSize())
- font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
+ font = [NSFont systemFontOfSize:[NSFont systemFontSize]];
}
- if (font) {
- NSFontManager *fontManager = [NSFontManager sharedFontManager];
- cachedDesc->setIsAbsoluteSize(true);
- cachedDesc->setOneFamily([font webCoreFamilyName]);
- cachedDesc->setSpecifiedSize([font pointSize]);
- cachedDesc->setWeight(toFontWeight([fontManager weightOfFont:font]));
- cachedDesc->setIsItalic([fontManager traitsOfFont:font] & NSItalicFontMask);
- }
- fontDescription = *cachedDesc;
+ if (!font)
+ return;
+
+ NSFontManager *fontManager = [NSFontManager sharedFontManager];
+ fontDescription.setIsAbsoluteSize(true);
+ fontDescription.setOneFamily([font webCoreFamilyName]);
+ fontDescription.setSpecifiedSize([font pointSize]);
+ fontDescription.setWeight(toFontWeight([fontManager weightOfFont:font]));
+ fontDescription.setIsItalic([fontManager traitsOfFont:font] & NSItalicFontMask);
}
static RGBA32 convertNSColorToColor(NSColor *color)
Modified: trunk/Source/WebCore/rendering/RenderThemeSafari.cpp (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeSafari.cpp 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeSafari.cpp 2015-01-24 01:41:30 UTC (rev 179050)
@@ -192,63 +192,40 @@
return sizes[controlSize];
}
-void RenderThemeSafari::systemFont(CSSValueID valueID, FontDescription& fontDescription) const
+void RenderThemeSafari::updateCachedSystemFontDescription(CSSValueID valueID, FontDescription& fontDescription) const
{
- static FontDescription systemFont;
- static FontDescription smallSystemFont;
- static FontDescription menuFont;
- static FontDescription labelFont;
- static FontDescription miniControlFont;
- static FontDescription smallControlFont;
- static FontDescription controlFont;
-
- FontDescription* cachedDesc;
- float fontSize = 0;
+ float fontSize;
switch (valueID) {
case CSSValueSmallCaption:
- cachedDesc = &smallSystemFont;
- if (!smallSystemFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSSmallControlSize);
+ fontSize = systemFontSizeForControlSize(NSSmallControlSize);
break;
case CSSValueMenu:
- cachedDesc = &menuFont;
- if (!menuFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSRegularControlSize);
+ fontSize = systemFontSizeForControlSize(NSRegularControlSize);
break;
case CSSValueStatusBar:
- cachedDesc = &labelFont;
- if (!labelFont.isAbsoluteSize())
- fontSize = 10.0f;
+ fontSize = 10.0f;
break;
case CSSValueWebkitMiniControl:
- cachedDesc = &miniControlFont;
- if (!miniControlFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSMiniControlSize);
+ fontSize = systemFontSizeForControlSize(NSMiniControlSize);
break;
case CSSValueWebkitSmallControl:
- cachedDesc = &smallControlFont;
- if (!smallControlFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSSmallControlSize);
+ fontSize = systemFontSizeForControlSize(NSSmallControlSize);
break;
case CSSValueWebkitControl:
- cachedDesc = &controlFont;
- if (!controlFont.isAbsoluteSize())
- fontSize = systemFontSizeForControlSize(NSRegularControlSize);
+ fontSize = systemFontSizeForControlSize(NSRegularControlSize);
break;
default:
- cachedDesc = &systemFont;
- if (!systemFont.isAbsoluteSize())
- fontSize = 13.0f;
+ fontSize = 13.0f;
}
- if (fontSize) {
- cachedDesc->setIsAbsoluteSize(true);
- cachedDesc->setOneFamily("Lucida Grande");
- cachedDesc->setSpecifiedSize(fontSize);
- cachedDesc->setWeight(FontWeightNormal);
- cachedDesc->setItalic(FontItalicOff);
- }
- fontDescription = *cachedDesc;
+ if (!fontSize)
+ return;
+
+ fontDescription.setIsAbsoluteSize(true);
+ fontDescription.setOneFamily("Lucida Grande");
+ fontDescription.setSpecifiedSize(fontSize);
+ fontDescription.setWeight(FontWeightNormal);
+ fontDescription.setItalic(FontItalicOff);
}
bool RenderThemeSafari::isControlStyled(const RenderStyle& style, const BorderData& border,
Modified: trunk/Source/WebCore/rendering/RenderThemeSafari.h (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeSafari.h 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeSafari.h 2015-01-24 01:41:30 UTC (rev 179050)
@@ -71,9 +71,6 @@
virtual Color platformFocusRingColor() const;
- // System fonts.
- virtual void systemFont(CSSValueID, FontDescription&) const;
-
virtual int minimumMenuListSize(RenderStyle&) const;
virtual void adjustSliderThumbSize(RenderStyle&, Element*) const;
@@ -85,6 +82,9 @@
virtual int popupInternalPaddingBottom(RenderStyle&) const;
protected:
+ // System fonts.
+ virtual void updateCachedSystemFontDescription(CSSValueID, FontDescription&) const override;
+
// Methods for each appearance value.
virtual bool paintCheckbox(const RenderObject&, const PaintInfo&, const IntRect&);
virtual void setCheckboxSize(RenderStyle&) const;
Modified: trunk/Source/WebCore/rendering/RenderThemeWin.cpp (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeWin.cpp 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeWin.cpp 2015-01-24 01:41:30 UTC (rev 179050)
@@ -329,22 +329,8 @@
fontDescription.setIsItalic(logFont.lfItalic);
}
-static void fillFontDescription(FontDescription& fontDescription, LOGFONT& logFont)
-{
- fillFontDescription(fontDescription, logFont, abs(logFont.lfHeight));
-}
-
-void RenderThemeWin::systemFont(CSSValueID valueID, FontDescription& fontDescription) const
+void RenderThemeWin::updateCachedSystemFontDescription(CSSValueID valueID, FontDescription& fontDescription) const
{
- static FontDescription captionFont;
- static FontDescription controlFont;
- static FontDescription smallCaptionFont;
- static FontDescription menuFont;
- static FontDescription iconFont;
- static FontDescription messageBoxFont;
- static FontDescription statusBarFont;
- static FontDescription systemFont;
-
static bool initialized;
static NONCLIENTMETRICS ncm;
@@ -354,66 +340,41 @@
::SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(ncm), &ncm, 0);
}
+ LOGFONT logFont;
+ bool shouldUseDefaultControlFontPixelSize = false;
switch (valueID) {
- case CSSValueIcon: {
- if (!iconFont.isAbsoluteSize()) {
- LOGFONT logFont;
- ::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(logFont), &logFont, 0);
- fillFontDescription(iconFont, logFont);
- }
- fontDescription = iconFont;
+ case CSSValueIcon:
+ ::SystemParametersInfo(SPI_GETICONTITLELOGFONT, sizeof(logFont), &logFont, 0);
break;
- }
case CSSValueMenu:
- if (!menuFont.isAbsoluteSize())
- fillFontDescription(menuFont, ncm.lfMenuFont);
- fontDescription = menuFont;
+ logFont = ncm.lfMenuFont;
break;
case CSSValueMessageBox:
- if (!messageBoxFont.isAbsoluteSize())
- fillFontDescription(messageBoxFont, ncm.lfMessageFont);
- fontDescription = messageBoxFont;
+ logFont = ncm.lfMessageFont;
break;
case CSSValueStatusBar:
- if (!statusBarFont.isAbsoluteSize())
- fillFontDescription(statusBarFont, ncm.lfStatusFont);
- fontDescription = statusBarFont;
+ logFont = ncm.lfStatusFont;
break;
case CSSValueCaption:
- if (!captionFont.isAbsoluteSize())
- fillFontDescription(captionFont, ncm.lfCaptionFont);
- fontDescription = captionFont;
+ logFont = ncm.lfCaptionFont;
break;
case CSSValueSmallCaption:
- if (!smallCaptionFont.isAbsoluteSize())
- fillFontDescription(smallCaptionFont, ncm.lfSmCaptionFont);
- fontDescription = smallCaptionFont;
+ logFont = ncm.lfSmCaptionFont;
break;
case CSSValueWebkitSmallControl:
case CSSValueWebkitMiniControl: // Just map to small.
case CSSValueWebkitControl: // Just map to small.
- if (!controlFont.isAbsoluteSize()) {
- HGDIOBJ hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
- if (hGDI) {
- LOGFONT logFont;
- if (::GetObject(hGDI, sizeof(logFont), &logFont) > 0)
- fillFontDescription(controlFont, logFont, defaultControlFontPixelSize);
- }
- }
- fontDescription = controlFont;
- break;
+ shouldUseDefaultControlFontPixelSize = true;
+ FALLTHROUGH;
default: { // Everything else uses the stock GUI font.
- if (!systemFont.isAbsoluteSize()) {
- HGDIOBJ hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
- if (hGDI) {
- LOGFONT logFont;
- if (::GetObject(hGDI, sizeof(logFont), &logFont) > 0)
- fillFontDescription(systemFont, logFont);
- }
- }
- fontDescription = systemFont;
+ HGDIOBJ hGDI = ::GetStockObject(DEFAULT_GUI_FONT);
+ if (!hGDI)
+ return;
+ if (::GetObject(hGDI, sizeof(logFont), &logFont) <= 0)
+ return;
}
}
+ fillFontDescription(fontDescription, logFont, shouldUseDefaultControlFontPixelSize ? defaultControlFontPixelSize : abs(logFont.lfHeight));
}
bool RenderThemeWin::supportsFocus(ControlPart appearance) const
Modified: trunk/Source/WebCore/rendering/RenderThemeWin.h (179049 => 179050)
--- trunk/Source/WebCore/rendering/RenderThemeWin.h 2015-01-24 01:38:10 UTC (rev 179049)
+++ trunk/Source/WebCore/rendering/RenderThemeWin.h 2015-01-24 01:41:30 UTC (rev 179050)
@@ -62,8 +62,6 @@
virtual Color platformActiveSelectionForegroundColor() const override;
virtual Color platformInactiveSelectionForegroundColor() const override;
- // System fonts.
- virtual void systemFont(CSSValueID, FontDescription&) const override;
virtual Color systemColor(CSSValueID) const override;
virtual bool paintCheckbox(const RenderObject& o, const PaintInfo& i, const IntRect& r) override
@@ -148,6 +146,9 @@
RenderThemeWin();
virtual ~RenderThemeWin();
+ // System fonts.
+ virtual void updateCachedSystemFontDescription(CSSValueID, FontDescription&) const override;
+
void addIntrinsicMargins(RenderStyle&) const;
void close();