Addressing post-review comment.
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 18:05:12 +0000 (18:05 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 14 Oct 2014 18:05:12 +0000 (18:05 +0000)
https://bugs.webkit.org/show_bug.cgi?id=137550

Unreviewed.

* WebView/WebHTMLView.mm:
(fontNameForDescription):
(-[WebHTMLView _addToStyle:fontA:fontB:]):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@174689 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebView/WebHTMLView.mm

index d07ef784e641c4ebb1e4159f0d85078a14000089..635efb6dd9ae55c8ff5f46698243df0fef73ba90 100644 (file)
@@ -1,3 +1,14 @@
+2014-10-14  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        Addressing post-review comment.
+        https://bugs.webkit.org/show_bug.cgi?id=137550
+
+        Unreviewed.
+
+        * WebView/WebHTMLView.mm:
+        (fontNameForDescription):
+        (-[WebHTMLView _addToStyle:fontA:fontB:]):
+
 2014-10-14  Chris Dumez  <cdumez@apple.com>
 
         Use is<>() / downcast<>() for RenderImage
index 93d38f0e8ca54b5f85f6187662509725122e9cc8..0863bdefaed8da1e1dc9b2eac826ca6664874fc4 100644 (file)
@@ -4859,6 +4859,18 @@ static PassRefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
     return [[NSFontManager sharedFontManager] fontWithFamily:@"Times" traits:NSFontItalicTrait weight:STANDARD_BOLD_WEIGHT size:12.0f];
 }
 
+static NSString *fontNameForDescription(NSString *familyName, BOOL italic, BOOL bold, int pointSize)
+{
+    // Find the font the same way the rendering code would later if it encountered this CSS.
+    FontDescription fontDescription;
+    fontDescription.setItalic(italic);
+    fontDescription.setWeight(bold ? FontWeight900 : FontWeight500);
+    fontDescription.setSpecifiedSize(pointSize);
+    FontCachePurgePreventer purgePreventer;
+    RefPtr<SimpleFontData> simpleFontData = fontCache().getCachedFontData(fontDescription, familyName, false, WebCore::FontCache::DoNotRetain);
+    return [simpleFontData->platformData().font() fontName];
+}
+
 - (void)_addToStyle:(DOMCSSStyleDeclaration *)style fontA:(NSFont *)a fontB:(NSFont *)b
 {
     // Since there's no way to directly ask NSFontManager what style change it's going to do
@@ -4893,18 +4905,9 @@ static PassRefPtr<KeyboardEvent> currentKeyboardEvent(Frame* coreFrame)
         // The family name may not be specific enough to get us the font specified.
         // In some cases, the only way to get exactly what we are looking for is to use
         // the Postscript name.
-        
-        // Find the font the same way the rendering code would later if it encountered this CSS.
-        FontDescription fontDescription;
-        fontDescription.setItalic(aIsItalic);
-        fontDescription.setWeight(aIsBold ? FontWeight900 : FontWeight500);
-        fontDescription.setSpecifiedSize(aPointSize);
-        FontCachePurgePreventer purgePreventer;
-        RefPtr<SimpleFontData> simpleFontData = fontCache().getCachedFontData(fontDescription, aFamilyName, false, WebCore::FontCache::DoNotRetain);
-
         // If we don't find a font with the same Postscript name, then we'll have to use the
         // Postscript name to make the CSS specific enough.
-        if (![[simpleFontData->platformData().font() fontName] isEqualToString:[a fontName]])
+        if (![fontNameForDescription(aFamilyName, aIsItalic, aIsBold, aPointSize) isEqualToString:[a fontName]])
             familyNameForCSS = [a fontName];
 
         // FIXME: Need more sophisticated escaping code if we want to handle family names