Title: [248067] branches/safari-608-branch/Source
Revision
248067
Author
[email protected]
Date
2019-07-31 13:56:44 -0700 (Wed, 31 Jul 2019)

Log Message

Cherry-pick r248018. rdar://problem/53764057

    REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
    https://bugs.webkit.org/show_bug.cgi?id=200065
    <rdar://problem/50912757>

    Reviewed by Simon Fraser.

    Source/WebCore:

    Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
    has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
    so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
    800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
    would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
    Therefore, the apparent visual change is from a weight change from 600 to 800.

    In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
    800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
    to give them a weight of 600 instead of 700. This way, the lighter font will be used.

    No new tests because quirks cannot be tested.

    * css/CSSFontSelector.cpp:
    (WebCore::resolveGenericFamily):
    (WebCore::CSSFontSelector::fontRangesForFamily):
    * page/Quirks.cpp:
    (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
    * page/Quirks.h:

    Source/WTF:

    * wtf/Platform.h:

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

Modified Paths

Diff

Modified: branches/safari-608-branch/Source/WTF/ChangeLog (248066 => 248067)


--- branches/safari-608-branch/Source/WTF/ChangeLog	2019-07-31 20:56:40 UTC (rev 248066)
+++ branches/safari-608-branch/Source/WTF/ChangeLog	2019-07-31 20:56:44 UTC (rev 248067)
@@ -1,3 +1,51 @@
+2019-07-31  Alan Coon  <[email protected]>
+
+        Cherry-pick r248018. rdar://problem/53764057
+
+    REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
+    https://bugs.webkit.org/show_bug.cgi?id=200065
+    <rdar://problem/50912757>
+    
+    Reviewed by Simon Fraser.
+    
+    Source/WebCore:
+    
+    Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
+    has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
+    so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
+    800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
+    would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
+    Therefore, the apparent visual change is from a weight change from 600 to 800.
+    
+    In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
+    800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
+    to give them a weight of 600 instead of 700. This way, the lighter font will be used.
+    
+    No new tests because quirks cannot be tested.
+    
+    * css/CSSFontSelector.cpp:
+    (WebCore::resolveGenericFamily):
+    (WebCore::CSSFontSelector::fontRangesForFamily):
+    * page/Quirks.cpp:
+    (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
+    * page/Quirks.h:
+    
+    Source/WTF:
+    
+    * wtf/Platform.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-30  Myles C. Maxfield  <[email protected]>
+
+            REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
+            https://bugs.webkit.org/show_bug.cgi?id=200065
+            <rdar://problem/50912757>
+
+            Reviewed by Simon Fraser.
+
+            * wtf/Platform.h:
+
 2019-07-29  Alan Coon  <[email protected]>
 
         Cherry-pick r247673. rdar://problem/53449723

Modified: branches/safari-608-branch/Source/WTF/wtf/Platform.h (248066 => 248067)


--- branches/safari-608-branch/Source/WTF/wtf/Platform.h	2019-07-31 20:56:40 UTC (rev 248066)
+++ branches/safari-608-branch/Source/WTF/wtf/Platform.h	2019-07-31 20:56:44 UTC (rev 248067)
@@ -1612,3 +1612,7 @@
 #if (PLATFORM(MAC) && __MAC_OS_X_VERSION_MIN_REQUIRED >= 101500) || (PLATFORM(IOS) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000)
 #define HAVE_DESIGN_SYSTEM_UI_FONTS 1
 #endif
+
+#if (PLATFORM(IOS_FAMILY) && __IPHONE_OS_VERSION_MIN_REQUIRED >= 130000) || (PLATFORM(WATCHOS) && __WATCH_OS_VERSION_MIN_REQUIRED >= 60000) || (PLATFORM(APPLETV) && __TV_OS_VERSION_MIN_REQUIRED >= 130000)
+#define USE_HIRAGINO_SANS_WORKAROUND 1
+#endif

Modified: branches/safari-608-branch/Source/WebCore/ChangeLog (248066 => 248067)


--- branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-31 20:56:40 UTC (rev 248066)
+++ branches/safari-608-branch/Source/WebCore/ChangeLog	2019-07-31 20:56:44 UTC (rev 248067)
@@ -1,5 +1,71 @@
 2019-07-31  Alan Coon  <[email protected]>
 
+        Cherry-pick r248018. rdar://problem/53764057
+
+    REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
+    https://bugs.webkit.org/show_bug.cgi?id=200065
+    <rdar://problem/50912757>
+    
+    Reviewed by Simon Fraser.
+    
+    Source/WebCore:
+    
+    Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
+    has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
+    so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
+    800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
+    would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
+    Therefore, the apparent visual change is from a weight change from 600 to 800.
+    
+    In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
+    800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
+    to give them a weight of 600 instead of 700. This way, the lighter font will be used.
+    
+    No new tests because quirks cannot be tested.
+    
+    * css/CSSFontSelector.cpp:
+    (WebCore::resolveGenericFamily):
+    (WebCore::CSSFontSelector::fontRangesForFamily):
+    * page/Quirks.cpp:
+    (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
+    * page/Quirks.h:
+    
+    Source/WTF:
+    
+    * wtf/Platform.h:
+    
+    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
+
+    2019-07-30  Myles C. Maxfield  <[email protected]>
+
+            REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
+            https://bugs.webkit.org/show_bug.cgi?id=200065
+            <rdar://problem/50912757>
+
+            Reviewed by Simon Fraser.
+
+            Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
+            has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
+            so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
+            800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
+            would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
+            Therefore, the apparent visual change is from a weight change from 600 to 800.
+
+            In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
+            800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
+            to give them a weight of 600 instead of 700. This way, the lighter font will be used.
+
+            No new tests because quirks cannot be tested.
+
+            * css/CSSFontSelector.cpp:
+            (WebCore::resolveGenericFamily):
+            (WebCore::CSSFontSelector::fontRangesForFamily):
+            * page/Quirks.cpp:
+            (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
+            * page/Quirks.h:
+
+2019-07-31  Alan Coon  <[email protected]>
+
         Cherry-pick r247934. rdar://problem/53764085
 
     MediaSource.isTypeSupported claims FLAC-in-MP4 support on iOS and macOS, but plays silence

Modified: branches/safari-608-branch/Source/WebCore/css/CSSFontSelector.cpp (248066 => 248067)


--- branches/safari-608-branch/Source/WebCore/css/CSSFontSelector.cpp	2019-07-31 20:56:40 UTC (rev 248066)
+++ branches/safari-608-branch/Source/WebCore/css/CSSFontSelector.cpp	2019-07-31 20:56:44 UTC (rev 248067)
@@ -46,6 +46,7 @@
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "Logging.h"
+#include "Quirks.h"
 #include "ResourceLoadObserver.h"
 #include "RuntimeEnabledFeatures.h"
 #include "Settings.h"
@@ -274,7 +275,7 @@
     dispatchInvalidationCallbacks();
 }
 
-static AtomString resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomString& familyName)
+static Optional<AtomString> resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomString& familyName)
 {
     auto platformResult = FontDescription::platformResolveGenericFamily(fontDescription.script(), fontDescription.locale(), familyName);
     if (!platformResult.isNull())
@@ -281,7 +282,7 @@
         return platformResult;
 
     if (!document)
-        return familyName;
+        return WTF::nullopt;
 
     const Settings& settings = document->settings();
 
@@ -301,7 +302,7 @@
     if (familyName == standardFamily)
         return settings.standardFontFamily(script);
 
-    return familyName;
+    return WTF::nullopt;
 }
 
 FontRanges CSSFontSelector::fontRangesForFamily(const FontDescription& fontDescription, const AtomString& familyName)
@@ -312,18 +313,34 @@
     // FIXME: The spec (and Firefox) says user specified generic families (sans-serif etc.) should be resolved before the @font-face lookup too.
     bool resolveGenericFamilyFirst = familyName == standardFamily;
 
-    AtomString familyForLookup = resolveGenericFamilyFirst ? resolveGenericFamily(m_document.get(), fontDescription, familyName) : familyName;
-    auto* face = m_cssFontFaceSet->fontFace(fontDescription.fontSelectionRequest(), familyForLookup);
+    AtomString familyForLookup = familyName;
+    Optional<FontDescription> overrideFontDescription;
+    const FontDescription* fontDescriptionForLookup = &fontDescription;
+    auto resolveGenericFamily = [&]() {
+        if (auto genericFamilyOptional = WebCore::resolveGenericFamily(m_document.get(), fontDescription, familyName)) {
+            if (m_document && m_document->quirks().shouldLightenJapaneseBoldSansSerif() && familyForLookup == sansSerifFamily && fontDescription.weight() == boldWeightValue() && fontDescription.script() == USCRIPT_KATAKANA_OR_HIRAGANA) {
+                overrideFontDescription = fontDescription;
+                overrideFontDescription->setWeight(FontSelectionValue(600));
+                fontDescriptionForLookup = &*overrideFontDescription;
+            }
+            familyForLookup = *genericFamilyOptional;
+        }
+    };
+
+    if (resolveGenericFamilyFirst)
+        resolveGenericFamily();
+    auto* face = m_cssFontFaceSet->fontFace(fontDescriptionForLookup->fontSelectionRequest(), familyForLookup);
     if (face) {
         if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) {
             if (m_document)
                 ResourceLoadObserver::shared().logFontLoad(*m_document, familyForLookup.string(), true);
         }
-        return face->fontRanges(fontDescription);
+        return face->fontRanges(*fontDescriptionForLookup);
     }
+
     if (!resolveGenericFamilyFirst)
-        familyForLookup = resolveGenericFamily(m_document.get(), fontDescription, familyName);
-    auto font = FontCache::singleton().fontForFamily(fontDescription, familyForLookup);
+        resolveGenericFamily();
+    auto font = FontCache::singleton().fontForFamily(*fontDescriptionForLookup, familyForLookup);
     if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) {
         if (m_document)
             ResourceLoadObserver::shared().logFontLoad(*m_document, familyForLookup.string(), !!font);

Modified: branches/safari-608-branch/Source/WebCore/page/Quirks.cpp (248066 => 248067)


--- branches/safari-608-branch/Source/WebCore/page/Quirks.cpp	2019-07-31 20:56:40 UTC (rev 248066)
+++ branches/safari-608-branch/Source/WebCore/page/Quirks.cpp	2019-07-31 20:56:44 UTC (rev 248067)
@@ -381,6 +381,22 @@
 #endif
 }
 
+bool Quirks::shouldLightenJapaneseBoldSansSerif() const
+{
+#if USE(HIRAGINO_SANS_WORKAROUND)
+    if (!needsQuirks())
+        return false;
+
+    // lang="ja" style="font: bold sans-serif;" content would naturally get HiraginoSans-W8 here, but that's visually
+    // too bold. Instead, we should pick HiraginoSans-W6 instead.
+    // FIXME: webkit.org/b/200047 Remove this quirk.
+    auto host = m_document->topDocument().url().host();
+    return equalLettersIgnoringASCIICase(host, "m.yahoo.co.jp");
+#else
+    return false;
+#endif
+}
+
 // FIXME(<rdar://problem/50394969>): Remove after desmos.com adopts inputmode="none".
 bool Quirks::needsInputModeNoneImplicitly(const HTMLElement& element) const
 {

Modified: branches/safari-608-branch/Source/WebCore/page/Quirks.h (248066 => 248067)


--- branches/safari-608-branch/Source/WebCore/page/Quirks.h	2019-07-31 20:56:40 UTC (rev 248066)
+++ branches/safari-608-branch/Source/WebCore/page/Quirks.h	2019-07-31 20:56:44 UTC (rev 248067)
@@ -57,6 +57,7 @@
     bool shouldDisablePointerEventsQuirk() const;
     bool needsInputModeNoneImplicitly(const HTMLElement&) const;
     bool needsDeferKeyDownAndKeyPressTimersUntilNextEditingCommand() const;
+    bool shouldLightenJapaneseBoldSansSerif() const;
 
     WEBCORE_EXPORT bool shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const;
     WEBCORE_EXPORT bool shouldSuppressAutocorrectionAndAutocaptializationInHiddenEditableAreas() const;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to