Diff
Modified: trunk/LayoutTests/ChangeLog (183303 => 183304)
--- trunk/LayoutTests/ChangeLog 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/LayoutTests/ChangeLog 2015-04-25 03:29:23 UTC (rev 183304)
@@ -1,3 +1,13 @@
+2015-04-24 Myles C. Maxfield <[email protected]>
+
+ Implement parsing support for font-synthesis CSS property
+ https://bugs.webkit.org/show_bug.cgi?id=144180
+
+ Reviewed by Tim Horton.
+
+ * fast/css3-text/font-synthesis-parse-expected.txt: Added.
+ * fast/css3-text/font-synthesis-parse.html: Added.
+
2015-04-24 Simon Fraser <[email protected]>
Track a coverage rect through GraphicsLayerCA flushes, use it to mark backing store attached
Added: trunk/LayoutTests/fast/css3-text/font-synthesis-parse-expected.txt (0 => 183304)
--- trunk/LayoutTests/fast/css3-text/font-synthesis-parse-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/css3-text/font-synthesis-parse-expected.txt 2015-04-25 03:29:23 UTC (rev 183304)
@@ -0,0 +1,56 @@
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('font-synthesis') is null
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('font-synthesis') is "initial"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('font-synthesis') is "weight"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "weight"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('font-synthesis') is "style"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('font-synthesis') is "style"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('font-synthesis') is "weight style"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('font-synthesis') is "weight style"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 1
+PASS declaration.getPropertyValue('font-synthesis') is "weight style"
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "style weight"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('font-synthesis') is null
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('font-synthesis') is null
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('font-synthesis') is null
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('font-synthesis') is null
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS cssRule.type is cssRule.STYLE_RULE
+PASS declaration.length is 0
+PASS declaration.getPropertyValue('font-synthesis') is null
+PASS computedStyle.getPropertyCSSValue('font-synthesis').cssText is "none"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/css3-text/font-synthesis-parse.html (0 => 183304)
--- trunk/LayoutTests/fast/css3-text/font-synthesis-parse.html (rev 0)
+++ trunk/LayoutTests/fast/css3-text/font-synthesis-parse.html 2015-04-25 03:29:23 UTC (rev 183304)
@@ -0,0 +1,123 @@
+<!DOCTYPE HTML>
+<html>
+<head>
+<script src=""
+</head>
+<body>
+ <div id="p"></div>
+ <div id="q"><div id="r"></div></div>
+ <script type="text/_javascript_">
+ function testEmptyIsNone(stylesheet, target) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "0");
+ shouldBe("declaration.getPropertyValue('font-synthesis')", "null");
+ computedStyle = window.getComputedStyle(target, null);
+ shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "none");
+ stylesheet.deleteRule(0);
+ }
+
+ function testInitialIsNone(stylesheet, target) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "1");
+ shouldBeEqualToString("declaration.getPropertyValue('font-synthesis')", "initial");
+ computedStyle = window.getComputedStyle(target, null);
+ shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "none");
+ stylesheet.deleteRule(0);
+ }
+
+ function testWeight(stylesheet, target) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "1");
+ shouldBeEqualToString("declaration.getPropertyValue('font-synthesis')", "weight");
+ computedStyle = window.getComputedStyle(target, null);
+ shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "weight");
+ stylesheet.deleteRule(0);
+ }
+
+ function testStyle(stylesheet, target) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "1");
+ shouldBeEqualToString("declaration.getPropertyValue('font-synthesis')", "style");
+ computedStyle = window.getComputedStyle(target, null);
+ shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style");
+ stylesheet.deleteRule(0);
+ }
+
+ function testWeightAndStyle(stylesheet, target) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "1");
+ shouldBeEqualToString("declaration.getPropertyValue('font-synthesis')", "weight style");
+ computedStyle = window.getComputedStyle(target, null);
+ shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style weight");
+ stylesheet.deleteRule(0);
+ }
+
+ function testStyleAndWeight(stylesheet, target) {
+ cssRule = stylesheet.cssRules.item(0);
+ shouldBe("cssRule.type", "cssRule.STYLE_RULE");
+ declaration = cssRule.style;
+ shouldBe("declaration.length", "1");
+ shouldBeEqualToString("declaration.getPropertyValue('font-synthesis')", "weight style");
+ computedStyle = window.getComputedStyle(target, null);
+ shouldBeEqualToString("computedStyle.getPropertyCSSValue('font-synthesis').cssText", "style weight");
+ stylesheet.deleteRule(0);
+ }
+
+ var styleElement = document.createElement("style");
+ document.head.appendChild(styleElement);
+ stylesheet = styleElement.sheet;
+ var target = document.getElementById("p");
+
+ stylesheet.insertRule("#p { }", 0);
+ testEmptyIsNone(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: initial; }", 0);
+ testInitialIsNone(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: weight }", 0);
+ testWeight(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: style style }", 0);
+ testStyle(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: style }", 0);
+ testStyle(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: weight style }", 0);
+ testWeightAndStyle(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: style weight weight}", 0);
+ testStyleAndWeight(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: style weight }", 0);
+ testStyleAndWeight(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: garbage style }", 0);
+ testEmptyIsNone(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: style garbage }", 0);
+ testEmptyIsNone(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: garbage style garbage }", 0);
+ testEmptyIsNone(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: style garbage style }", 0);
+ testEmptyIsNone(stylesheet, target);
+
+ stylesheet.insertRule("#p { font-synthesis: weight garbage }", 0);
+ testEmptyIsNone(stylesheet, target);
+
+ </script>
+<script src=""
+</body>
+</html>
Modified: trunk/Source/WebCore/ChangeLog (183303 => 183304)
--- trunk/Source/WebCore/ChangeLog 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/ChangeLog 2015-04-25 03:29:23 UTC (rev 183304)
@@ -1,3 +1,38 @@
+2015-04-24 Myles C. Maxfield <[email protected]>
+
+ Implement parsing support for font-synthesis CSS property
+ https://bugs.webkit.org/show_bug.cgi?id=144180
+ <rdar://problem/20692791>
+ <rdar://problem/20625024>
+
+ Reviewed by Tim Horton.
+
+ See http://www.w3.org/TR/css-fonts-3/#font-synthesis-prop
+
+ This property allows web authors to opt out of font synthesis. This patch only
+ implements parsing support for the property.
+
+ Test: fast/css3-text/font-synthesis-parse.html
+
+ * css/CSSComputedStyleDeclaration.cpp:
+ (WebCore::fontSynthesisFromStyle): Create a CSSValue for the existing style object.
+ (WebCore::ComputedStyleExtractor::propertyValue): Call fontSynthesisFromStyle().
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseValue): Call parseFontSynthesis().
+ (WebCore::CSSParser::parseFontSynthesis): Accept the grammar
+ "none | [ weight || style ]"
+ * css/CSSParser.h: Function signature.
+ * css/CSSPropertyNames.in: New CSS property name.
+ * css/CSSValueKeywords.in: New CSS value names.
+ * css/StyleBuilderCustom.h:
+ (WebCore::StyleBuilderCustom::applyValueFontSynthesis): Construct an internal
+ representation of font-synthesis for a given CSSValue.
+ * rendering/style/RenderStyle.h: Function signature.
+ * rendering/style/RenderStyleConstants.h: Internal representation of
+ font-synthesis.
+ * rendering/style/StyleRareInheritedData.h: Where we actually store the bits
+ related to this internal representation.
+
2015-04-24 Simon Fraser <[email protected]>
Have the web inspector report accurate memory use for layers with detached backing store
Modified: trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp (183303 => 183304)
--- trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/css/CSSComputedStyleDeclaration.cpp 2015-04-25 03:29:23 UTC (rev 183304)
@@ -1611,6 +1611,19 @@
return cssValuePool().createIdentifierValue(CSSValueNormal);
}
+static Ref<CSSValue> fontSynthesisFromStyle(RenderStyle& style)
+{
+ if (style.fontSynthesis() == FontSynthesisNone)
+ return cssValuePool().createIdentifierValue(CSSValueNone);
+
+ auto list = CSSValueList::createSpaceSeparated();
+ if (style.fontSynthesis() & FontSynthesisStyle)
+ list.get().append(cssValuePool().createIdentifierValue(CSSValueStyle));
+ if (style.fontSynthesis() & FontSynthesisWeight)
+ list.get().append(cssValuePool().createIdentifierValue(CSSValueWeight));
+ return Ref<CSSValue>(list.get());
+}
+
typedef const Length& (RenderStyle::*RenderStyleLengthGetter)() const;
typedef LayoutUnit (RenderBoxModelObject::*RenderBoxComputedCSSValueGetter)() const;
@@ -2234,6 +2247,8 @@
return fontVariantFromStyle(style.get());
case CSSPropertyFontWeight:
return fontWeightFromStyle(style.get());
+ case CSSPropertyFontSynthesis:
+ return fontSynthesisFromStyle(*style.get());
case CSSPropertyWebkitFontFeatureSettings: {
const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
if (!featureSettings || !featureSettings->size())
Modified: trunk/Source/WebCore/css/CSSParser.cpp (183303 => 183304)
--- trunk/Source/WebCore/css/CSSParser.cpp 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2015-04-25 03:29:23 UTC (rev 183304)
@@ -1982,6 +1982,10 @@
return false;
return parseFontWeight(important);
}
+
+ case CSSPropertyFontSynthesis: // none | [ weight || style ]
+ return parseFontSynthesis(important);
+
case CSSPropertyBorderSpacing: {
if (num == 1) {
ShorthandScope scope(this, CSSPropertyBorderSpacing);
@@ -6769,6 +6773,41 @@
return false;
}
+bool CSSParser::parseFontSynthesis(bool important)
+{
+ // none | [ weight || style ]
+ CSSParserValue* value = m_valueList->current();
+ if (value && value->id == CSSValueNone) {
+ addProperty(CSSPropertyFontSynthesis, cssValuePool().createIdentifierValue(CSSValueNone), important);
+ m_valueList->next();
+ return true;
+ }
+
+ bool encounteredWeight = false;
+ bool encounteredStyle = false;
+ while (value) {
+ switch (value->id) {
+ case CSSValueWeight:
+ encounteredWeight = true;
+ break;
+ case CSSValueStyle:
+ encounteredStyle = true;
+ break;
+ default:
+ return false;
+ }
+ value = m_valueList->next();
+ }
+
+ RefPtr<CSSValueList> list = CSSValueList::createSpaceSeparated();
+ if (encounteredWeight)
+ list->append(cssValuePool().createIdentifierValue(CSSValueWeight));
+ if (encounteredStyle)
+ list->append(cssValuePool().createIdentifierValue(CSSValueStyle));
+ addProperty(CSSPropertyFontSynthesis, list.release(), important);
+ return true;
+}
+
bool CSSParser::parseFontFaceSrcURI(CSSValueList& valueList)
{
RefPtr<CSSFontFaceSrcValue> uriValue(CSSFontFaceSrcValue::create(completeURL(m_valueList->current()->string)));
Modified: trunk/Source/WebCore/css/CSSParser.h (183303 => 183304)
--- trunk/Source/WebCore/css/CSSParser.h 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/css/CSSParser.h 2015-04-25 03:29:23 UTC (rev 183304)
@@ -263,6 +263,7 @@
bool parseFontSize(bool important);
bool parseFontVariant(bool important);
bool parseFontWeight(bool important);
+ bool parseFontSynthesis(bool important);
bool parseFontFaceSrc();
bool parseFontFaceUnicodeRange();
Modified: trunk/Source/WebCore/css/CSSPropertyNames.in (183303 => 183304)
--- trunk/Source/WebCore/css/CSSPropertyNames.in 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/css/CSSPropertyNames.in 2015-04-25 03:29:23 UTC (rev 183304)
@@ -223,6 +223,7 @@
flood-opacity [SVG, Converter=Opacity]
font [Inherited, Longhands=font-family|font-size|font-style|font-variant|font-weight|line-height]
font-stretch [SkipBuilder]
+font-synthesis [Inherited, Custom=Value]
glyph-orientation-horizontal [Inherited, SVG, Converter=GlyphOrientation]
glyph-orientation-vertical [Inherited, SVG, Converter=GlyphOrientationOrAuto]
height [Initial=initialSize, Converter=LengthSizing]
Modified: trunk/Source/WebCore/css/CSSValueKeywords.in (183303 => 183304)
--- trunk/Source/WebCore/css/CSSValueKeywords.in 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/css/CSSValueKeywords.in 2015-04-25 03:29:23 UTC (rev 183304)
@@ -1111,3 +1111,7 @@
// -apple-trailing-word
-webkit-partially-balanced
#endif
+
+// font-synthesis
+weight
+style
\ No newline at end of file
Modified: trunk/Source/WebCore/css/StyleBuilderCustom.h (183303 => 183304)
--- trunk/Source/WebCore/css/StyleBuilderCustom.h 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/css/StyleBuilderCustom.h 2015-04-25 03:29:23 UTC (rev 183304)
@@ -76,6 +76,7 @@
DECLARE_PROPERTY_CUSTOM_HANDLERS(FontFamily);
DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSize);
DECLARE_PROPERTY_CUSTOM_HANDLERS(FontWeight);
+ DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSynthesis);
#if ENABLE(CSS_IMAGE_RESOLUTION)
DECLARE_PROPERTY_CUSTOM_HANDLERS(ImageResolution);
#endif
@@ -1375,6 +1376,32 @@
styleResolver.setFontDescription(fontDescription);
}
+inline void StyleBuilderCustom::applyValueFontSynthesis(StyleResolver& styleResolver, CSSValue& value)
+{
+ if (is<CSSPrimitiveValue>(value)) {
+ ASSERT(downcast<CSSPrimitiveValue>(value).getValueID() == CSSValueNone);
+ styleResolver.style()->setFontSynthesis(FontSynthesisNone);
+ }
+
+ FontSynthesis result = FontSynthesisNone;
+ ASSERT(is<CSSValueList>(value));
+ for (CSSValue& i : downcast<CSSValueList>(value)) {
+ switch (downcast<CSSPrimitiveValue>(i).getValueID()) {
+ case CSSValueWeight:
+ result |= FontSynthesisWeight;
+ break;
+ case CSSValueStyle:
+ result |= FontSynthesisStyle;
+ break;
+ default:
+ ASSERT_NOT_REACHED();
+ break;
+ }
+ }
+
+ styleResolver.style()->setFontSynthesis(result);
+}
+
inline void StyleBuilderCustom::applyInitialColumnGap(StyleResolver& styleResolver)
{
styleResolver.style()->setHasNormalColumnGap();
Modified: trunk/Source/WebCore/rendering/style/RenderStyle.h (183303 => 183304)
--- trunk/Source/WebCore/rendering/style/RenderStyle.h 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/rendering/style/RenderStyle.h 2015-04-25 03:29:23 UTC (rev 183304)
@@ -1024,6 +1024,8 @@
TextOrientation textOrientation() const { return static_cast<TextOrientation>(rareInheritedData->m_textOrientation); }
+ FontSynthesis fontSynthesis() const { return static_cast<FontSynthesis>(rareInheritedData->fontSynthesis); }
+
ObjectFit objectFit() const { return static_cast<ObjectFit>(rareNonInheritedData->m_objectFit); }
// Return true if any transform related property (currently transform, transformStyle3D or perspective)
@@ -1533,6 +1535,7 @@
void setMarginAfterCollapse(EMarginCollapse c) { SET_VAR(rareNonInheritedData, marginAfterCollapse, c); }
void setWordBreak(EWordBreak b) { SET_VAR(rareInheritedData, wordBreak, b); }
void setOverflowWrap(EOverflowWrap b) { SET_VAR(rareInheritedData, overflowWrap, b); }
+ void setFontSynthesis(FontSynthesis synthesis) { SET_VAR(rareInheritedData, fontSynthesis, synthesis); }
void setNBSPMode(ENBSPMode b) { SET_VAR(rareInheritedData, nbspMode, b); }
void setLineBreak(LineBreak b) { SET_VAR(rareInheritedData, lineBreak, b); }
void setHyphens(Hyphens h) { SET_VAR(rareInheritedData, hyphens, h); }
@@ -2061,6 +2064,7 @@
static BlendMode initialBlendMode() { return BlendModeNormal; }
static Isolation initialIsolation() { return IsolationAuto; }
#endif
+ static FontSynthesis initialFontSynthesis() { return FontSynthesisNone; }
static ptrdiff_t noninheritedFlagsMemoryOffset() { return OBJECT_OFFSETOF(RenderStyle, noninherited_flags); }
Modified: trunk/Source/WebCore/rendering/style/RenderStyleConstants.h (183303 => 183304)
--- trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/rendering/style/RenderStyleConstants.h 2015-04-25 03:29:23 UTC (rev 183304)
@@ -416,6 +416,13 @@
CAPITALIZE, UPPERCASE, LOWERCASE, TTNONE
};
+enum FontSynthesisValues {
+ FontSynthesisNone = 0x0,
+ FontSynthesisWeight = 0x1,
+ FontSynthesisStyle = 0x2
+};
+typedef unsigned FontSynthesis;
+
#if ENABLE(LETTERPRESS)
static const size_t TextDecorationBits = 5;
#else
Modified: trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h (183303 => 183304)
--- trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2015-04-25 01:31:05 UTC (rev 183303)
+++ trunk/Source/WebCore/rendering/style/StyleRareInheritedData.h 2015-04-25 03:29:23 UTC (rev 183304)
@@ -133,6 +133,8 @@
unsigned trailingWord : 1;
#endif
+ unsigned fontSynthesis : 2;
+
AtomicString hyphenationString;
short hyphenationLimitBefore;
short hyphenationLimitAfter;