Remove 'font' shorthand property special casing
authorcdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Jan 2015 02:11:14 +0000 (02:11 +0000)
committercdumez@apple.com <cdumez@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 26 Jan 2015 02:11:14 +0000 (02:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=140577

Reviewed by Darin Adler.

Source/WebCore:

Expand system font values during 'font' property parsing. The 'font'
CSS property was the only shorthand that wasn't always expanded in
the CSS parser, so it needed a lot of special handling that we can
now get rid of.

This patch is inspired from the following Blink revision:
https://src.chromium.org/viewvc/blink?view=rev&revision=184449

Tests:
- fast/css/css2-system-fonts.html (existing)
- fast/css/CSSPrimitiveValue-font-family-primitiveType.html (new)
- fast/css/font-systemFontID-parsing.html (new)
- fast/css/font-shorthand-line-height.html (rebased)

* WebCore.xcodeproj/project.pbxproj:
* css/CSSCalculationValue.cpp:
(WebCore::hasDoubleValue):
Handle CSS_FONT_FAMILY similarly to CSS_STRING in the switch.

* css/CSSFontFamily.h: Added.
Introduce new CSSFontFamily class to store font families inside
CSSPrimitive, instead of using a simple String as previously. We need
an additional 'fromSystemFontID' flag in addition to the font family
name now that system font ID are expanded during parsing. This
information is needed later on by the StyleBuilder (see comment below).

* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
Update code dealing with font family CSSPrimitiveValues now that they
hold a CSSFontFamily internally instead of a String.

* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue):
(WebCore::CSSParser::parseSystemFont):
Expand system font values for the 'font' property by asking the
RenderTheme for the system font and using it to set the 'font'
longhand properties.

* css/CSSParserValues.cpp:
(WebCore::CSSParserValue::createCSSValue):
Handle CSS_FONT_FAMILY value in the switch.

* css/CSSPrimitiveValue.cpp:
(WebCore::CSSPrimitiveValue::primitiveType):
Make sure we still expose font family CSSPrimitiveValues to the Web as
CSS_STRING, even though we are using a slightly different representation
internally. This is so that we don't change web-exposed behavior and I
added a new layout test to cover this.

(WebCore::isValidCSSUnitTypeForDoubleConversion):
(WebCore::CSSPrimitiveValue::cleanup):
(WebCore::CSSPrimitiveValue::getStringValue):
(WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText):
(WebCore::CSSPrimitiveValue::cloneForCSSOM):
(WebCore::CSSPrimitiveValue::equals):
Handle CSS_FONT_FAMILY type in switches.

* css/CSSPrimitiveValue.h:
(WebCore::CSSPrimitiveValue::isFontFamily):
Add method to test if a CSSPrimitiveValue holds a CSSFontFamily
internally.

(WebCore::CSSPrimitiveValue::fontFamily):
Add a getter to retrieve the internal CSSFontFamily object if the
primitive type is CSS_FONT_FAMILY.

* css/CSSPropertyNames.in:
Treat 'font' as a regular shorthand property. Specify its longhand
properties so that makeprop.pl can generate the shorthand code for
us. Also demote 'font' to being a low-priority property as it is
now always expanded during parsing.

* css/CSSValuePool.cpp:
(WebCore::CSSValuePool::createFontFamilyValue):
* css/CSSValuePool.h:
* css/StyleBuilderCustom.h:
(WebCore::StyleBuilderCustom::applyValueFontFamily):
- Update the 'font-family' value setter in the StyleBuilder to reflect
the changes in the CSS parser. The CSSPrimitiveValues in the list now
have CSS_FONT_FAMILY type instead of CSS_STRING.
- We also set the 'isGenericFamily' flag if the font-family was expanded
  from a system font ID (e.g. caption). The 'isGenericFamily' flag is
  used later on to property set the 'isSpecifiedFont' flag on the
  FontDescription object. If we don't do this, system font values will
  be treated as specified fonts, which means that we will no longer use
  the 'use backslash as Yen sign' hack for those. This is covered by the
  following layout tests:
  - fast/text/backslash-to-yen-sign-euc.html
  - editing/selection/find-yensign-and-backslash.html

(WebCore::StyleBuilderCustom::applyInitialFont): Deleted.
(WebCore::StyleBuilderCustom::applyInheritFont): Deleted.
(WebCore::StyleBuilderCustom::applyValueFont): Deleted.
Remove StyleBuilder code dealing with the 'font' property. Now that
the 'font' property is always expanded during parsing, this code can
never be reached.

* css/StylePropertyShorthand.cpp:
(WebCore::isExpandedShorthand):
Stop returning false for 'font' as it is now expanded during parsing
as well. We should probably consider renaming this method to something
else now that all shorthands are expanded, maybe isCSSShorthand() or
isShorthandProperty().

(WebCore::fontShorthand): Deleted.
* css/StylePropertyShorthand.h:
(WebCore::matchingCustomShorthandsForLonghand): Deleted.
Remove custom shorthand code for the 'font' property as it is now
generated by makeprop.pl, like other shorthands.

* css/StyleResolver.cpp:
(WebCore::StyleResolver::applyFont): Deleted.
This is unused now that the StyleBuilder code for 'font' has been
removed.

* css/makeprop.pl:
Remove custom shorthand code for 'font' as it no longer requires any
special handling.

LayoutTests:

* fast/css/CSSPrimitiveValue-font-family-primitiveType-expected.txt: Added.
* fast/css/CSSPrimitiveValue-font-family-primitiveType.html: Added.
Add layout test to make sure that the font-family is still exposed to the
Web as a CSSValueList of CSSPrimitiveValues whose primitiveType is
CSS_STRING. This is useful because we now use a slightly different
representation internally.

* fast/css/font-shorthand-line-height-expected.txt:
* fast/css/font-shorthand-line-height.html:
Rebaseline the test. This is a progression. Setting the 'font' property
to a system font ID is supposed to reset the line-height property to
'normal'. It previously did not because system font IDs were not
expanded at parsing time. The new behavior is consistent with Chrome and
Firefox as well.

* fast/css/font-systemFontID-parsing-expected.txt: Added.
* fast/css/font-systemFontID-parsing.html: Added.
Add a layout test to make sure that the CSS parser is rejecting a 'font'
property with more than one system font id.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179100 268f45cc-cd09-0410-ab3c-d52691b4dbfc

27 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/css/CSSPrimitiveValue-font-family-primitiveType-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/CSSPrimitiveValue-font-family-primitiveType.html [new file with mode: 0644]
LayoutTests/fast/css/font-shorthand-line-height-expected.txt
LayoutTests/fast/css/font-shorthand-line-height.html
LayoutTests/fast/css/font-systemFontID-parsing-expected.txt [new file with mode: 0644]
LayoutTests/fast/css/font-systemFontID-parsing.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSCalculationValue.cpp
Source/WebCore/css/CSSFontFamily.h [new file with mode: 0644]
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSParserValues.cpp
Source/WebCore/css/CSSPrimitiveValue.cpp
Source/WebCore/css/CSSPrimitiveValue.h
Source/WebCore/css/CSSPrimitiveValueMappings.h
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSValuePool.cpp
Source/WebCore/css/CSSValuePool.h
Source/WebCore/css/StyleBuilderCustom.h
Source/WebCore/css/StylePropertyShorthand.cpp
Source/WebCore/css/StylePropertyShorthand.h
Source/WebCore/css/StyleResolver.cpp
Source/WebCore/css/StyleResolver.h
Source/WebCore/css/makeprop.pl

index 7e2f63f..39d3fcf 100644 (file)
@@ -1,3 +1,30 @@
+2015-01-25  Chris Dumez  <cdumez@apple.com>
+
+        Remove 'font' shorthand property special casing
+        https://bugs.webkit.org/show_bug.cgi?id=140577
+
+        Reviewed by Darin Adler.
+
+        * fast/css/CSSPrimitiveValue-font-family-primitiveType-expected.txt: Added.
+        * fast/css/CSSPrimitiveValue-font-family-primitiveType.html: Added.
+        Add layout test to make sure that the font-family is still exposed to the
+        Web as a CSSValueList of CSSPrimitiveValues whose primitiveType is
+        CSS_STRING. This is useful because we now use a slightly different
+        representation internally.
+
+        * fast/css/font-shorthand-line-height-expected.txt:
+        * fast/css/font-shorthand-line-height.html:
+        Rebaseline the test. This is a progression. Setting the 'font' property
+        to a system font ID is supposed to reset the line-height property to
+        'normal'. It previously did not because system font IDs were not
+        expanded at parsing time. The new behavior is consistent with Chrome and
+        Firefox as well.
+
+        * fast/css/font-systemFontID-parsing-expected.txt: Added.
+        * fast/css/font-systemFontID-parsing.html: Added.
+        Add a layout test to make sure that the CSS parser is rejecting a 'font'
+        property with more than one system font id.
+
 2015-01-25  Brent Fulgham  <bfulgham@apple.com>
 
         [Win] Unreviewed gardening.
diff --git a/LayoutTests/fast/css/CSSPrimitiveValue-font-family-primitiveType-expected.txt b/LayoutTests/fast/css/CSSPrimitiveValue-font-family-primitiveType-expected.txt
new file mode 100644 (file)
index 0000000..6594b91
--- /dev/null
@@ -0,0 +1,20 @@
+Test that the font-family CSSValue is a CSSValueList of CSSPrimitiveValues that are of primitive type CSS_STRING.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS fontFamilyCSSValue.__proto__ is CSSValueList.prototype
+PASS fontFamilyCSSValue.length is 3
+PASS fontFamilyCSSValue[0].__proto__ is CSSPrimitiveValue.prototype
+PASS fontFamilyCSSValue[0].primitiveType is CSSPrimitiveValue.CSS_STRING
+PASS fontFamilyCSSValue[0].getStringValue() is "times"
+PASS fontFamilyCSSValue[1].__proto__ is CSSPrimitiveValue.prototype
+PASS fontFamilyCSSValue[1].primitiveType is CSSPrimitiveValue.CSS_STRING
+PASS fontFamilyCSSValue[1].getStringValue() is "courier"
+PASS fontFamilyCSSValue[2].__proto__ is CSSPrimitiveValue.prototype
+PASS fontFamilyCSSValue[2].primitiveType is CSSPrimitiveValue.CSS_STRING
+PASS fontFamilyCSSValue[2].getStringValue() is "arial"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/CSSPrimitiveValue-font-family-primitiveType.html b/LayoutTests/fast/css/CSSPrimitiveValue-font-family-primitiveType.html
new file mode 100644 (file)
index 0000000..01e9c78
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<div id="testDiv" style="font-family: times, courier, arial">
+<script>
+description("Test that the font-family CSSValue is a CSSValueList of CSSPrimitiveValues that are of primitive type CSS_STRING.");
+
+var testDiv = document.getElementById("testDiv");
+var fontFamilyCSSValue = testDiv.style.getPropertyCSSValue('font-family');
+
+shouldBe("fontFamilyCSSValue.__proto__", "CSSValueList.prototype");
+shouldBe("fontFamilyCSSValue.length", "3");
+
+shouldBe("fontFamilyCSSValue[0].__proto__", "CSSPrimitiveValue.prototype");
+shouldBe("fontFamilyCSSValue[0].primitiveType", "CSSPrimitiveValue.CSS_STRING");
+shouldBeEqualToString("fontFamilyCSSValue[0].getStringValue()", "times");
+
+shouldBe("fontFamilyCSSValue[1].__proto__", "CSSPrimitiveValue.prototype");
+shouldBe("fontFamilyCSSValue[1].primitiveType", "CSSPrimitiveValue.CSS_STRING");
+shouldBeEqualToString("fontFamilyCSSValue[1].getStringValue()", "courier");
+
+shouldBe("fontFamilyCSSValue[2].__proto__", "CSSPrimitiveValue.prototype");
+shouldBe("fontFamilyCSSValue[2].primitiveType", "CSSPrimitiveValue.CSS_STRING");
+shouldBeEqualToString("fontFamilyCSSValue[2].getStringValue()", "arial");
+
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index e9c778f..434ca9f 100644 (file)
@@ -4,7 +4,7 @@ On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE
 
 
 PASS lineHeight(system_font_1) is '100px'
-PASS lineHeight(system_font_2) is '100px'
+PASS lineHeight(system_font_2) is 'normal'
 PASS lineHeight(shorthand_normal_1) is '100px'
 PASS lineHeight(shorthand_normal_2) is 'normal'
 PASS lineHeight(shorthand_line_height_1) is '100px'
index 05e4737..0e41609 100644 (file)
@@ -24,7 +24,7 @@
     }
 
     shouldBe("lineHeight(system_font_1)", "'100px'");
-    shouldBe("lineHeight(system_font_2)", "'100px'");
+    shouldBe("lineHeight(system_font_2)", "'normal'");
     shouldBe("lineHeight(shorthand_normal_1)", "'100px'");
     shouldBe("lineHeight(shorthand_normal_2)", "'normal'");
     shouldBe("lineHeight(shorthand_line_height_1)", "'100px'");
diff --git a/LayoutTests/fast/css/font-systemFontID-parsing-expected.txt b/LayoutTests/fast/css/font-systemFontID-parsing-expected.txt
new file mode 100644 (file)
index 0000000..acb6b21
--- /dev/null
@@ -0,0 +1,11 @@
+Tests 'font' CSS property parsing with system font values.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS testDivInvalid.style.getPropertyCSSValue('font-family') is null
+PASS testDivValid.style.getPropertyCSSValue('font-family') is not null
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/fast/css/font-systemFontID-parsing.html b/LayoutTests/fast/css/font-systemFontID-parsing.html
new file mode 100644 (file)
index 0000000..b681488
--- /dev/null
@@ -0,0 +1,15 @@
+<!DOCTYPE html>
+<html>
+<body>
+<script src="../../resources/js-test-pre.js"></script>
+<div id="testDivInvalid" style="font: caption icon"></div>
+<div id="testDivValid" style="font: caption"></div>
+<script>
+description("Tests 'font' CSS property parsing with system font values.");
+
+shouldBeNull("testDivInvalid.style.getPropertyCSSValue('font-family')");
+shouldNotBe("testDivValid.style.getPropertyCSSValue('font-family')", "null");
+</script>
+<script src="../../resources/js-test-post.js"></script>
+</body>
+</html>
index d2b34da..fc1f28f 100644 (file)
@@ -1,3 +1,129 @@
+2015-01-25  Chris Dumez  <cdumez@apple.com>
+
+        Remove 'font' shorthand property special casing
+        https://bugs.webkit.org/show_bug.cgi?id=140577
+
+        Reviewed by Darin Adler.
+
+        Expand system font values during 'font' property parsing. The 'font'
+        CSS property was the only shorthand that wasn't always expanded in
+        the CSS parser, so it needed a lot of special handling that we can
+        now get rid of.
+
+        This patch is inspired from the following Blink revision:
+        https://src.chromium.org/viewvc/blink?view=rev&revision=184449
+
+        Tests:
+        - fast/css/css2-system-fonts.html (existing)
+        - fast/css/CSSPrimitiveValue-font-family-primitiveType.html (new)
+        - fast/css/font-systemFontID-parsing.html (new)
+        - fast/css/font-shorthand-line-height.html (rebased)
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSCalculationValue.cpp:
+        (WebCore::hasDoubleValue):
+        Handle CSS_FONT_FAMILY similarly to CSS_STRING in the switch.
+
+        * css/CSSFontFamily.h: Added.
+        Introduce new CSSFontFamily class to store font families inside
+        CSSPrimitive, instead of using a simple String as previously. We need
+        an additional 'fromSystemFontID' flag in addition to the font family
+        name now that system font ID are expanded during parsing. This
+        information is needed later on by the StyleBuilder (see comment below).
+
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule):
+        Update code dealing with font family CSSPrimitiveValues now that they
+        hold a CSSFontFamily internally instead of a String.
+
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue):
+        (WebCore::CSSParser::parseSystemFont):
+        Expand system font values for the 'font' property by asking the
+        RenderTheme for the system font and using it to set the 'font'
+        longhand properties.
+
+        * css/CSSParserValues.cpp:
+        (WebCore::CSSParserValue::createCSSValue):
+        Handle CSS_FONT_FAMILY value in the switch.
+
+        * css/CSSPrimitiveValue.cpp:
+        (WebCore::CSSPrimitiveValue::primitiveType):
+        Make sure we still expose font family CSSPrimitiveValues to the Web as
+        CSS_STRING, even though we are using a slightly different representation
+        internally. This is so that we don't change web-exposed behavior and I
+        added a new layout test to cover this.
+
+        (WebCore::isValidCSSUnitTypeForDoubleConversion):
+        (WebCore::CSSPrimitiveValue::cleanup):
+        (WebCore::CSSPrimitiveValue::getStringValue):
+        (WebCore::CSSPrimitiveValue::formatNumberForCustomCSSText):
+        (WebCore::CSSPrimitiveValue::cloneForCSSOM):
+        (WebCore::CSSPrimitiveValue::equals):
+        Handle CSS_FONT_FAMILY type in switches.
+
+        * css/CSSPrimitiveValue.h:
+        (WebCore::CSSPrimitiveValue::isFontFamily):
+        Add method to test if a CSSPrimitiveValue holds a CSSFontFamily
+        internally.
+
+        (WebCore::CSSPrimitiveValue::fontFamily):
+        Add a getter to retrieve the internal CSSFontFamily object if the
+        primitive type is CSS_FONT_FAMILY.
+
+        * css/CSSPropertyNames.in:
+        Treat 'font' as a regular shorthand property. Specify its longhand
+        properties so that makeprop.pl can generate the shorthand code for
+        us. Also demote 'font' to being a low-priority property as it is
+        now always expanded during parsing.
+
+        * css/CSSValuePool.cpp:
+        (WebCore::CSSValuePool::createFontFamilyValue):
+        * css/CSSValuePool.h:
+        * css/StyleBuilderCustom.h:
+        (WebCore::StyleBuilderCustom::applyValueFontFamily):
+        - Update the 'font-family' value setter in the StyleBuilder to reflect
+        the changes in the CSS parser. The CSSPrimitiveValues in the list now
+        have CSS_FONT_FAMILY type instead of CSS_STRING.
+        - We also set the 'isGenericFamily' flag if the font-family was expanded
+          from a system font ID (e.g. caption). The 'isGenericFamily' flag is
+          used later on to property set the 'isSpecifiedFont' flag on the
+          FontDescription object. If we don't do this, system font values will
+          be treated as specified fonts, which means that we will no longer use
+          the 'use backslash as Yen sign' hack for those. This is covered by the
+          following layout tests:
+          - fast/text/backslash-to-yen-sign-euc.html
+          - editing/selection/find-yensign-and-backslash.html
+
+        (WebCore::StyleBuilderCustom::applyInitialFont): Deleted.
+        (WebCore::StyleBuilderCustom::applyInheritFont): Deleted.
+        (WebCore::StyleBuilderCustom::applyValueFont): Deleted.
+        Remove StyleBuilder code dealing with the 'font' property. Now that
+        the 'font' property is always expanded during parsing, this code can
+        never be reached.
+
+        * css/StylePropertyShorthand.cpp:
+        (WebCore::isExpandedShorthand):
+        Stop returning false for 'font' as it is now expanded during parsing
+        as well. We should probably consider renaming this method to something
+        else now that all shorthands are expanded, maybe isCSSShorthand() or
+        isShorthandProperty().
+
+        (WebCore::fontShorthand): Deleted.
+        * css/StylePropertyShorthand.h:
+        (WebCore::matchingCustomShorthandsForLonghand): Deleted.
+        Remove custom shorthand code for the 'font' property as it is now
+        generated by makeprop.pl, like other shorthands.
+
+        * css/StyleResolver.cpp:
+        (WebCore::StyleResolver::applyFont): Deleted.
+        This is unused now that the StyleBuilder code for 'font' has been
+        removed.
+
+        * css/makeprop.pl:
+        Remove custom shorthand code for 'font' as it no longer requires any
+        special handling.
+
 2015-01-25  Timothy Horton  <timothy_horton@apple.com>
 
         Long spins under Frame::rangeForPoint when doing Lookup on feedly.com
index d0d9e94..1978ca1 100644 (file)
                82E3D8DF122EA0D1003AE5BC /* CSSPropertySourceData.h in Headers */ = {isa = PBXBuildFile; fileRef = 82E3D8DD122EA0D1003AE5BC /* CSSPropertySourceData.h */; settings = {ATTRIBUTES = (Private, ); }; };
                832B843419D8E55100B26055 /* SVGAnimateElementBase.h in Headers */ = {isa = PBXBuildFile; fileRef = 832B843319D8E55100B26055 /* SVGAnimateElementBase.h */; };
                832B843619D8E57400B26055 /* SVGAnimateElementBase.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 832B843519D8E57400B26055 /* SVGAnimateElementBase.cpp */; };
+               83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */ = {isa = PBXBuildFile; fileRef = 83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */; };
                835D363719FF6193004C93AB /* StyleBuilderCustom.h in Headers */ = {isa = PBXBuildFile; fileRef = 835D363619FF6193004C93AB /* StyleBuilderCustom.h */; };
                836FBCEA178C113200B21A15 /* SVGAnimatedTypeAnimator.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 836FBCE9178C113200B21A15 /* SVGAnimatedTypeAnimator.cpp */; };
                836FBCEC178C117F00B21A15 /* SVGAnimatedProperty.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 836FBCEB178C117F00B21A15 /* SVGAnimatedProperty.cpp */; };
                82E3D8DD122EA0D1003AE5BC /* CSSPropertySourceData.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSPropertySourceData.h; sourceTree = "<group>"; };
                832B843319D8E55100B26055 /* SVGAnimateElementBase.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SVGAnimateElementBase.h; sourceTree = "<group>"; };
                832B843519D8E57400B26055 /* SVGAnimateElementBase.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimateElementBase.cpp; sourceTree = "<group>"; };
+               83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontFamily.h; sourceTree = "<group>"; };
                835D363619FF6193004C93AB /* StyleBuilderCustom.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StyleBuilderCustom.h; sourceTree = "<group>"; };
                836FBCE9178C113200B21A15 /* SVGAnimatedTypeAnimator.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedTypeAnimator.cpp; sourceTree = "<group>"; };
                836FBCEB178C117F00B21A15 /* SVGAnimatedProperty.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SVGAnimatedProperty.cpp; sourceTree = "<group>"; };
                F523D18402DE42E8018635CA /* css */ = {
                        isa = PBXGroup;
                        children = (
+                               83520C7D1A71BFCC006BD2AA /* CSSFontFamily.h */,
                                FBD6AF8415EF21D4008B7110 /* BasicShapeFunctions.cpp */,
                                FBD6AF8515EF21D4008B7110 /* BasicShapeFunctions.h */,
                                A80E6CDA0A1989CA007FB8C5 /* Counter.h */,
                                F59C96001255B23F000623C0 /* BaseDateAndTimeInputType.h in Headers */,
                                F55B3DAE1251F12D003EF269 /* BaseTextInputType.h in Headers */,
                                FBD6AF8A15EF25DF008B7110 /* BasicShapeFunctions.h in Headers */,
+                               83520C7E1A71BFCC006BD2AA /* CSSFontFamily.h in Headers */,
                                FBD6AF8C15EF2604008B7110 /* BasicShapes.h in Headers */,
                                BC9462D8107A7B4C00857193 /* BeforeLoadEvent.h in Headers */,
                                AB23A32809BBA7D00067CC53 /* BeforeTextInsertedEvent.h in Headers */,
index 9aa98f9..c45a51a 100644 (file)
@@ -125,6 +125,7 @@ static bool hasDoubleValue(CSSPrimitiveValue::UnitTypes type)
         return true;
     case CSSPrimitiveValue::CSS_UNKNOWN:
     case CSSPrimitiveValue::CSS_STRING:
+    case CSSPrimitiveValue::CSS_FONT_FAMILY:
     case CSSPrimitiveValue::CSS_URI:
     case CSSPrimitiveValue::CSS_IDENT:
     case CSSPrimitiveValue::CSS_ATTR:
diff --git a/Source/WebCore/css/CSSFontFamily.h b/Source/WebCore/css/CSSFontFamily.h
new file mode 100644 (file)
index 0000000..85f0204
--- /dev/null
@@ -0,0 +1,57 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef CSSFontFamily_h
+#define CSSFontFamily_h
+
+#include <wtf/text/WTFString.h>
+
+namespace WebCore {
+
+// We use a CSSFontFamily instead of a String to store the font family inside CSSPrimitiveValue.
+// This is because require an extra bit to determine if the font family was resolved by the CSS
+// parser from a system font ID (caption | icon | menu | message-box | small-caption |
+// status-bar).
+//
+// This is needed by the StyleBuilder to correctly set the "isSpecifiedFont" flag on the
+// FontDescription. This flag is used to determine if we should do the "use backslash as Yen
+// sign" hack.
+
+enum FromSystemFontIDOrNot { NotFromSystemFontID, FromSystemFontID };
+
+struct CSSFontFamily {
+    String familyName;
+    FromSystemFontIDOrNot fromSystemFontID;
+};
+
+inline bool operator==(const CSSFontFamily& a, const CSSFontFamily& b)
+{
+    return a.familyName == b.familyName && a.fromSystemFontID == b.fromSystemFontID;
+}
+
+} // namespace WebCore
+
+#endif // CSSFontFamily_h
+
index 638c1c9..d956f65 100644 (file)
@@ -32,6 +32,7 @@
 #include "CSSFontFaceRule.h"
 #include "CSSFontFaceSource.h"
 #include "CSSFontFaceSrcValue.h"
+#include "CSSFontFamily.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSPropertyNames.h"
 #include "CSSSegmentedFontFace.h"
@@ -256,16 +257,15 @@ void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace* fontFaceRule)
     }
 
     // Hash under every single family name.
-    int familyLength = familyList.length();
-    for (int i = 0; i < familyLength; i++) {
-        CSSPrimitiveValue* item = downcast<CSSPrimitiveValue>(familyList.itemWithoutBoundsCheck(i));
+    for (auto& item : familyList) {
+        auto& value = downcast<CSSPrimitiveValue>(item.get());
         String familyName;
-        if (item->isString()) {
-            familyName = item->getStringValue();
-        } else if (item->isValueID()) {
+        if (value.isFontFamily()) {
+            familyName = value.fontFamily().familyName;
+        } else if (value.isValueID()) {
             // We need to use the raw text for all the generic family types, since @font-face is a way of actually
             // defining what font to use for those types.
-            switch (item->getValueID()) {
+            switch (value.getValueID()) {
                 case CSSValueSerif:
                     familyName = serifFamily;
                     break;
index 9693318..03e9f59 100644 (file)
@@ -1,12 +1,13 @@
 /*
  * Copyright (C) 2003 Lars Knoll (knoll@kde.org)
  * Copyright (C) 2005 Allan Sandfeld Jensen (kde@carewolf.com)
- * Copyright (C) 2004-2014 Apple Inc. All rights reserved.
+ * Copyright (C) 2004-2015 Apple Inc. All rights reserved.
  * Copyright (C) 2007 Nicholas Shanks <webkit@nickshanks.com>
  * Copyright (C) 2008 Eric Seidel <eric@webkit.org>
  * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/)
  * Copyright (C) 2012, 2013 Adobe Systems Incorporated. All rights reserved.
  * Copyright (C) 2012 Intel Corporation. All rights reserved.
+ * Copyright (C) 2014 Google Inc. All rights reserved.
  *
  * This library is free software; you can redistribute it and/or
  * modify it under the terms of the GNU Library General Public
@@ -49,6 +50,7 @@
 #include "CSSMediaRule.h"
 #include "CSSPageRule.h"
 #include "CSSPrimitiveValue.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSPropertySourceData.h"
 #include "CSSReflectValue.h"
 #include "CSSSelector.h"
@@ -2891,11 +2893,11 @@ bool CSSParser::parseValue(CSSPropertyID propId, bool important)
     case CSSPropertyFont:
         // [ [ 'font-style' || 'font-variant' || 'font-weight' ]? 'font-size' [ / 'line-height' ]?
         // 'font-family' ] | caption | icon | menu | message-box | small-caption | status-bar | inherit
-        if (id >= CSSValueCaption && id <= CSSValueStatusBar)
-            validPrimitive = true;
-        else
-            return parseFont(important);
-        break;
+        if (num == 1 && id >= CSSValueCaption && id <= CSSValueStatusBar) {
+            parseSystemFont(important);
+            return true;
+        }
+        return parseFont(important);
     case CSSPropertyListStyle:
         return parseShorthand(propId, listStyleShorthand(), important);
     case CSSPropertyColumns:
@@ -6269,6 +6271,29 @@ bool CSSParser::parseFont(bool important)
     return true;
 }
 
+void CSSParser::parseSystemFont(bool important)
+{
+    ASSERT(m_valueList->size() == 1);
+    CSSValueID systemFontID = m_valueList->valueAt(0)->id;
+    ASSERT(systemFontID >= CSSValueCaption && systemFontID <= CSSValueStatusBar);
+    m_valueList->next();
+
+    FontDescription fontDescription;
+    RenderTheme::defaultTheme()->systemFont(systemFontID, fontDescription);
+    if (!fontDescription.isAbsoluteSize())
+        return;
+
+    ShorthandScope scope(this, CSSPropertyFont);
+    addProperty(CSSPropertyFontStyle, cssValuePool().createIdentifierValue(fontDescription.italic() == FontItalicOn ? CSSValueItalic : CSSValueNormal), important);
+    addProperty(CSSPropertyFontWeight, cssValuePool().createValue(fontDescription.weight()), important);
+    addProperty(CSSPropertyFontSize, cssValuePool().createValue(fontDescription.specifiedSize(), CSSPrimitiveValue::CSS_PX), important);
+    Ref<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated();
+    fontFamilyList->append(cssValuePool().createFontFamilyValue(fontDescription.familyAt(0), FromSystemFontID));
+    addProperty(CSSPropertyFontFamily, WTF::move(fontFamilyList), important);
+    addProperty(CSSPropertyFontVariant, cssValuePool().createIdentifierValue(CSSValueNormal), important);
+    addProperty(CSSPropertyLineHeight, cssValuePool().createIdentifierValue(CSSValueNormal), important);
+}
+
 class FontFamilyValueBuilder {
 public:
     FontFamilyValueBuilder(CSSValueList& list)
index 47c6909..141bd3c 100644 (file)
@@ -215,6 +215,7 @@ public:
     PassRefPtr<CSSBasicShape> parseBasicShapeInset(CSSParserValueList&);
 
     bool parseFont(bool important);
+    void parseSystemFont(bool important);
     PassRefPtr<CSSValueList> parseFontFamily();
 
     bool parseCounter(CSSPropertyID, int defaultValue, bool important);
index 0392759..e12990a 100644 (file)
@@ -140,6 +140,7 @@ PassRefPtr<CSSValue> CSSParserValue::createCSSValue()
     case CSSPrimitiveValue::CSS_PARSER_IDENTIFIER:
     case CSSPrimitiveValue::CSS_COUNTER_NAME:
     case CSSPrimitiveValue::CSS_SHAPE:
+    case CSSPrimitiveValue::CSS_FONT_FAMILY:
     case CSSPrimitiveValue::CSS_QUAD:
 #if ENABLE(CSS_SCROLL_SNAP)
     case CSSPrimitiveValue::CSS_LENGTH_REPEAT:
index 57ebcfe..0b344ad 100644 (file)
 
 #include "CSSBasicShapes.h"
 #include "CSSCalculationValue.h"
+#include "CSSFontFamily.h"
 #include "CSSHelper.h"
 #include "CSSParser.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSPropertyNames.h"
 #include "CSSToLengthConversionData.h"
 #include "CSSValueKeywords.h"
@@ -123,6 +125,7 @@ static inline bool isValidCSSUnitTypeForDoubleConversion(CSSPrimitiveValue::Unit
     case CSSPrimitiveValue::CSS_RGBCOLOR:
     case CSSPrimitiveValue::CSS_SHAPE:
     case CSSPrimitiveValue::CSS_STRING:
+    case CSSPrimitiveValue::CSS_FONT_FAMILY:
     case CSSPrimitiveValue::CSS_UNICODE_RANGE:
     case CSSPrimitiveValue::CSS_UNKNOWN:
     case CSSPrimitiveValue::CSS_URI:
@@ -183,6 +186,11 @@ unsigned short CSSPrimitiveValue::primitiveType() const
     if (m_primitiveUnitType == CSS_PROPERTY_ID || m_primitiveUnitType == CSS_VALUE_ID)
         return CSS_IDENT;
 
+    // Web-exposed content expects font family values to have CSS_STRING primitive type
+    // so we need to map our internal CSS_FONT_FAMILY type here.
+    if (m_primitiveUnitType == CSS_FONT_FAMILY)
+        return CSS_STRING;
+
     if (m_primitiveUnitType != CSSPrimitiveValue::CSS_CALC)
         return m_primitiveUnitType;
 
@@ -485,6 +493,11 @@ void CSSPrimitiveValue::cleanup()
     case CSS_SHAPE:
         m_value.shape->deref();
         break;
+    case CSS_FONT_FAMILY:
+        ASSERT(m_value.fontFamily);
+        delete m_value.fontFamily;
+        m_value.fontFamily = nullptr;
+        break;
     case CSS_NUMBER:
     case CSS_PARSER_INTEGER:
     case CSS_PERCENTAGE:
@@ -844,6 +857,8 @@ String CSSPrimitiveValue::getStringValue(ExceptionCode& ec) const
     case CSS_ATTR:
     case CSS_URI:
         return m_value.string;
+    case CSS_FONT_FAMILY:
+        return m_value.fontFamily->familyName;
     case CSS_VALUE_ID:
         return valueName(m_value.valueID);
     case CSS_PROPERTY_ID:
@@ -863,6 +878,8 @@ String CSSPrimitiveValue::getStringValue() const
     case CSS_ATTR:
     case CSS_URI:
         return m_value.string;
+    case CSS_FONT_FAMILY:
+        return m_value.fontFamily->familyName;
     case CSS_VALUE_ID:
         return valueName(m_value.valueID);
     case CSS_PROPERTY_ID:
@@ -1026,6 +1043,8 @@ ALWAYS_INLINE String CSSPrimitiveValue::formatNumberForCustomCSSText() const
         // the actual dimension, just the numeric value as a string.
     case CSS_STRING:
         return quoteCSSStringIfNeeded(m_value.string);
+    case CSS_FONT_FAMILY:
+        return quoteCSSStringIfNeeded(m_value.fontFamily->familyName);
     case CSS_URI:
         return "url(" + quoteCSSURLIfNeeded(m_value.string) + ')';
     case CSS_VALUE_ID:
@@ -1203,6 +1222,9 @@ PassRefPtr<CSSPrimitiveValue> CSSPrimitiveValue::cloneForCSSOM() const
     case CSS_COUNTER_NAME:
         result = CSSPrimitiveValue::create(m_value.string, static_cast<UnitTypes>(m_primitiveUnitType));
         break;
+    case CSS_FONT_FAMILY:
+        result = CSSPrimitiveValue::create(*m_value.fontFamily);
+        break;
     case CSS_COUNTER:
         result = CSSPrimitiveValue::create(m_value.counter->cloneForCSSOM());
         break;
@@ -1365,6 +1387,8 @@ bool CSSPrimitiveValue::equals(const CSSPrimitiveValue& other) const
         return m_value.calc && other.m_value.calc && m_value.calc->equals(*other.m_value.calc);
     case CSS_SHAPE:
         return m_value.shape && other.m_value.shape && m_value.shape->equals(*other.m_value.shape);
+    case CSS_FONT_FAMILY:
+        return fontFamily() == other.fontFamily();
     }
     return false;
 }
index eeccb73..62e6ea0 100644 (file)
@@ -48,6 +48,7 @@ class CSSBasicShape;
 class LengthRepeat;
 #endif
 
+struct CSSFontFamily;
 struct Length;
 struct LengthSize;
 
@@ -149,6 +150,8 @@ public:
         CSS_CALC_PERCENTAGE_WITH_NUMBER = 114,
         CSS_CALC_PERCENTAGE_WITH_LENGTH = 115,
 
+        CSS_FONT_FAMILY = 116,
+
         CSS_PROPERTY_ID = 117,
         CSS_VALUE_ID = 118
     };
@@ -200,6 +203,7 @@ public:
     bool isRGBColor() const { return m_primitiveUnitType == CSS_RGBCOLOR; }
     bool isShape() const { return m_primitiveUnitType == CSS_SHAPE; }
     bool isString() const { return m_primitiveUnitType == CSS_STRING; }
+    bool isFontFamily() const { return m_primitiveUnitType == CSS_FONT_FAMILY; }
     bool isTime() const { return m_primitiveUnitType == CSS_S || m_primitiveUnitType == CSS_MS; }
     bool isURI() const { return m_primitiveUnitType == CSS_URI; }
     bool isCalculated() const { return m_primitiveUnitType == CSS_CALC; }
@@ -333,15 +337,17 @@ public:
     RGBA32 getRGBA32Value() const { return m_primitiveUnitType != CSS_RGBCOLOR ? 0 : m_value.rgbcolor; }
 
     Pair* getPairValue(ExceptionCode&) const;
-    Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? 0 : m_value.pair; }
+    Pair* getPairValue() const { return m_primitiveUnitType != CSS_PAIR ? nullptr : m_value.pair; }
 
 #if ENABLE(DASHBOARD_SUPPORT)
-    DashboardRegion* getDashboardRegionValue() const { return m_primitiveUnitType != CSS_DASHBOARD_REGION ? 0 : m_value.region; }
+    DashboardRegion* getDashboardRegionValue() const { return m_primitiveUnitType != CSS_DASHBOARD_REGION ? nullptr : m_value.region; }
 #endif
 
-    CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? 0 : m_value.shape; }
+    CSSBasicShape* getShapeValue() const { return m_primitiveUnitType != CSS_SHAPE ? nullptr : m_value.shape; }
+
+    const CSSFontFamily& fontFamily() const { ASSERT(m_primitiveUnitType == CSS_FONT_FAMILY); return *m_value.fontFamily; }
 
-    CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? 0 : m_value.calc; }
+    CSSCalcValue* cssCalcValue() const { return m_primitiveUnitType != CSS_CALC ? nullptr : m_value.calc; }
 
     CSSPropertyID getPropertyID() const { return m_primitiveUnitType == CSS_PROPERTY_ID ? m_value.propertyID : CSSPropertyInvalid; }
     CSSValueID getValueID() const { return m_primitiveUnitType == CSS_VALUE_ID ? m_value.valueID : CSSValueInvalid; }
@@ -435,6 +441,7 @@ private:
         DashboardRegion* region;
         CSSBasicShape* shape;
         CSSCalcValue* calc;
+        CSSFontFamily* fontFamily;
     } m_value;
 };
 
index 615d852..d723377 100644 (file)
@@ -31,6 +31,7 @@
 #define CSSPrimitiveValueMappings_h
 
 #include "CSSCalculationValue.h"
+#include "CSSFontFamily.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSReflectionDirection.h"
 #include "CSSToLengthConversionData.h"
@@ -4918,6 +4919,13 @@ template<> inline CSSPrimitiveValue::operator SVGWritingMode() const
     return WM_LRTB;
 }
 
+template<> inline CSSPrimitiveValue::CSSPrimitiveValue(CSSFontFamily fontFamily)
+    : CSSValue(PrimitiveClass)
+{
+    m_primitiveUnitType = CSS_FONT_FAMILY;
+    m_value.fontFamily = new CSSFontFamily(WTF::move(fontFamily));
+}
+
 template<> inline CSSPrimitiveValue::CSSPrimitiveValue(EVectorEffect e)
     : CSSValue(PrimitiveClass)
 {
index 22da9de..207ef74 100644 (file)
@@ -99,7 +99,6 @@
 color [Inherited, VisitedLinkColorSupport, NoDefaultColor]
 direction [Inherited, Custom=Value]
 display [Custom=Inherit|Value]
-font [Inherited, Custom=All]
 font-family [Inherited, Custom=All]
 font-size [Inherited, Custom=All]
 font-style [Inherited, FontProperty, NameForMethods=Italic]
@@ -229,6 +228,7 @@ filter [SVG, Converter=SVGURIReference, NameForMethods=FilterResource]
 float [NameForMethods=Floating]
 flood-color [SVG, Converter=SVGColor]
 flood-opacity [SVG, Converter=Opacity]
+font [Inherited, Longhands=font-family|font-size|font-style|font-variant|font-weight|line-height]
 font-stretch [SkipBuilder]
 glyph-orientation-horizontal [Inherited, SVG, Converter=GlyphOrientation]
 glyph-orientation-vertical [Inherited, SVG, Converter=GlyphOrientationOrAuto]
index 66593e0..4a3f2a2 100644 (file)
@@ -27,6 +27,7 @@
 #include "CSSValuePool.h"
 
 #include "CSSParser.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSStyleSheet.h"
 #include "CSSValueKeywords.h"
 #include "CSSValueList.h"
@@ -118,11 +119,11 @@ Ref<CSSPrimitiveValue> CSSValuePool::createValue(double value, CSSPrimitiveValue
     return *cache[intValue];
 }
 
-Ref<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName)
+Ref<CSSPrimitiveValue> CSSValuePool::createFontFamilyValue(const String& familyName, FromSystemFontIDOrNot fromSystemFontID)
 {
-    RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add(familyName, nullptr).iterator->value;
+    RefPtr<CSSPrimitiveValue>& value = m_fontFamilyValueCache.add({familyName, fromSystemFontID}, nullptr).iterator->value;
     if (!value)
-        value = CSSPrimitiveValue::create(familyName, CSSPrimitiveValue::CSS_STRING);
+        value = CSSPrimitiveValue::create(CSSFontFamily{familyName, fromSystemFontID});
     return *value;
 }
 
index 52680cb..860fb7b 100644 (file)
@@ -26,6 +26,7 @@
 #ifndef CSSValuePool_h
 #define CSSValuePool_h
 
+#include "CSSFontFamily.h"
 #include "CSSInheritedValue.h"
 #include "CSSInitialValue.h"
 #include "CSSPrimitiveValue.h"
@@ -44,7 +45,7 @@ class CSSValuePool {
     WTF_MAKE_FAST_ALLOCATED;
 public:
     PassRefPtr<CSSValueList> createFontFaceValue(const AtomicString&);
-    Ref<CSSPrimitiveValue> createFontFamilyValue(const String&);
+    Ref<CSSPrimitiveValue> createFontFamilyValue(const String&, FromSystemFontIDOrNot = NotFromSystemFontID);
     Ref<CSSInheritedValue> createInheritedValue() { return m_inheritedValue.copyRef(); }
     Ref<CSSInitialValue> createImplicitInitialValue() { return m_implicitInitialValue.copyRef(); }
     Ref<CSSInitialValue> createExplicitInitialValue() { return m_explicitInitialValue.copyRef(); }
@@ -83,7 +84,7 @@ private:
     typedef HashMap<AtomicString, RefPtr<CSSValueList>> FontFaceValueCache;
     FontFaceValueCache m_fontFaceValueCache;
 
-    typedef HashMap<String, RefPtr<CSSPrimitiveValue>> FontFamilyValueCache;
+    typedef HashMap<std::pair<String, bool>, RefPtr<CSSPrimitiveValue>> FontFamilyValueCache;
     FontFamilyValueCache m_fontFamilyValueCache;
 
     friend class WTF::NeverDestroyed<CSSValuePool>;
index 61fc661..6246f25 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "CSSAspectRatioValue.h"
 #include "CSSCursorImageValue.h"
+#include "CSSFontFamily.h"
 #include "CSSFontValue.h"
 #include "CSSGradientValue.h"
 #include "CSSShadowValue.h"
@@ -72,7 +73,6 @@ public:
     DECLARE_PROPERTY_CUSTOM_HANDLERS(CounterReset);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Cursor);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(Fill);
-    DECLARE_PROPERTY_CUSTOM_HANDLERS(Font);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontFamily);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontSize);
     DECLARE_PROPERTY_CUSTOM_HANDLERS(FontWeight);
@@ -858,9 +858,12 @@ inline void StyleBuilderCustom::applyValueFontFamily(StyleResolver& styleResolve
         auto& contentValue = downcast<CSSPrimitiveValue>(item.get());
         AtomicString family;
         bool isGenericFamily = false;
-        if (contentValue.isString())
-            family = contentValue.getStringValue();
-        else {
+        if (contentValue.isFontFamily()) {
+            const CSSFontFamily& fontFamily = contentValue.fontFamily();
+            family = fontFamily.familyName;
+            // If the family name was resolved by the CSS parser from a system font ID, then it is generic.
+            isGenericFamily = fontFamily.fromSystemFontID;
+        } else {
             switch (contentValue.getValueID()) {
             case CSSValueWebkitBody:
                 if (Settings* settings = styleResolver.document().settings())
@@ -1290,48 +1293,6 @@ inline void StyleBuilderCustom::applyValueColumnGap(StyleResolver& styleResolver
         styleResolver.style()->setColumnGap(StyleBuilderConverter::convertComputedLength<float>(styleResolver, value));
 }
 
-inline void StyleBuilderCustom::applyInitialFont(StyleResolver& styleResolver)
-{
-    Settings* settings = styleResolver.documentSettings();
-    ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings
-    styleResolver.initializeFontStyle(settings);
-}
-
-inline void StyleBuilderCustom::applyInheritFont(StyleResolver& styleResolver)
-{
-    FontDescription fontDescription = styleResolver.parentStyle()->fontDescription();
-    styleResolver.style()->setLineHeight(styleResolver.parentStyle()->specifiedLineHeight());
-    styleResolver.state().setLineHeightValue(0);
-    styleResolver.setFontDescription(fontDescription);
-}
-
-inline void StyleBuilderCustom::applyValueFont(StyleResolver& styleResolver, CSSValue& value)
-{
-    if (is<CSSPrimitiveValue>(value)) {
-        styleResolver.style()->setLineHeight(RenderStyle::initialLineHeight());
-        styleResolver.state().setLineHeightValue(0);
-
-        FontDescription fontDescription;
-        RenderTheme::defaultTheme()->systemFont(downcast<CSSPrimitiveValue>(value).getValueID(), fontDescription);
-
-        // Double-check and see if the theme did anything. If not, don't bother updating the font.
-        if (fontDescription.isAbsoluteSize()) {
-            // Make sure the rendering mode and printer font settings are updated.
-            Settings* settings = styleResolver.documentSettings();
-            ASSERT(settings); // If we're doing style resolution, this document should always be in a frame and thus have settings
-            fontDescription.setRenderingMode(settings->fontRenderingMode());
-            fontDescription.setUsePrinterFont(styleResolver.document().printing() || !settings->screenFontSubstitutionEnabled());
-
-            // Handle the zoom factor.
-            fontDescription.setComputedSize(Style::computedFontSizeFromSpecifiedSize(fontDescription.specifiedSize(), fontDescription.isAbsoluteSize(), styleResolver.useSVGZoomRules(), styleResolver.style(), styleResolver.document()));
-            styleResolver.setFontDescription(fontDescription);
-        }
-        return;
-    }
-    if (is<CSSFontValue>(value))
-        styleResolver.applyFont(downcast<CSSFontValue>(value));
-}
-
 inline void StyleBuilderCustom::applyInitialContent(StyleResolver& styleResolver)
 {
     styleResolver.style()->clearContent();
index 090da35..a7c2994 100644 (file)
@@ -33,19 +33,6 @@ StylePropertyShorthand borderAbridgedShorthand()
     return StylePropertyShorthand(CSSPropertyBorder, borderAbridgedProperties, propertiesForInitialization);
 }
 
-StylePropertyShorthand fontShorthand()
-{
-    static const CSSPropertyID fontProperties[] = {
-        CSSPropertyFontFamily,
-        CSSPropertyFontSize,
-        CSSPropertyFontStyle,
-        CSSPropertyFontVariant,
-        CSSPropertyFontWeight,
-        CSSPropertyLineHeight
-    };
-    return StylePropertyShorthand(CSSPropertyFont, fontProperties);
-}
-
 StylePropertyShorthand animationShorthandForParsing(CSSPropertyID propId)
 {
     // When we parse the animation shorthand we need to look for animation-name
@@ -84,13 +71,6 @@ StylePropertyShorthand animationShorthandForParsing(CSSPropertyID propId)
 
 bool isExpandedShorthand(CSSPropertyID id)
 {
-    // The system fonts bypass the normal style resolution by using RenderTheme,
-    // thus we need to special case it here. FIXME: This is a violation of CSS 3 Fonts
-    // as we should still be able to change the longhands.
-    // DON'T ADD ANY SHORTHAND HERE UNLESS IT ISN'T ALWAYS EXPANDED AT PARSE TIME (which is wrong).
-    if (id == CSSPropertyFont)
-        return false;
-
     return shorthandForProperty(id).length();
 }
 
index d513661..d0f5ac6 100644 (file)
@@ -62,7 +62,6 @@ private:
 // Custom StylePropertyShorthand functions.
 StylePropertyShorthand animationShorthandForParsing(CSSPropertyID);
 StylePropertyShorthand borderAbridgedShorthand();
-StylePropertyShorthand fontShorthand();
 
 // Returns empty value if the property is not a shorthand.
 // The implementation is generated in StylePropertyShorthandFunctions.cpp.
@@ -76,24 +75,6 @@ unsigned indexOfShorthandForLonghand(CSSPropertyID, const Vector<StylePropertySh
 
 bool isExpandedShorthand(CSSPropertyID);
 
-// FIXME: This should try to get rid of this function and generate the rest of these shorthands.
-inline Vector<StylePropertyShorthand> matchingCustomShorthandsForLonghand(CSSPropertyID propertyID)
-{
-    switch (propertyID) {
-    case CSSPropertyFontFamily:
-    case CSSPropertyFontSize:
-    case CSSPropertyFontStyle:
-    case CSSPropertyFontVariant:
-    case CSSPropertyFontWeight:
-    case CSSPropertyLineHeight:
-        return Vector<StylePropertyShorthand>{fontShorthand()};
-    default:
-        break;
-    }
-
-    return Vector<StylePropertyShorthand>();
-}
-
 } // namespace WebCore
 
 #endif // StylePropertyShorthand_h
index 2a84e17..8bc1109 100644 (file)
@@ -1837,25 +1837,6 @@ void StyleResolver::applyPropertyToCurrentStyle(CSSPropertyID id, CSSValue* valu
         applyProperty(id, value);
 }
 
-void StyleResolver::applyFont(CSSFontValue& font)
-{
-    if (!font.style || !font.variant || !font.weight || !font.size || !font.lineHeight || !font.family)
-        return;
-    applyProperty(CSSPropertyFontStyle, font.style.get());
-    applyProperty(CSSPropertyFontVariant, font.variant.get());
-    applyProperty(CSSPropertyFontWeight, font.weight.get());
-    // The previous properties can dirty our font but they don't try to read the font's
-    // properties back, which is safe. However if font-size is using the 'ex' unit, it will
-    // need query the dirtied font's x-height to get the computed size. To be safe in this
-    // case, let's just update the font now.
-    updateFont();
-    applyProperty(CSSPropertyFontSize, font.size.get());
-
-    m_state.setLineHeightValue(font.lineHeight.get());
-
-    applyProperty(CSSPropertyFontFamily, font.family.get());
-}
-
 inline bool isValidVisitedLinkProperty(CSSPropertyID id)
 {
     switch (id) {
index 7a116c4..7338532 100644 (file)
@@ -201,7 +201,6 @@ public:
 
     void applyPropertyToCurrentStyle(CSSPropertyID, CSSValue*);
 
-    void applyFont(CSSFontValue&);
     void updateFont();
     void initializeFontStyle(Settings*);
 
index 187d19b..078a1b3 100755 (executable)
@@ -977,11 +977,7 @@ foreach my $name (@names) {
   print SHORTHANDS_CPP "        return " . lcfirst($nameToId{$name}) . "Shorthand();\n";
 }
 
-# FIXME: CSSPropertyFont is currently an exception. It is hard-coded here
-# because it is not marked as a shorthand in CSSPropertyNames.in.
 print SHORTHANDS_CPP << "EOF";
-    case CSSPropertyFont:
-        return fontShorthand();
     default:
         return emptyShorthand;
     }
@@ -1021,7 +1017,7 @@ for my $vector (sort keys %vectorToLonghands) {
 
 print SHORTHANDS_CPP << "EOF";
     default:
-        return matchingCustomShorthandsForLonghand(propertyID);
+        return { };
     }
 }
 EOF