Changeset 19421 in webkit


Ignore:
Timestamp:
Feb 5, 2007 6:27:17 PM (17 years ago)
Author:
bdash
Message:

2007-02-06 Mark Rowe <mrowe@apple.com>

Roll out incomplete support for font-stretch (r19350) at Dave Hyatt's request.
See http://bugs.webkit.org/show_bug.cgi?id=12530#c9 for more info.

  • css/CSSComputedStyleDeclaration.cpp: (WebCore::): (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
  • css/cssparser.cpp: (WebCore::CSSParser::parseValue):
  • css/cssstyleselector.cpp: (WebCore::CSSStyleSelector::applyDeclarations): (WebCore::CSSStyleSelector::applyProperty):
  • platform/FontCache.cpp: (WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey): (WebCore::FontPlatformDataCacheKey::operator==): (WebCore::computeHash): (WebCore::FontPlatformDataCacheKeyTraits::deletedValue): (WebCore::FontPlatformDataCacheKeyTraits::emptyValue): (WebCore::FontCache::getCachedFontPlatformData):
  • platform/FontDescription.h: (WebCore::FontDescription::FontDescription): (WebCore::FontDescription::weight): (WebCore::FontDescription::setWeight): (WebCore::FontDescription::operator==):
  • platform/mac/FontCacheMac.mm: (WebCore::FontCache::createFontPlatformData):
  • platform/mac/WebFontCache.mm: (acceptableChoice): (betterChoice): (+[WebFontCache fontWithFamily:traits:size:]):

2007-02-06 Mark Rowe <mrowe@apple.com>

Roll out incomplete support for font-stretch (r19350) at Dave Hyatt's request.
See http://bugs.webkit.org/show_bug.cgi?id=12530#c9 for more info.

  • WebInspector/webInspector/inspector.js:
  • WebView/WebHTMLView.mm: (-[WebHTMLView _addToStyle:fontA:fontB:]):

2007-02-06 Mark Rowe <mrowe@apple.com>

Roll out incomplete support for font-stretch (r19350) at Dave Hyatt's request.
See http://bugs.webkit.org/show_bug.cgi?id=12530#c9 for more info.

  • fast/css/computed-style-expected.txt:
  • fast/css/font-stretch-expected.checksum: Removed.
  • fast/css/font-stretch-expected.png: Removed.
  • fast/css/font-stretch-expected.txt: Removed.
  • fast/css/font-stretch.html: Removed.
Location:
trunk
Files:
4 deleted
13 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r19417 r19421  
     12007-02-06  Mark Rowe  <mrowe@apple.com>
     2
     3        Roll out incomplete support for font-stretch (r19350) at Dave Hyatt's request.
     4        See http://bugs.webkit.org/show_bug.cgi?id=12530#c9 for more info.
     5
     6        * fast/css/computed-style-expected.txt:
     7        * fast/css/font-stretch-expected.checksum: Removed.
     8        * fast/css/font-stretch-expected.png: Removed.
     9        * fast/css/font-stretch-expected.txt: Removed.
     10        * fast/css/font-stretch.html: Removed.
     11
    1122007-02-05  Justin Garcia  <justin.garcia@apple.com>
    213
  • trunk/LayoutTests/fast/css/computed-style-expected.txt

    r19350 r19421  
    3232font-family: Times;
    3333font-size: 16px;
    34 font-stretch: normal;
    3534font-style: normal;
    3635font-variant: normal;
  • trunk/WebCore/ChangeLog

    r19420 r19421  
     12007-02-06  Mark Rowe  <mrowe@apple.com>
     2
     3        Roll out incomplete support for font-stretch (r19350) at Dave Hyatt's request.
     4        See http://bugs.webkit.org/show_bug.cgi?id=12530#c9 for more info.
     5
     6        * css/CSSComputedStyleDeclaration.cpp:
     7        (WebCore::):
     8        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue):
     9        * css/cssparser.cpp:
     10        (WebCore::CSSParser::parseValue):
     11        * css/cssstyleselector.cpp:
     12        (WebCore::CSSStyleSelector::applyDeclarations):
     13        (WebCore::CSSStyleSelector::applyProperty):
     14        * platform/FontCache.cpp:
     15        (WebCore::FontPlatformDataCacheKey::FontPlatformDataCacheKey):
     16        (WebCore::FontPlatformDataCacheKey::operator==):
     17        (WebCore::computeHash):
     18        (WebCore::FontPlatformDataCacheKeyTraits::deletedValue):
     19        (WebCore::FontPlatformDataCacheKeyTraits::emptyValue):
     20        (WebCore::FontCache::getCachedFontPlatformData):
     21        * platform/FontDescription.h:
     22        (WebCore::FontDescription::FontDescription):
     23        (WebCore::FontDescription::weight):
     24        (WebCore::FontDescription::setWeight):
     25        (WebCore::FontDescription::operator==):
     26        * platform/mac/FontCacheMac.mm:
     27        (WebCore::FontCache::createFontPlatformData):
     28        * platform/mac/WebFontCache.mm:
     29        (acceptableChoice):
     30        (betterChoice):
     31        (+[WebFontCache fontWithFamily:traits:size:]):
     32
    1332007-02-05  Adele Peterson  <adele@apple.com>
    234
  • trunk/WebCore/css/CSSComputedStyleDeclaration.cpp

    r19350 r19421  
    7171    CSS_PROP_FONT_FAMILY,
    7272    CSS_PROP_FONT_SIZE,
    73     CSS_PROP_FONT_STRETCH,
    7473    CSS_PROP_FONT_STYLE,
    7574    CSS_PROP_FONT_VARIANT,
     
    964963        case CSS_PROP__WEBKIT_BINDING:
    965964            break;
    966         case CSS_PROP_FONT_STRETCH:
    967             if (style->fontDescription().stretch() == FontStretchCondensed)
    968                 return new CSSPrimitiveValue(CSS_VAL_CONDENSED);
    969             if (style->fontDescription().stretch() == FontStretchExpanded)
    970                 return new CSSPrimitiveValue(CSS_VAL_EXPANDED);
    971             return new CSSPrimitiveValue(CSS_VAL_NORMAL);
    972965        case CSS_PROP_FONT_STYLE:
    973966            if (style->fontDescription().italic())
     
    15491542        case CSS_PROP_COUNTER_RESET:
    15501543        case CSS_PROP_FONT:
     1544        case CSS_PROP_FONT_STRETCH:
    15511545        case CSS_PROP_LIST_STYLE:
    15521546        case CSS_PROP_MARGIN:
     
    16601654    CSS_PROP_FONT_FAMILY,
    16611655    CSS_PROP_FONT_SIZE,
    1662     CSS_PROP_FONT_STRETCH,
    16631656    CSS_PROP_FONT_STYLE,
    16641657    CSS_PROP_FONT_VARIANT,
  • trunk/WebCore/css/cssparser.cpp

    r19350 r19421  
    715715            }
    716716        }
    717         break;
    718 
    719     case CSS_PROP_FONT_STRETCH:  // normal | wider | narrower | ultra-condensed | extra-condensed | condensed | semi-condensed | semi-expanded | expanded | extra-expanded | ultra-expanded | inherit
    720         if (id == CSS_VAL_NORMAL || (id >= CSS_VAL_WIDER && id <= CSS_VAL_ULTRA_EXPANDED))
    721             valid_primitive = true;
    722717        break;
    723718
     
    14771472    case CSS_PROP_INVALID:
    14781473        return false;
     1474    case CSS_PROP_FONT_STRETCH:
    14791475    case CSS_PROP_PAGE:
    14801476    case CSS_PROP_TEXT_LINE_THROUGH:
  • trunk/WebCore/css/cssstyleselector.cpp

    r19350 r19421  
    18221822                    case CSS_PROP_FONT_FAMILY:
    18231823                    case CSS_PROP_FONT_WEIGHT:
    1824                     case CSS_PROP_FONT_STRETCH:
     1824                    case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:
    18251825                    case CSS_PROP_FONT_VARIANT:
    1826                     case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:
    18271826                        // these have to be applied first, because other properties use the computed
    18281827                        // values of these porperties.
     
    21502149    }
    21512150       
    2152     case CSS_PROP_FONT_STRETCH: {
    2153         FontDescription fontDescription = style->fontDescription();
    2154         if (isInherit)
    2155             fontDescription.setStretch(parentStyle->fontDescription().stretch());
    2156         else if (isInitial)
    2157             fontDescription.setStretch(FontStretchNormal);
    2158         else {
    2159             if (!primitiveValue || !primitiveValue->getIdent())
    2160                 return;
    2161             switch (primitiveValue->getIdent()) {
    2162                 case CSS_VAL_WIDER:
    2163                     fontDescription.setStretch(fontDescription.widerStretch());
    2164                     break;
    2165                 case CSS_VAL_NARROWER:
    2166                     fontDescription.setStretch(fontDescription.narrowerStretch());
    2167                     break;
    2168                 case CSS_VAL_NORMAL:
    2169                     fontDescription.setStretch(FontStretchNormal);
    2170                     break;
    2171                 case CSS_VAL_SEMI_EXPANDED:
    2172                 case CSS_VAL_EXPANDED:
    2173                 case CSS_VAL_EXTRA_EXPANDED:
    2174                 case CSS_VAL_ULTRA_EXPANDED:
    2175                     fontDescription.setStretch(FontStretchExpanded);
    2176                     break;
    2177                 case CSS_VAL_ULTRA_CONDENSED:
    2178                 case CSS_VAL_EXTRA_CONDENSED:
    2179                 case CSS_VAL_CONDENSED:
    2180                 case CSS_VAL_SEMI_CONDENSED:
    2181                     fontDescription.setStretch(FontStretchCondensed);
    2182                     break;
    2183                 default:
    2184                     return;
    2185             }
    2186         }
    2187         if (style->setFontDescription(fontDescription))
    2188             fontDirty = true;
    2189         return;
    2190     }
    2191    
    21922151    case CSS_PROP_LIST_STYLE_POSITION:
    21932152    {
     
    44134372    case CSS_PROP_INVALID:
    44144373        return;
     4374    case CSS_PROP_FONT_STRETCH:
    44154375    case CSS_PROP_PAGE:
    44164376    case CSS_PROP_QUOTES:
  • trunk/WebCore/platform/FontCache.cpp

    r19350 r19421  
    3939
    4040struct FontPlatformDataCacheKey {
    41     FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), unsigned size = 0, bool bold = false, unsigned stretch = 5, bool italic = false)
     41    FontPlatformDataCacheKey(const AtomicString& family = AtomicString(), unsigned size = 0, bool bold = false, bool italic = false)
    4242        : m_family(family)
    4343        , m_size(size)
    4444        , m_bold(bold)
    45         , m_stretch(stretch)
    4645        , m_italic(italic)
    4746    {
     
    5049    bool operator==(const FontPlatformDataCacheKey& other) const
    5150    {
    52         return equalIgnoringCase(m_family, other.m_family) && m_size == other.m_size && m_bold == other.m_bold && m_stretch == other.m_stretch && m_italic == other.m_italic;
     51        return equalIgnoringCase(m_family, other.m_family) && m_size == other.m_size && m_bold == other.m_bold && m_italic == other.m_italic;
    5352    }
    5453   
     
    5655    unsigned m_size;
    5756    bool m_bold;
    58     unsigned m_stretch;
    5957    bool m_italic;
    6058};
     
    6260inline unsigned computeHash(const FontPlatformDataCacheKey& fontKey)
    6361{
    64     unsigned hashCodes[4] = {
     62    unsigned hashCodes[3] = {
    6563        CaseInsensitiveHash<String>::hash(fontKey.m_family),
    6664        fontKey.m_size,
    67         fontKey.m_stretch,
    6865        static_cast<unsigned>(fontKey.m_bold) << 1 | static_cast<unsigned>(fontKey.m_italic)
    6966    };
    70     return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), 4 * sizeof(unsigned) / sizeof(UChar));
     67    return StringImpl::computeHash(reinterpret_cast<UChar*>(hashCodes), 3 * sizeof(unsigned) / sizeof(UChar));
    7168}
    7269
     
    8885    static const FontPlatformDataCacheKey& deletedValue()
    8986    {
    90         static FontPlatformDataCacheKey key(nullAtom, 0xFFFFFFFFU, false, 0, false);
     87        static FontPlatformDataCacheKey key(nullAtom, 0xFFFFFFFFU, false, false);
    9188        return key;
    9289    }
    9390    static const FontPlatformDataCacheKey& emptyValue()
    9491    {
    95         static FontPlatformDataCacheKey key(nullAtom, 0, false, 0, false);
     92        static FontPlatformDataCacheKey key(nullAtom, 0, false, false);
    9693        return key;
    9794    }
     
    137134    }
    138135
    139     FontPlatformDataCacheKey key(familyName, fontDescription.computedPixelSize(), fontDescription.bold(), static_cast<unsigned>(fontDescription.stretch()), fontDescription.italic());
     136    FontPlatformDataCacheKey key(familyName, fontDescription.computedPixelSize(), fontDescription.bold(), fontDescription.italic());
    140137    FontPlatformData* result = 0;
    141138    bool foundResult;
  • trunk/WebCore/platform/FontDescription.h

    r19350 r19421  
    3232const unsigned cBoldWeight = 63;
    3333
    34 enum FontStretch {
    35     FontStretchCondensed = 3,
    36     FontStretchNormal = 5,
    37     FontStretchExpanded = 7
    38 };
    39 
    4034class FontDescription {
    4135public:
     
    4640        : m_specifiedSize(0), m_computedSize(0),
    4741          m_italic(false), m_smallCaps(false), m_isAbsoluteSize(false), m_weight(cNormalWeight),
    48           m_stretch(FontStretchNormal), m_genericFamily(NoFamily), m_usePrinterFont(false), m_keywordSize(0)
     42          m_genericFamily(NoFamily), m_usePrinterFont(false), m_keywordSize(0)
    4943          {}
    5044   
     
    6256    bool isAbsoluteSize() const { return m_isAbsoluteSize; }
    6357    unsigned weight() const { return m_weight; }
    64     FontStretch stretch() const { return static_cast<FontStretch>(m_stretch); }
    65     FontStretch narrowerStretch() const { return (m_stretch == FontStretchExpanded) ? FontStretchNormal : FontStretchCondensed; }
    66     FontStretch widerStretch() const { return (m_stretch == FontStretchCondensed) ? FontStretchNormal : FontStretchExpanded; }
    6758    GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); }
    6859    bool usePrinterFont() const { return m_usePrinterFont; }
     
    7768    void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; }
    7869    void setWeight(unsigned w) { m_weight = w; }
    79     void setStretch(FontStretch s) { m_stretch = s; }
    8070    void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; }
    8171    void setUsePrinterFont(bool p) { m_usePrinterFont = p; }
     
    9484                                 // (logical sizes like "medium" don't count).
    9585    unsigned m_weight : 8;
    96     unsigned m_stretch : 4;       // FontStretch
    9786    unsigned m_genericFamily : 3; // GenericFamilyType
    9887    bool m_usePrinterFont : 1;
     
    112101        && m_isAbsoluteSize == other.m_isAbsoluteSize
    113102        && m_weight == other.m_weight
    114         && m_stretch == other.m_stretch
    115103        && m_genericFamily == other.m_genericFamily
    116104        && m_usePrinterFont == other.m_usePrinterFont
  • trunk/WebCore/platform/mac/FontCacheMac.mm

    r19350 r19421  
    204204    if (fontDescription.bold())
    205205        traits |= NSBoldFontMask;
    206     switch (fontDescription.stretch()) {
    207         case FontStretchCondensed:
    208             traits |= NSFontCondensedTrait;
    209             break;
    210         case FontStretchExpanded:
    211             traits |= NSFontExpandedTrait;
    212             break;
    213         case FontStretchNormal:
    214             break;
    215     }
    216206    float size = fontDescription.computedPixelSize();
    217207   
     
    221211
    222212    NSFontTraitMask actualTraits = 0;
    223     if ((traits & NSFontBoldTrait) || (traits & NSFontItalicTrait))
     213    if (fontDescription.bold() || fontDescription.italic())
    224214        actualTraits = [[NSFontManager sharedFontManager] traitsOfFont:nsFont];
    225215   
  • trunk/WebCore/platform/mac/WebFontCache.mm

    r19350 r19421  
    2929#import "config.h"
    3030#import "WebFontCache.h"
    31 #import "FontDescription.h"
    3231
    3332#import <math.h>
    3433
    3534#define SYNTHESIZED_FONT_TRAITS (NSBoldFontMask | NSItalicFontMask)
    36 #define ACCEPTABLE_FONT_TRAITS (NSFontCondensedTrait | NSFontExpandedTrait)
     35
    3736#define IMPORTANT_FONT_TRAITS (0 \
    3837    | NSBoldFontMask \
     
    4645)
    4746
     47#define DESIRED_WEIGHT 5
     48
    4849static BOOL acceptableChoice(NSFontTraitMask desiredTraits, int desiredWeight,
    4950    NSFontTraitMask candidateTraits, int candidateWeight)
    5051{
    5152    desiredTraits &= ~SYNTHESIZED_FONT_TRAITS;
    52     desiredTraits &= ~ACCEPTABLE_FONT_TRAITS;
    5353    return (candidateTraits & desiredTraits) == desiredTraits;
    5454}
     
    5858    NSFontTraitMask candidateTraits, int candidateWeight)
    5959{
    60     if (!acceptableChoice(desiredTraits, desiredWeight, candidateTraits, candidateWeight))
     60    if (!acceptableChoice(desiredTraits, desiredWeight, candidateTraits, candidateWeight)) {
    6161        return NO;
    62    
    63     unsigned chosenWeightDelta = abs(chosenWeight - desiredWeight);
    64     unsigned candidateWeightDelta = abs(candidateWeight - desiredWeight);
    65    
    66     // prefer a closer weight regardless of traits
    67     if (candidateWeightDelta < chosenWeightDelta)
    68         return YES;
    69     if (candidateWeightDelta > chosenWeightDelta)
    70         return NO;
     62    }
    7163   
    7264    // A list of the traits we care about.
     
    9587    }
    9688   
     89    int chosenWeightDelta = chosenWeight - desiredWeight;
     90    int candidateWeightDelta = candidateWeight - desiredWeight;
     91   
     92    int chosenWeightDeltaMagnitude = abs(chosenWeightDelta);
     93    int candidateWeightDeltaMagnitude = abs(candidateWeightDelta);
     94   
    9795    // Smaller magnitude wins.
    9896    // If both have same magnitude, tie breaker is that the smaller weight wins.
    9997    // Otherwise, first font in the array wins (should almost never happen).
    100     if (candidateWeightDelta < chosenWeightDelta)
     98    if (candidateWeightDeltaMagnitude < chosenWeightDeltaMagnitude) {
    10199        return YES;
    102     if (candidateWeightDelta == chosenWeightDelta && candidateWeight < chosenWeight)
     100    }
     101    if (candidateWeightDeltaMagnitude == chosenWeightDeltaMagnitude && candidateWeight < chosenWeight) {
    103102        return YES;
     103    }
    104104   
    105105    return NO;
     
    114114{
    115115    NSFontManager *fontManager = [NSFontManager sharedFontManager];
    116     int desiredWeight = (desiredTraits & NSFontBoldTrait)? 9 : 5;
    117116
    118117    // Look for an exact match first.
     
    173172        BOOL newWinner;
    174173        if (!choseFont)
    175             newWinner = acceptableChoice(desiredTraits, desiredWeight, fontTraits, fontWeight);
     174            newWinner = acceptableChoice(desiredTraits, DESIRED_WEIGHT, fontTraits, fontWeight);
    176175        else
    177             newWinner = betterChoice(desiredTraits, desiredWeight, chosenTraits, chosenWeight, fontTraits, fontWeight);
     176            newWinner = betterChoice(desiredTraits, DESIRED_WEIGHT, chosenTraits, chosenWeight, fontTraits, fontWeight);
    178177
    179178        if (newWinner) {
     
    182181            chosenTraits = fontTraits;
    183182
    184             if (chosenWeight == desiredWeight && (chosenTraits & IMPORTANT_FONT_TRAITS) == (desiredTraits & IMPORTANT_FONT_TRAITS))
     183            if (chosenWeight == DESIRED_WEIGHT && (chosenTraits & IMPORTANT_FONT_TRAITS) == (desiredTraits & IMPORTANT_FONT_TRAITS))
    185184                break;
    186185        }
  • trunk/WebKit/ChangeLog

    r19409 r19421  
     12007-02-06  Mark Rowe  <mrowe@apple.com>
     2
     3        Roll out incomplete support for font-stretch (r19350) at Dave Hyatt's request.
     4        See http://bugs.webkit.org/show_bug.cgi?id=12530#c9 for more info.
     5
     6        * WebInspector/webInspector/inspector.js:
     7        * WebView/WebHTMLView.mm:
     8        (-[WebHTMLView _addToStyle:fontA:fontB:]):
     9
    1102007-02-05  Beth Dakin  <bdakin@apple.com>
    211
  • trunk/WebKit/WebInspector/webInspector/inspector.js

    r19350 r19421  
    107107    "empty-cells": "show",
    108108    "float": "none",
    109     "font-stretch": "normal",
    110109    "font-style": "normal",
    111110    "font-variant": "normal",
  • trunk/WebKit/WebView/WebHTMLView.mm

    r19350 r19421  
    39983998    BOOL aIsBold = aWeight >= MIN_BOLD_WEIGHT;
    39993999
    4000     unsigned aTraits = [fm traitsOfFont:a];
    4001     unsigned bTraits = [fm traitsOfFont:b];
     4000    BOOL aIsItalic = ([fm traitsOfFont:a] & NSItalicFontMask) != 0;
     4001    BOOL bIsItalic = ([fm traitsOfFont:b] & NSItalicFontMask) != 0;
    40024002
    40034003    if ([aFamilyName isEqualToString:bFamilyName]) {
     
    40124012        if (aIsBold)
    40134013            traits |= NSBoldFontMask;
    4014         traits |= (aTraits & NSFontItalicTrait);
    4015         traits |= (aTraits & NSFontCondensedTrait);
    4016         traits |= (aTraits & NSFontExpandedTrait);
     4014        if (aIsItalic)
     4015            traits |= NSItalicFontMask;
    40174016        NSFont *foundFont = WebCoreFindFont(aFamilyName, traits, aPointSize);
    40184017
     
    40244023
    40254024        // FIXME: Need more sophisticated escaping code if we want to handle family names
    4026         // with characters like apostrophe or backslash in their names.
     4025        // with characters like single quote or backslash in their names.
    40274026        [style setFontFamily:[NSString stringWithFormat:@"'%@'", familyNameForCSS]];
    40284027    }
     
    40394038        [style setFontWeight:aIsBold ? @"bold" : @"normal"];
    40404039
    4041     if ((aTraits & NSFontItalicTrait) == (bTraits & NSFontItalicTrait))
    4042         [style setFontStyle:(aTraits & NSFontItalicTrait) ? @"italic" :  @"normal"];
    4043     if ((aTraits & NSFontCondensedTrait) == (bTraits & NSFontCondensedTrait))
    4044         [style setFontStretch:(aTraits & NSFontCondensedTrait) ? @"condensed" :  @"normal"];
    4045     else if ((aTraits & NSFontExpandedTrait) == (bTraits & NSFontExpandedTrait))
    4046         [style setFontStretch:(aTraits & NSFontExpandedTrait) ? @"extended" :  @"normal"];
     4040    if (aIsItalic == bIsItalic)
     4041        [style setFontStyle:aIsItalic ? @"italic" :  @"normal"];
    40474042}
    40484043
Note: See TracChangeset for help on using the changeset viewer.