Changeset 209875 in webkit
- Timestamp:
- Dec 15, 2016 2:12:21 PM (7 years ago)
- Location:
- trunk
- Files:
-
- 4 added
- 16 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r209867 r209875 1 2016-12-15 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Implement font-synthesis: small-caps 4 https://bugs.webkit.org/show_bug.cgi?id=165892 5 6 Reviewed by David Hyatt. 7 8 * fast/text/font-synthesis-parsing-expected.txt: Added. 9 * fast/text/font-synthesis-parsing.html: Added. 10 * css3/font-synthesis-small-caps-expected.html: Added. 11 * css3/font-synthesis-small-caps.html: Added. 12 * fast/css/getComputedStyle/computed-style-expected.txt: 13 * fast/css/getComputedStyle/computed-style-font-family-expected.txt: 14 * fast/css/getComputedStyle/computed-style-without-renderer-expected.txt: 15 * fast/css3-text/font-synthesis-parse-expected.txt: 16 * fast/css3-text/font-synthesis-parse.html: 17 * svg/css/getComputedStyle-basic-expected.txt: 18 1 19 2016-12-15 Simon Fraser <simon.fraser@apple.com> 2 20 -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-expected.txt
r207757 r209875 46 46 font-size: 16px; 47 47 font-style: normal; 48 font-synthesis: style weight ;48 font-synthesis: style weight small-caps; 49 49 font-variant: normal; 50 50 font-weight: normal; -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-font-family-expected.txt
r190192 r209875 4 4 font-size: 16px; 5 5 font-style: normal; 6 font-synthesis: style weight ;6 font-synthesis: style weight small-caps; 7 7 font-variant: normal; 8 8 font-weight: normal; -
trunk/LayoutTests/fast/css/getComputedStyle/computed-style-without-renderer-expected.txt
r207757 r209875 45 45 font-size: 16px 46 46 font-style: normal 47 font-synthesis: style weight 47 font-synthesis: style weight small-caps 48 48 font-variant: normal 49 49 font-weight: normal -
trunk/LayoutTests/fast/css3-text/font-synthesis-parse-expected.txt
r208733 r209875 2 2 PASS declaration.length is 0 3 3 PASS declaration.getPropertyValue('font-synthesis') is "" 4 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight "4 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight small-caps" 5 5 PASS cssRule.type is cssRule.STYLE_RULE 6 6 PASS declaration.length is 1 7 7 PASS declaration.getPropertyValue('font-synthesis') is "initial" 8 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight "8 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight small-caps" 9 9 PASS cssRule.type is cssRule.STYLE_RULE 10 10 PASS declaration.length is 1 … … 26 26 PASS declaration.length is 0 27 27 PASS declaration.getPropertyValue('font-synthesis') is "" 28 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight "28 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight small-caps" 29 29 PASS cssRule.type is cssRule.STYLE_RULE 30 30 PASS declaration.length is 0 31 31 PASS declaration.getPropertyValue('font-synthesis') is "" 32 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight "32 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight small-caps" 33 33 PASS cssRule.type is cssRule.STYLE_RULE 34 34 PASS declaration.length is 0 35 35 PASS declaration.getPropertyValue('font-synthesis') is "" 36 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight "36 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight small-caps" 37 37 PASS cssRule.type is cssRule.STYLE_RULE 38 38 PASS declaration.length is 0 39 39 PASS declaration.getPropertyValue('font-synthesis') is "" 40 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight "40 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight small-caps" 41 41 PASS cssRule.type is cssRule.STYLE_RULE 42 42 PASS declaration.length is 0 43 43 PASS declaration.getPropertyValue('font-synthesis') is "" 44 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight "44 PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight small-caps" 45 45 PASS successfullyParsed is true 46 46 -
trunk/LayoutTests/fast/css3-text/font-synthesis-parse.html
r208733 r209875 15 15 shouldBeEqualToString("declaration.getPropertyValue('font-synthesis')", ""); 16 16 computedStyle = window.getComputedStyle(target, null); 17 shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style weight ");17 shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style weight small-caps"); 18 18 stylesheet.deleteRule(0); 19 19 } … … 26 26 shouldBeEqualToString("declaration.getPropertyValue('font-synthesis')", "initial"); 27 27 computedStyle = window.getComputedStyle(target, null); 28 shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style weight ");28 shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style weight small-caps"); 29 29 stylesheet.deleteRule(0); 30 30 } -
trunk/LayoutTests/svg/css/getComputedStyle-basic-expected.txt
r209777 r209875 89 89 rect: style.getPropertyValue(font-style) : normal 90 90 rect: style.getPropertyCSSValue(font-style) : [object CSSPrimitiveValue] 91 rect: style.getPropertyValue(font-synthesis) : style weight 91 rect: style.getPropertyValue(font-synthesis) : style weight small-caps 92 92 rect: style.getPropertyCSSValue(font-synthesis) : [object CSSValueList] 93 93 rect: style.getPropertyValue(font-variant) : normal … … 597 597 g: style.getPropertyValue(font-style) : normal 598 598 g: style.getPropertyCSSValue(font-style) : [object CSSPrimitiveValue] 599 g: style.getPropertyValue(font-synthesis) : style weight 599 g: style.getPropertyValue(font-synthesis) : style weight small-caps 600 600 g: style.getPropertyCSSValue(font-synthesis) : [object CSSValueList] 601 601 g: style.getPropertyValue(font-variant) : normal -
trunk/Source/WebCore/ChangeLog
r209873 r209875 1 2016-12-15 Myles C. Maxfield <mmaxfield@apple.com> 2 3 [Cocoa] Implement font-synthesis: small-caps 4 https://bugs.webkit.org/show_bug.cgi?id=165892 5 6 Reviewed by David Hyatt. 7 8 The CSS Fonts level 4 spec adds a new value to the "font-synthesis" 9 property which controls whether or not small-caps is allowed to be 10 synthesized. Luckily, we already have an implementation of this 11 straightforward, so the implementation is quite simple. 12 13 Tests: css3/font-synthesis-small-caps.html 14 fast/text/font-synthesis-parsing.html 15 16 * css/CSSComputedStyleDeclaration.cpp: 17 (WebCore::fontSynthesisFromStyle): 18 * css/StyleBuilderConverter.h: 19 (WebCore::StyleBuilderConverter::convertFontSynthesis): 20 * css/parser/CSSPropertyParser.cpp: 21 (WebCore::consumeFontSynthesis): 22 * platform/graphics/FontCache.h: 23 (WebCore::FontDescriptionKey::makeFlagsKey): 24 * platform/graphics/FontDescription.cpp: 25 (WebCore::FontDescription::FontDescription): 26 * platform/graphics/FontDescription.h: 27 (WebCore::FontCascadeDescription::initialFontSynthesis): 28 * platform/graphics/mac/ComplexTextController.cpp: 29 (WebCore::shouldSynthesize): 30 (WebCore::ComplexTextController::collectComplexTextRuns): 31 1 32 2016-12-15 Brady Eidson <beidson@apple.com> 2 33 -
trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp
r209805 r209875 2145 2145 if (style.fontDescription().fontSynthesis() & FontSynthesisWeight) 2146 2146 list.get().append(CSSValuePool::singleton().createIdentifierValue(CSSValueWeight)); 2147 if (style.fontDescription().fontSynthesis() & FontSynthesisSmallCaps) 2148 list.get().append(CSSValuePool::singleton().createIdentifierValue(CSSValueSmallCaps)); 2147 2149 return Ref<CSSValue>(list.get()); 2148 2150 } -
trunk/Source/WebCore/css/StyleBuilderConverter.h
r209788 r209875 1442 1442 result |= FontSynthesisStyle; 1443 1443 break; 1444 case CSSValueSmallCaps: 1445 result |= FontSynthesisSmallCaps; 1446 break; 1444 1447 default: 1445 1448 ASSERT_NOT_REACHED(); -
trunk/Source/WebCore/css/parser/CSSPropertyParser.cpp
r209826 r209875 949 949 static RefPtr<CSSValue> consumeFontSynthesis(CSSParserTokenRange& range) 950 950 { 951 // none | [ weight || style ]951 // none | [ weight || style || small-caps ] 952 952 CSSValueID id = range.peek().id(); 953 953 if (id == CSSValueNone) … … 956 956 RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated(); 957 957 while (true) { 958 auto ident = consumeIdent<CSSValueWeight, CSSValueStyle >(range);958 auto ident = consumeIdent<CSSValueWeight, CSSValueStyle, CSSValueSmallCaps>(range); 959 959 if (!ident) 960 960 break; -
trunk/Source/WebCore/platform/graphics/FontCache.h
r206839 r209875 122 122 { 123 123 static_assert(USCRIPT_CODE_LIMIT < 0x1000, "Script code must fit in an unsigned along with the other flags"); 124 unsigned first = static_cast<unsigned>(description.script()) << 1 0125 | static_cast<unsigned>(description.textRenderingMode()) << 8124 unsigned first = static_cast<unsigned>(description.script()) << 11 125 | static_cast<unsigned>(description.textRenderingMode()) << 9 126 126 | static_cast<unsigned>(description.fontSynthesis()) << 6 127 127 | static_cast<unsigned>(description.widthVariant()) << 4 -
trunk/Source/WebCore/platform/graphics/FontDescription.cpp
r206839 r209875 62 62 , m_textRendering(AutoTextRendering) 63 63 , m_script(USCRIPT_COMMON) 64 , m_fontSynthesis(FontSynthesisWeight | FontSynthesisStyle )64 , m_fontSynthesis(FontSynthesisWeight | FontSynthesisStyle | FontSynthesisSmallCaps) 65 65 , m_variantCommonLigatures(static_cast<unsigned>(FontVariantLigatures::Normal)) 66 66 , m_variantDiscretionaryLigatures(static_cast<unsigned>(FontVariantLigatures::Normal)) -
trunk/Source/WebCore/platform/graphics/FontDescription.h
r206839 r209875 144 144 unsigned m_textRendering : 2; // TextRenderingMode 145 145 unsigned m_script : 7; // Used to help choose an appropriate font for generic font families. 146 unsigned m_fontSynthesis : 2; // FontSynthesis type146 unsigned m_fontSynthesis : 3; // FontSynthesis type 147 147 unsigned m_variantCommonLigatures : 2; // FontVariantLigatures 148 148 unsigned m_variantDiscretionaryLigatures : 2; // FontVariantLigatures … … 266 266 static FontSmoothingMode initialFontSmoothing() { return AutoSmoothing; } 267 267 static TextRenderingMode initialTextRenderingMode() { return AutoTextRendering; } 268 static FontSynthesis initialFontSynthesis() { return FontSynthesisWeight | FontSynthesisStyle ; }268 static FontSynthesis initialFontSynthesis() { return FontSynthesisWeight | FontSynthesisStyle | FontSynthesisSmallCaps; } 269 269 static FontVariantPosition initialVariantPosition() { return FontVariantPosition::Normal; } 270 270 static FontVariantCaps initialVariantCaps() { return FontVariantCaps::Normal; } -
trunk/Source/WebCore/platform/graphics/mac/ComplexTextController.cpp
r209410 r209875 289 289 } 290 290 291 static bool shouldSynthesize(const Font* nextFont, UChar32 baseCharacter, std::optional<UChar32> capitalizedBase, FontVariantCaps fontVariantCaps, bool engageAllSmallCapsProcessing) 292 { 291 static bool shouldSynthesize(bool dontSynthesizeSmallCaps, const Font* nextFont, UChar32 baseCharacter, std::optional<UChar32> capitalizedBase, FontVariantCaps fontVariantCaps, bool engageAllSmallCapsProcessing) 292 { 293 if (dontSynthesizeSmallCaps) 294 return false; 293 295 if (!nextFont || nextFont == Font::systemFallback()) 294 296 return false; … … 316 318 317 319 auto fontVariantCaps = m_font.fontDescription().variantCaps(); 320 bool dontSynthesizeSmallCaps = !static_cast<bool>(m_font.fontDescription().fontSynthesis() & FontSynthesisSmallCaps); 318 321 bool engageAllSmallCapsProcessing = fontVariantCaps == FontVariantCaps::AllSmall || fontVariantCaps == FontVariantCaps::AllPetite; 319 322 bool engageSmallCapsProcessing = engageAllSmallCapsProcessing || fontVariantCaps == FontVariantCaps::Small || fontVariantCaps == FontVariantCaps::Petite; … … 342 345 343 346 auto capitalizedBase = capitalized(baseCharacter); 344 if (shouldSynthesize( nextFont, baseCharacter, capitalizedBase, fontVariantCaps, engageAllSmallCapsProcessing)) {347 if (shouldSynthesize(dontSynthesizeSmallCaps, nextFont, baseCharacter, capitalizedBase, fontVariantCaps, engageAllSmallCapsProcessing)) { 345 348 synthesizedFont = &nextFont->noSynthesizableFeaturesFont(); 346 349 smallSynthesizedFont = synthesizedFont->smallCapsFont(m_font.fontDescription()); … … 383 386 384 387 capitalizedBase = capitalized(baseCharacter); 385 if (!synthesizedFont && shouldSynthesize( nextFont, baseCharacter, capitalizedBase, fontVariantCaps, engageAllSmallCapsProcessing)) {388 if (!synthesizedFont && shouldSynthesize(dontSynthesizeSmallCaps, nextFont, baseCharacter, capitalizedBase, fontVariantCaps, engageAllSmallCapsProcessing)) { 386 389 // Rather than synthesize each character individually, we should synthesize the entire "run" if any character requires synthesis. 387 390 synthesizedFont = &nextFont->noSynthesizableFeaturesFont(); -
trunk/Source/WebCore/platform/text/TextFlags.h
r205282 r209875 61 61 FontSynthesisNone = 0x0, 62 62 FontSynthesisWeight = 0x1, 63 FontSynthesisStyle = 0x2 63 FontSynthesisStyle = 0x2, 64 FontSynthesisSmallCaps = 0x4 64 65 }; 65 66 typedef unsigned FontSynthesis; 66 const unsigned FontSynthesisWidth = 2;67 const unsigned FontSynthesisWidth = 3; 67 68 68 69 enum class FontVariantLigatures {
Note: See TracChangeset
for help on using the changeset viewer.