⚠ Archived content — this site is no longer maintained.   Current WebKit documentation is at docs.webkit.org.

Changeset 248355 in webkit


Ignore:
Timestamp:
Aug 6, 2019, 11:52:53 PM (7 years ago)
Author:
Kocsen Chung
Message:

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

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

  1. 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

Location:
branches/safari-608.1-branch/Source
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • branches/safari-608.1-branch/Source/WTF/ChangeLog

    r248298 r248355  
     12019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r248018. rdar://problem/54017893
     4
     5    REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
     6    https://bugs.webkit.org/show_bug.cgi?id=200065
     7    <rdar://problem/50912757>
     8   
     9    Reviewed by Simon Fraser.
     10   
     11    Source/WebCore:
     12   
     13    Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
     14    has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
     15    so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
     16    800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
     17    would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
     18    Therefore, the apparent visual change is from a weight change from 600 to 800.
     19   
     20    In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
     21    800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
     22    to give them a weight of 600 instead of 700. This way, the lighter font will be used.
     23   
     24    No new tests because quirks cannot be tested.
     25   
     26    * css/CSSFontSelector.cpp:
     27    (WebCore::resolveGenericFamily):
     28    (WebCore::CSSFontSelector::fontRangesForFamily):
     29    * page/Quirks.cpp:
     30    (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
     31    * page/Quirks.h:
     32   
     33    Source/WTF:
     34   
     35    * wtf/Platform.h:
     36   
     37    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     38
     39    2019-07-30  Myles C. Maxfield  <mmaxfield@apple.com>
     40
     41            REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
     42            https://bugs.webkit.org/show_bug.cgi?id=200065
     43            <rdar://problem/50912757>
     44
     45            Reviewed by Simon Fraser.
     46
     47            * wtf/Platform.h:
     48
    1492019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
    250
  • branches/safari-608.1-branch/Source/WTF/wtf/Platform.h

    r247632 r248355  
    16101610#define HAVE_DESIGN_SYSTEM_UI_FONTS 1
    16111611#endif
     1612
     1613#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)
     1614#define USE_HIRAGINO_SANS_WORKAROUND 1
     1615#endif
  • branches/safari-608.1-branch/Source/WebCore/ChangeLog

    r248351 r248355  
     12019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
     2
     3        Cherry-pick r248018. rdar://problem/54017893
     4
     5    REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
     6    https://bugs.webkit.org/show_bug.cgi?id=200065
     7    <rdar://problem/50912757>
     8   
     9    Reviewed by Simon Fraser.
     10   
     11    Source/WebCore:
     12   
     13    Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
     14    has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
     15    so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
     16    800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
     17    would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
     18    Therefore, the apparent visual change is from a weight change from 600 to 800.
     19   
     20    In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
     21    800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
     22    to give them a weight of 600 instead of 700. This way, the lighter font will be used.
     23   
     24    No new tests because quirks cannot be tested.
     25   
     26    * css/CSSFontSelector.cpp:
     27    (WebCore::resolveGenericFamily):
     28    (WebCore::CSSFontSelector::fontRangesForFamily):
     29    * page/Quirks.cpp:
     30    (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
     31    * page/Quirks.h:
     32   
     33    Source/WTF:
     34   
     35    * wtf/Platform.h:
     36   
     37    git-svn-id: https://svn.webkit.org/repository/webkit/trunk@248018 268f45cc-cd09-0410-ab3c-d52691b4dbfc
     38
     39    2019-07-30  Myles C. Maxfield  <mmaxfield@apple.com>
     40
     41            REGRESSION(r241288): Text on Yahoo Japan mobile looks too bold
     42            https://bugs.webkit.org/show_bug.cgi?id=200065
     43            <rdar://problem/50912757>
     44
     45            Reviewed by Simon Fraser.
     46
     47            Before r241288, we were mapping Japanese sans-serif to Hiragino Kaku Gothic ProN, which
     48            has a 300 weight and a 600 weight. However, we can't use that font because it's user-installed,
     49            so in r241288 we switched to using Hiragino Sans, which has a 300 weight, a 600 weight, and an
     50            800 weight. According to the CSS font selection algorithm, sites that request a weight of 700
     51            would get the 800 weight instead of the 600 weight, which caused the text to look too heavy.
     52            Therefore, the apparent visual change is from a weight change from 600 to 800.
     53
     54            In general, this is working as intended. However, text on Yahoo Japan looks too heavy in weight
     55            800. Instead, this patch adds a quirk specific to Yahoo Japan that overwrites any font requests
     56            to give them a weight of 600 instead of 700. This way, the lighter font will be used.
     57
     58            No new tests because quirks cannot be tested.
     59
     60            * css/CSSFontSelector.cpp:
     61            (WebCore::resolveGenericFamily):
     62            (WebCore::CSSFontSelector::fontRangesForFamily):
     63            * page/Quirks.cpp:
     64            (WebCore::Quirks::shouldLightenJapaneseBoldSansSerif const):
     65            * page/Quirks.h:
     66
    1672019-08-06  Kocsen Chung  <kocsen_chung@apple.com>
    268
  • branches/safari-608.1-branch/Source/WebCore/css/CSSFontSelector.cpp

    r246490 r248355  
    4747#include "FrameLoader.h"
    4848#include "Logging.h"
     49#include "Quirks.h"
    4950#include "ResourceLoadObserver.h"
    5051#include "RuntimeEnabledFeatures.h"
     
    275276}
    276277
    277 static AtomString resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomString& familyName)
     278static Optional<AtomString> resolveGenericFamily(Document* document, const FontDescription& fontDescription, const AtomString& familyName)
    278279{
    279280    auto platformResult = FontDescription::platformResolveGenericFamily(fontDescription.script(), fontDescription.locale(), familyName);
     
    282283
    283284    if (!document)
    284         return familyName;
     285        return WTF::nullopt;
    285286
    286287    const Settings& settings = document->settings();
     
    302303        return settings.standardFontFamily(script);
    303304
    304     return familyName;
     305    return WTF::nullopt;
    305306}
    306307
     
    313314    bool resolveGenericFamilyFirst = familyName == standardFamily;
    314315
    315     AtomString familyForLookup = resolveGenericFamilyFirst ? resolveGenericFamily(m_document.get(), fontDescription, familyName) : familyName;
    316     auto* face = m_cssFontFaceSet->fontFace(fontDescription.fontSelectionRequest(), familyForLookup);
     316    AtomString familyForLookup = familyName;
     317    Optional<FontDescription> overrideFontDescription;
     318    const FontDescription* fontDescriptionForLookup = &fontDescription;
     319    auto resolveGenericFamily = [&]() {
     320        if (auto genericFamilyOptional = WebCore::resolveGenericFamily(m_document.get(), fontDescription, familyName)) {
     321            if (m_document && m_document->quirks().shouldLightenJapaneseBoldSansSerif() && familyForLookup == sansSerifFamily && fontDescription.weight() == boldWeightValue() && fontDescription.script() == USCRIPT_KATAKANA_OR_HIRAGANA) {
     322                overrideFontDescription = fontDescription;
     323                overrideFontDescription->setWeight(FontSelectionValue(600));
     324                fontDescriptionForLookup = &*overrideFontDescription;
     325            }
     326            familyForLookup = *genericFamilyOptional;
     327        }
     328    };
     329
     330    if (resolveGenericFamilyFirst)
     331        resolveGenericFamily();
     332    auto* face = m_cssFontFaceSet->fontFace(fontDescriptionForLookup->fontSelectionRequest(), familyForLookup);
    317333    if (face) {
    318334        if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) {
     
    320336                ResourceLoadObserver::shared().logFontLoad(*m_document, familyForLookup.string(), true);
    321337        }
    322         return face->fontRanges(fontDescription);
    323     }
     338        return face->fontRanges(*fontDescriptionForLookup);
     339    }
     340
    324341    if (!resolveGenericFamilyFirst)
    325         familyForLookup = resolveGenericFamily(m_document.get(), fontDescription, familyName);
    326     auto font = FontCache::singleton().fontForFamily(fontDescription, familyForLookup);
     342        resolveGenericFamily();
     343    auto font = FontCache::singleton().fontForFamily(*fontDescriptionForLookup, familyForLookup);
    327344    if (RuntimeEnabledFeatures::sharedFeatures().webAPIStatisticsEnabled()) {
    328345        if (m_document)
  • branches/safari-608.1-branch/Source/WebCore/page/Quirks.cpp

    r247798 r248355  
    360360}
    361361
     362bool Quirks::shouldLightenJapaneseBoldSansSerif() const
     363{
     364#if USE(HIRAGINO_SANS_WORKAROUND)
     365    if (!needsQuirks())
     366        return false;
     367
     368    // lang="ja" style="font: bold sans-serif;" content would naturally get HiraginoSans-W8 here, but that's visually
     369    // too bold. Instead, we should pick HiraginoSans-W6 instead.
     370    // FIXME: webkit.org/b/200047 Remove this quirk.
     371    auto host = m_document->topDocument().url().host();
     372    return equalLettersIgnoringASCIICase(host, "m.yahoo.co.jp");
     373#else
     374    return false;
     375#endif
     376}
     377
    362378// FIXME(<rdar://problem/50394969>): Remove after desmos.com adopts inputmode="none".
    363379bool Quirks::needsInputModeNoneImplicitly(const HTMLElement& element) const
  • branches/safari-608.1-branch/Source/WebCore/page/Quirks.h

    r247798 r248355  
    5757    bool needsInputModeNoneImplicitly(const HTMLElement&) const;
    5858    bool needsDeferKeyDownAndKeyPressTimersUntilNextEditingCommand() const;
     59    bool shouldLightenJapaneseBoldSansSerif() const;
    5960
    6061    WEBCORE_EXPORT bool shouldDispatchSyntheticMouseEventsWhenModifyingSelection() const;
Note: See TracChangeset for help on using the changeset viewer.