font-style needs a new CSSValue to make CSSRule.cssText work correctly
authormmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Mar 2017 18:23:48 +0000 (18:23 +0000)
committermmaxfield@apple.com <mmaxfield@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 24 Mar 2017 18:23:48 +0000 (18:23 +0000)
https://bugs.webkit.org/show_bug.cgi?id=169258

Reviewed by David Hyatt.

Source/WebCore:

With variation fonts, font-style's value can't be captured in a CSSPrimitiveValue (nor any other subclass
off CSSValue) any more. Instead, we need to create two new CSSValues which represent the grammar that font-
style and it's associated @font-face descriptor accept.

The grammar of the font-style property is "normal | italic | oblique [ <<angle>> ]?"
The grammar of the font-style descriptor is "normal | italic | oblique [ <<angle>> | <<angle>> <<angle>> ]?"

We currently still support numbers in place of the <<angle>> value (contrary to the spec). We will remove
this support in https://bugs.webkit.org/show_bug.cgi?id=169357.

Tests: fast/text/font-selection-font-face-parse.html:
       fast/text/font-style-parse.html:

* CMakeLists.txt:
* WebCore.xcodeproj/project.pbxproj:
* css/CSSAllInOne.cpp:
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::fontStyleFromStyle):
(WebCore::fontShorthandValueForSelectionProperties):
* css/CSSFontFace.cpp:
(WebCore::calculateWeightRange):
(WebCore::calculateStretchRange):
(WebCore::calculateItalicRange):
* css/CSSFontFaceSet.cpp:
(WebCore::computeFontSelectionRequest):
(WebCore::CSSFontFaceSet::matchingFaces):
(WebCore::calculateWeightValue): Deleted.
(WebCore::calculateStretchValue): Deleted.
(WebCore::calculateStyleValue): Deleted.
* css/CSSFontFaceSet.h:
* css/CSSFontSelector.cpp:
(WebCore::CSSFontSelector::addFontFaceRule):
* css/CSSFontStyleRangeValue.cpp: Added.
(WebCore::CSSFontStyleRangeValue::customCSSText):
(WebCore::CSSFontStyleRangeValue::equals):
* css/CSSFontStyleRangeValue.h: Added.
* css/CSSFontStyleValue.cpp: Added.
(WebCore::CSSFontStyleValue::customCSSText):
(WebCore::CSSFontStyleValue::equals):
* css/CSSFontStyleValue.h: Added.
* css/CSSFontValue.cpp:
(WebCore::CSSFontValue::customCSSText):
* css/CSSFontValue.h:
* css/CSSValue.cpp:
(WebCore::CSSValue::equals):
(WebCore::CSSValue::cssText):
(WebCore::CSSValue::destroy):
* css/CSSValue.h:
(WebCore::CSSValue::isFontStyleValue):
(WebCore::CSSValue::isFontStyleRangeValue):
* css/FontFace.cpp:
(WebCore::FontFace::style):
(WebCore::FontFace::weight):
(WebCore::FontFace::stretch):
* css/StyleBuilderConverter.h:
(WebCore::StyleBuilderConverter::convertFontWeightFromValue):
(WebCore::StyleBuilderConverter::convertFontStretchFromValue):
(WebCore::StyleBuilderConverter::convertFontStyleFromValue):
(WebCore::StyleBuilderConverter::convertFontWeight):
(WebCore::StyleBuilderConverter::convertFontStretch):
(WebCore::StyleBuilderConverter::convertFontStyle):
* css/parser/CSSPropertyParser.cpp:
(WebCore::consumeFontStyle):
(WebCore::consumeFontStyleRange):
(WebCore::CSSPropertyParser::consumeSystemFont):
(WebCore::CSSPropertyParser::consumeFont):
* svg/SVGFontFaceElement.cpp:
(WebCore::SVGFontFaceElement::parseAttribute):

LayoutTests:

Update tests' expected results.

* fast/text/font-selection-font-face-parse-expected.txt:
* fast/text/font-selection-font-face-parse.html:
* fast/text/font-style-parse-expected.txt:
* fast/text/font-style-parse.html:
* platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt:
* svg/css/getComputedStyle-basic-expected.txt:

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

29 files changed:
LayoutTests/ChangeLog
LayoutTests/fast/text/font-selection-font-face-parse-expected.txt
LayoutTests/fast/text/font-selection-font-face-parse.html
LayoutTests/fast/text/font-style-parse-expected.txt
LayoutTests/fast/text/font-style-parse.html
LayoutTests/platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt
LayoutTests/svg/css/getComputedStyle-basic-expected.txt
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSAllInOne.cpp
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSFontFace.cpp
Source/WebCore/css/CSSFontFaceSet.cpp
Source/WebCore/css/CSSFontFaceSet.h
Source/WebCore/css/CSSFontSelector.cpp
Source/WebCore/css/CSSFontStyleRangeValue.cpp [new file with mode: 0644]
Source/WebCore/css/CSSFontStyleRangeValue.h [new file with mode: 0644]
Source/WebCore/css/CSSFontStyleValue.cpp [new file with mode: 0644]
Source/WebCore/css/CSSFontStyleValue.h [new file with mode: 0644]
Source/WebCore/css/CSSFontValue.cpp
Source/WebCore/css/CSSFontValue.h
Source/WebCore/css/CSSValue.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/FontFace.cpp
Source/WebCore/css/StyleBuilderConverter.h
Source/WebCore/css/parser/CSSPropertyParser.cpp
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/svg/SVGFontFaceElement.cpp

index aef6a34..ec5c512 100644 (file)
@@ -1,3 +1,19 @@
+2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        font-style needs a new CSSValue to make CSSRule.cssText work correctly
+        https://bugs.webkit.org/show_bug.cgi?id=169258
+
+        Reviewed by David Hyatt.
+
+        Update tests' expected results.
+
+        * fast/text/font-selection-font-face-parse-expected.txt:
+        * fast/text/font-selection-font-face-parse.html:
+        * fast/text/font-style-parse-expected.txt:
+        * fast/text/font-style-parse.html:
+        * platform/mac-elcapitan/fast/text/font-selection-font-face-parse-expected.txt:
+        * svg/css/getComputedStyle-basic-expected.txt:
+
 2017-03-24  Youenn Fablet  <youenn@apple.com>
 
         Add libwebrtc backend support for RTCRtpSender::replaceTrack
index af40893..b6b2dfe 100644 (file)
@@ -69,46 +69,46 @@ PASS stretchTestSheet.cssRules[36].style.fontStretch is ""
 PASS stretchTestSheet.cssRules[37].style.fontStretch is ""
 PASS stretchTestSheet.cssRules[38].style.fontStretch is "7 / 8"
 PASS stretchTestSheet.cssRules[39].style.fontStretch is "2 / 7"
-PASS styleTestSheet.cssRules[0].style.fontStyle is "1deg"
-PASS styleTestSheet.cssRules[1].style.fontStyle is "200grad"
-PASS styleTestSheet.cssRules[2].style.fontStyle is "6.28318rad"
-PASS styleTestSheet.cssRules[3].style.fontStyle is "4turn"
-PASS styleTestSheet.cssRules[4].style.fontStyle is "5"
-PASS styleTestSheet.cssRules[5].style.fontStyle is "20"
+PASS styleTestSheet.cssRules[0].style.fontStyle is "oblique 1deg"
+PASS styleTestSheet.cssRules[1].style.fontStyle is "oblique 200grad"
+PASS styleTestSheet.cssRules[2].style.fontStyle is "oblique 6.28318rad"
+PASS styleTestSheet.cssRules[3].style.fontStyle is "oblique 4turn"
+PASS styleTestSheet.cssRules[4].style.fontStyle is "oblique 5"
+PASS styleTestSheet.cssRules[5].style.fontStyle is "oblique 20"
 PASS styleTestSheet.cssRules[6].style.fontStyle is "italic"
 PASS styleTestSheet.cssRules[7].style.fontStyle is "oblique"
 PASS styleTestSheet.cssRules[8].style.fontStyle is "normal"
 PASS styleTestSheet.cssRules[9].style.fontStyle is ""
 PASS styleTestSheet.cssRules[10].style.fontStyle is ""
-PASS styleTestSheet.cssRules[11].style.fontStyle is "7"
-PASS styleTestSheet.cssRules[12].style.fontStyle is "calc(1441deg)"
-PASS styleTestSheet.cssRules[13].style.fontStyle is "100 / 200"
-PASS styleTestSheet.cssRules[14].style.fontStyle is "100 / 200"
+PASS styleTestSheet.cssRules[11].style.fontStyle is "oblique 7"
+PASS styleTestSheet.cssRules[12].style.fontStyle is "oblique calc(1441deg)"
+PASS styleTestSheet.cssRules[13].style.fontStyle is "oblique 100deg 200deg"
+PASS styleTestSheet.cssRules[14].style.fontStyle is "oblique 100deg 200deg"
 PASS styleTestSheet.cssRules[15].style.fontStyle is ""
 PASS styleTestSheet.cssRules[16].style.fontStyle is ""
 PASS styleTestSheet.cssRules[17].style.fontStyle is ""
 PASS styleTestSheet.cssRules[18].style.fontStyle is ""
 PASS styleTestSheet.cssRules[19].style.fontStyle is ""
 PASS styleTestSheet.cssRules[20].style.fontStyle is ""
-PASS styleTestSheet.cssRules[21].style.fontStyle is "1 / 2"
-PASS styleTestSheet.cssRules[22].style.fontStyle is "-2 / -1"
+PASS styleTestSheet.cssRules[21].style.fontStyle is "oblique 1deg 2deg"
+PASS styleTestSheet.cssRules[22].style.fontStyle is "oblique -2deg -1deg"
 PASS styleTestSheet.cssRules[23].style.fontStyle is ""
-PASS styleTestSheet.cssRules[24].style.fontStyle is "100deg / 200deg"
-PASS styleTestSheet.cssRules[25].style.fontStyle is "100deg / 200deg"
+PASS styleTestSheet.cssRules[24].style.fontStyle is "oblique 100deg 200deg"
+PASS styleTestSheet.cssRules[25].style.fontStyle is "oblique 100deg 200deg"
 PASS styleTestSheet.cssRules[26].style.fontStyle is ""
 PASS styleTestSheet.cssRules[27].style.fontStyle is ""
 PASS styleTestSheet.cssRules[28].style.fontStyle is ""
 PASS styleTestSheet.cssRules[29].style.fontStyle is ""
 PASS styleTestSheet.cssRules[30].style.fontStyle is ""
 PASS styleTestSheet.cssRules[31].style.fontStyle is ""
-PASS styleTestSheet.cssRules[32].style.fontStyle is "1deg / 2deg"
-PASS styleTestSheet.cssRules[33].style.fontStyle is "-2deg / -1deg"
+PASS styleTestSheet.cssRules[32].style.fontStyle is "oblique 1deg 2deg"
+PASS styleTestSheet.cssRules[33].style.fontStyle is "oblique -2deg -1deg"
 PASS styleTestSheet.cssRules[34].style.fontStyle is ""
 PASS styleTestSheet.cssRules[35].style.fontStyle is ""
 PASS styleTestSheet.cssRules[36].style.fontStyle is ""
-PASS styleTestSheet.cssRules[37].style.fontStyle is "2deg / 1turn"
-PASS styleTestSheet.cssRules[38].style.fontStyle is "7 / 8"
-PASS styleTestSheet.cssRules[39].style.fontStyle is "2 / 7"
+PASS styleTestSheet.cssRules[37].style.fontStyle is "oblique 2deg 1turn"
+PASS styleTestSheet.cssRules[38].style.fontStyle is "oblique 7deg 8deg"
+PASS styleTestSheet.cssRules[39].style.fontStyle is "oblique 2deg 7deg"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 06b1a22..19ceb58 100644 (file)
     font-style: oblique calc(4turn + 1deg);
 }
 @font-face {
-    font-style: oblique 100/200;
+    font-style: oblique 100 200;
 }
 @font-face {
-    font-style: oblique 100 / 200;
+    font-style: oblique 100  200;
 }
 @font-face {
-    font-style: oblique a 100 200;
+    font-style: oblique a 100 200;
 }
 @font-face {
-    font-style: oblique 100 200 a;
+    font-style: oblique 100 200 a;
 }
 @font-face {
-    font-style: oblique 100 a 200;
+    font-style: oblique 100 a 200;
 }
 @font-face {
-    font-style: oblique 100 a200;
+    font-style: oblique 100 a200;
 }
 @font-face {
-    font-style: oblique 100 /a 200;
+    font-style: oblique 100a 200;
 }
 @font-face {
-    font-style: oblique 100 / a200;
+    font-style: oblique 100  a200;
 }
 @font-face {
-    font-style: oblique 1 2;
+    font-style: oblique 1 2;
 }
 @font-face {
-    font-style: oblique -2 -1;
+    font-style: oblique -2 -1;
 }
 @font-face {
-    font-style: oblique 2 1;
+    font-style: oblique 2 1;
 }
 @font-face {
-    font-style: oblique 100deg/200deg;
+    font-style: oblique 100deg 200deg;
 }
 @font-face {
-    font-style: oblique 100deg / 200deg;
+    font-style: oblique 100deg   200deg;
 }
 @font-face {
-    font-style: oblique a 100deg 200deg;
+    font-style: oblique a 100deg 200deg;
 }
 @font-face {
-    font-style: oblique 100deg 200deg a;
+    font-style: oblique 100deg 200deg a;
 }
 @font-face {
-    font-style: oblique 100deg a 200deg;
+    font-style: oblique 100deg a 200deg;
 }
 @font-face {
-    font-style: oblique 100deg a200deg;
+    font-style: oblique 100deg a200deg;
 }
 @font-face {
-    font-style: oblique 100deg /a 200deg;
+    font-style: oblique 100dega 200deg;
 }
 @font-face {
-    font-style: oblique 100deg / a200deg;
+    font-style: oblique 100deg  a200deg;
 }
 @font-face {
-    font-style: oblique 1deg 2deg;
+    font-style: oblique 1deg 2deg;
 }
 @font-face {
-    font-style: oblique -2deg -1deg;
+    font-style: oblique -2deg -1deg;
 }
 @font-face {
-    font-style: oblique 2deg 1deg;
+    font-style: oblique 2deg 1deg;
 }
 @font-face {
-    font-style: oblique 1 2deg;
+    font-style: oblique 1 2deg;
 }
 @font-face {
-    font-style: oblique 1deg 2;
+    font-style: oblique 1deg 2;
 }
 @font-face {
-    font-style: oblique 2deg 1turn;
+    font-style: oblique 2deg 1turn;
 }
 @font-face {
-    font-style: oblique calc(3 + 4) 8;
+    font-style: oblique calc(3 + 4) 8;
 }
 @font-face {
-    font-style: oblique 2 calc(3 + 4);
+    font-style: oblique 2 calc(3 + 4);
 }
 </style>
 </head>
@@ -421,47 +421,47 @@ shouldBeEqualToString("stretchTestSheet.cssRules[38].style.fontStretch", "7 / 8"
 shouldBeEqualToString("stretchTestSheet.cssRules[39].style.fontStretch", "2 / 7");
 
 var styleTestSheet = document.getElementById("styleTest").sheet;
-shouldBeEqualToString("styleTestSheet.cssRules[0].style.fontStyle", "1deg");
-shouldBeEqualToString("styleTestSheet.cssRules[1].style.fontStyle", "200grad");
-shouldBeEqualToString("styleTestSheet.cssRules[2].style.fontStyle", "6.28318rad");
-shouldBeEqualToString("styleTestSheet.cssRules[3].style.fontStyle", "4turn");
-shouldBeEqualToString("styleTestSheet.cssRules[4].style.fontStyle", "5");
-shouldBeEqualToString("styleTestSheet.cssRules[5].style.fontStyle", "20");
+shouldBeEqualToString("styleTestSheet.cssRules[0].style.fontStyle", "oblique 1deg");
+shouldBeEqualToString("styleTestSheet.cssRules[1].style.fontStyle", "oblique 200grad");
+shouldBeEqualToString("styleTestSheet.cssRules[2].style.fontStyle", "oblique 6.28318rad");
+shouldBeEqualToString("styleTestSheet.cssRules[3].style.fontStyle", "oblique 4turn");
+shouldBeEqualToString("styleTestSheet.cssRules[4].style.fontStyle", "oblique 5");
+shouldBeEqualToString("styleTestSheet.cssRules[5].style.fontStyle", "oblique 20");
 shouldBeEqualToString("styleTestSheet.cssRules[6].style.fontStyle", "italic");
 shouldBeEqualToString("styleTestSheet.cssRules[7].style.fontStyle", "oblique");
 shouldBeEqualToString("styleTestSheet.cssRules[8].style.fontStyle", "normal");
 shouldBeEqualToString("styleTestSheet.cssRules[9].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[10].style.fontStyle", "");
-shouldBeEqualToString("styleTestSheet.cssRules[11].style.fontStyle", "7");
-shouldBeEqualToString("styleTestSheet.cssRules[12].style.fontStyle", "calc(1441deg)");
+shouldBeEqualToString("styleTestSheet.cssRules[11].style.fontStyle", "oblique 7");
+shouldBeEqualToString("styleTestSheet.cssRules[12].style.fontStyle", "oblique calc(1441deg)");
 
-shouldBeEqualToString("styleTestSheet.cssRules[13].style.fontStyle", "100 / 200");
-shouldBeEqualToString("styleTestSheet.cssRules[14].style.fontStyle", "100 / 200");
+shouldBeEqualToString("styleTestSheet.cssRules[13].style.fontStyle", "oblique 100deg 200deg");
+shouldBeEqualToString("styleTestSheet.cssRules[14].style.fontStyle", "oblique 100deg 200deg");
 shouldBeEqualToString("styleTestSheet.cssRules[15].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[16].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[17].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[18].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[19].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[20].style.fontStyle", "");
-shouldBeEqualToString("styleTestSheet.cssRules[21].style.fontStyle", "1 / 2");
-shouldBeEqualToString("styleTestSheet.cssRules[22].style.fontStyle", "-2 / -1");
+shouldBeEqualToString("styleTestSheet.cssRules[21].style.fontStyle", "oblique 1deg 2deg");
+shouldBeEqualToString("styleTestSheet.cssRules[22].style.fontStyle", "oblique -2deg -1deg");
 shouldBeEqualToString("styleTestSheet.cssRules[23].style.fontStyle", "");
-shouldBeEqualToString("styleTestSheet.cssRules[24].style.fontStyle", "100deg / 200deg");
-shouldBeEqualToString("styleTestSheet.cssRules[25].style.fontStyle", "100deg / 200deg");
+shouldBeEqualToString("styleTestSheet.cssRules[24].style.fontStyle", "oblique 100deg 200deg");
+shouldBeEqualToString("styleTestSheet.cssRules[25].style.fontStyle", "oblique 100deg 200deg");
 shouldBeEqualToString("styleTestSheet.cssRules[26].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[27].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[28].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[29].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[30].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[31].style.fontStyle", "");
-shouldBeEqualToString("styleTestSheet.cssRules[32].style.fontStyle", "1deg / 2deg");
-shouldBeEqualToString("styleTestSheet.cssRules[33].style.fontStyle", "-2deg / -1deg");
+shouldBeEqualToString("styleTestSheet.cssRules[32].style.fontStyle", "oblique 1deg 2deg");
+shouldBeEqualToString("styleTestSheet.cssRules[33].style.fontStyle", "oblique -2deg -1deg");
 shouldBeEqualToString("styleTestSheet.cssRules[34].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[35].style.fontStyle", "");
 shouldBeEqualToString("styleTestSheet.cssRules[36].style.fontStyle", "");
-shouldBeEqualToString("styleTestSheet.cssRules[37].style.fontStyle", "2deg / 1turn");
-shouldBeEqualToString("styleTestSheet.cssRules[38].style.fontStyle", "7 / 8");
-shouldBeEqualToString("styleTestSheet.cssRules[39].style.fontStyle", "2 / 7");
+shouldBeEqualToString("styleTestSheet.cssRules[37].style.fontStyle", "oblique 2deg 1turn");
+shouldBeEqualToString("styleTestSheet.cssRules[38].style.fontStyle", "oblique 7deg 8deg");
+shouldBeEqualToString("styleTestSheet.cssRules[39].style.fontStyle", "oblique 2deg 7deg");
 </script>
 <script src="../../resources/js-test-post.js"></script>
 </body>
index 7af10cf..af77cbe 100644 (file)
@@ -1,24 +1,24 @@
 PASS window.getComputedStyle(document.getElementById('test1')).fontStyle is "normal"
-PASS window.getComputedStyle(document.getElementById('test2')).fontStyle is "1deg"
-PASS window.getComputedStyle(document.getElementById('test3')).fontStyle is "180deg"
-PASS window.getComputedStyle(document.getElementById('test4')).fontStyle is "359.75deg"
-PASS window.getComputedStyle(document.getElementById('test5')).fontStyle is "1440deg"
-PASS window.getComputedStyle(document.getElementById('test6')).fontStyle is "5deg"
+PASS window.getComputedStyle(document.getElementById('test2')).fontStyle is "oblique 1deg"
+PASS window.getComputedStyle(document.getElementById('test3')).fontStyle is "oblique 180deg"
+PASS window.getComputedStyle(document.getElementById('test4')).fontStyle is "oblique 359.75deg"
+PASS window.getComputedStyle(document.getElementById('test5')).fontStyle is "oblique 1440deg"
+PASS window.getComputedStyle(document.getElementById('test6')).fontStyle is "oblique 5deg"
 PASS window.getComputedStyle(document.getElementById('test7')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test8')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test9')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test10')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test11')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test12')).fontStyle is "normal"
-PASS window.getComputedStyle(document.getElementById('test13')).fontStyle is "7deg"
-PASS window.getComputedStyle(document.getElementById('test14')).fontStyle is "1441deg"
+PASS window.getComputedStyle(document.getElementById('test13')).fontStyle is "oblique 7deg"
+PASS window.getComputedStyle(document.getElementById('test14')).fontStyle is "oblique 1441deg"
 PASS window.getComputedStyle(document.getElementById('test15')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test16')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test17')).fontStyle is "normal"
 PASS window.getComputedStyle(document.getElementById('test18')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test19')).fontStyle is "italic"
 PASS window.getComputedStyle(document.getElementById('test20')).fontStyle is "normal"
-PASS window.getComputedStyle(document.getElementById('test21')).fontStyle is "14deg"
+PASS window.getComputedStyle(document.getElementById('test21')).fontStyle is "oblique 14deg"
 PASS window.getComputedStyle(document.getElementById('test1')).font is "normal normal normal normal 16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test2')).font is "16px/18px Times"
 PASS window.getComputedStyle(document.getElementById('test3')).font is "16px/18px Times"
@@ -47,7 +47,7 @@ PASS document.getElementById('test17').style.font is "100 48px/49px 'Helvetica N
 PASS document.getElementById('test18').style.font is "italic 48px/49px 'Helvetica Neue'"
 PASS document.getElementById('test19').style.font is "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'"
 PASS document.getElementById('test20').style.font is ""
-PASS document.getElementById('test21').style.font is "14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'"
+PASS document.getElementById('test21').style.font is "oblique 14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'"
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 1b5ce01..0b078f7 100644 (file)
 </div>
 <script>
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).fontStyle", "normal");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test2')).fontStyle", "1deg");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test3')).fontStyle", "180deg");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test4')).fontStyle", "359.75deg");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test5')).fontStyle", "1440deg");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test6')).fontStyle", "5deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test2')).fontStyle", "oblique 1deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test3')).fontStyle", "oblique 180deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test4')).fontStyle", "oblique 359.75deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test5')).fontStyle", "oblique 1440deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test6')).fontStyle", "oblique 5deg");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test7')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test8')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test9')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test10')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test11')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test12')).fontStyle", "normal");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test13')).fontStyle", "7deg");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test14')).fontStyle", "1441deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test13')).fontStyle", "oblique 7deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test14')).fontStyle", "oblique 1441deg");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test15')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test16')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test17')).fontStyle", "normal");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test18')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test19')).fontStyle", "italic");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test20')).fontStyle", "normal");
-shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).fontStyle", "14deg");
+shouldBeEqualToString("window.getComputedStyle(document.getElementById('test21')).fontStyle", "oblique 14deg");
 
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test1')).font", "normal normal normal normal 16px/18px Times");
 shouldBeEqualToString("window.getComputedStyle(document.getElementById('test2')).font", "16px/18px Times");
@@ -79,7 +79,7 @@ shouldBeEqualToString("document.getElementById('test17').style.font", "100 48px/
 shouldBeEqualToString("document.getElementById('test18').style.font", "italic 48px/49px 'Helvetica Neue'");
 shouldBeEqualToString("document.getElementById('test19').style.font", "italic small-caps 100 extra-expanded 48px/49px 'Helvetica Neue'");
 shouldBeEqualToString("document.getElementById('test20').style.font", "");
-shouldBeEqualToString("document.getElementById('test21').style.font", "14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'");
+shouldBeEqualToString("document.getElementById('test21').style.font", "oblique 14deg small-caps 123 extra-expanded 48px/49px 'Helvetica Neue'");
 </script>
 <script src="../../resources/js-test-post.js"></script>
 </body>
index d96744a..2714710 100644 (file)
@@ -69,46 +69,46 @@ PASS stretchTestSheet.cssRules[36].style.fontStretch is ""
 PASS stretchTestSheet.cssRules[37].style.fontStretch is ""
 FAIL stretchTestSheet.cssRules[38].style.fontStretch should be 7 / 8. Was .
 FAIL stretchTestSheet.cssRules[39].style.fontStretch should be 2 / 7. Was .
-PASS styleTestSheet.cssRules[0].style.fontStyle is "1deg"
-PASS styleTestSheet.cssRules[1].style.fontStyle is "200grad"
-PASS styleTestSheet.cssRules[2].style.fontStyle is "6.28318rad"
-PASS styleTestSheet.cssRules[3].style.fontStyle is "4turn"
-PASS styleTestSheet.cssRules[4].style.fontStyle is "5"
-PASS styleTestSheet.cssRules[5].style.fontStyle is "20"
+PASS styleTestSheet.cssRules[0].style.fontStyle is "oblique 1deg"
+PASS styleTestSheet.cssRules[1].style.fontStyle is "oblique 200grad"
+PASS styleTestSheet.cssRules[2].style.fontStyle is "oblique 6.28318rad"
+PASS styleTestSheet.cssRules[3].style.fontStyle is "oblique 4turn"
+FAIL styleTestSheet.cssRules[4].style.fontStyle should be oblique 5. Was oblique 5deg.
+FAIL styleTestSheet.cssRules[5].style.fontStyle should be oblique 20. Was oblique 20deg.
 PASS styleTestSheet.cssRules[6].style.fontStyle is "italic"
 PASS styleTestSheet.cssRules[7].style.fontStyle is "oblique"
 PASS styleTestSheet.cssRules[8].style.fontStyle is "normal"
 PASS styleTestSheet.cssRules[9].style.fontStyle is ""
 PASS styleTestSheet.cssRules[10].style.fontStyle is ""
-PASS styleTestSheet.cssRules[11].style.fontStyle is "7"
-PASS styleTestSheet.cssRules[12].style.fontStyle is "calc(1441deg)"
-FAIL styleTestSheet.cssRules[13].style.fontStyle should be 100 / 200. Was .
-FAIL styleTestSheet.cssRules[14].style.fontStyle should be 100 / 200. Was .
+FAIL styleTestSheet.cssRules[11].style.fontStyle should be oblique 7. Was oblique 7deg.
+PASS styleTestSheet.cssRules[12].style.fontStyle is "oblique calc(1441deg)"
+FAIL styleTestSheet.cssRules[13].style.fontStyle should be oblique 100deg 200deg. Was .
+FAIL styleTestSheet.cssRules[14].style.fontStyle should be oblique 100deg 200deg. Was .
 PASS styleTestSheet.cssRules[15].style.fontStyle is ""
 PASS styleTestSheet.cssRules[16].style.fontStyle is ""
 PASS styleTestSheet.cssRules[17].style.fontStyle is ""
 PASS styleTestSheet.cssRules[18].style.fontStyle is ""
 PASS styleTestSheet.cssRules[19].style.fontStyle is ""
 PASS styleTestSheet.cssRules[20].style.fontStyle is ""
-FAIL styleTestSheet.cssRules[21].style.fontStyle should be 1 / 2. Was .
-FAIL styleTestSheet.cssRules[22].style.fontStyle should be -2 / -1. Was .
+FAIL styleTestSheet.cssRules[21].style.fontStyle should be oblique 1deg 2deg. Was .
+FAIL styleTestSheet.cssRules[22].style.fontStyle should be oblique -2deg -1deg. Was .
 PASS styleTestSheet.cssRules[23].style.fontStyle is ""
-FAIL styleTestSheet.cssRules[24].style.fontStyle should be 100deg / 200deg. Was .
-FAIL styleTestSheet.cssRules[25].style.fontStyle should be 100deg / 200deg. Was .
+FAIL styleTestSheet.cssRules[24].style.fontStyle should be oblique 100deg 200deg. Was .
+FAIL styleTestSheet.cssRules[25].style.fontStyle should be oblique 100deg 200deg. Was .
 PASS styleTestSheet.cssRules[26].style.fontStyle is ""
 PASS styleTestSheet.cssRules[27].style.fontStyle is ""
 PASS styleTestSheet.cssRules[28].style.fontStyle is ""
 PASS styleTestSheet.cssRules[29].style.fontStyle is ""
 PASS styleTestSheet.cssRules[30].style.fontStyle is ""
 PASS styleTestSheet.cssRules[31].style.fontStyle is ""
-FAIL styleTestSheet.cssRules[32].style.fontStyle should be 1deg / 2deg. Was .
-FAIL styleTestSheet.cssRules[33].style.fontStyle should be -2deg / -1deg. Was .
+FAIL styleTestSheet.cssRules[32].style.fontStyle should be oblique 1deg 2deg. Was .
+FAIL styleTestSheet.cssRules[33].style.fontStyle should be oblique -2deg -1deg. Was .
 PASS styleTestSheet.cssRules[34].style.fontStyle is ""
 PASS styleTestSheet.cssRules[35].style.fontStyle is ""
 PASS styleTestSheet.cssRules[36].style.fontStyle is ""
-FAIL styleTestSheet.cssRules[37].style.fontStyle should be 2deg / 1turn. Was .
-FAIL styleTestSheet.cssRules[38].style.fontStyle should be 7 / 8. Was .
-FAIL styleTestSheet.cssRules[39].style.fontStyle should be 2 / 7. Was .
+FAIL styleTestSheet.cssRules[37].style.fontStyle should be oblique 2deg 1turn. Was .
+FAIL styleTestSheet.cssRules[38].style.fontStyle should be oblique 7deg 8deg. Was .
+FAIL styleTestSheet.cssRules[39].style.fontStyle should be oblique 2deg 7deg. Was .
 PASS successfullyParsed is true
 
 TEST COMPLETE
index 1e0ec84..caeffd7 100644 (file)
@@ -91,7 +91,7 @@ rect: style.getPropertyCSSValue(float) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(font-size) : 16px
 rect: style.getPropertyCSSValue(font-size) : [object CSSPrimitiveValue]
 rect: style.getPropertyValue(font-style) : normal
-rect: style.getPropertyCSSValue(font-style) : [object CSSPrimitiveValue]
+rect: style.getPropertyCSSValue(font-style) : [object CSSValue]
 rect: style.getPropertyValue(font-synthesis) : style weight small-caps
 rect: style.getPropertyCSSValue(font-synthesis) : [object CSSValueList]
 rect: style.getPropertyValue(font-variant) : normal
@@ -643,7 +643,7 @@ g: style.getPropertyCSSValue(float) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(font-size) : 16px
 g: style.getPropertyCSSValue(font-size) : [object CSSPrimitiveValue]
 g: style.getPropertyValue(font-style) : normal
-g: style.getPropertyCSSValue(font-style) : [object CSSPrimitiveValue]
+g: style.getPropertyCSSValue(font-style) : [object CSSValue]
 g: style.getPropertyValue(font-synthesis) : style weight small-caps
 g: style.getPropertyCSSValue(font-synthesis) : [object CSSValueList]
 g: style.getPropertyValue(font-variant) : normal
index bff639b..2758dae 100644 (file)
@@ -1314,6 +1314,8 @@ set(WebCore_SOURCES
     css/CSSFontFaceSrcValue.cpp
     css/CSSFontFeatureValue.cpp
     css/CSSFontSelector.cpp
+    css/CSSFontStyleRangeValue.cpp
+    css/CSSFontStyleValue.cpp
     css/CSSFontValue.cpp
     css/CSSFontVariationValue.cpp
     css/CSSFunctionValue.cpp
index c32d06c..f4c3201 100644 (file)
@@ -1,3 +1,79 @@
+2017-03-24  Myles C. Maxfield  <mmaxfield@apple.com>
+
+        font-style needs a new CSSValue to make CSSRule.cssText work correctly
+        https://bugs.webkit.org/show_bug.cgi?id=169258
+
+        Reviewed by David Hyatt.
+
+        With variation fonts, font-style's value can't be captured in a CSSPrimitiveValue (nor any other subclass
+        off CSSValue) any more. Instead, we need to create two new CSSValues which represent the grammar that font-
+        style and it's associated @font-face descriptor accept.
+
+        The grammar of the font-style property is "normal | italic | oblique [ <<angle>> ]?"
+        The grammar of the font-style descriptor is "normal | italic | oblique [ <<angle>> | <<angle>> <<angle>> ]?"
+
+        We currently still support numbers in place of the <<angle>> value (contrary to the spec). We will remove
+        this support in https://bugs.webkit.org/show_bug.cgi?id=169357.
+
+        Tests: fast/text/font-selection-font-face-parse.html:
+               fast/text/font-style-parse.html:
+
+        * CMakeLists.txt:
+        * WebCore.xcodeproj/project.pbxproj:
+        * css/CSSAllInOne.cpp:
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::fontStyleFromStyle):
+        (WebCore::fontShorthandValueForSelectionProperties):
+        * css/CSSFontFace.cpp:
+        (WebCore::calculateWeightRange):
+        (WebCore::calculateStretchRange):
+        (WebCore::calculateItalicRange):
+        * css/CSSFontFaceSet.cpp:
+        (WebCore::computeFontSelectionRequest):
+        (WebCore::CSSFontFaceSet::matchingFaces):
+        (WebCore::calculateWeightValue): Deleted.
+        (WebCore::calculateStretchValue): Deleted.
+        (WebCore::calculateStyleValue): Deleted.
+        * css/CSSFontFaceSet.h:
+        * css/CSSFontSelector.cpp:
+        (WebCore::CSSFontSelector::addFontFaceRule):
+        * css/CSSFontStyleRangeValue.cpp: Added.
+        (WebCore::CSSFontStyleRangeValue::customCSSText):
+        (WebCore::CSSFontStyleRangeValue::equals):
+        * css/CSSFontStyleRangeValue.h: Added.
+        * css/CSSFontStyleValue.cpp: Added.
+        (WebCore::CSSFontStyleValue::customCSSText):
+        (WebCore::CSSFontStyleValue::equals):
+        * css/CSSFontStyleValue.h: Added.
+        * css/CSSFontValue.cpp:
+        (WebCore::CSSFontValue::customCSSText):
+        * css/CSSFontValue.h:
+        * css/CSSValue.cpp:
+        (WebCore::CSSValue::equals):
+        (WebCore::CSSValue::cssText):
+        (WebCore::CSSValue::destroy):
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isFontStyleValue):
+        (WebCore::CSSValue::isFontStyleRangeValue):
+        * css/FontFace.cpp:
+        (WebCore::FontFace::style):
+        (WebCore::FontFace::weight):
+        (WebCore::FontFace::stretch):
+        * css/StyleBuilderConverter.h:
+        (WebCore::StyleBuilderConverter::convertFontWeightFromValue):
+        (WebCore::StyleBuilderConverter::convertFontStretchFromValue):
+        (WebCore::StyleBuilderConverter::convertFontStyleFromValue):
+        (WebCore::StyleBuilderConverter::convertFontWeight):
+        (WebCore::StyleBuilderConverter::convertFontStretch):
+        (WebCore::StyleBuilderConverter::convertFontStyle):
+        * css/parser/CSSPropertyParser.cpp:
+        (WebCore::consumeFontStyle):
+        (WebCore::consumeFontStyleRange):
+        (WebCore::CSSPropertyParser::consumeSystemFont):
+        (WebCore::CSSPropertyParser::consumeFont):
+        * svg/SVGFontFaceElement.cpp:
+        (WebCore::SVGFontFaceElement::parseAttribute):
+
 2017-03-24  Alex Christensen  <achristensen@webkit.org>
 
         REGRESSION: Content Blocker: Blocking "a[href*=randomString]" doesn't work
index cd714f4..0f84d21 100644 (file)
                C2AB0AF61E6B3C6C001348C5 /* FontSelectionAlgorithm.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2AB0AF41E6B3C6C001348C5 /* FontSelectionAlgorithm.cpp */; };
                C2AB0AF71E6B3C6C001348C5 /* FontSelectionAlgorithm.h in Headers */ = {isa = PBXBuildFile; fileRef = C2AB0AF51E6B3C6C001348C5 /* FontSelectionAlgorithm.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2E1F43F1D6254E10094625C /* BreakLines.h in Headers */ = {isa = PBXBuildFile; fileRef = BCEA4816097D93020094C9E4 /* BreakLines.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               C2E38EFD1E8396FD00CA3ADF /* CSSFontStyleValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2E38EFB1E8396FD00CA3ADF /* CSSFontStyleValue.cpp */; };
+               C2E38EFE1E8396FD00CA3ADF /* CSSFontStyleValue.h in Headers */ = {isa = PBXBuildFile; fileRef = C2E38EFC1E8396FD00CA3ADF /* CSSFontStyleValue.h */; };
+               C2E38F011E84573500CA3ADF /* CSSFontStyleRangeValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2E38EFF1E84573500CA3ADF /* CSSFontStyleRangeValue.cpp */; };
+               C2E38F021E84573500CA3ADF /* CSSFontStyleRangeValue.h in Headers */ = {isa = PBXBuildFile; fileRef = C2E38F001E84573500CA3ADF /* CSSFontStyleRangeValue.h */; };
                C2F4E78A1E45BEA1006D7105 /* ComplexTextController.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C2F4E7881E45AEDF006D7105 /* ComplexTextController.cpp */; };
                C2F4E78C1E45C3EF006D7105 /* ComplexTextController.h in Headers */ = {isa = PBXBuildFile; fileRef = C2F4E7891E45AEDF006D7105 /* ComplexTextController.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C330A22313EC196B0000B45B /* ColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = C330A22113EC196B0000B45B /* ColorChooser.h */; settings = {ATTRIBUTES = (Private, ); }; };
                C2AB0AF51E6B3C6C001348C5 /* FontSelectionAlgorithm.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontSelectionAlgorithm.h; sourceTree = "<group>"; };
                C2AB0B021E6DE32B001348C5 /* FontSelectionKeywordValues.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSelectionKeywordValues.h; sourceTree = "<group>"; };
                C2AB0B031E6DE92C001348C5 /* FontSelectionValueInlines.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontSelectionValueInlines.h; sourceTree = "<group>"; };
+               C2E38EFB1E8396FD00CA3ADF /* CSSFontStyleValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontStyleValue.cpp; sourceTree = "<group>"; };
+               C2E38EFC1E8396FD00CA3ADF /* CSSFontStyleValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontStyleValue.h; sourceTree = "<group>"; };
+               C2E38EFF1E84573500CA3ADF /* CSSFontStyleRangeValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CSSFontStyleRangeValue.cpp; sourceTree = "<group>"; };
+               C2E38F001E84573500CA3ADF /* CSSFontStyleRangeValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CSSFontStyleRangeValue.h; sourceTree = "<group>"; };
                C2F4E7881E45AEDF006D7105 /* ComplexTextController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ComplexTextController.cpp; sourceTree = "<group>"; };
                C2F4E7891E45AEDF006D7105 /* ComplexTextController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ComplexTextController.h; sourceTree = "<group>"; };
                C330A22113EC196B0000B45B /* ColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooser.h; sourceTree = "<group>"; };
                                3FFFF9A7159D9A550020BBD5 /* WebKitCSSViewportRule.h */,
                                3F2B33E3165ABD3500E3987C /* WebKitCSSViewportRule.idl */,
                                31055BB81E4FE18900EB604E /* WebKitFontFamilyNames.in */,
+                               C2E38EFB1E8396FD00CA3ADF /* CSSFontStyleValue.cpp */,
+                               C2E38EFC1E8396FD00CA3ADF /* CSSFontStyleValue.h */,
+                               C2E38EFF1E84573500CA3ADF /* CSSFontStyleRangeValue.cpp */,
+                               C2E38F001E84573500CA3ADF /* CSSFontStyleRangeValue.h */,
                        );
                        path = css;
                        sourceTree = "<group>";
                                316DCB201E78CA55001B5F87 /* JSRTCOfferAnswerOptions.h in Headers */,
                                51E269371DD3BD9B006B6A58 /* IDBIterateCursorData.h in Headers */,
                                5185FC951BB4C4E80012898F /* IDBKey.h in Headers */,
+                               C2E38F021E84573500CA3ADF /* CSSFontStyleRangeValue.h in Headers */,
                                5185FC971BB4C4E80012898F /* IDBKeyData.h in Headers */,
                                5185FC991BB4C4E80012898F /* IDBKeyPath.h in Headers */,
                                5185FC9B1BB4C4E80012898F /* IDBKeyRange.h in Headers */,
                                088C2F7A12390081003D65CE /* SVGTextLayoutAttributes.h in Headers */,
                                081093DC1255F0E700ED9D29 /* SVGTextLayoutAttributesBuilder.h in Headers */,
                                081668DA125603D5006F25DE /* SVGTextLayoutEngine.h in Headers */,
+                               C2E38EFE1E8396FD00CA3ADF /* CSSFontStyleValue.h in Headers */,
                                080E49261255F3BD00EFCA27 /* SVGTextLayoutEngineBaseline.h in Headers */,
                                080E49281255F3BD00EFCA27 /* SVGTextLayoutEngineSpacing.h in Headers */,
                                08F0BFC61255C53C00075185 /* SVGTextMetrics.h in Headers */,
                                9444CBE31D8861980073A074 /* CSSCustomIdentValue.cpp in Sources */,
                                94D4AC621DC24C8E0080F02D /* CSSCustomPropertyValue.cpp in Sources */,
                                4A9CC81716BB9AC600EC645A /* CSSDefaultStyleSheets.cpp in Sources */,
+                               C2E38F011E84573500CA3ADF /* CSSFontStyleRangeValue.cpp in Sources */,
                                94476BDA1DFCAC0300690E23 /* CSSDeferredParser.cpp in Sources */,
                                FBB0C5B717BBD626003D3677 /* CSSFilterImageValue.cpp in Sources */,
                                BC64B4D50CB4298A005F2B62 /* CSSFontFace.cpp in Sources */,
                                BC2274780E8366E200E7F975 /* SVGRenderStyle.cpp in Sources */,
                                BC22747A0E8366E200E7F975 /* SVGRenderStyleDefs.cpp in Sources */,
                                B2227AA20D00BF220071B782 /* SVGScriptElement.cpp in Sources */,
+                               C2E38EFD1E8396FD00CA3ADF /* CSSFontStyleValue.cpp in Sources */,
                                B2227AA50D00BF220071B782 /* SVGSetElement.cpp in Sources */,
                                E4AFD00F0DAF335500F5F55C /* SVGSMILElement.cpp in Sources */,
                                B2227AA80D00BF220071B782 /* SVGStopElement.cpp in Sources */,
index b116afa..c7fed35 100644 (file)
@@ -46,6 +46,7 @@
 #include "CSSFontFaceSrcValue.cpp"
 #include "CSSFontFeatureValue.cpp"
 #include "CSSFontSelector.cpp"
+#include "CSSFontStyleValue.cpp"
 #include "CSSFontValue.cpp"
 #include "CSSFontVariationValue.cpp"
 #include "CSSFunctionValue.cpp"
index f8dd5e1..b879e67 100644 (file)
@@ -35,6 +35,7 @@
 #include "CSSBorderImageSliceValue.h"
 #include "CSSCustomPropertyValue.h"
 #include "CSSFontFeatureValue.h"
+#include "CSSFontStyleValue.h"
 #include "CSSFontValue.h"
 #include "CSSFontVariationValue.h"
 #include "CSSFunctionValue.h"
@@ -1929,12 +1930,14 @@ static Ref<CSSPrimitiveValue> fontStretchFromStyle(const RenderStyle& style)
     return CSSValuePool::singleton().createValue(static_cast<float>(stretch), CSSPrimitiveValue::CSS_PERCENTAGE);
 }
 
-static Ref<CSSPrimitiveValue> fontStyleFromStyle(const RenderStyle& style)
+static Ref<CSSFontStyleValue> fontStyleFromStyle(const RenderStyle& style)
 {
-    auto italic = style.fontDescription().italic();
-    if (auto italicValue = fontStyleKeyword(italic))
-        return CSSValuePool::singleton().createIdentifierValue(italicValue.value());
-    return CSSValuePool::singleton().createValue(static_cast<float>(italic), CSSPrimitiveValue::CSS_DEG);
+    FontSelectionValue italic = style.fontDescription().italic();
+    if (italic == normalItalicValue())
+        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueNormal));
+    if (italic == italicValue())
+        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueItalic));
+    return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), CSSValuePool::singleton().createValue(static_cast<float>(italic), CSSPrimitiveValue::CSS_DEG));
 }
 
 static Ref<CSSValue> fontVariantFromStyle(const RenderStyle& style)
@@ -2550,7 +2553,7 @@ static Ref<CSSFontValue> fontShorthandValueForSelectionProperties(const FontDesc
         return CSSFontValue::create();
 
     if (auto italic = fontStyleKeyword(fontDescription.italic()))
-        computedFont->style = CSSValuePool::singleton().createIdentifierValue(italic.value());
+        computedFont->style = CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(italic.value()));
     else
         return CSSFontValue::create();
 
index 9a44558..34bdbee 100644 (file)
@@ -31,6 +31,8 @@
 #include "CSSFontFamily.h"
 #include "CSSFontFeatureValue.h"
 #include "CSSFontSelector.h"
+#include "CSSFontStyleRangeValue.h"
+#include "CSSFontStyleValue.h"
 #include "CSSPrimitiveValueMappings.h"
 #include "CSSSegmentedFontFace.h"
 #include "CSSUnicodeRangeValue.h"
@@ -43,6 +45,7 @@
 #include "FontVariantBuilder.h"
 #include "RuntimeEnabledFeatures.h"
 #include "Settings.h"
+#include "StyleBuilderConverter.h"
 #include "StyleProperties.h"
 #include "StyleRule.h"
 
@@ -135,28 +138,14 @@ static FontSelectionRange calculateWeightRange(CSSValue& value)
         ASSERT(valueList.item(1)->isPrimitiveValue());
         auto& value0 = downcast<CSSPrimitiveValue>(*valueList.item(0));
         auto& value1 = downcast<CSSPrimitiveValue>(*valueList.item(1));
-        ASSERT(value0.isNumber());
-        ASSERT(value1.isNumber());
-        return { FontSelectionValue::clampFloat(value0.floatValue()), FontSelectionValue::clampFloat(value1.floatValue()) };
+        auto result0 = StyleBuilderConverter::convertFontWeightFromValue(value0);
+        auto result1 = StyleBuilderConverter::convertFontWeightFromValue(value1);
+        return { result0, result1 };
     }
 
     ASSERT(is<CSSPrimitiveValue>(value));
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
-
-    FontSelectionValue result;
-    if (primitiveValue.isNumber()) {
-        result = FontSelectionValue::clampFloat(primitiveValue.floatValue());
-        return { result, result };
-    }
-
-    ASSERT(primitiveValue.isValueID());
-    if (auto value = fontWeightValue(primitiveValue.valueID()))
-        result = value.value();
-    else {
-        ASSERT_NOT_REACHED();
-        result = normalWeightValue();
-    }
-
+    FontSelectionValue result = StyleBuilderConverter::convertFontWeightFromValue(primitiveValue);
     return { result, result };
 }
 
@@ -184,28 +173,14 @@ static FontSelectionRange calculateStretchRange(CSSValue& value)
         ASSERT(valueList.item(1)->isPrimitiveValue());
         auto& value0 = downcast<CSSPrimitiveValue>(*valueList.item(0));
         auto& value1 = downcast<CSSPrimitiveValue>(*valueList.item(1));
-        ASSERT(value0.isPercentage() || value0.isNumber());
-        ASSERT(value1.isPercentage() || value1.isNumber());
-        return { FontSelectionValue::clampFloat(value0.floatValue()), FontSelectionValue::clampFloat(value1.floatValue()) };
+        auto result0 = StyleBuilderConverter::convertFontStretchFromValue(value0);
+        auto result1 = StyleBuilderConverter::convertFontStretchFromValue(value1);
+        return { result0, result1 };
     }
 
     ASSERT(is<CSSPrimitiveValue>(value));
     const auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
-
-    FontSelectionValue result;
-    if (primitiveValue.isPercentage() || primitiveValue.isNumber()) {
-        result = FontSelectionValue::clampFloat(primitiveValue.floatValue());
-        return { result, result };
-    }
-
-    ASSERT(primitiveValue.isValueID());
-    if (auto value = fontStretchValue(primitiveValue.valueID()))
-        result = value.value();
-    else {
-        ASSERT_NOT_REACHED();
-        result = normalStretchValue();
-    }
-
+    FontSelectionValue result = StyleBuilderConverter::convertFontStretchFromValue(primitiveValue);
     return { result, result };
 }
 
@@ -224,37 +199,34 @@ void CSSFontFace::setStretch(CSSValue& style)
 
 static FontSelectionRange calculateItalicRange(CSSValue& value)
 {
-    if (value.isValueList()) {
-        auto& valueList = downcast<CSSValueList>(value);
-        ASSERT(valueList.length() == 2);
-        if (valueList.length() != 2)
-            return { normalItalicValue(), normalItalicValue() };
-        ASSERT(valueList.item(0)->isPrimitiveValue());
-        ASSERT(valueList.item(1)->isPrimitiveValue());
-        auto& value0 = downcast<CSSPrimitiveValue>(*valueList.item(0));
-        auto& value1 = downcast<CSSPrimitiveValue>(*valueList.item(1));
-        ASSERT(value0.isAngle() || value0.isNumber() || value0.isCalculated());
-        ASSERT(value1.isAngle() || value1.isNumber() || value1.isCalculated());
-        return { FontSelectionValue::clampFloat(value0.floatValue(CSSPrimitiveValue::CSS_DEG)), FontSelectionValue::clampFloat(value1.floatValue(CSSPrimitiveValue::CSS_DEG)) };
-    }
-
-    ASSERT(is<CSSPrimitiveValue>(value));
-    const auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
-
-    FontSelectionValue result;
-    if (primitiveValue.isAngle() || primitiveValue.isNumber() || primitiveValue.isCalculated()) {
-        result = FontSelectionValue::clampFloat(primitiveValue.floatValue(CSSPrimitiveValue::CSS_DEG));
+    if (value.isFontStyleValue()) {
+        auto result = StyleBuilderConverter::convertFontStyleFromValue(value);
         return { result, result };
     }
 
-    ASSERT(primitiveValue.isValueID());
-    if (auto value = fontStyleValue(primitiveValue.valueID()))
-        result = value.value();
-    else {
-        ASSERT_NOT_REACHED();
-        result = normalItalicValue();
+    ASSERT(value.isFontStyleRangeValue());
+    auto& rangeValue = downcast<CSSFontStyleRangeValue>(value);
+    ASSERT(rangeValue.fontStyleValue->isValueID());
+    auto valueID = rangeValue.fontStyleValue->valueID();
+    if (!rangeValue.obliqueValues) {
+        if (valueID == CSSValueNormal)
+            return { normalItalicValue(), normalItalicValue() };
+        ASSERT(valueID == CSSValueItalic || valueID == CSSValueOblique);
+        return { italicValue(), italicValue() };
     }
-    return { result, result };
+    ASSERT(valueID == CSSValueOblique);
+    auto length = rangeValue.obliqueValues->length();
+    if (length == 1) {
+        auto& primitiveValue = downcast<CSSPrimitiveValue>(*rangeValue.obliqueValues->item(0));
+        FontSelectionValue result(primitiveValue.value<float>(CSSPrimitiveValue::CSS_DEG));
+        return { result, result };
+    }
+    ASSERT(length == 2);
+    auto& primitiveValue1 = downcast<CSSPrimitiveValue>(*rangeValue.obliqueValues->item(0));
+    auto& primitiveValue2 = downcast<CSSPrimitiveValue>(*rangeValue.obliqueValues->item(1));
+    FontSelectionValue result1(primitiveValue1.value<float>(CSSPrimitiveValue::CSS_DEG));
+    FontSelectionValue result2(primitiveValue2.value<float>(CSSPrimitiveValue::CSS_DEG));
+    return { result1, result2 };
 }
 
 void CSSFontFace::setStyle(CSSValue& style)
index 34d280c..882688c 100644 (file)
@@ -29,6 +29,7 @@
 #include "CSSFontFaceSource.h"
 #include "CSSFontFamily.h"
 #include "CSSFontSelector.h"
+#include "CSSFontStyleValue.h"
 #include "CSSParser.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSSegmentedFontFace.h"
@@ -36,6 +37,7 @@
 #include "CSSValuePool.h"
 #include "ExceptionCode.h"
 #include "FontCache.h"
+#include "StyleBuilderConverter.h"
 #include "StyleProperties.h"
 
 namespace WebCore {
@@ -286,91 +288,25 @@ CSSFontFace& CSSFontFaceSet::operator[](size_t i)
     return m_faces[i];
 }
 
-static std::optional<FontSelectionValue> calculateWeightValue(CSSValue& weight)
-{
-    if (!is<CSSPrimitiveValue>(weight))
-        return std::nullopt;
-
-    auto& primitiveWeight = downcast<CSSPrimitiveValue>(weight);
-    if (primitiveWeight.isNumber())
-        return FontSelectionValue::clampFloat(primitiveWeight.floatValue());
-
-    if (!primitiveWeight.isValueID())
-        return std::nullopt;
-
-    if (auto value = fontWeightValue(primitiveWeight.valueID()))
-        return value.value();
-    ASSERT_NOT_REACHED();
-    return normalWeightValue();
-}
-
-static std::optional<FontSelectionValue> calculateStretchValue(CSSValue& style)
-{
-    if (!is<CSSPrimitiveValue>(style))
-        return std::nullopt;
-
-    auto& primitiveStretch = downcast<CSSPrimitiveValue>(style);
-    if (primitiveStretch.isNumber() || primitiveStretch.isPercentage())
-        return FontSelectionValue::clampFloat(primitiveStretch.floatValue());
-
-    if (!primitiveStretch.isValueID())
-        return std::nullopt;
-
-    if (auto value = fontStretchValue(primitiveStretch.valueID()))
-        return value.value();
-    return normalStretchValue();
-}
-
-static std::optional<FontSelectionValue> calculateStyleValue(CSSValue& style)
-{
-    if (!is<CSSPrimitiveValue>(style))
-        return std::nullopt;
-
-    auto& primitiveSlant = downcast<CSSPrimitiveValue>(style);
-    if (primitiveSlant.isNumber() || primitiveSlant.isAngle())
-        return FontSelectionValue::clampFloat(primitiveSlant.floatValue());
-
-    if (!primitiveSlant.isValueID())
-        return std::nullopt;
-
-    if (auto value = fontStyleValue(downcast<CSSPrimitiveValue>(style).valueID()))
-        return value.value();
-    return normalItalicValue();
-}
-
-static std::optional<FontSelectionRequest> computeFontSelectionRequest(MutableStyleProperties& style)
+static FontSelectionRequest computeFontSelectionRequest(MutableStyleProperties& style)
 {
     RefPtr<CSSValue> weightValue = style.getPropertyCSSValue(CSSPropertyFontWeight).get();
     if (!weightValue)
         weightValue = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal).ptr();
 
-    FontSelectionValue weightSelectionValue;
-    if (auto weightOptional = calculateWeightValue(*weightValue))
-        weightSelectionValue = weightOptional.value();
-    else
-        return std::nullopt;
-
     RefPtr<CSSValue> stretchValue = style.getPropertyCSSValue(CSSPropertyFontStretch).get();
     if (!stretchValue)
         stretchValue = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal).ptr();
 
-    FontSelectionValue stretchSelectionValue;
-    if (auto stretchOptional = calculateStretchValue(*weightValue))
-        stretchSelectionValue = stretchOptional.value();
-    else
-        return std::nullopt;
-
     RefPtr<CSSValue> styleValue = style.getPropertyCSSValue(CSSPropertyFontStyle).get();
     if (!styleValue)
-        styleValue = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal).ptr();
+        styleValue = CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueNormal));
 
-    FontSelectionValue styleSelectionValue;
-    if (auto styleOptional = calculateStyleValue(*styleValue))
-        styleSelectionValue = styleOptional.value();
-    else
-        return std::nullopt;
+    FontSelectionValue weightSelectionValue = StyleBuilderConverter::convertFontWeightFromValue(*weightValue);
+    FontSelectionValue stretchSelectionValue = StyleBuilderConverter::convertFontStretchFromValue(*stretchValue);
+    FontSelectionValue styleSelectionValue = StyleBuilderConverter::convertFontStyleFromValue(*styleValue);
 
-    return {{ weightSelectionValue, stretchSelectionValue, styleSelectionValue }};
+    return { weightSelectionValue, stretchSelectionValue, styleSelectionValue };
 }
 
 static HashSet<UChar32> codePointsFromString(StringView stringView)
@@ -396,11 +332,7 @@ ExceptionOr<Vector<std::reference_wrapper<CSSFontFace>>> CSSFontFaceSet::matchin
     if (parseResult == CSSParser::ParseResult::Error)
         return Exception { SYNTAX_ERR };
 
-    FontSelectionRequest request;
-    if (auto fontSelectionRequestOptional = computeFontSelectionRequest(style.get()))
-        request = fontSelectionRequestOptional.value();
-    else
-        return Exception { SYNTAX_ERR };
+    FontSelectionRequest request = computeFontSelectionRequest(style.get());
 
     auto family = style->getPropertyCSSValue(CSSPropertyFontFamily);
     if (!is<CSSValueList>(family.get()))
index 2b7e2eb..ad44787 100644 (file)
@@ -52,6 +52,10 @@ public:
     }
     ~CSSFontFaceSet();
 
+    static FontSelectionValue convertFontWeightFromValue(const CSSValue&);
+    static FontSelectionValue convertFontStretchFromValue(const CSSValue&);
+    static FontSelectionValue convertFontStyleFromValue(const CSSValue&);
+
     void addClient(CSSFontFaceSetClient&);
     void removeClient(CSSFontFaceSetClient&);
 
index fe07600..3a37a47 100644 (file)
@@ -33,6 +33,8 @@
 #include "CSSFontFaceSource.h"
 #include "CSSFontFamily.h"
 #include "CSSFontFeatureValue.h"
+#include "CSSFontStyleRangeValue.h"
+#include "CSSFontStyleValue.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSPrimitiveValueMappings.h"
 #include "CSSPropertyNames.h"
@@ -163,7 +165,7 @@ void CSSFontSelector::addFontFaceRule(StyleRuleFontFace& fontFaceRule, bool isIn
         return;
 
     if (!fontStyle)
-        fontStyle = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal).ptr();
+        fontStyle = CSSFontStyleRangeValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueNormal));
 
     if (!fontWeight)
         fontWeight = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
diff --git a/Source/WebCore/css/CSSFontStyleRangeValue.cpp b/Source/WebCore/css/CSSFontStyleRangeValue.cpp
new file mode 100644 (file)
index 0000000..847f57c
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include "CSSFontStyleRangeValue.h"
+
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+String CSSFontStyleRangeValue::customCSSText() const
+{
+    if (!obliqueValues)
+        return fontStyleValue->cssText();
+
+    StringBuilder builder;
+    builder.append(fontStyleValue->cssText());
+    builder.append(" ");
+    builder.append(obliqueValues->cssText());
+    return builder.toString();
+}
+
+bool CSSFontStyleRangeValue::equals(const CSSFontStyleRangeValue& other) const
+{
+    if (!obliqueValues)
+        return fontStyleValue.get() == other.fontStyleValue.get();
+    return fontStyleValue.get() == other.fontStyleValue.get()
+        && *obliqueValues == *other.obliqueValues;
+}
+
+}
diff --git a/Source/WebCore/css/CSSFontStyleRangeValue.h b/Source/WebCore/css/CSSFontStyleRangeValue.h
new file mode 100644 (file)
index 0000000..7571113
--- /dev/null
@@ -0,0 +1,64 @@
+/*
+ * Copyright (C) 2017 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. ``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
+ * 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.
+ */
+
+#pragma once
+
+#include "CSSPrimitiveValue.h"
+#include "CSSValue.h"
+#include "CSSValueList.h"
+#include "FontSelectionAlgorithm.h"
+
+namespace WebCore {
+
+class CSSFontStyleRangeValue final : public CSSValue {
+public:
+    static Ref<CSSFontStyleRangeValue> create(Ref<CSSPrimitiveValue>&& fontStyleValue)
+    {
+        return adoptRef(*new CSSFontStyleRangeValue(WTFMove(fontStyleValue), nullptr));
+    }
+    static Ref<CSSFontStyleRangeValue> create(Ref<CSSPrimitiveValue>&& fontStyleValue, RefPtr<CSSValueList>&& obliqueValues)
+    {
+        return adoptRef(*new CSSFontStyleRangeValue(WTFMove(fontStyleValue), WTFMove(obliqueValues)));
+    }
+
+    String customCSSText() const;
+
+    bool equals(const CSSFontStyleRangeValue&) const;
+
+    Ref<CSSPrimitiveValue> fontStyleValue;
+    RefPtr<CSSValueList> obliqueValues;
+
+private:
+    CSSFontStyleRangeValue(Ref<CSSPrimitiveValue>&& fontStyleValue, RefPtr<CSSValueList>&& obliqueValues)
+        : CSSValue(FontStyleRangeClass)
+        , fontStyleValue(WTFMove(fontStyleValue))
+        , obliqueValues(WTFMove(obliqueValues))
+    {
+    }
+};
+
+}
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSFontStyleRangeValue, isFontStyleRangeValue())
diff --git a/Source/WebCore/css/CSSFontStyleValue.cpp b/Source/WebCore/css/CSSFontStyleValue.cpp
new file mode 100644 (file)
index 0000000..237cd1f
--- /dev/null
@@ -0,0 +1,53 @@
+/*
+ * Copyright (C) 2017 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. ``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
+ * 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.
+ */
+
+#include "config.h"
+#include "CSSFontStyleValue.h"
+
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+String CSSFontStyleValue::customCSSText() const
+{
+    if (!obliqueValue)
+        return fontStyleValue->cssText();
+
+    StringBuilder builder;
+    builder.append(fontStyleValue->cssText());
+    builder.append(" ");
+    builder.append(obliqueValue->cssText());
+    return builder.toString();
+}
+
+bool CSSFontStyleValue::equals(const CSSFontStyleValue& other) const
+{
+    if (!obliqueValue)
+        return fontStyleValue.get() == other.fontStyleValue.get();
+    return fontStyleValue.get() == other.fontStyleValue.get()
+        && *obliqueValue == *other.obliqueValue;
+}
+
+}
diff --git a/Source/WebCore/css/CSSFontStyleValue.h b/Source/WebCore/css/CSSFontStyleValue.h
new file mode 100644 (file)
index 0000000..c21bc29
--- /dev/null
@@ -0,0 +1,72 @@
+/*
+ * Copyright (C) 2017 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. ``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
+ * 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.
+ */
+
+#pragma once
+
+#include "CSSPrimitiveValue.h"
+#include "CSSValue.h"
+#include "FontSelectionAlgorithm.h"
+
+namespace WebCore {
+
+class CSSFontStyleValue final : public CSSValue {
+public:
+    static Ref<CSSFontStyleValue> create(Ref<CSSPrimitiveValue>&& fontStyleValue)
+    {
+        return adoptRef(*new CSSFontStyleValue(WTFMove(fontStyleValue), nullptr));
+    }
+    static Ref<CSSFontStyleValue> create(Ref<CSSPrimitiveValue>&& fontStyleValue, RefPtr<CSSPrimitiveValue>&& obliqueValue)
+    {
+        return adoptRef(*new CSSFontStyleValue(WTFMove(fontStyleValue), WTFMove(obliqueValue)));
+    }
+
+    String customCSSText() const;
+
+    bool equals(const CSSFontStyleValue&) const;
+
+    bool isItalic() const
+    {
+        if (!obliqueValue) {
+            auto valueID = fontStyleValue->valueID();
+            return valueID == CSSValueItalic || CSSValueOblique;
+        }
+        return obliqueValue->value<float>(CSSPrimitiveValue::CSS_DEG) >= static_cast<float>(italicValue());
+    }
+
+    Ref<CSSPrimitiveValue> fontStyleValue;
+    RefPtr<CSSPrimitiveValue> obliqueValue;
+
+private:
+    CSSFontStyleValue(Ref<CSSPrimitiveValue>&& fontStyleValue, RefPtr<CSSPrimitiveValue>&& obliqueValue)
+        : CSSValue(FontStyleClass)
+        , fontStyleValue(WTFMove(fontStyleValue))
+        , obliqueValue(WTFMove(obliqueValue))
+    {
+    }
+};
+
+}
+
+SPECIALIZE_TYPE_TRAITS_CSS_VALUE(CSSFontStyleValue, isFontStyleValue())
index 2392c3a..784c80d 100644 (file)
@@ -20,6 +20,7 @@
 #include "config.h"
 #include "CSSFontValue.h"
 
+#include "CSSFontStyleValue.h"
 #include "CSSPrimitiveValue.h"
 #include "CSSValueList.h"
 #include <wtf/text/StringBuilder.h>
@@ -44,7 +45,7 @@ String CSSFontValue::customCSSText() const
             result.append(' ');
         result.append(weight->cssText());
     }
-    if (weight) {
+    if (stretch) {
         if (!result.isEmpty())
             result.append(' ');
         result.append(stretch->cssText());
index 70eaf34..7b168be 100644 (file)
@@ -20,6 +20,7 @@
 
 #pragma once
 
+#include "CSSFontStyleValue.h"
 #include "CSSValue.h"
 #include <wtf/RefPtr.h>
 
@@ -39,7 +40,7 @@ public:
 
     bool equals(const CSSFontValue&) const;
 
-    RefPtr<CSSPrimitiveValue> style;
+    RefPtr<CSSFontStyleValue> style;
     RefPtr<CSSPrimitiveValue> variant;
     RefPtr<CSSPrimitiveValue> weight;
     RefPtr<CSSPrimitiveValue> stretch;
index c619e8f..aad61ca 100644 (file)
@@ -41,6 +41,8 @@
 #include "CSSFilterImageValue.h"
 #include "CSSFontFaceSrcValue.h"
 #include "CSSFontFeatureValue.h"
+#include "CSSFontStyleRangeValue.h"
+#include "CSSFontStyleValue.h"
 #include "CSSFontValue.h"
 #include "CSSFontVariationValue.h"
 #include "CSSFunctionValue.h"
@@ -206,6 +208,10 @@ bool CSSValue::equals(const CSSValue& other) const
             return compareCSSValues<CSSVariableReferenceValue>(*this, other);
         case PendingSubstitutionValueClass:
             return compareCSSValues<CSSPendingSubstitutionValue>(*this, other);
+        case FontStyleClass:
+            return compareCSSValues<CSSFontStyleValue>(*this, other);
+        case FontStyleRangeClass:
+            return compareCSSValues<CSSFontStyleRangeValue>(*this, other);
         default:
             ASSERT_NOT_REACHED();
             return false;
@@ -302,6 +308,10 @@ String CSSValue::cssText() const
         return downcast<CSSVariableReferenceValue>(*this).customCSSText();
     case PendingSubstitutionValueClass:
         return downcast<CSSPendingSubstitutionValue>(*this).customCSSText();
+    case FontStyleClass:
+        return downcast<CSSFontStyleValue>(*this).customCSSText();
+    case FontStyleRangeClass:
+        return downcast<CSSFontStyleRangeValue>(*this).customCSSText();
     }
 
     ASSERT_NOT_REACHED();
@@ -432,6 +442,12 @@ void CSSValue::destroy()
     case PendingSubstitutionValueClass:
         delete downcast<CSSPendingSubstitutionValue>(this);
         return;
+    case FontStyleClass:
+        delete downcast<CSSFontStyleValue>(this);
+        return;
+    case FontStyleRangeClass:
+        delete downcast<CSSFontStyleRangeValue>(this);
+        return;
     }
     ASSERT_NOT_REACHED();
 }
index 47c6208..758c9a3 100644 (file)
@@ -79,6 +79,8 @@ public:
 #endif
     bool isFontFaceSrcValue() const { return m_classType == FontFaceSrcClass; }
     bool isFontValue() const { return m_classType == FontClass; }
+    bool isFontStyleValue() const { return m_classType == FontStyleClass; }
+    bool isFontStyleRangeValue() const { return m_classType == FontStyleRangeClass; }
     bool isImageGeneratorValue() const { return m_classType >= CanvasClass && m_classType <= RadialGradientClass; }
     bool isGradientValue() const { return m_classType >= LinearGradientClass && m_classType <= RadialGradientClass; }
     bool isNamedImageValue() const { return m_classType == NamedImageClass; }
@@ -155,6 +157,8 @@ protected:
         FontVariationClass,
 #endif
         FontClass,
+        FontStyleClass,
+        FontStyleRangeClass,
         FontFaceSrcClass,
         FunctionClass,
 
index 1178387..42fb8ec 100644 (file)
@@ -305,7 +305,7 @@ String FontFace::style() const
         return String::format("oblique %fdeg", static_cast<float>(style.minimum));
     }
 
-    return String::format("oblique %fdeg-%fdeg", static_cast<float>(style.minimum), static_cast<float>(style.maximum));
+    return String::format("oblique %fdeg %fdeg", static_cast<float>(style.minimum), static_cast<float>(style.maximum));
 }
 
 String FontFace::weight() const
@@ -328,7 +328,7 @@ String FontFace::weight() const
         return String::format("%f", static_cast<float>(weight.minimum));
     }
 
-    return String::format("%f-%f", static_cast<float>(weight.minimum), static_cast<float>(weight.maximum));
+    return String::format("%f %f", static_cast<float>(weight.minimum), static_cast<float>(weight.maximum));
 }
 
 String FontFace::stretch() const
@@ -365,7 +365,7 @@ String FontFace::stretch() const
         return String::format("%f%%", static_cast<float>(stretch.minimum));
     }
 
-    return String::format("%f%%-%f%%", static_cast<float>(stretch.minimum), static_cast<float>(stretch.maximum));
+    return String::format("%f%% %f%%", static_cast<float>(stretch.minimum), static_cast<float>(stretch.maximum));
 }
 
 String FontFace::unicodeRange() const
index 462afe4..6279632 100644 (file)
@@ -30,6 +30,7 @@
 #include "CSSCalculationValue.h"
 #include "CSSContentDistributionValue.h"
 #include "CSSFontFeatureValue.h"
+#include "CSSFontStyleValue.h"
 #include "CSSFontVariationValue.h"
 #include "CSSFunctionValue.h"
 #include "CSSGridAutoRepeatValue.h"
@@ -39,6 +40,7 @@
 #include "CSSImageSetValue.h"
 #include "CSSImageValue.h"
 #include "CSSPrimitiveValue.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSReflectValue.h"
 #include "FontSelectionValueInlines.h"
 #include "Frame.h"
@@ -115,6 +117,9 @@ public:
     static bool convertOverflowScrolling(StyleResolver&, const CSSValue&);
 #endif
     static FontFeatureSettings convertFontFeatureSettings(StyleResolver&, const CSSValue&);
+    static FontSelectionValue convertFontWeightFromValue(const CSSValue&);
+    static FontSelectionValue convertFontStretchFromValue(const CSSValue&);
+    static FontSelectionValue convertFontStyleFromValue(const CSSValue&);
     static FontSelectionValue convertFontWeight(StyleResolver&, const CSSValue&);
     static FontSelectionValue convertFontStretch(StyleResolver&, const CSSValue&);
     static FontSelectionValue convertFontStyle(StyleResolver&, const CSSValue&);
@@ -1160,7 +1165,7 @@ inline FontFeatureSettings StyleBuilderConverter::convertFontFeatureSettings(Sty
     return settings;
 }
 
-inline FontSelectionValue StyleBuilderConverter::convertFontWeight(StyleResolver& styleResolver, const CSSValue& value)
+inline FontSelectionValue StyleBuilderConverter::convertFontWeightFromValue(const CSSValue& value)
 {
     ASSERT(is<CSSPrimitiveValue>(value));
     auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
@@ -1173,18 +1178,17 @@ inline FontSelectionValue StyleBuilderConverter::convertFontWeight(StyleResolver
     case CSSValueNormal:
         return normalWeightValue();
     case CSSValueBold:
-        return boldWeightValue();
     case CSSValueBolder:
-        return FontCascadeDescription::bolderWeight(styleResolver.parentStyle()->fontDescription().weight());
+        return boldWeightValue();
     case CSSValueLighter:
-        return FontCascadeDescription::lighterWeight(styleResolver.parentStyle()->fontDescription().weight());
+        return lightWeightValue();
     default:
         ASSERT_NOT_REACHED();
         return normalWeightValue();
     }
 }
 
-inline FontSelectionValue StyleBuilderConverter::convertFontStretch(StyleResolver&, const CSSValue& value)
+inline FontSelectionValue StyleBuilderConverter::convertFontStretchFromValue(const CSSValue& value)
 {
     ASSERT(is<CSSPrimitiveValue>(value));
     const auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
@@ -1199,19 +1203,44 @@ inline FontSelectionValue StyleBuilderConverter::convertFontStretch(StyleResolve
     return normalStretchValue();
 }
 
-inline FontSelectionValue StyleBuilderConverter::convertFontStyle(StyleResolver&, const CSSValue& value)
+inline FontSelectionValue StyleBuilderConverter::convertFontStyleFromValue(const CSSValue& value)
+{
+    ASSERT(is<CSSFontStyleValue>(value));
+    const auto& fontStyleValue = downcast<CSSFontStyleValue>(value);
+
+    auto valueID = fontStyleValue.fontStyleValue->valueID();
+    if (valueID == CSSValueNormal)
+        return normalItalicValue();
+    if (valueID == CSSValueItalic)
+        return italicValue();
+    ASSERT(valueID == CSSValueOblique);
+    if (auto* obliqueValue = fontStyleValue.obliqueValue.get())
+        return FontSelectionValue(obliqueValue->value<float>(CSSPrimitiveValue::CSS_DEG));
+    return italicValue();
+}
+
+inline FontSelectionValue StyleBuilderConverter::convertFontWeight(StyleResolver& styleResolver, const CSSValue& value)
 {
     ASSERT(is<CSSPrimitiveValue>(value));
-    const auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    auto& primitiveValue = downcast<CSSPrimitiveValue>(value);
+    if (primitiveValue.isValueID()) {
+        auto valueID = primitiveValue.valueID();
+        if (valueID == CSSValueBolder)
+            return FontCascadeDescription::bolderWeight(styleResolver.parentStyle()->fontDescription().weight());
+        if (valueID == CSSValueLighter)
+            return FontCascadeDescription::lighterWeight(styleResolver.parentStyle()->fontDescription().weight());
+    }
+    return convertFontWeightFromValue(value);
+}
 
-    if (primitiveValue.isAngle() || primitiveValue.isNumber() || primitiveValue.isCalculated())
-        return FontSelectionValue::clampFloat(primitiveValue.floatValue(CSSPrimitiveValue::CSS_DEG));
+inline FontSelectionValue StyleBuilderConverter::convertFontStretch(StyleResolver&, const CSSValue& value)
+{
+    return convertFontStretchFromValue(value);
+}
 
-    ASSERT(primitiveValue.isValueID());
-    if (auto value = fontStyleValue(primitiveValue.valueID()))
-        return value.value();
-    ASSERT_NOT_REACHED();
-    return normalItalicValue();
+inline FontSelectionValue StyleBuilderConverter::convertFontStyle(StyleResolver&, const CSSValue& value)
+{
+    return convertFontStyleFromValue(value);
 }
 
 #if ENABLE(VARIATION_FONTS)
index acc6d69..57dcecc 100644 (file)
@@ -45,6 +45,8 @@
 #if ENABLE(VARIATION_FONTS)
 #include "CSSFontVariationValue.h"
 #endif
+#include "CSSFontStyleRangeValue.h"
+#include "CSSFontStyleValue.h"
 #include "CSSFunctionValue.h"
 #include "CSSGridAutoRepeatValue.h"
 #include "CSSGridLineNamesValue.h"
@@ -960,66 +962,70 @@ static RefPtr<CSSPrimitiveValue> consumeFontStyleKeywordValue(CSSParserTokenRang
     return consumeIdent<CSSValueNormal, CSSValueItalic, CSSValueOblique>(range);
 }
 
-static RefPtr<CSSPrimitiveValue> consumeFontStyle(CSSParserTokenRange& range, CSSParserMode cssParserMode)
+static RefPtr<CSSFontStyleValue> consumeFontStyle(CSSParserTokenRange& range, CSSParserMode cssParserMode)
 {
-    if (auto result = consumeFontStyleKeywordValue(range)) {
-        if (result->valueID() == CSSValueOblique) {
-            if (range.atEnd())
-                return result;
-            if (auto angle = consumeAngle(range, cssParserMode))
-                return angle;
-            if (auto number = consumeNumber(range, ValueRangeAll))
-                return number;
-        }
-        return result;
-    }
-    return nullptr;
+    auto result = consumeFontStyleKeywordValue(range);
+    if (!result)
+        return nullptr;
+
+    if (result->valueID() == CSSValueNormal)
+        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueNormal));
+    if (result->valueID() == CSSValueItalic)
+        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueItalic));
+    ASSERT(result->valueID() == CSSValueOblique);
+    if (range.atEnd())
+        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique));
+    if (auto angle = consumeAngle(range, cssParserMode))
+        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), WTFMove(angle));
+    if (auto number = consumeNumber(range, ValueRangeAll))
+        return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique), CSSValuePool::singleton().createValue(number->value<double>(), CSSPrimitiveValue::CSS_DEG));
+    return CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueOblique));
 }
 
 #if ENABLE(VARIATION_FONTS)
-static RefPtr<CSSValue> consumeFontStyleRange(CSSParserTokenRange& range, CSSParserMode cssParserMode)
-{
-    if (auto result = consumeFontStyleKeywordValue(range)) {
-        if (result->valueID() == CSSValueOblique) {
-            if (range.atEnd())
-                return result;
-
-            if (auto firstAngle = consumeAngle(range, cssParserMode)) {
-                if (range.atEnd())
-                    return firstAngle;
-                if (!consumeSlashIncludingWhitespace(range))
-                    return nullptr;
-                auto secondAngle = consumeAngle(range, cssParserMode);
-                if (!secondAngle)
-                    return nullptr;
-                if (firstAngle->floatValue(CSSPrimitiveValue::CSS_DEG) > secondAngle->floatValue(CSSPrimitiveValue::CSS_DEG))
-                    return nullptr;
-                auto result = CSSValueList::createSlashSeparated();
-                result->append(firstAngle.releaseNonNull());
-                result->append(secondAngle.releaseNonNull());
-                return RefPtr<CSSValue>(WTFMove(result));
-            }
+static RefPtr<CSSFontStyleRangeValue> consumeFontStyleRange(CSSParserTokenRange& range, CSSParserMode cssParserMode)
+{
+    auto keyword = consumeFontStyleKeywordValue(range);
+    if (!keyword)
+        return nullptr;
 
-            if (auto firstNumber = consumeNumber(range, ValueRangeAll)) {
-                if (range.atEnd())
-                    return firstNumber;
-                if (!consumeSlashIncludingWhitespace(range))
-                    return nullptr;
-                auto secondNumber = consumeNumber(range, ValueRangeAll);
-                if (!secondNumber)
-                    return nullptr;
-                if (firstNumber->floatValue() > secondNumber->floatValue())
-                    return nullptr;
-                auto result = CSSValueList::createSlashSeparated();
-                result->append(firstNumber.releaseNonNull());
-                result->append(secondNumber.releaseNonNull());
-                return RefPtr<CSSValue>(WTFMove(result));
-            }
+    if (keyword->valueID() != CSSValueOblique || range.atEnd())
+        return CSSFontStyleRangeValue::create(keyword.releaseNonNull());
 
+    if (auto firstAngle = consumeAngle(range, cssParserMode)) {
+        if (range.atEnd()) {
+            auto result = CSSValueList::createSpaceSeparated();
+            result->append(firstAngle.releaseNonNull());
+            return CSSFontStyleRangeValue::create(keyword.releaseNonNull(), WTFMove(result));
+        }
+        auto secondAngle = consumeAngle(range, cssParserMode);
+        if (!secondAngle)
+            return nullptr;
+        if (firstAngle->floatValue(CSSPrimitiveValue::CSS_DEG) > secondAngle->floatValue(CSSPrimitiveValue::CSS_DEG))
             return nullptr;
+        auto result = CSSValueList::createSpaceSeparated();
+        result->append(firstAngle.releaseNonNull());
+        result->append(secondAngle.releaseNonNull());
+        return CSSFontStyleRangeValue::create(keyword.releaseNonNull(), WTFMove(result));
+    }
+
+    if (auto firstNumber = consumeNumber(range, ValueRangeAll)) {
+        if (range.atEnd()) {
+            auto result = CSSValueList::createSpaceSeparated();
+            result->append(firstNumber.releaseNonNull());
+            return CSSFontStyleRangeValue::create(keyword.releaseNonNull(), WTFMove(result));
         }
-        return result;
+        auto secondNumber = consumeNumber(range, ValueRangeAll);
+        if (!secondNumber)
+            return nullptr;
+        if (firstNumber->floatValue() > secondNumber->floatValue())
+            return nullptr;
+        auto result = CSSValueList::createSpaceSeparated();
+        result->append(CSSValuePool::singleton().createValue(firstNumber->value<double>(), CSSPrimitiveValue::CSS_DEG));
+        result->append(CSSValuePool::singleton().createValue(secondNumber->value<double>(), CSSPrimitiveValue::CSS_DEG));
+        return CSSFontStyleRangeValue::create(keyword.releaseNonNull(), WTFMove(result));
     }
+
     return nullptr;
 }
 #endif
@@ -4385,7 +4391,7 @@ bool CSSPropertyParser::consumeSystemFont(bool important)
     if (!fontDescription.isAbsoluteSize())
         return false;
     
-    addProperty(CSSPropertyFontStyle, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(isItalic(fontDescription.italic()) ? CSSValueItalic : CSSValueNormal), important);
+    addProperty(CSSPropertyFontStyle, CSSPropertyFont, CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(isItalic(fontDescription.italic()) ? CSSValueItalic : CSSValueNormal)), important);
     addProperty(CSSPropertyFontWeight, CSSPropertyFont, CSSValuePool::singleton().createValue(static_cast<float>(fontDescription.weight())), important);
     addProperty(CSSPropertyFontSize, CSSPropertyFont, CSSValuePool::singleton().createValue(fontDescription.specifiedSize(), CSSPrimitiveValue::CSS_PX), important);
     Ref<CSSValueList> fontFamilyList = CSSValueList::createCommaSeparated();
@@ -4409,7 +4415,7 @@ bool CSSPropertyParser::consumeFont(bool important)
             return false;
     }
     // Optional font-style, font-variant, font-stretch and font-weight.
-    RefPtr<CSSPrimitiveValue> fontStyle;
+    RefPtr<CSSFontStyleValue> fontStyle;
     RefPtr<CSSPrimitiveValue> fontVariantCaps;
     RefPtr<CSSPrimitiveValue> fontWeight;
     RefPtr<CSSPrimitiveValue> fontStretch;
@@ -4448,8 +4454,11 @@ bool CSSPropertyParser::consumeFont(bool important)
     bool hasVariant = fontVariantCaps;
     bool hasWeight = fontWeight;
     bool hasStretch = fontStretch;
+
+    if (!fontStyle)
+        fontStyle = CSSFontStyleValue::create(CSSValuePool::singleton().createIdentifierValue(CSSValueNormal));
     
-    addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle ? fontStyle.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !hasStyle);
+    addProperty(CSSPropertyFontStyle, CSSPropertyFont, fontStyle.releaseNonNull(), important, !hasStyle);
     addProperty(CSSPropertyFontVariantCaps, CSSPropertyFont, fontVariantCaps ? fontVariantCaps.releaseNonNull() : CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, !hasVariant);
 /*  
     // FIXME-NEWPARSER: What do we do with these? They aren't part of our fontShorthand().
@@ -4472,9 +4481,8 @@ bool CSSPropertyParser::consumeFont(bool important)
         if (!lineHeight)
             return false;
         addProperty(CSSPropertyLineHeight, CSSPropertyFont, lineHeight.releaseNonNull(), important);
-    } else {
+    } else
         addProperty(CSSPropertyLineHeight, CSSPropertyFont, CSSValuePool::singleton().createIdentifierValue(CSSValueNormal), important, true);
-    }
 
     // Font family must come now.
     RefPtr<CSSValue> parsedFamilyValue = consumeFontFamily(m_range);
index e7db4e5..ae4953b 100644 (file)
@@ -29,6 +29,7 @@
 
 #include "ApplyStyleCommand.h"
 #include "CSSComputedStyleDeclaration.h"
+#include "CSSFontStyleValue.h"
 #include "CSSParser.h"
 #include "CSSRuleList.h"
 #include "CSSStyleRule.h"
@@ -142,6 +143,8 @@ template<typename T>
 int identifierForStyleProperty(T& style, CSSPropertyID propertyID)
 {
     RefPtr<CSSValue> value = extractPropertyValue(style, propertyID);
+    if (propertyID == CSSPropertyFontStyle && is<CSSFontStyleValue>(value.get()) && downcast<CSSFontStyleValue>(value.get())->isItalic())
+        return CSSValueItalic;
     if (!is<CSSPrimitiveValue>(value.get()))
         return 0;
     return downcast<CSSPrimitiveValue>(*value).valueID();
index 4a93c7e..b8ba9b0 100644 (file)
@@ -65,6 +65,7 @@ void SVGFontFaceElement::parseAttribute(const QualifiedName& name, const AtomicS
 {    
     CSSPropertyID propId = cssPropertyIdForSVGAttributeName(name);
     if (propId > 0) {
+        // FIXME: Parse using the @font-face descriptor grammars, not the property grammars.
         m_fontFaceRule->mutableProperties().setProperty(propId, value, false);
         rebuildFontFace();
         return;