https://bugs.webkit.org/show_bug.cgi?id=145146
Reviewed by Benjamin Poulain.
Source/WebCore:
See per-file comments.
No new tests because there is no behavior change.
* platform/graphics/mac/FontCacheMac.mm:
(WebCore::fontWithFamilySpecialCase): Use equalIgnoringASCIICase() AtomicString overload.
* rendering/RenderThemeMac.mm:
(WebCore::RenderThemeMac::updateCachedSystemFontDescription): Implement Ben's ideas for
cheaply constructing AtomicStrings only when necessary.
Source/WTF:
Create an overload for equalIgnoringASCIICase() for AtomicString and string literals.
* wtf/text/AtomicString.h:
(WTF::equalIgnoringASCIICase):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184519
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2015-05-18 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Addressing post-review comments on r184353
+ https://bugs.webkit.org/show_bug.cgi?id=145146
+
+ Reviewed by Benjamin Poulain.
+
+ Create an overload for equalIgnoringASCIICase() for AtomicString and string literals.
+
+ * wtf/text/AtomicString.h:
+ (WTF::equalIgnoringASCIICase):
+
2015-05-18 Skachkov Alexandr <gskachkov@gmail.com>
[ES6] Arrow function syntax. Feature flag for arrow function
inline bool equalIgnoringASCIICase(const AtomicString& a, const String& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); }
inline bool equalIgnoringASCIICase(const String& a, const AtomicString& b) { return equalIgnoringASCIICase(a.impl(), b.impl()); }
+template <unsigned charactersCount>
+inline bool equalIgnoringASCIICase(const AtomicString& a, const char (&b)[charactersCount]) { return equalIgnoringASCIICase<charactersCount>(a.impl(), b); }
+
// Define external global variables for the commonly used atomic strings.
// These are only usable from the main thread.
#ifndef ATOMICSTRING_HIDE_GLOBALS
+2015-05-18 Myles C. Maxfield <mmaxfield@apple.com>
+
+ Addressing post-review comments on r184353
+ https://bugs.webkit.org/show_bug.cgi?id=145146
+
+ Reviewed by Benjamin Poulain.
+
+ See per-file comments.
+
+ No new tests because there is no behavior change.
+
+ * platform/graphics/mac/FontCacheMac.mm:
+ (WebCore::fontWithFamilySpecialCase): Use equalIgnoringASCIICase() AtomicString overload.
+ * rendering/RenderThemeMac.mm:
+ (WebCore::RenderThemeMac::updateCachedSystemFontDescription): Implement Ben's ideas for
+ cheaply constructing AtomicStrings only when necessary.
+
2015-05-18 Skachkov Alexandr <gskachkov@gmail.com>
[ES6] Arrow function syntax. Feature flag for arrow function
static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, FontWeight weight, float size)
{
- if (equalIgnoringASCIICase(family.string(), "-webkit-system-font")
- || equalIgnoringASCIICase(family.string(), "-apple-system")
- || equalIgnoringASCIICase(family.string(), "-apple-system-font")) {
+ if (equalIgnoringASCIICase(family, "-webkit-system-font")
+ || equalIgnoringASCIICase(family, "-apple-system")
+ || equalIgnoringASCIICase(family, "-apple-system-font")) {
#if __MAC_OS_X_VERSION_MIN_REQUIRED >= 101000
return [NSFont systemFontOfSize:size weight:toNSFontWeight(weight)];
#else
#endif
}
- if (equalIgnoringASCIICase(family.string(), "-apple-system-monospaced-numbers")) {
+ if (equalIgnoringASCIICase(family, "-apple-system-monospaced-numbers")) {
NSArray *featureArray = @[ @{ NSFontFeatureTypeIdentifierKey : @(kNumberSpacingType),
NSFontFeatureSelectorIdentifierKey : @(kMonospacedNumbersSelector) } ];
return [NSFont fontWithDescriptor:desc size:size];
}
- if (equalIgnoringASCIICase(family.string(), "-apple-menu"))
+ if (equalIgnoringASCIICase(family, "-apple-menu"))
return [NSFont menuFontOfSize:size];
- if (equalIgnoringASCIICase(family.string(), "-apple-status-bar"))
+ if (equalIgnoringASCIICase(family, "-apple-status-bar"))
return [NSFont labelFontOfSize:size];
return Optional<NSFont*>(Nullopt);
// System-font-ness can't be encapsulated by simply a font name. Instead, we must use a token
// which FontCache will look for.
// Make sure we keep this list of possible tokens in sync with FontCascade::primaryFontIsSystemFont()
- String fontName(ASCIILiteral("-apple-system"));
+ AtomicString fontName;
switch (cssValueId) {
case CSSValueSmallCaption:
font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
break;
case CSSValueMenu:
font = [NSFont menuFontOfSize:[NSFont systemFontSize]];
- fontName = String(ASCIILiteral("-apple-menu"));
+ fontName = AtomicString("-apple-menu", AtomicString::ConstructFromLiteral);
break;
case CSSValueStatusBar:
font = [NSFont labelFontOfSize:[NSFont labelFontSize]];
- fontName = String(ASCIILiteral("-apple-status-bar"));
+ fontName = AtomicString("-apple-status-bar", AtomicString::ConstructFromLiteral);
break;
case CSSValueWebkitMiniControl:
font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
if (!font)
return;
+ if (fontName.isNull())
+ fontName = AtomicString("-apple-system", AtomicString::ConstructFromLiteral);
+
NSFontManager *fontManager = [NSFontManager sharedFontManager];
fontDescription.setIsAbsoluteSize(true);
fontDescription.setOneFamily(fontName);