Changeset 104678 in webkit


Ignore:
Timestamp:
Jan 11, 2012 12:38:29 AM (12 years ago)
Author:
mitz@apple.com
Message:

<rdar://problem/10674686> Implement the font-kerning CSS property
https://bugs.webkit.org/show_bug.cgi?id=76033

Reviewed by Darin Adler.

Source/WebCore:

Tests: fast/text/font-kerning-expected.html

fast/text/font-kerning.html

  • css/CSSComputedStyleDeclaration.cpp:

(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added code to handle
font-kerning.

  • css/CSSParser.cpp:

(WebCore::CSSParser::parseValue): Ditto.

  • css/CSSPrimitiveValueMappings.h:

(WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added mapping from FontDescription::Kerning.
(WebCore::CSSPrimitiveValue::operator FontDescription::Kerning): Added mapping to
FontDescription::Kerning.

  • css/CSSProperty.cpp:

(WebCore::CSSProperty::isInheritedProperty): Added font-kerning to the set of inherited
properties.

  • css/CSSPropertyNames.in: Added -webkit-font-kerning.
  • css/CSSStyleApplyProperty.cpp:

(WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): Added a handler for font-kerning.

  • css/CSSStyleSelector.cpp:

(WebCore::CSSStyleSelector::applyDeclaration): Updated for the number of properties that
affect the font.

  • platform/graphics/Font.h:

(WebCore::Font::typesettingFeatures): Changed to enable kerning if font-kerning is set to
normal, disable it if font-kerning is set to none, and leave it to the default (determined
by the text-rendering property) if font-kerning is set to auto.

  • platform/graphics/FontDescription.h:

(WebCore::FontDescription::FontDescription): Added a Kerning enum.
(WebCore::FontDescription::kerning): Added this getter.
(WebCore::FontDescription::setKerning): Added this setter.
(WebCore::FontDescription::operator==): Updated to compare the m_kerning member.

LayoutTests:

  • fast/css/getComputedStyle/computed-style-expected.txt:
  • fast/text/font-kerning-expected.html: Added.
  • fast/text/font-kerning.html: Added.
  • platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
  • platform/chromium-win/svg/css/getComputedStyle-basic-expected.txt:
  • platform/gtk/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
  • platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
  • platform/qt/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
  • svg/css/getComputedStyle-basic-expected.txt:
Location:
trunk
Files:
2 added
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r104673 r104678  
     12012-01-11  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/10674686> Implement the font-kerning CSS property
     4        https://bugs.webkit.org/show_bug.cgi?id=76033
     5
     6        Reviewed by Darin Adler.
     7
     8        * fast/css/getComputedStyle/computed-style-expected.txt:
     9        * fast/text/font-kerning-expected.html: Added.
     10        * fast/text/font-kerning.html: Added.
     11        * platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
     12        * platform/chromium-win/svg/css/getComputedStyle-basic-expected.txt:
     13        * platform/gtk/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
     14        * platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
     15        * platform/qt/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt:
     16        * svg/css/getComputedStyle-basic-expected.txt:
     17
    1182012-01-10  Sheriff Bot  <webkit.review.bot@gmail.com>
    219
  • trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt

    r104625 r104678  
    149149-webkit-flex-flow: row nowrap;
    150150-webkit-flex-wrap: nowrap;
     151-webkit-font-kerning: auto;
    151152-webkit-font-smoothing: auto;
    152153-webkit-highlight: none;
  • trunk/LayoutTests/platform/chromium-win/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt

    r104642 r104678  
    148148    -webkit-flex-flow: row nowrap
    149149    -webkit-flex-wrap: nowrap
     150    -webkit-font-kerning: auto
    150151    -webkit-font-smoothing: auto
    151152    -webkit-highlight: none
  • trunk/LayoutTests/platform/chromium-win/svg/css/getComputedStyle-basic-expected.txt

    r104642 r104678  
    295295rect: style.getPropertyValue(-webkit-flex-wrap) : nowrap
    296296rect: style.getPropertyCSSValue(-webkit-flex-wrap) : [object CSSPrimitiveValue]
     297rect: style.getPropertyValue(-webkit-font-kerning) : auto
     298rect: style.getPropertyCSSValue(-webkit-font-kerning) : [object CSSPrimitiveValue]
    297299rect: style.getPropertyValue(-webkit-font-smoothing) : auto
    298300rect: style.getPropertyCSSValue(-webkit-font-smoothing) : [object CSSPrimitiveValue]
     
    803805g: style.getPropertyValue(-webkit-flex-wrap) : nowrap
    804806g: style.getPropertyCSSValue(-webkit-flex-wrap) : [object CSSPrimitiveValue]
     807g: style.getPropertyValue(-webkit-font-kerning) : auto
     808g: style.getPropertyCSSValue(-webkit-font-kerning) : [object CSSPrimitiveValue]
    805809g: style.getPropertyValue(-webkit-font-smoothing) : auto
    806810g: style.getPropertyCSSValue(-webkit-font-smoothing) : [object CSSPrimitiveValue]
  • trunk/LayoutTests/platform/gtk/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt

    r102897 r104678  
    148148    -webkit-flex-flow: row nowrap
    149149    -webkit-flex-wrap: nowrap
     150    -webkit-font-kerning: auto
    150151    -webkit-font-smoothing: auto
    151152    -webkit-highlight: none
  • trunk/LayoutTests/platform/mac/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt

    r104625 r104678  
    148148    -webkit-flex-flow: row nowrap
    149149    -webkit-flex-wrap: nowrap
     150    -webkit-font-kerning: auto
    150151    -webkit-font-smoothing: auto
    151152    -webkit-highlight: none
  • trunk/LayoutTests/platform/qt/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt

    r104640 r104678  
    148148    -webkit-flex-flow: row nowrap
    149149    -webkit-flex-wrap: nowrap
     150    -webkit-font-kerning: auto
    150151    -webkit-font-smoothing: auto
    151152    -webkit-highlight: none
  • trunk/Source/WebCore/ChangeLog

    r104675 r104678  
     12012-01-11  Dan Bernstein  <mitz@apple.com>
     2
     3        <rdar://problem/10674686> Implement the font-kerning CSS property
     4        https://bugs.webkit.org/show_bug.cgi?id=76033
     5
     6        Reviewed by Darin Adler.
     7
     8        Tests: fast/text/font-kerning-expected.html
     9               fast/text/font-kerning.html
     10
     11        * css/CSSComputedStyleDeclaration.cpp:
     12        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added code to handle
     13        font-kerning.
     14        * css/CSSParser.cpp:
     15        (WebCore::CSSParser::parseValue): Ditto.
     16        * css/CSSPrimitiveValueMappings.h:
     17        (WebCore::CSSPrimitiveValue::CSSPrimitiveValue): Added mapping from FontDescription::Kerning.
     18        (WebCore::CSSPrimitiveValue::operator FontDescription::Kerning): Added mapping to
     19        FontDescription::Kerning.
     20        * css/CSSProperty.cpp:
     21        (WebCore::CSSProperty::isInheritedProperty): Added font-kerning to the set of inherited
     22        properties.
     23        * css/CSSPropertyNames.in: Added -webkit-font-kerning.
     24        * css/CSSStyleApplyProperty.cpp:
     25        (WebCore::CSSStyleApplyProperty::CSSStyleApplyProperty): Added a handler for font-kerning.
     26        * css/CSSStyleSelector.cpp:
     27        (WebCore::CSSStyleSelector::applyDeclaration): Updated for the number of properties that
     28        affect the font.
     29        * platform/graphics/Font.h:
     30        (WebCore::Font::typesettingFeatures): Changed to enable kerning if font-kerning is set to
     31        normal, disable it if font-kerning is set to none, and leave it to the default (determined
     32        by the text-rendering property) if font-kerning is set to auto.
     33        * platform/graphics/FontDescription.h:
     34        (WebCore::FontDescription::FontDescription): Added a Kerning enum.
     35        (WebCore::FontDescription::kerning): Added this getter.
     36        (WebCore::FontDescription::setKerning): Added this setter.
     37        (WebCore::FontDescription::operator==): Updated to compare the m_kerning member.
     38
    1392012-01-10  Ryosuke Niwa  <rniwa@webkit.org>
    240
  • trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp

    r104625 r104678  
    222222    CSSPropertyWebkitFlexFlow,
    223223    CSSPropertyWebkitFlexWrap,
     224    CSSPropertyWebkitFontKerning,
    224225    CSSPropertyWebkitFontSmoothing,
    225226#if ENABLE(CSS_GRID_LAYOUT)
     
    18671868        case CSSPropertyResize:
    18681869            return cssValuePool->createValue(style->resize());
     1870        case CSSPropertyWebkitFontKerning:
     1871            return cssValuePool->createValue(style->fontDescription().kerning());
    18691872        case CSSPropertyWebkitFontSmoothing:
    18701873            return cssValuePool->createValue(style->fontDescription().fontSmoothing());
  • trunk/Source/WebCore/css/CSSParser.cpp

    r104625 r104678  
    22272227        else
    22282228            return parseFontFeatureSettings(important);
     2229        break;
     2230
     2231    case CSSPropertyWebkitFontKerning:
     2232        if (id == CSSValueAuto || id == CSSValueNormal || id == CSSValueNone)
     2233            validPrimitive = true;
    22292234        break;
    22302235
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r104625 r104678  
    28272827}
    28282828
     2829template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontDescription::Kerning kerning)
     2830    : CSSValue(PrimitiveClass)
     2831{
     2832    m_primitiveUnitType = CSS_IDENT;
     2833    switch (kerning) {
     2834    case FontDescription::AutoKerning:
     2835        m_value.ident = CSSValueAuto;
     2836        return;
     2837    case FontDescription::NormalKerning:
     2838        m_value.ident = CSSValueNormal;
     2839        return;
     2840    case FontDescription::NoneKerning:
     2841        m_value.ident = CSSValueNone;
     2842        return;
     2843    }
     2844
     2845    ASSERT_NOT_REACHED();
     2846    m_value.ident = CSSValueAuto;
     2847}
     2848
     2849template<> inline CSSPrimitiveValue::operator FontDescription::Kerning() const
     2850{
     2851    switch (m_value.ident) {
     2852    case CSSValueAuto:
     2853        return FontDescription::AutoKerning;
     2854    case CSSValueNormal:
     2855        return FontDescription::NormalKerning;
     2856    case CSSValueNone:
     2857        return FontDescription::NoneKerning;
     2858    }
     2859
     2860    ASSERT_NOT_REACHED();
     2861    return FontDescription::AutoKerning;
     2862}
     2863
    28292864template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmoothingMode smoothing)
    28302865    : CSSValue(PrimitiveClass)
  • trunk/Source/WebCore/css/CSSProperty.cpp

    r104625 r104678  
    319319    case CSSPropertyWebkitColorCorrection:
    320320    case CSSPropertyWebkitFontFeatureSettings:
     321    case CSSPropertyWebkitFontKerning:
    321322    case CSSPropertyWebkitFontSmoothing:
    322323    case CSSPropertyWebkitLocale:
  • trunk/Source/WebCore/css/CSSPropertyNames.in

    r104625 r104678  
    2222text-rendering
    2323-webkit-font-feature-settings
     24-webkit-font-kerning
    2425-webkit-font-smoothing
    2526-webkit-locale
  • trunk/Source/WebCore/css/CSSStyleApplyProperty.cpp

    r104625 r104678  
    16821682    setPropertyHandler(CSSPropertyFontVariant, ApplyPropertyFont<FontSmallCaps, &FontDescription::smallCaps, &FontDescription::setSmallCaps, FontSmallCapsOff>::createHandler());
    16831683    setPropertyHandler(CSSPropertyTextRendering, ApplyPropertyFont<TextRenderingMode, &FontDescription::textRenderingMode, &FontDescription::setTextRenderingMode, AutoTextRendering>::createHandler());
     1684    setPropertyHandler(CSSPropertyWebkitFontKerning, ApplyPropertyFont<FontDescription::Kerning, &FontDescription::kerning, &FontDescription::setKerning, FontDescription::AutoKerning>::createHandler());
    16841685    setPropertyHandler(CSSPropertyWebkitFontSmoothing, ApplyPropertyFont<FontSmoothingMode, &FontDescription::fontSmoothing, &FontDescription::setFontSmoothing, AutoSmoothing>::createHandler());
    16851686    setPropertyHandler(CSSPropertyWebkitTextOrientation, ApplyPropertyFont<TextOrientation, &FontDescription::textOrientation, &FontDescription::setTextOrientation, TextOrientationVerticalRight>::createHandler());
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r104625 r104678  
    22282228        if (applyFirst) {
    22292229            COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property);
    2230             COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 16, CSS_zoom_is_end_of_first_prop_range);
     2230            COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 17, CSS_zoom_is_end_of_first_prop_range);
    22312231            COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_line_height_is_after_zoom);
    22322232            // give special priority to font-xxx, color properties, etc
  • trunk/Source/WebCore/platform/graphics/Font.h

    r95394 r104678  
    117117    {
    118118        TextRenderingMode textRenderingMode = m_fontDescription.textRenderingMode();
    119         return textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? Kerning | Ligatures : 0;
     119        TypesettingFeatures features = textRenderingMode == OptimizeLegibility || textRenderingMode == GeometricPrecision ? Kerning | Ligatures : 0;
     120
     121        switch (m_fontDescription.kerning()) {
     122        case FontDescription::NoneKerning:
     123            features &= ~Kerning;
     124            break;
     125        case FontDescription::NormalKerning:
     126            features |= Kerning;
     127            break;
     128        case FontDescription::AutoKerning:
     129            break;
     130        }
     131
     132        return features;
    120133    }
    121134
  • trunk/Source/WebCore/platform/graphics/FontDescription.h

    r96705 r104678  
    7272    enum GenericFamilyType { NoFamily, StandardFamily, SerifFamily, SansSerifFamily,
    7373                             MonospaceFamily, CursiveFamily, FantasyFamily, PictographFamily };
     74
     75    enum Kerning { AutoKerning, NormalKerning, NoneKerning };
    7476
    7577    FontDescription()
     
    8688        , m_usePrinterFont(false)
    8789        , m_renderingMode(NormalRenderingMode)
     90        , m_kerning(AutoKerning)
    8891        , m_keywordSize(0)
    8992        , m_fontSmoothing(AutoSmoothing)
     
    113116    bool useFixedDefaultSize() const { return genericFamily() == MonospaceFamily && !family().next() && family().family() == monospaceFamily; }
    114117    FontRenderingMode renderingMode() const { return static_cast<FontRenderingMode>(m_renderingMode); }
     118    Kerning kerning() const { return static_cast<Kerning>(m_kerning); }
    115119    unsigned keywordSize() const { return m_keywordSize; }
    116120    FontSmoothingMode fontSmoothing() const { return static_cast<FontSmoothingMode>(m_fontSmoothing); }
     
    142146#endif
    143147    void setRenderingMode(FontRenderingMode mode) { m_renderingMode = mode; }
     148    void setKerning(Kerning kerning) { m_kerning = kerning; }
    144149    void setKeywordSize(unsigned s) { m_keywordSize = s; }
    145150    void setFontSmoothing(FontSmoothingMode smoothing) { m_fontSmoothing = smoothing; }
     
    174179
    175180    unsigned m_renderingMode : 1;  // Used to switch between CG and GDI text on Windows.
     181    unsigned m_kerning : 2; // Kerning
    176182
    177183    unsigned m_keywordSize : 4; // We cache whether or not a font is currently represented by a CSS keyword (e.g., medium).  If so,
     
    197203        && m_usePrinterFont == other.m_usePrinterFont
    198204        && m_renderingMode == other.m_renderingMode
     205        && m_kerning == other.m_kerning
    199206        && m_keywordSize == other.m_keywordSize
    200207        && m_fontSmoothing == other.m_fontSmoothing
Note: See TracChangeset for help on using the changeset viewer.