Title: [184495] branches/safari-601.1.32.2-branch

Diff

Modified: branches/safari-601.1.32.2-branch/LayoutTests/ChangeLog (184494 => 184495)


--- branches/safari-601.1.32.2-branch/LayoutTests/ChangeLog	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/LayoutTests/ChangeLog	2015-05-18 17:01:03 UTC (rev 184495)
@@ -1,3 +1,21 @@
+2015-05-18  Matthew Hanson  <[email protected]>
+
+        Merge r184353. rdar://problem/20809399
+
+    2015-05-14  Myles C. Maxfield  <[email protected]>
+
+            [Mac] Expose more font weights for -apple-system
+            https://bugs.webkit.org/show_bug.cgi?id=144707
+
+            Reviewed by Simon Fraser.
+
+            * platform/mac/fast/text/systemFont-expected.txt: Update expectations.
+            * platform/mac/fast/text/systemFont.html: Update test to include font weights for -apple-system.
+            * platform/mac/fast/css/css2-system-fonts-expected.txt: Updated to not hardcode the system font family name.
+            * platform/mac-mavericks/fast/css/css2-system-fonts-expected.txt: Ditto.
+            * platform/mac/fast/forms/select/optgroup-rendering-expected.txt: Updated to not use synthetic bold.
+            * platform/mac/fast/forms/validation-message-appearance-expected.txt: Ditto.
+
 2015-05-12  Dana Burkart <[email protected]>
 
         Merge r184116. rdar://problem/20774613

Modified: branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/css/css2-system-fonts-expected.txt (184494 => 184495)


--- branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/css/css2-system-fonts-expected.txt	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/css/css2-system-fonts-expected.txt	2015-05-18 17:01:03 UTC (rev 184495)
@@ -1,10 +1,10 @@
 This tests platform specific system font styles. If any of the styles appear in monospace the test fails.
-caption: normal normal normal 13px/16px '.HelveticaNeueDeskInterface-Regular'
-icon: normal normal normal 13px/16px '.HelveticaNeueDeskInterface-Regular'
-menu: normal normal normal 13px/16px '.HelveticaNeueDeskInterface-Regular'
-message-box: normal normal normal 13px/16px '.HelveticaNeueDeskInterface-Regular'
-small-caption: normal normal normal 11px/13px '.HelveticaNeueDeskInterface-Regular'
-status-bar: normal normal normal 10px/12px '.HelveticaNeueDeskInterface-Regular'
--webkit-mini-control: normal normal normal 9px/11px '.HelveticaNeueDeskInterface-Regular'
--webkit-small-control: normal normal normal 11px/13px '.HelveticaNeueDeskInterface-Regular'
--webkit-control: normal normal normal 13px/16px '.HelveticaNeueDeskInterface-Regular'
+caption: normal normal normal 13px/16px -apple-system
+icon: normal normal normal 13px/16px -apple-system
+menu: normal normal normal 13px/16px -apple-menu
+message-box: normal normal normal 13px/16px -apple-system
+small-caption: normal normal normal 11px/13px -apple-system
+status-bar: normal normal normal 10px/12px -apple-status-bar
+-webkit-mini-control: normal normal normal 9px/11px -apple-system
+-webkit-small-control: normal normal normal 11px/13px -apple-system
+-webkit-control: normal normal normal 13px/16px -apple-system

Modified: branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/forms/select/optgroup-rendering-expected.txt (184494 => 184495)


--- branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/forms/select/optgroup-rendering-expected.txt	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/forms/select/optgroup-rendering-expected.txt	2015-05-18 17:01:03 UTC (rev 184495)
@@ -4,10 +4,10 @@
   RenderBlock {HTML} at (0,0) size 800x323
     RenderBody {BODY} at (8,8) size 784x307
       RenderBlock {FORM} at (0,0) size 784x307
-        RenderListBox {SELECT} at (2,2) size 67x281 [bgcolor=#FFFFFF] [border: (1px inset #808080)]
-        RenderText {#text} at (71,264) size 4x18
-          text run at (71,264) width 4: " "
-        RenderBR {BR} at (75,264) size 0x18
+        RenderListBox {SELECT} at (2,2) size 69x281 [bgcolor=#FFFFFF] [border: (1px inset #808080)]
+        RenderText {#text} at (73,264) size 4x18
+          text run at (73,264) width 4: " "
+        RenderBR {BR} at (77,264) size 0x18
         RenderMenuList {SELECT} at (2,287) size 75x18 [bgcolor=#FFFFFF]
           RenderBlock (anonymous) at (0,0) size 75x18
             RenderText at (8,2) size 30x13

Modified: branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt (184494 => 184495)


--- branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/LayoutTests/platform/mac/fast/forms/validation-message-appearance-expected.txt	2015-05-18 17:01:03 UTC (rev 184495)
@@ -25,8 +25,8 @@
     RenderBlock {DIV} at (10,10) size 0x64
     RenderBlock {DIV} at (10,10) size 200x64
       RenderBlock {DIV} at (0,0) size 200x16
-        RenderText {#text} at (0,0) size 86x16
-          text run at (0,0) width 86: "value missing"
+        RenderText {#text} at (0,0) size 90x16
+          text run at (0,0) width 90: "value missing"
       RenderBlock {DIV} at (0,16) size 200x48
         RenderText {#text} at (0,0) size 147x16
           text run at (0,0) width 147: "Needs at least 8 letters."

Deleted: branches/safari-601.1.32.2-branch/LayoutTests/platform/mac-mavericks/fast/css/css2-system-fonts-expected.txt (184494 => 184495)


--- branches/safari-601.1.32.2-branch/LayoutTests/platform/mac-mavericks/fast/css/css2-system-fonts-expected.txt	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/LayoutTests/platform/mac-mavericks/fast/css/css2-system-fonts-expected.txt	2015-05-18 17:01:03 UTC (rev 184495)
@@ -1,10 +0,0 @@
-This tests platform specific system font styles. If any of the styles appear in monospace the test fails.
-caption: normal normal normal 13px/16px '.LucidaGrandeUI'
-icon: normal normal normal 13px/16px '.LucidaGrandeUI'
-menu: normal normal normal 13px/16px '.LucidaGrandeUI'
-message-box: normal normal normal 13px/16px '.LucidaGrandeUI'
-small-caption: normal normal normal 11px/13px '.LucidaGrandeUI'
-status-bar: normal normal normal 10px/12px '.LucidaGrandeUI'
--webkit-mini-control: normal normal normal 9px/11px '.LucidaGrandeUI'
--webkit-small-control: normal normal normal 11px/13px '.LucidaGrandeUI'
--webkit-control: normal normal normal 13px/16px '.LucidaGrandeUI'

Modified: branches/safari-601.1.32.2-branch/Source/WebCore/ChangeLog (184494 => 184495)


--- branches/safari-601.1.32.2-branch/Source/WebCore/ChangeLog	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/Source/WebCore/ChangeLog	2015-05-18 17:01:03 UTC (rev 184495)
@@ -1,3 +1,61 @@
+2015-05-18  Matthew Hanson  <[email protected]>
+
+        Merge r184353. rdar://problem/20809399
+
+    2015-05-14  Myles C. Maxfield  <[email protected]>
+
+            [Mac] Expose more font weights for -apple-system
+            https://bugs.webkit.org/show_bug.cgi?id=144707
+
+            Reviewed by Simon Fraser.
+
+            Previously, when we parsed a CSS declaration of the form font: keyword; where keyword
+            is one of caption, icon, menu, message-box, small-caption, -webkit-mini-control, -webkit-small-control,
+            or -webkit-control (which html.css does for form controls), we would ask the system what the appropriate
+            system font is, get that font's family name, and synthesize a font-family CSS property for the element.
+            Then, later when we actually go to look up the font, we would look up the font by family name using this
+            information. However, this round-tripping of a font through a family name is actually lossy, and is not
+            guaranteed to preserve system-font-ness (which we use for various things including metrics calculations).
+
+            This patch modifies this logic to specify a token family name instead, which the font lookup code special
+            cases (and reacts by making the appropriate system-font lookup call). This approach is currently how iOS
+            handles these system fonts; this patch simply brings this approach to OS X.
+
+            There is also an added progression here. We used to simply call [NSFont fontWithName:size:] on the system
+            font family name (which the parser found for us) which entirely disregards weight. This means that we
+            used to be getting synthesized bold in form controls which ask for a heavy weight. Migrating to this
+            system-font aware call means that we get the real bold font instead of synthesized bold.
+
+            Once this system-font-ness is guaranteed to be preserved between parsing time and font lookup time, we
+            can safely migrate to using [NSFont systemFontOfSize:weight] instead of [NSFont systemFontOfSize:] on
+            platforms which support it.
+
+            Tests: fast/text/systemFont.html
+                   fast/css/css2-system-fonts.html
+                   fast/forms/select/optgroup-rendering.html
+                   fast/forms/validation-message-appearance.html
+
+            * css/CSSParser.cpp:
+            (WebCore::CSSParser::parseSystemFont): Add a comment regarding why we are bothering with expanding out
+            the font property in the first place.
+            * platform/graphics/cocoa/FontCascadeCocoa.mm:
+            (WebCore::FontCascade::primaryFontIsSystemFont): Update to use new system font tokens.
+            * platform/graphics/mac/FontCacheMac.mm:
+            (WebCore::toNSFontWeight): New static method to map font weights to NSFontWeight constants available on
+            Yosemite and later.
+            (WebCore::fontWithFamilySpecialCase): Pull all these special-case font token name handling into a
+            separate function, which returns an Optional.
+            (WebCore::fontWithFamily):
+            * platform/mac/ThemeMac.mm:
+            (WebCore::ThemeMac::controlFont): Use the font token name instead of the generated system font family
+            name.
+            * platform/spi/mac/NSFontSPI.h: Add [NSFont systemFontWithSize:weight:] and the proper NSFontWeight
+            constants.
+            * rendering/RenderThemeMac.mm:
+            (WebCore::RenderThemeMac::updateCachedSystemFontDescription): Use the font token names instead of the
+            generated system font family name.
+            (WebCore::RenderThemeMac::setFontFromControlSize): Ditto.
+
 2015-05-13  Babak Shafiei  <[email protected]>
 
         Merge r183976.

Modified: branches/safari-601.1.32.2-branch/Source/WebCore/css/CSSParser.cpp (184494 => 184495)


--- branches/safari-601.1.32.2-branch/Source/WebCore/css/CSSParser.cpp	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/Source/WebCore/css/CSSParser.cpp	2015-05-18 17:01:03 UTC (rev 184495)
@@ -6617,6 +6617,7 @@
     if (!fontDescription.isAbsoluteSize())
         return;
 
+    // We must set font's constituent properties, even for system fonts, so the cascade functions correctly.
     ShorthandScope scope(this, CSSPropertyFont);
     addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontDescription.italic() == FontItalicOn ? CSSValueItalic : CSSValueNormal), important);
     addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontDescription.weight()), important);

Modified: branches/safari-601.1.32.2-branch/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm (184494 => 184495)


--- branches/safari-601.1.32.2-branch/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/Source/WebCore/platform/graphics/cocoa/FontCascadeCocoa.mm	2015-05-18 17:01:03 UTC (rev 184495)
@@ -687,9 +687,12 @@
     const auto& fontData = primaryFont();
     return !fontData.isSVGFont() && CTFontDescriptorIsSystemUIFont(adoptCF(CTFontCopyFontDescriptor(fontData.platformData().ctFont())).get());
 #else
-    // System fonts are hidden by having a name that begins with a period, so simply search
-    // for that here rather than try to keep the list up to date.
-    return firstFamily().startsWith('.');
+    const String& firstFamily = this->firstFamily();
+    return equalIgnoringASCIICase(firstFamily, "-webkit-system-font")
+        || equalIgnoringASCIICase(firstFamily, "-apple-system-font")
+        || equalIgnoringASCIICase(firstFamily, "-apple-system")
+        || equalIgnoringASCIICase(firstFamily, "-apple-menu")
+        || equalIgnoringASCIICase(firstFamily, "-apple-status-bar");
 #endif
 }
 

Modified: branches/safari-601.1.32.2-branch/Source/WebCore/platform/graphics/mac/FontCacheMac.mm (184494 => 184495)


--- branches/safari-601.1.32.2-branch/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/Source/WebCore/platform/graphics/mac/FontCacheMac.mm	2015-05-18 17:01:03 UTC (rev 184495)
@@ -43,6 +43,7 @@
 #import <AppKit/AppKit.h>
 #import <wtf/MainThread.h>
 #import <wtf/NeverDestroyed.h>
+#import <wtf/Optional.h>
 #import <wtf/StdLibExtras.h>
 #import <wtf/Threading.h>
 #import <wtf/text/AtomicStringHash.h>
@@ -207,7 +208,7 @@
 static CGFloat toNSFontWeight(FontWeight fontWeight)
 {
     static CGFloat nsFontWeights[] = {
-        NSFontWeightUltraLight, // Values between ultra-light and thin are swapped.
+        NSFontWeightUltraLight,
         NSFontWeightThin,
         NSFontWeightLight,
         NSFontWeightRegular,
@@ -217,17 +218,16 @@
         NSFontWeightHeavy,
         NSFontWeightBlack
     };
+    ASSERT(fontWeight >= 0 && fontWeight <= 8);
     return nsFontWeights[fontWeight];
 }
 #endif
 
-// Family name is somewhat of a misnomer here. We first attempt to find an exact match
-// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
-// we then do a search based on the family names of the installed fonts.
-static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, float size)
+static Optional<NSFont*> fontWithFamilySpecialCase(const AtomicString& family, FontWeight weight, float size)
 {
-    if (equalIgnoringASCIICase(family.string(), String(@"-webkit-system-font")) || equalIgnoringASCIICase(family.string(), String(@"-apple-system")) || equalIgnoringASCIICase(family.string(), String(@"-apple-system-font"))) {
-        // We ignore italic for system font.
+    if (equalIgnoringASCIICase(family.string(), "-webkit-system-font")
+        || equalIgnoringASCIICase(family.string(), "-apple-system")
+        || equalIgnoringASCIICase(family.string(), "-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(), String(@"-apple-system-monospaced-numbers"))) {
+    if (equalIgnoringASCIICase(family.string(), "-apple-system-monospaced-numbers")) {
         NSArray *featureArray = @[ @{ NSFontFeatureTypeIdentifierKey : @(kNumberSpacingType),
             NSFontFeatureSelectorIdentifierKey : @(kMonospacedNumbersSelector) } ];
 
@@ -244,6 +244,23 @@
         return [NSFont fontWithDescriptor:desc size:size];
     }
 
+    if (equalIgnoringASCIICase(family.string(), "-apple-menu"))
+        return [NSFont menuFontOfSize:size];
+
+    if (equalIgnoringASCIICase(family.string(), "-apple-status-bar"))
+        return [NSFont labelFontOfSize:size];
+
+    return Optional<NSFont*>(Nullopt);
+}
+
+// Family name is somewhat of a misnomer here. We first attempt to find an exact match
+// comparing the desiredFamily to the PostScript name of the installed fonts. If that fails
+// we then do a search based on the family names of the installed fonts.
+static NSFont *fontWithFamily(const AtomicString& family, NSFontTraitMask desiredTraits, FontWeight weight, float size)
+{
+    if (const auto& specialCase = fontWithFamilySpecialCase(family, weight, size))
+        return specialCase.value();
+
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
     NSString *desiredFamily = family;
     NSString *availableFamily;
@@ -252,8 +269,6 @@
 
 #if ENABLE(PLATFORM_FONT_LOOKUP)
 
-    if (family.length() > 0 && family.string().at(0) == '.')
-        return [NSFont fontWithName:desiredFamily size:size];
     const auto& whitelist = fontWhitelist();
     if (whitelist.size() && !whitelist.contains(family.lower()))
         return nil;

Modified: branches/safari-601.1.32.2-branch/Source/WebCore/platform/mac/ThemeMac.mm (184494 => 184495)


--- branches/safari-601.1.32.2-branch/Source/WebCore/platform/mac/ThemeMac.mm	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/Source/WebCore/platform/mac/ThemeMac.mm	2015-05-18 17:01:03 UTC (rev 184495)
@@ -675,7 +675,7 @@
             fontDescription.setIsAbsoluteSize(true);
 
             NSFont* nsFont = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSizeForFont(font)]];
-            fontDescription.setOneFamily([nsFont webCoreFamilyName]);
+            fontDescription.setOneFamily(AtomicString("-apple-system", AtomicString::ConstructFromLiteral));
             fontDescription.setComputedSize([nsFont pointSize] * zoomFactor);
             fontDescription.setSpecifiedSize([nsFont pointSize] * zoomFactor);
             return fontDescription;

Modified: branches/safari-601.1.32.2-branch/Source/WebCore/rendering/RenderThemeMac.mm (184494 => 184495)


--- branches/safari-601.1.32.2-branch/Source/WebCore/rendering/RenderThemeMac.mm	2015-05-18 17:00:45 UTC (rev 184494)
+++ branches/safari-601.1.32.2-branch/Source/WebCore/rendering/RenderThemeMac.mm	2015-05-18 17:01:03 UTC (rev 184495)
@@ -347,15 +347,21 @@
 void RenderThemeMac::updateCachedSystemFontDescription(CSSValueID cssValueId, FontDescription& fontDescription) const
 {
     NSFont* font;
+    // 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"));
     switch (cssValueId) {
         case CSSValueSmallCaption:
             font = [NSFont systemFontOfSize:[NSFont smallSystemFontSize]];
             break;
         case CSSValueMenu:
             font = [NSFont menuFontOfSize:[NSFont systemFontSize]];
+            fontName = String(ASCIILiteral("-apple-menu"));
             break;
         case CSSValueStatusBar:
             font = [NSFont labelFontOfSize:[NSFont labelFontSize]];
+            fontName = String(ASCIILiteral("-apple-status-bar"));
             break;
         case CSSValueWebkitMiniControl:
             font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:NSMiniControlSize]];
@@ -375,7 +381,7 @@
 
     NSFontManager *fontManager = [NSFontManager sharedFontManager];
     fontDescription.setIsAbsoluteSize(true);
-    fontDescription.setOneFamily([font webCoreFamilyName]);
+    fontDescription.setOneFamily(fontName);
     fontDescription.setSpecifiedSize([font pointSize]);
     fontDescription.setWeight(toFontWeight([fontManager weightOfFont:font]));
     fontDescription.setIsItalic([fontManager traitsOfFont:font] & NSItalicFontMask);
@@ -821,7 +827,7 @@
     fontDescription.setIsAbsoluteSize(true);
 
     NSFont* font = [NSFont systemFontOfSize:[NSFont systemFontSizeForControlSize:controlSize]];
-    fontDescription.setOneFamily([font webCoreFamilyName]);
+    fontDescription.setOneFamily(AtomicString("-apple-system", AtomicString::ConstructFromLiteral));
     fontDescription.setComputedSize([font pointSize] * style.effectiveZoom());
     fontDescription.setSpecifiedSize([font pointSize] * style.effectiveZoom());
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to