Addressing post-review comments on r184353
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2015 23:16:15 +0000 (23:16 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 18 May 2015 23:16:15 +0000 (23:16 +0000)
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

Source/WTF/ChangeLog
Source/WTF/wtf/text/AtomicString.h
Source/WebCore/ChangeLog
Source/WebCore/platform/graphics/mac/FontCacheMac.mm
Source/WebCore/rendering/RenderThemeMac.mm

index a4137e7..ca0071b 100644 (file)
@@ -1,3 +1,15 @@
+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
index cbfdc89..a685a31 100644 (file)
@@ -290,6 +290,9 @@ inline bool equalIgnoringASCIICase(const AtomicString& a, const AtomicString& b)
 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
index d302195..8c2b9a0 100644 (file)
@@ -1,3 +1,20 @@
+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
index 635adcb..2a07132 100644 (file)
@@ -225,9 +225,9 @@ static CGFloat toNSFontWeight(FontWeight fontWeight)
 
 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
@@ -235,7 +235,7 @@ static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, F
 #endif
     }
 
-    if (equalIgnoringASCIICase(family.string(), "-apple-system-monospaced-numbers")) {
+    if (equalIgnoringASCIICase(family, "-apple-system-monospaced-numbers")) {
         NSArray *featureArray = @[ @{ NSFontFeatureTypeIdentifierKey : @(kNumberSpacingType),
             NSFontFeatureSelectorIdentifierKey : @(kMonospacedNumbersSelector) } ];
 
@@ -244,10 +244,10 @@ static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, F
         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);
index 11481b9..14a8ed6 100644 (file)
@@ -350,18 +350,18 @@ void RenderThemeMac::updateCachedSystemFontDescription(CSSValueID cssValueId, Fo
     // 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]];
@@ -379,6 +379,9 @@ void RenderThemeMac::updateCachedSystemFontDescription(CSSValueID cssValueId, Fo
     if (!font)
         return;
 
+    if (fontName.isNull())
+        fontName = AtomicString("-apple-system", AtomicString::ConstructFromLiteral);
+
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
     fontDescription.setIsAbsoluteSize(true);
     fontDescription.setOneFamily(fontName);