Changeset 176789 in webkit


Ignore:
Timestamp:
Dec 4, 2014 3:50:26 AM (9 years ago)
Author:
Antti Koivisto
Message:

Remove isSpecifiedFont boolean from FontDescription
https://bugs.webkit.org/show_bug.cgi?id=139233

Reviewed by Andreas Kling.

It is barely used.

  • css/StyleBuilderCustom.h:

(WebCore::StyleBuilderCustom::applyInheritFontFamily):
(WebCore::StyleBuilderCustom::applyValueFontFamily):

  • platform/graphics/FontDescription.cpp:

(WebCore::genericFamiliesSet):
(WebCore::FontDescription::hasGenericFirstFamily):

Add a function to test for generic families.

  • platform/graphics/FontDescription.h:

(WebCore::FontDescription::FontDescription):
(WebCore::FontDescription::setTextRenderingMode):
(WebCore::FontDescription::operator==):
(WebCore::FontDescription::isSpecifiedFont): Deleted.
(WebCore::FontDescription::setIsSpecifiedFont): Deleted.

  • rendering/RenderText.cpp:

(WebCore::RenderText::computeUseBackslashAsYenSymbol):

This is the only client.
Figure out the equivalent information dynamically if needed.

Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176780 r176789  
     12014-12-03  Antti Koivisto  <antti@apple.com>
     2
     3        Remove isSpecifiedFont boolean from FontDescription
     4        https://bugs.webkit.org/show_bug.cgi?id=139233
     5
     6        Reviewed by Andreas Kling.
     7
     8        It is barely used.
     9
     10        * css/StyleBuilderCustom.h:
     11        (WebCore::StyleBuilderCustom::applyInheritFontFamily):
     12        (WebCore::StyleBuilderCustom::applyValueFontFamily):
     13        * platform/graphics/FontDescription.cpp:
     14        (WebCore::genericFamiliesSet):
     15        (WebCore::FontDescription::hasGenericFirstFamily):
     16
     17            Add a function to test for generic families.
     18
     19        * platform/graphics/FontDescription.h:
     20        (WebCore::FontDescription::FontDescription):
     21        (WebCore::FontDescription::setTextRenderingMode):
     22        (WebCore::FontDescription::operator==):
     23        (WebCore::FontDescription::isSpecifiedFont): Deleted.
     24        (WebCore::FontDescription::setIsSpecifiedFont): Deleted.
     25        * rendering/RenderText.cpp:
     26        (WebCore::RenderText::computeUseBackslashAsYenSymbol):
     27
     28            This is the only client.
     29            Figure out the equivalent information dynamically if needed.
     30
    1312014-12-03  Joonghun Park  <jh718.park@samsung.com>
    232
  • trunk/Source/WebCore/css/StyleBuilderCustom.h

    r176751 r176789  
    912912
    913913    fontDescription.setFamilies(parentFontDescription.families());
    914     fontDescription.setIsSpecifiedFont(parentFontDescription.isSpecifiedFont());
    915914    styleResolver.setFontDescription(fontDescription);
    916915}
     
    930929        auto& contentValue = downcast<CSSPrimitiveValue>(item.get());
    931930        AtomicString family;
    932         bool isGenericFamily = false;
    933931        if (contentValue.isString())
    934932            family = contentValue.getStringValue();
     
    941939            case CSSValueSerif:
    942940                family = serifFamily;
    943                 isGenericFamily = true;
    944941                break;
    945942            case CSSValueSansSerif:
    946943                family = sansSerifFamily;
    947                 isGenericFamily = true;
    948944                break;
    949945            case CSSValueCursive:
    950946                family = cursiveFamily;
    951                 isGenericFamily = true;
    952947                break;
    953948            case CSSValueFantasy:
    954949                family = fantasyFamily;
    955                 isGenericFamily = true;
    956950                break;
    957951            case CSSValueMonospace:
    958952                family = monospaceFamily;
    959                 isGenericFamily = true;
    960953                break;
    961954            case CSSValueWebkitPictograph:
    962955                family = pictographFamily;
    963                 isGenericFamily = true;
    964956                break;
    965957            default:
     
    967959            }
    968960        }
    969 
    970961        if (family.isEmpty())
    971962            continue;
    972         if (families.isEmpty())
    973             fontDescription.setIsSpecifiedFont(!isGenericFamily);
    974963        families.uncheckedAppend(family);
    975964    }
  • trunk/Source/WebCore/platform/graphics/FontDescription.cpp

    r175043 r176789  
    3030#include "config.h"
    3131#include "FontDescription.h"
     32
     33#include <wtf/HashSet.h>
     34#include <wtf/NeverDestroyed.h>
     35#include <wtf/text/AtomicStringHash.h>
    3236
    3337namespace WebCore {
     
    102106}
    103107
     108static const HashSet<AtomicString>& genericFamiliesSet()
     109{
     110    static NeverDestroyed<HashSet<AtomicString>> set;
     111    if (set.get().isEmpty()) {
     112        set.get().add(cursiveFamily);
     113        set.get().add(fantasyFamily);
     114        set.get().add(monospaceFamily);
     115        set.get().add(pictographFamily);
     116        set.get().add(sansSerifFamily);
     117        set.get().add(serifFamily);
     118        set.get().add(standardFamily);
     119    }
     120    return set.get();
     121}
     122
     123bool FontDescription::hasGenericFirstFamily() const
     124{
     125    auto& family = firstFamily();
     126    if (family.isNull())
     127        return false;
     128    return genericFamiliesSet().contains(family);
     129}
     130
    104131#if ENABLE(IOS_TEXT_AUTOSIZING)
    105132bool FontDescription::familiesEqualForTextAutoSizing(const FontDescription& other) const
  • trunk/Source/WebCore/platform/graphics/FontDescription.h

    r176751 r176789  
    9494        , m_fontSmoothing(AutoSmoothing)
    9595        , m_textRendering(AutoTextRendering)
    96         , m_isSpecifiedFont(false)
    9796        , m_script(USCRIPT_COMMON)
    9897    {
     
    128127    TextRenderingMode textRenderingMode() const { return static_cast<TextRenderingMode>(m_textRendering); }
    129128    UScriptCode script() const { return static_cast<UScriptCode>(m_script); }
     129    bool hasGenericFirstFamily() const;
    130130
    131131    FontTraitsMask traitsMask() const;
    132     bool isSpecifiedFont() const { return m_isSpecifiedFont; }
    133132    FontOrientation orientation() const { return static_cast<FontOrientation>(m_orientation); }
    134133    NonCJKGlyphOrientation nonCJKGlyphOrientation() const { return static_cast<NonCJKGlyphOrientation>(m_nonCJKGlyphOrientation); }
     
    157156    void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoothing; }
    158157    void setTextRenderingMode(TextRenderingMode rendering) { m_textRendering = rendering; }
    159     void setIsSpecifiedFont(bool isSpecifiedFont) { m_isSpecifiedFont = isSpecifiedFont; }
    160158    void setOrientation(FontOrientation orientation) { m_orientation = orientation; }
    161159    void setNonCJKGlyphOrientation(NonCJKGlyphOrientation orientation) { m_nonCJKGlyphOrientation = orientation; }
     
    210208    unsigned m_fontSmoothing : 2; // FontSmoothingMode
    211209    unsigned m_textRendering : 2; // TextRenderingMode
    212     unsigned m_isSpecifiedFont : 1; // True if a web page specifies a non-generic font family as the first font family.
    213210    unsigned m_script : 7; // Used to help choose an appropriate font for generic font families.
    214211};
     
    232229        && m_fontSmoothing == other.m_fontSmoothing
    233230        && m_textRendering == other.m_textRendering
    234         && m_isSpecifiedFont == other.m_isSpecifiedFont
    235231        && m_orientation == other.m_orientation
    236232        && m_nonCJKGlyphOrientation == other.m_nonCJKGlyphOrientation
  • trunk/Source/WebCore/rendering/RenderText.cpp

    r176473 r176789  
    214214{
    215215    const RenderStyle& style = this->style();
    216     const FontDescription& fontDescription = style.font().fontDescription();
    217216    if (style.font().useBackslashAsYenSymbol())
    218217        return true;
    219     if (fontDescription.isSpecifiedFont())
     218    if (!document().decoder() || document().decoder()->encoding().backslashAsCurrencySymbol() == '\\')
    220219        return false;
    221     const TextEncoding* encoding = document().decoder() ? &document().decoder()->encoding() : 0;
    222     if (encoding && encoding->backslashAsCurrencySymbol() != '\\')
    223         return true;
    224     return false;
     220    return style.font().fontDescription().hasGenericFirstFamily() || style.font().primaryFontDataIsSystemFont();
    225221}
    226222
Note: See TracChangeset for help on using the changeset viewer.