Changeset 19421 in webkit
- Timestamp:
- Feb 5, 2007 6:27:17 PM (17 years ago)
- Location:
- trunk
- Files:
-
- 4 deleted
- 13 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r19417 r19421 1 2007-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 1 12 2007-02-05 Justin Garcia <justin.garcia@apple.com> 2 13 -
trunk/LayoutTests/fast/css/computed-style-expected.txt
r19350 r19421 32 32 font-family: Times; 33 33 font-size: 16px; 34 font-stretch: normal;35 34 font-style: normal; 36 35 font-variant: normal; -
trunk/WebCore/ChangeLog
r19420 r19421 1 2007-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 1 33 2007-02-05 Adele Peterson <adele@apple.com> 2 34 -
trunk/WebCore/css/CSSComputedStyleDeclaration.cpp
r19350 r19421 71 71 CSS_PROP_FONT_FAMILY, 72 72 CSS_PROP_FONT_SIZE, 73 CSS_PROP_FONT_STRETCH,74 73 CSS_PROP_FONT_STYLE, 75 74 CSS_PROP_FONT_VARIANT, … … 964 963 case CSS_PROP__WEBKIT_BINDING: 965 964 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);972 965 case CSS_PROP_FONT_STYLE: 973 966 if (style->fontDescription().italic()) … … 1549 1542 case CSS_PROP_COUNTER_RESET: 1550 1543 case CSS_PROP_FONT: 1544 case CSS_PROP_FONT_STRETCH: 1551 1545 case CSS_PROP_LIST_STYLE: 1552 1546 case CSS_PROP_MARGIN: … … 1660 1654 CSS_PROP_FONT_FAMILY, 1661 1655 CSS_PROP_FONT_SIZE, 1662 CSS_PROP_FONT_STRETCH,1663 1656 CSS_PROP_FONT_STYLE, 1664 1657 CSS_PROP_FONT_VARIANT, -
trunk/WebCore/css/cssparser.cpp
r19350 r19421 715 715 } 716 716 } 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 | inherit720 if (id == CSS_VAL_NORMAL || (id >= CSS_VAL_WIDER && id <= CSS_VAL_ULTRA_EXPANDED))721 valid_primitive = true;722 717 break; 723 718 … … 1477 1472 case CSS_PROP_INVALID: 1478 1473 return false; 1474 case CSS_PROP_FONT_STRETCH: 1479 1475 case CSS_PROP_PAGE: 1480 1476 case CSS_PROP_TEXT_LINE_THROUGH: -
trunk/WebCore/css/cssstyleselector.cpp
r19350 r19421 1822 1822 case CSS_PROP_FONT_FAMILY: 1823 1823 case CSS_PROP_FONT_WEIGHT: 1824 case CSS_PROP_ FONT_STRETCH:1824 case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST: 1825 1825 case CSS_PROP_FONT_VARIANT: 1826 case CSS_PROP__WEBKIT_TEXT_SIZE_ADJUST:1827 1826 // these have to be applied first, because other properties use the computed 1828 1827 // values of these porperties. … … 2150 2149 } 2151 2150 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 2192 2151 case CSS_PROP_LIST_STYLE_POSITION: 2193 2152 { … … 4413 4372 case CSS_PROP_INVALID: 4414 4373 return; 4374 case CSS_PROP_FONT_STRETCH: 4415 4375 case CSS_PROP_PAGE: 4416 4376 case CSS_PROP_QUOTES: -
trunk/WebCore/platform/FontCache.cpp
r19350 r19421 39 39 40 40 struct 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) 42 42 : m_family(family) 43 43 , m_size(size) 44 44 , m_bold(bold) 45 , m_stretch(stretch)46 45 , m_italic(italic) 47 46 { … … 50 49 bool operator==(const FontPlatformDataCacheKey& other) const 51 50 { 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; 53 52 } 54 53 … … 56 55 unsigned m_size; 57 56 bool m_bold; 58 unsigned m_stretch;59 57 bool m_italic; 60 58 }; … … 62 60 inline unsigned computeHash(const FontPlatformDataCacheKey& fontKey) 63 61 { 64 unsigned hashCodes[ 4] = {62 unsigned hashCodes[3] = { 65 63 CaseInsensitiveHash<String>::hash(fontKey.m_family), 66 64 fontKey.m_size, 67 fontKey.m_stretch,68 65 static_cast<unsigned>(fontKey.m_bold) << 1 | static_cast<unsigned>(fontKey.m_italic) 69 66 }; 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)); 71 68 } 72 69 … … 88 85 static const FontPlatformDataCacheKey& deletedValue() 89 86 { 90 static FontPlatformDataCacheKey key(nullAtom, 0xFFFFFFFFU, false, 0,false);87 static FontPlatformDataCacheKey key(nullAtom, 0xFFFFFFFFU, false, false); 91 88 return key; 92 89 } 93 90 static const FontPlatformDataCacheKey& emptyValue() 94 91 { 95 static FontPlatformDataCacheKey key(nullAtom, 0, false, 0,false);92 static FontPlatformDataCacheKey key(nullAtom, 0, false, false); 96 93 return key; 97 94 } … … 137 134 } 138 135 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()); 140 137 FontPlatformData* result = 0; 141 138 bool foundResult; -
trunk/WebCore/platform/FontDescription.h
r19350 r19421 32 32 const unsigned cBoldWeight = 63; 33 33 34 enum FontStretch {35 FontStretchCondensed = 3,36 FontStretchNormal = 5,37 FontStretchExpanded = 738 };39 40 34 class FontDescription { 41 35 public: … … 46 40 : m_specifiedSize(0), m_computedSize(0), 47 41 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) 49 43 {} 50 44 … … 62 56 bool isAbsoluteSize() const { return m_isAbsoluteSize; } 63 57 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; }67 58 GenericFamilyType genericFamily() const { return static_cast<GenericFamilyType>(m_genericFamily); } 68 59 bool usePrinterFont() const { return m_usePrinterFont; } … … 77 68 void setIsAbsoluteSize(bool s) { m_isAbsoluteSize = s; } 78 69 void setWeight(unsigned w) { m_weight = w; } 79 void setStretch(FontStretch s) { m_stretch = s; }80 70 void setGenericFamily(GenericFamilyType genericFamily) { m_genericFamily = genericFamily; } 81 71 void setUsePrinterFont(bool p) { m_usePrinterFont = p; } … … 94 84 // (logical sizes like "medium" don't count). 95 85 unsigned m_weight : 8; 96 unsigned m_stretch : 4; // FontStretch97 86 unsigned m_genericFamily : 3; // GenericFamilyType 98 87 bool m_usePrinterFont : 1; … … 112 101 && m_isAbsoluteSize == other.m_isAbsoluteSize 113 102 && m_weight == other.m_weight 114 && m_stretch == other.m_stretch115 103 && m_genericFamily == other.m_genericFamily 116 104 && m_usePrinterFont == other.m_usePrinterFont -
trunk/WebCore/platform/mac/FontCacheMac.mm
r19350 r19421 204 204 if (fontDescription.bold()) 205 205 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 }216 206 float size = fontDescription.computedPixelSize(); 217 207 … … 221 211 222 212 NSFontTraitMask actualTraits = 0; 223 if ( (traits & NSFontBoldTrait) || (traits & NSFontItalicTrait))213 if (fontDescription.bold() || fontDescription.italic()) 224 214 actualTraits = [[NSFontManager sharedFontManager] traitsOfFont:nsFont]; 225 215 -
trunk/WebCore/platform/mac/WebFontCache.mm
r19350 r19421 29 29 #import "config.h" 30 30 #import "WebFontCache.h" 31 #import "FontDescription.h"32 31 33 32 #import <math.h> 34 33 35 34 #define SYNTHESIZED_FONT_TRAITS (NSBoldFontMask | NSItalicFontMask) 36 #define ACCEPTABLE_FONT_TRAITS (NSFontCondensedTrait | NSFontExpandedTrait) 35 37 36 #define IMPORTANT_FONT_TRAITS (0 \ 38 37 | NSBoldFontMask \ … … 46 45 ) 47 46 47 #define DESIRED_WEIGHT 5 48 48 49 static BOOL acceptableChoice(NSFontTraitMask desiredTraits, int desiredWeight, 49 50 NSFontTraitMask candidateTraits, int candidateWeight) 50 51 { 51 52 desiredTraits &= ~SYNTHESIZED_FONT_TRAITS; 52 desiredTraits &= ~ACCEPTABLE_FONT_TRAITS;53 53 return (candidateTraits & desiredTraits) == desiredTraits; 54 54 } … … 58 58 NSFontTraitMask candidateTraits, int candidateWeight) 59 59 { 60 if (!acceptableChoice(desiredTraits, desiredWeight, candidateTraits, candidateWeight)) 60 if (!acceptableChoice(desiredTraits, desiredWeight, candidateTraits, candidateWeight)) { 61 61 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 } 71 63 72 64 // A list of the traits we care about. … … 95 87 } 96 88 89 int chosenWeightDelta = chosenWeight - desiredWeight; 90 int candidateWeightDelta = candidateWeight - desiredWeight; 91 92 int chosenWeightDeltaMagnitude = abs(chosenWeightDelta); 93 int candidateWeightDeltaMagnitude = abs(candidateWeightDelta); 94 97 95 // Smaller magnitude wins. 98 96 // If both have same magnitude, tie breaker is that the smaller weight wins. 99 97 // Otherwise, first font in the array wins (should almost never happen). 100 if (candidateWeightDelta < chosenWeightDelta)98 if (candidateWeightDeltaMagnitude < chosenWeightDeltaMagnitude) { 101 99 return YES; 102 if (candidateWeightDelta == chosenWeightDelta && candidateWeight < chosenWeight) 100 } 101 if (candidateWeightDeltaMagnitude == chosenWeightDeltaMagnitude && candidateWeight < chosenWeight) { 103 102 return YES; 103 } 104 104 105 105 return NO; … … 114 114 { 115 115 NSFontManager *fontManager = [NSFontManager sharedFontManager]; 116 int desiredWeight = (desiredTraits & NSFontBoldTrait)? 9 : 5;117 116 118 117 // Look for an exact match first. … … 173 172 BOOL newWinner; 174 173 if (!choseFont) 175 newWinner = acceptableChoice(desiredTraits, desiredWeight, fontTraits, fontWeight);174 newWinner = acceptableChoice(desiredTraits, DESIRED_WEIGHT, fontTraits, fontWeight); 176 175 else 177 newWinner = betterChoice(desiredTraits, desiredWeight, chosenTraits, chosenWeight, fontTraits, fontWeight);176 newWinner = betterChoice(desiredTraits, DESIRED_WEIGHT, chosenTraits, chosenWeight, fontTraits, fontWeight); 178 177 179 178 if (newWinner) { … … 182 181 chosenTraits = fontTraits; 183 182 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)) 185 184 break; 186 185 } -
trunk/WebKit/ChangeLog
r19409 r19421 1 2007-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 1 10 2007-02-05 Beth Dakin <bdakin@apple.com> 2 11 -
trunk/WebKit/WebInspector/webInspector/inspector.js
r19350 r19421 107 107 "empty-cells": "show", 108 108 "float": "none", 109 "font-stretch": "normal",110 109 "font-style": "normal", 111 110 "font-variant": "normal", -
trunk/WebKit/WebView/WebHTMLView.mm
r19350 r19421 3998 3998 BOOL aIsBold = aWeight >= MIN_BOLD_WEIGHT; 3999 3999 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; 4002 4002 4003 4003 if ([aFamilyName isEqualToString:bFamilyName]) { … … 4012 4012 if (aIsBold) 4013 4013 traits |= NSBoldFontMask; 4014 traits |= (aTraits & NSFontItalicTrait); 4015 traits |= (aTraits & NSFontCondensedTrait); 4016 traits |= (aTraits & NSFontExpandedTrait); 4014 if (aIsItalic) 4015 traits |= NSItalicFontMask; 4017 4016 NSFont *foundFont = WebCoreFindFont(aFamilyName, traits, aPointSize); 4018 4017 … … 4024 4023 4025 4024 // 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. 4027 4026 [style setFontFamily:[NSString stringWithFormat:@"'%@'", familyNameForCSS]]; 4028 4027 } … … 4039 4038 [style setFontWeight:aIsBold ? @"bold" : @"normal"]; 4040 4039 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"]; 4047 4042 } 4048 4043
Note: See TracChangeset
for help on using the changeset viewer.