Changeset 84609 in webkit


Ignore:
Timestamp:
Apr 22, 2011 12:40:32 AM (13 years ago)
Author:
commit-queue@webkit.org
Message:

2011-04-22 Luke Macpherson <macpherson@chromium.org>

Reviewed by Eric Seidel.

Add FontItalics and FontSmallCaps enums to be used instead of boolean values.
https://bugs.webkit.org/show_bug.cgi?id=59080

No new tests as no new functionality added.

  • css/CSSPrimitiveValueMappings.h: Add casts to/from FontItalics and FontSmallCaps
  • css/CSSStyleSelector.cpp: Use new casts defined in PrimitiveValueMappings.h
  • platform/graphics/Font.h: Use FontItalics enum.
  • platform/graphics/FontDescription.h: Define and use FontItalics and FontSmallCaps enums.
Location:
trunk/Source/WebCore
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r84607 r84609  
     12011-04-22  Luke Macpherson   <macpherson@chromium.org>
     2
     3        Reviewed by Eric Seidel.
     4
     5        Add FontItalics and FontSmallCaps enums to be used instead of boolean values.
     6        https://bugs.webkit.org/show_bug.cgi?id=59080
     7
     8        No new tests as no new functionality added.
     9
     10        * css/CSSPrimitiveValueMappings.h:
     11        Add casts to/from FontItalics and FontSmallCaps
     12        * css/CSSStyleSelector.cpp:
     13        Use new casts defined in PrimitiveValueMappings.h
     14        * platform/graphics/Font.h:
     15        Use FontItalics enum.
     16        * platform/graphics/FontDescription.h:
     17        Define and use FontItalics and FontSmallCaps enums.
     18
    1192011-04-21  Andrey Kosyakov  <caseq@chromium.org>
    220
  • trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h

    r84385 r84609  
    3434#include "CSSPrimitiveValue.h"
    3535#include "CSSValueKeywords.h"
     36#include "FontDescription.h"
    3637#include "FontSmoothingMode.h"
    3738#include "GraphicsTypes.h"
     
    23242325}
    23252326
     2327template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontItalic italic)
     2328    : m_type(CSS_IDENT)
     2329    , m_hasCachedCSSText(false)
     2330{
     2331    switch (italic) {
     2332    case FontItalicOff:
     2333        m_value.ident = CSSValueNormal;
     2334        return;
     2335    case FontItalicOn:
     2336        m_value.ident = CSSValueItalic;
     2337        return;
     2338    }
     2339
     2340    ASSERT_NOT_REACHED();
     2341    m_value.ident = CSSValueNormal;
     2342}
     2343
     2344template<> inline CSSPrimitiveValue::operator FontItalic() const
     2345{
     2346    switch (m_value.ident) {
     2347    case CSSValueOblique:
     2348    // FIXME: oblique is the same as italic for the moment...
     2349    case CSSValueItalic:
     2350        return FontItalicOn;
     2351    case CSSValueNormal:
     2352        return FontItalicOff;
     2353    }
     2354    ASSERT_NOT_REACHED();
     2355    return FontItalicOff;
     2356}
     2357
     2358template<> inline CSSPrimitiveValue::CSSPrimitiveValue(FontSmallCaps smallCaps)
     2359    : m_type(CSS_IDENT)
     2360    , m_hasCachedCSSText(false)
     2361{
     2362    switch (smallCaps) {
     2363    case FontSmallCapsOff:
     2364        m_value.ident = CSSValueNormal;
     2365        return;
     2366    case FontSmallCapsOn:
     2367        m_value.ident = CSSValueSmallCaps;
     2368        return;
     2369    }
     2370
     2371    ASSERT_NOT_REACHED();
     2372    m_value.ident = CSSValueNormal;
     2373}
     2374
     2375template<> inline CSSPrimitiveValue::operator FontSmallCaps() const
     2376{
     2377    switch (m_value.ident) {
     2378    case CSSValueSmallCaps:
     2379        return FontSmallCapsOn;
     2380    case CSSValueNormal:
     2381        return FontSmallCapsOff;
     2382    }
     2383    ASSERT_NOT_REACHED();
     2384    return FontSmallCapsOff;
     2385}
     2386
    23262387template<> inline CSSPrimitiveValue::CSSPrimitiveValue(TextRenderingMode e)
    23272388    : m_type(CSS_IDENT)
  • trunk/Source/WebCore/css/CSSStyleSelector.cpp

    r84603 r84609  
    36773677            fontDescription.setItalic(m_parentStyle->fontDescription().italic());
    36783678        else if (isInitial)
    3679             fontDescription.setItalic(false);
     3679            fontDescription.setItalic(FontItalicOff);
    36803680        else {
    36813681            if (!primitiveValue)
    36823682                return;
    3683             switch (primitiveValue->getIdent()) {
    3684                 case CSSValueOblique:
    3685                 // FIXME: oblique is the same as italic for the moment...
    3686                 case CSSValueItalic:
    3687                     fontDescription.setItalic(true);
    3688                     break;
    3689                 case CSSValueNormal:
    3690                     fontDescription.setItalic(false);
    3691                     break;
    3692                 default:
    3693                     return;
    3694             }
     3683            fontDescription.setItalic((FontItalic)*primitiveValue);
    36953684        }
    36963685        if (m_style->setFontDescription(fontDescription))
     
    37053694            fontDescription.setSmallCaps(m_parentStyle->fontDescription().smallCaps());
    37063695        else if (isInitial)
    3707             fontDescription.setSmallCaps(false);
     3696            fontDescription.setSmallCaps(FontSmallCapsOff);
    37083697        else {
    37093698            if (!primitiveValue)
    37103699                return;
    3711             int id = primitiveValue->getIdent();
    3712             if (id == CSSValueNormal)
    3713                 fontDescription.setSmallCaps(false);
    3714             else if (id == CSSValueSmallCaps)
    3715                 fontDescription.setSmallCaps(true);
    3716             else
    3717                 return;
     3700            fontDescription.setSmallCaps((FontSmallCaps)*primitiveValue);
    37183701        }
    37193702        if (m_style->setFontDescription(fontDescription))
  • trunk/Source/WebCore/platform/graphics/Font.h

    r84264 r84609  
    124124    const FontFamily& family() const { return m_fontDescription.family(); }
    125125
    126     bool italic() const { return m_fontDescription.italic(); }
     126    FontItalic italic() const { return m_fontDescription.italic(); }
    127127    FontWeight weight() const { return m_fontDescription.weight(); }
    128128    FontWidthVariant widthVariant() const { return m_fontDescription.widthVariant(); }
  • trunk/Source/WebCore/platform/graphics/FontDescription.h

    r80582 r84609  
    5151};
    5252
     53enum FontItalic {
     54    FontItalicOff = 0,
     55    FontItalicOn = 1
     56};
     57
     58enum FontSmallCaps {
     59    FontSmallCapsOff = 0,
     60    FontSmallCapsOn = 1
     61};
     62
    5363class FontDescription {
    5464public:
     
    6272        , m_textOrientation(TextOrientationVerticalRight)
    6373        , m_widthVariant(RegularWidth)
    64         , m_italic(false)
    65         , m_smallCaps(false)
     74        , m_italic(FontItalicOff)
     75        , m_smallCaps(FontSmallCapsOff)
    6676        , m_isAbsoluteSize(false)
    6777        , m_weight(FontWeightNormal)
     
    8393    float specifiedSize() const { return m_specifiedSize; }
    8494    float computedSize() const { return m_computedSize; }
    85     bool italic() const { return m_italic; }
     95    FontItalic italic() const { return static_cast<FontItalic>(m_italic); }
    8696    int computedPixelSize() const { return int(m_computedSize + 0.5f); }
    87     bool smallCaps() const { return m_smallCaps; }
     97    FontSmallCaps smallCaps() const { return static_cast<FontSmallCaps>(m_smallCaps); }
    8898    bool isAbsoluteSize() const { return m_isAbsoluteSize; }
    8999    FontWeight weight() const { return static_cast<FontWeight>(m_weight); }
     
    108118    void setComputedSize(float s) { m_computedSize = s; }
    109119    void setSpecifiedSize(float s) { m_specifiedSize = s; }
    110     void setItalic(bool i) { m_italic = i; }
    111     void setSmallCaps(bool c) { m_smallCaps = c; }
     120    void setItalic(FontItalic i) { m_italic = i; }
     121    void setItalic(bool i) { setItalic(i ? FontItalicOn : FontItalicOff); }
     122    void setSmallCaps(FontSmallCaps c) { m_smallCaps = c; }
     123    void setSmallCaps(bool c) { setSmallCaps(c ? FontSmallCapsOn : FontSmallCapsOff); }
    112124    void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
    113125    void setWeight(FontWeight w) { m_weight = w; }
     
    139151    FontWidthVariant m_widthVariant;
    140152
    141     bool m_italic : 1;
    142     bool m_smallCaps : 1;
     153    unsigned m_italic : 1; // FontItalic
     154    unsigned m_smallCaps : 1; // FontSmallCaps
    143155    bool m_isAbsoluteSize : 1;   // Whether or not CSS specified an explicit size
    144156                                 // (logical sizes like "medium" don't count).
Note: See TracChangeset for help on using the changeset viewer.