Title: [184519] trunk/Source
Revision
184519
Author
[email protected]
Date
2015-05-18 16:16:15 -0700 (Mon, 18 May 2015)

Log Message

Addressing post-review comments on r184353
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):

Modified Paths

Diff

Modified: trunk/Source/WTF/ChangeLog (184518 => 184519)


--- trunk/Source/WTF/ChangeLog	2015-05-18 23:01:08 UTC (rev 184518)
+++ trunk/Source/WTF/ChangeLog	2015-05-18 23:16:15 UTC (rev 184519)
@@ -1,3 +1,15 @@
+2015-05-18  Myles C. Maxfield  <[email protected]>
+
+        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  <[email protected]>
 
         [ES6] Arrow function syntax. Feature flag for arrow function

Modified: trunk/Source/WTF/wtf/text/AtomicString.h (184518 => 184519)


--- trunk/Source/WTF/wtf/text/AtomicString.h	2015-05-18 23:01:08 UTC (rev 184518)
+++ trunk/Source/WTF/wtf/text/AtomicString.h	2015-05-18 23:16:15 UTC (rev 184519)
@@ -290,6 +290,9 @@
 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

Modified: trunk/Source/WebCore/ChangeLog (184518 => 184519)


--- trunk/Source/WebCore/ChangeLog	2015-05-18 23:01:08 UTC (rev 184518)
+++ trunk/Source/WebCore/ChangeLog	2015-05-18 23:16:15 UTC (rev 184519)
@@ -1,3 +1,20 @@
+2015-05-18  Myles C. Maxfield  <[email protected]>
+
+        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  <[email protected]>
 
         [ES6] Arrow function syntax. Feature flag for arrow function

Modified: trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (184518 => 184519)


--- trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-05-18 23:01:08 UTC (rev 184518)
+++ trunk/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-05-18 23:16:15 UTC (rev 184519)
@@ -225,9 +225,9 @@
 
 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 @@
 #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 @@
         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);

Modified: trunk/Source/WebCore/rendering/RenderThemeMac.mm (184518 => 184519)


--- trunk/Source/WebCore/rendering/RenderThemeMac.mm	2015-05-18 23:01:08 UTC (rev 184518)
+++ trunk/Source/WebCore/rendering/RenderThemeMac.mm	2015-05-18 23:16:15 UTC (rev 184519)
@@ -350,18 +350,18 @@
     // 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 @@
     if (!font)
         return;
 
+    if (fontName.isNull())
+        fontName = AtomicString("-apple-system", AtomicString::ConstructFromLiteral);
+
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
     fontDescription.setIsAbsoluteSize(true);
     fontDescription.setOneFamily(fontName);
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to