Parsing CSS3 font-feature-settings property
authorbashi@chromium.org <bashi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Aug 2011 07:34:58 +0000 (07:34 +0000)
committerbashi@chromium.org <bashi@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 5 Aug 2011 07:34:58 +0000 (07:34 +0000)
https://bugs.webkit.org/show_bug.cgi?id=63618

Source/WebCore:

Introduces CSS3 font-feature-settings property as -webkit-font-feature-settings.  This change only contains parsing part.  Parsed information are stored in FontDescription class.

Patch by Kenichi Ishibashi <bashi@chromium.org> on 2011-08-05
Reviewed by Shinichiro Hamaji.

Test: css3/font-feature-settings-parsing.html

* CMakeLists.txt: Added FontFeatureValue.{h,cpp} and FontFeatureSettings.{h,cpp}.
* GNUmakefile.list.am: Ditto.
* WebCore.gypi: Ditto.
* WebCore.pro: Ditto.
* WebCore.vcproj/WebCore.vcproj: Ditto.
* WebCore.xcodeproj/project.pbxproj: Ditto.
* css/CSSComputedStyleDeclaration.cpp:
(WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added CSSPropertyWebkitFontFeatureSettings.
* css/CSSParser.cpp:
(WebCore::CSSParser::parseValue): Added parsing code for -webkit-font-feature-settings.
(WebCore::CSSParser::parseFontFeatureTag): Added.
(WebCore::CSSParser::parseFontFeatureSettings): Added.
* css/CSSParser.h: Added parseFontFeatureSettings().
* css/CSSPropertyNames.in: Added -webkit-font-feature-settings.
* css/CSSStyleSelector.cpp:
(WebCore::CSSStyleSelector::applyDeclarations): Modified a compile assert to follow adding -webkit-font-feature-settings.
(WebCore::CSSStyleSelector::applyProperty): Added a case clause for CSSPropertyWebkitFontFeatureSettings.
* css/CSSValue.h:
(WebCore::CSSValue::isFontFeatureValue): Added.
* css/CSSValueKeywords.in: Added 'on' and 'off' keywords.
* css/FontFeatureValue.cpp: Added.
(WebCore::FontFeatureValue::FontFeatureValue):
(WebCore::FontFeatureValue::value):
(WebCore::FontFeatureValue::cssText):
* css/FontFeatureValue.h: Added.
(WebCore::FontFeatureValue::create):
(WebCore::FontFeatureValue::tag):
(WebCore::FontFeatureValue::isFontFeatureValue):
* platform/graphics/FontDescription.cpp:
(WebCore::FontDescription::makeNormalFeatureSettings): Added.
* platform/graphics/FontDescription.h:
(WebCore::FontDescription::FontDescription): Added m_featureSettings member variable.
(WebCore::FontDescription::featureSettings): Added.
(WebCore::FontDescription::setFeatureSettings): Added.
(WebCore::FontDescription::operator==): Modified to take into account m_featureSettings
* platform/graphics/FontFeatureSettings.cpp: Added.
(WebCore::FontFeature::FontFeature):
(WebCore::FontFeature::operator=):
(WebCore::FontFeature::operator==):
(WebCore::FontFeatureSettings::FontFeatureSettings):
* platform/graphics/FontFeatureSettings.h: Added.
(WebCore::FontFeature::tag):
(WebCore::FontFeature::value):
(WebCore::FontFeatureSettings::create):
(WebCore::FontFeatureSettings::append):
(WebCore::FontFeatureSettings::size):
(WebCore::FontFeatureSettings::operator[]):
(WebCore::FontFeatureSettings::at):

LayoutTests:

Add parsing test case for -webkit-font-feature-settings property.

Patch by Kenichi Ishibashi <bashi@chromium.org> on 2011-08-05
Reviewed by Shinichiro Hamaji.

* css3/font-feature-settings-parsing-expected.txt: Added.
* css3/font-feature-settings-parsing.html: Added.

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

23 files changed:
LayoutTests/ChangeLog
LayoutTests/css3/font-feature-settings-parsing-expected.txt [new file with mode: 0644]
LayoutTests/css3/font-feature-settings-parsing.html [new file with mode: 0644]
Source/WebCore/CMakeLists.txt
Source/WebCore/ChangeLog
Source/WebCore/GNUmakefile.list.am
Source/WebCore/WebCore.gypi
Source/WebCore/WebCore.pro
Source/WebCore/WebCore.vcproj/WebCore.vcproj
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/css/CSSComputedStyleDeclaration.cpp
Source/WebCore/css/CSSParser.cpp
Source/WebCore/css/CSSParser.h
Source/WebCore/css/CSSPropertyNames.in
Source/WebCore/css/CSSStyleSelector.cpp
Source/WebCore/css/CSSValue.h
Source/WebCore/css/CSSValueKeywords.in
Source/WebCore/css/FontFeatureValue.cpp [new file with mode: 0644]
Source/WebCore/css/FontFeatureValue.h [new file with mode: 0644]
Source/WebCore/platform/graphics/FontDescription.cpp
Source/WebCore/platform/graphics/FontDescription.h
Source/WebCore/platform/graphics/FontFeatureSettings.cpp [new file with mode: 0644]
Source/WebCore/platform/graphics/FontFeatureSettings.h [new file with mode: 0644]

index a71927a..56d182b 100644 (file)
@@ -1,3 +1,15 @@
+2011-08-05  Kenichi Ishibashi  <bashi@chromium.org>
+
+        Parsing CSS3 font-feature-settings property
+        https://bugs.webkit.org/show_bug.cgi?id=63618
+
+        Add parsing test case for -webkit-font-feature-settings property.
+
+        Reviewed by Shinichiro Hamaji.
+
+        * css3/font-feature-settings-parsing-expected.txt: Added.
+        * css3/font-feature-settings-parsing.html: Added.
+
 2011-08-05  Sheriff Bot  <webkit.review.bot@gmail.com>
 
         Unreviewed, rolling out r92439.
diff --git a/LayoutTests/css3/font-feature-settings-parsing-expected.txt b/LayoutTests/css3/font-feature-settings-parsing-expected.txt
new file mode 100644 (file)
index 0000000..c0c4c07
--- /dev/null
@@ -0,0 +1,45 @@
+Test parsing of the CSS3 font-feature-settings property.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+- Tests valid inputs.
+PASS parseResultOf("valid_normal") is "normal"
+PASS parseResultOf("valid_value_1") is "'dlig' 1"
+PASS parseResultOf("valid_value_2") is "'swsh' 2"
+PASS parseResultOf("valid_value_on") is "'smcp' 1"
+PASS parseResultOf("valid_value_off") is "'liga' 0"
+PASS parseResultOf("valid_value_omit") is "'c2sc' 1"
+PASS parseResultOf("valid_valuelist") is "'tnum' 1, 'hist' 1"
+PASS parseResultOf("valid_singlequote") is "'PKRN' 1"
+PASS parseResultOf("valid_ident") is "'dlig' 1"
+PASS parseResultOf("valid_unusual_tag") is "'!@#$' 1"
+PASS parseResultOf("valid_tag_space") is "'a bc' 1"
+PASS parseResultOf("valid_cases") is "'dlig' 1, 'DLIG' 1, 'DLig' 1"
+PASS parseResultOf("valid_composite") is "'dlig' 1, 'smcp' 1, 'liga' 0"
+- Tests invalid inputs.  Results should be "normal".
+PASS parseResultOf("invalid_1") is "normal"
+PASS parseResultOf("invalid_off") is "normal"
+PASS parseResultOf("invalid_normal_duplicate") is "normal"
+PASS parseResultOf("invalid_normal_list") is "normal"
+PASS parseResultOf("invalid_longer_ident") is "normal"
+PASS parseResultOf("invalid_longer_quote") is "normal"
+PASS parseResultOf("invalid_negative") is "normal"
+PASS parseResultOf("invalid_float") is "normal"
+PASS parseResultOf("invalid_missing_comma") is "normal"
+PASS parseResultOf("invalid_missing_comma_ident") is "normal"
+PASS parseResultOf("invalid_comma") is "normal"
+PASS parseResultOf("invalid_ending_comma") is "normal"
+PASS parseResultOf("invalid_beginning_comma") is "normal"
+PASS parseResultOf("invalid_on") is "normal"
+PASS parseResultOf("invalid_0") is "normal"
+- Tests inherit.
+PASS parseResultOf("outer") is "'dlig' 1"
+PASS parseResultOf("inner") is "'dlig' 1"
+- Tests @font-face.
+PASS fontFaceRuleValid is "'liga' 1"
+PASS fontFaceRuleInvalid is ""
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/css3/font-feature-settings-parsing.html b/LayoutTests/css3/font-feature-settings-parsing.html
new file mode 100644 (file)
index 0000000..a3b37ed
--- /dev/null
@@ -0,0 +1,223 @@
+<html>
+<head>
+<link rel="stylesheet" href="../fast/js/resources/js-test-style.css">
+<script src="../fast/js/resources/js-test-pre.js"></script>
+<style>
+#valid_normal {
+    -webkit-font-feature-settings: normal;
+}
+
+#valid_value_1 {
+    -webkit-font-feature-settings: "dlig" 1;
+}
+
+#valid_value_2 {
+    -webkit-font-feature-settings: "swsh" 2;
+}
+
+#valid_value_on {
+    -webkit-font-feature-settings: "smcp" on;
+}
+
+#valid_value_off {
+    -webkit-font-feature-settings: "liga" off;
+}
+
+#valid_value_omit {
+    -webkit-font-feature-settings: "c2sc";
+}
+
+#valid_valuelist {
+    -webkit-font-feature-settings: "tnum", 'hist';
+}
+
+#valid_singlequote {
+    -webkit-font-feature-settings: 'PKRN';
+}
+
+#valid_ident {
+    -webkit-font-feature-settings: dlig;
+}
+
+#valid_unusual_tag {
+    -webkit-font-feature-settings: "!@#$";
+}
+
+#valid_cases {
+    -webkit-font-feature-settings: dlig, DLIG, DLig;
+}
+
+#valid_tag_space {
+    -webkit-font-feature-settings: "a bc";
+}
+
+#valid_composite {
+    -webkit-font-feature-settings: "dlig" 1, 'smcp' on, liga off;
+}
+
+#invalid_1 {
+    -webkit-font-feature-settings: 1;
+}
+
+#invalid_off {
+    -webkit-font-feature-settings: off;
+}
+
+#invalid_normal_duplicate {
+    -webkit-font-feature-settings: normal, normal;
+}
+
+#invalid_normal_list {
+    -webkit-font-feature-settings: normal, aaaa;
+}
+
+#invalid_longer_ident {
+    -webkit-font-feature-settings: aaaaa;
+}
+
+#invalid_longer_quote {
+    -webkit-font-feature-settings: "aaaaa";
+}
+
+#invalid_negative {
+    -webkit-font-feature-settings: aaaa -1;
+}
+
+#invalid_float {
+    -webkit-font-feature-settings: aaaa 1.5;
+}
+
+#invalid_missing_comma {
+    -webkit-font-feature-settings: aaaa "bbbb";
+}
+
+#invalid_missing_comma_ident {
+    -webkit-font-feature-settings: aaaa bbbb;
+}
+
+#invalid_comma {
+    -webkit-font-feature-settings: ,;
+}
+
+#invalid_ending_comma {
+    -webkit-font-feature-settings: aaaa,;
+}
+
+#invalid_beginning_comma {
+    -webkit-font-feature-settings: ,aaaa;
+}
+
+#invalid_on {
+    -webkit-font-feature-settings: aaaa, on;
+}
+
+#invalid_0 {
+    -webkit-font-feature-settings: "aaaa" 1, "bbbb", 0;
+}
+
+#invalid_composite {
+    -webkit-font-feature-settings: aaaaa on, dlig on, PKRN -1;
+}
+</style>
+<style>
+@font-face {
+    -webkit-font-feature-settings: 'liga';
+}
+
+@font-face {
+    -webkit-font-feature-settings: aaaaa;
+}
+</style>
+</head>
+<body>
+<div id="valid_normal"></div>
+<div id="valid_value_1"></div>
+<div id="valid_value_2"></div>
+<div id="valid_value_on"></div>
+<div id="valid_value_off"></div>
+<div id="valid_value_omit"></div>
+<div id="valid_valuelist"></div>
+<div id="valid_singlequote"></div>
+<div id="valid_ident"></div>
+<div id="valid_unusual_tag"></div>
+<div id="valid_tag_space"></div>
+<div id="valid_cases"></div>
+<div id="valid_composite"></div>
+
+<div id="invalid_1"></div>
+<div id="invalid_off"></div>
+<div id="invalid_normal_duplicate"></div>
+<div id="invalid_normal_list"></div>
+<div id="invalid_longer_ident"></div>
+<div id="invalid_longer_quote"></div>
+<div id="invalid_negative"></div>
+<div id="invalid_float"></div>
+<div id="invalid_missing_comma"></div>
+<div id="invalid_missing_comma_ident"></div>
+<div id="invalid_comma"></div>
+<div id="invalid_ending_comma"></div>
+<div id="invalid_beginning_comma"></div>
+<div id="invalid_on"></div>
+<div id="invalid_0"></div>
+
+<div id="outer" style="-webkit-font-feature-settings: dlig;">
+  <div id="inner"></div>
+</div>
+
+<p id="description"></p>
+<div id="console"></div>
+<script>
+description('Test parsing of the CSS3 font-feature-settings property.');
+
+function parseResultOf(id) {
+    var element = document.getElementById(id);
+    return window.getComputedStyle(element)['-webkit-font-feature-settings'];
+}
+
+debug('- Tests valid inputs.');
+shouldBeEqualToString('parseResultOf("valid_normal")', "normal");
+shouldBeEqualToString('parseResultOf("valid_value_1")', "'dlig' 1");
+shouldBeEqualToString('parseResultOf("valid_value_2")', "'swsh' 2");
+shouldBeEqualToString('parseResultOf("valid_value_on")', "'smcp' 1");
+shouldBeEqualToString('parseResultOf("valid_value_off")', "'liga' 0");
+shouldBeEqualToString('parseResultOf("valid_value_omit")', "'c2sc' 1");
+shouldBeEqualToString('parseResultOf("valid_valuelist")', "'tnum' 1, 'hist' 1");
+shouldBeEqualToString('parseResultOf("valid_singlequote")', "'PKRN' 1");
+shouldBeEqualToString('parseResultOf("valid_ident")', "'dlig' 1");
+shouldBeEqualToString('parseResultOf("valid_unusual_tag")', "'!@#$' 1");
+shouldBeEqualToString('parseResultOf("valid_tag_space")', "'a bc' 1");
+shouldBeEqualToString('parseResultOf("valid_cases")', "'dlig' 1, 'DLIG' 1, 'DLig' 1");
+shouldBeEqualToString('parseResultOf("valid_composite")', "'dlig' 1, 'smcp' 1, 'liga' 0");
+
+debug('- Tests invalid inputs.  Results should be "normal".');
+shouldBe('parseResultOf("invalid_1")', '"normal"');
+shouldBe('parseResultOf("invalid_off")', '"normal"');
+shouldBe('parseResultOf("invalid_normal_duplicate")', '"normal"');
+shouldBe('parseResultOf("invalid_normal_list")', '"normal"');
+shouldBe('parseResultOf("invalid_longer_ident")', '"normal"');
+shouldBe('parseResultOf("invalid_longer_quote")', '"normal"');
+shouldBe('parseResultOf("invalid_negative")', '"normal"');
+shouldBe('parseResultOf("invalid_float")', '"normal"');
+shouldBe('parseResultOf("invalid_missing_comma")', '"normal"');
+shouldBe('parseResultOf("invalid_missing_comma_ident")', '"normal"');
+shouldBe('parseResultOf("invalid_comma")', '"normal"');
+shouldBe('parseResultOf("invalid_ending_comma")', '"normal"');
+shouldBe('parseResultOf("invalid_beginning_comma")', '"normal"');
+shouldBe('parseResultOf("invalid_on")', '"normal"');
+shouldBe('parseResultOf("invalid_0")', '"normal"');
+
+debug('- Tests inherit.');
+shouldBeEqualToString('parseResultOf("outer")', "'dlig' 1");
+shouldBeEqualToString('parseResultOf("inner")', "'dlig' 1");
+
+debug('- Tests @font-face.');
+var fontFaceRuleValid = document.styleSheets[2].cssRules[0].style['-webkit-font-feature-settings'];
+var fontFaceRuleInvalid = document.styleSheets[2].cssRules[1].style['-webkit-font-feature-settings'];
+shouldBeEqualToString('fontFaceRuleValid', "'liga' 1");
+shouldBeEqualToString('fontFaceRuleInvalid', "");
+
+var successfullyParsed = true;
+</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
index baf67b4..75e45c8 100644 (file)
@@ -465,6 +465,7 @@ SET(WebCore_SOURCES
     css/CSSUnicodeRangeValue.cpp
     css/CSSValueList.cpp
     css/FontFamilyValue.cpp
+    css/FontFeatureValue.cpp
     css/FontValue.cpp
     css/MediaFeatureNames.cpp
     css/MediaList.cpp
@@ -1062,6 +1063,7 @@ SET(WebCore_SOURCES
     platform/graphics/FontFallbackList.cpp
     platform/graphics/FontFamily.cpp
     platform/graphics/FontFastPath.cpp
+    platform/graphics/FontFeatureSettings.cpp
     platform/graphics/GeneratedImage.cpp
     platform/graphics/GlyphPageTreeNode.cpp
     platform/graphics/Gradient.cpp
index 6181163..95c60a6 100644 (file)
@@ -1,3 +1,63 @@
+2011-08-05  Kenichi Ishibashi  <bashi@chromium.org>
+
+        Parsing CSS3 font-feature-settings property
+        https://bugs.webkit.org/show_bug.cgi?id=63618
+
+        Introduces CSS3 font-feature-settings property as -webkit-font-feature-settings.  This change only contains parsing part.  Parsed information are stored in FontDescription class.
+
+        Reviewed by Shinichiro Hamaji.
+
+        Test: css3/font-feature-settings-parsing.html
+
+        * CMakeLists.txt: Added FontFeatureValue.{h,cpp} and FontFeatureSettings.{h,cpp}.
+        * GNUmakefile.list.am: Ditto.
+        * WebCore.gypi: Ditto.
+        * WebCore.pro: Ditto.
+        * WebCore.vcproj/WebCore.vcproj: Ditto.
+        * WebCore.xcodeproj/project.pbxproj: Ditto.
+        * css/CSSComputedStyleDeclaration.cpp:
+        (WebCore::CSSComputedStyleDeclaration::getPropertyCSSValue): Added CSSPropertyWebkitFontFeatureSettings.
+        * css/CSSParser.cpp:
+        (WebCore::CSSParser::parseValue): Added parsing code for -webkit-font-feature-settings.
+        (WebCore::CSSParser::parseFontFeatureTag): Added.
+        (WebCore::CSSParser::parseFontFeatureSettings): Added.
+        * css/CSSParser.h: Added parseFontFeatureSettings().
+        * css/CSSPropertyNames.in: Added -webkit-font-feature-settings.
+        * css/CSSStyleSelector.cpp:
+        (WebCore::CSSStyleSelector::applyDeclarations): Modified a compile assert to follow adding -webkit-font-feature-settings.
+        (WebCore::CSSStyleSelector::applyProperty): Added a case clause for CSSPropertyWebkitFontFeatureSettings.
+        * css/CSSValue.h:
+        (WebCore::CSSValue::isFontFeatureValue): Added.
+        * css/CSSValueKeywords.in: Added 'on' and 'off' keywords.
+        * css/FontFeatureValue.cpp: Added.
+        (WebCore::FontFeatureValue::FontFeatureValue):
+        (WebCore::FontFeatureValue::value):
+        (WebCore::FontFeatureValue::cssText):
+        * css/FontFeatureValue.h: Added.
+        (WebCore::FontFeatureValue::create):
+        (WebCore::FontFeatureValue::tag):
+        (WebCore::FontFeatureValue::isFontFeatureValue):
+        * platform/graphics/FontDescription.cpp:
+        (WebCore::FontDescription::makeNormalFeatureSettings): Added.
+        * platform/graphics/FontDescription.h:
+        (WebCore::FontDescription::FontDescription): Added m_featureSettings member variable.
+        (WebCore::FontDescription::featureSettings): Added.
+        (WebCore::FontDescription::setFeatureSettings): Added.
+        (WebCore::FontDescription::operator==): Modified to take into account m_featureSettings
+        * platform/graphics/FontFeatureSettings.cpp: Added.
+        (WebCore::FontFeature::FontFeature):
+        (WebCore::FontFeature::operator=):
+        (WebCore::FontFeature::operator==):
+        (WebCore::FontFeatureSettings::FontFeatureSettings):
+        * platform/graphics/FontFeatureSettings.h: Added.
+        (WebCore::FontFeature::tag):
+        (WebCore::FontFeature::value):
+        (WebCore::FontFeatureSettings::create):
+        (WebCore::FontFeatureSettings::append):
+        (WebCore::FontFeatureSettings::size):
+        (WebCore::FontFeatureSettings::operator[]):
+        (WebCore::FontFeatureSettings::at):
+
 2011-08-05  Mark Pilgrim  <pilgrim@chromium.org>
 
         Remove LegacyDefaultOptionalArguments flag from websockets
index 46e904d..5638bbc 100644 (file)
@@ -1016,6 +1016,8 @@ webcore_sources += \
        Source/WebCore/css/DashboardRegion.h \
        Source/WebCore/css/FontFamilyValue.cpp \
        Source/WebCore/css/FontFamilyValue.h \
+       Source/WebCore/css/FontFeatureValue.cpp \
+       Source/WebCore/css/FontFeatureValue.h \
        Source/WebCore/css/FontValue.cpp \
        Source/WebCore/css/FontValue.h \
        Source/WebCore/css/MediaFeatureNames.cpp \
@@ -2504,6 +2506,8 @@ webcore_sources += \
        Source/WebCore/platform/graphics/FontFamily.cpp \
        Source/WebCore/platform/graphics/FontFamily.h \
        Source/WebCore/platform/graphics/FontFastPath.cpp \
+       Source/WebCore/platform/graphics/FontFeatureSettings.cpp \
+       Source/WebCore/platform/graphics/FontFeatureSettings.h \
        Source/WebCore/platform/graphics/Font.h \
        Source/WebCore/platform/graphics/FontMetrics.h \
        Source/WebCore/platform/graphics/FontOrientation.h \
index 6932ef9..5d5b79a 100644 (file)
             'platform/graphics/FontDescription.h',
             'platform/graphics/FontFallbackList.h',
             'platform/graphics/FontFamily.h',
+            'platform/graphics/FontFeatureSettings.h',
             'platform/graphics/FontMetrics.h',
             'platform/graphics/FontOrientation.h',
             'platform/graphics/FontRenderingMode.h',
             'css/DashboardRegion.h',
             'css/FontFamilyValue.cpp',
             'css/FontFamilyValue.h',
+            'css/FontFeatureValue.cpp',
+            'css/FontFeatureValue.h',
             'css/FontValue.cpp',
             'css/FontValue.h',
             'css/MediaFeatureNames.cpp',
             'platform/graphics/FontDescription.cpp',
             'platform/graphics/FontFallbackList.cpp',
             'platform/graphics/FontFamily.cpp',
+            'platform/graphics/FontFeatureSettings.cpp',
             'platform/graphics/FontFastPath.cpp',
             'platform/graphics/FontPlatformData.cpp',
             'platform/graphics/FontPlatformData.h',
index eca801b..7008c21 100644 (file)
@@ -428,6 +428,7 @@ SOURCES += \
     css/CSSUnicodeRangeValue.cpp \
     css/CSSValueList.cpp \
     css/FontFamilyValue.cpp \
+    css/FontFeatureValue.cpp \
     css/FontValue.cpp \
     css/MediaFeatureNames.cpp \
     css/MediaList.cpp \
@@ -980,6 +981,7 @@ SOURCES += \
     platform/graphics/FontDescription.cpp \
     platform/graphics/FontFallbackList.cpp \
     platform/graphics/FontFamily.cpp \
+    platform/graphics/FontFeatureSettings.cpp \
     platform/graphics/BitmapImage.cpp \
     platform/graphics/Color.cpp \
     platform/graphics/FloatPoint3D.cpp \
@@ -1426,6 +1428,7 @@ HEADERS += \
     css/CSSUnicodeRangeValue.h \
     css/CSSValueList.h \
     css/FontFamilyValue.h \
+    css/FontFeatureValue.h \
     css/FontValue.h \
     css/MediaFeatureNames.h \
     css/MediaList.h \
@@ -1981,6 +1984,7 @@ HEADERS += \
     platform/graphics/FontData.h \
     platform/graphics/FontDescription.h \
     platform/graphics/FontFamily.h \
+    platform/graphics/FontFeatureSettings.h \
     platform/graphics/FontMetrics.h \
     platform/graphics/Font.h \
     platform/graphics/GeneratedImage.h \
index 7f3cbc8..391b2fd 100755 (executable)
                                        >
                                </File>
                                <File
+                                       RelativePath="..\platform\graphics\FontFeatureSettings.cpp"
+                                       >
+                               </File>
+                               <File
+                                       RelativePath="..\platform\graphics\FontFeatureSettings.h"
+                                       >
+                               </File>
+                               <File
                                        RelativePath="..\platform\graphics\FontFastPath.cpp"
                                        >
                                </File>
                                >
                        </File>
                        <File
+                               RelativePath="..\css\FontFeatureValue.cpp"
+                               >
+                       </File>
+                       <File
+                               RelativePath="..\css\FontFeatureValue.h"
+                               >
+                       </File>
+                       <File
                                RelativePath="..\css\FontValue.cpp"
                                >
                        </File>
index b0cacb3..a583064 100644 (file)
                49FFBF4011C93EE3006A7118 /* WebGLLayer.mm in Sources */ = {isa = PBXBuildFile; fileRef = 49FFBF3E11C93EE3006A7118 /* WebGLLayer.mm */; };
                4A0DA2FE129B241900AB61E1 /* FormAssociatedElement.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A0DA2FC129B241900AB61E1 /* FormAssociatedElement.cpp */; };
                4A0DA2FF129B241900AB61E1 /* FormAssociatedElement.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A0DA2FD129B241900AB61E1 /* FormAssociatedElement.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4A6E9FC313C17D1D0046A7F8 /* FontFeatureValue.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */; };
+               4A6E9FC413C17D1D0046A7F8 /* FontFeatureValue.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */; settings = {ATTRIBUTES = (Private, ); }; };
+               4A6E9FC713C17D570046A7F8 /* FontFeatureSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */; };
+               4A6E9FC813C17D570046A7F8 /* FontFeatureSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = 4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
                4A8C96EB0BE69032004EEFF0 /* FrameSelectionMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = 4A8C96EA0BE69032004EEFF0 /* FrameSelectionMac.mm */; };
                4ACBC0BE12713CBD0094F9B2 /* ClassList.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 4ACBC0BC12713CBD0094F9B2 /* ClassList.cpp */; };
                4ACBC0BF12713CBD0094F9B2 /* ClassList.h in Headers */ = {isa = PBXBuildFile; fileRef = 4ACBC0BD12713CBD0094F9B2 /* ClassList.h */; };
                49FFBF3E11C93EE3006A7118 /* WebGLLayer.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WebGLLayer.mm; sourceTree = "<group>"; };
                4A0DA2FC129B241900AB61E1 /* FormAssociatedElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FormAssociatedElement.cpp; sourceTree = "<group>"; };
                4A0DA2FD129B241900AB61E1 /* FormAssociatedElement.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FormAssociatedElement.h; sourceTree = "<group>"; };
+               4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFeatureValue.cpp; sourceTree = "<group>"; };
+               4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FontFeatureValue.h; sourceTree = "<group>"; };
+               4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FontFeatureSettings.cpp; sourceTree = "<group>"; };
+               4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */ = {isa = PBXFileReference; explicitFileType = sourcecode.c.h; fileEncoding = 4; path = FontFeatureSettings.h; sourceTree = "<group>"; };
                4A8C96EA0BE69032004EEFF0 /* FrameSelectionMac.mm */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = sourcecode.cpp.objcpp; name = FrameSelectionMac.mm; path = mac/FrameSelectionMac.mm; sourceTree = "<group>"; };
                4ACBC0BC12713CBD0094F9B2 /* ClassList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ClassList.cpp; sourceTree = "<group>"; };
                4ACBC0BD12713CBD0094F9B2 /* ClassList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ClassList.h; sourceTree = "<group>"; };
                                B2C3DA580D006CD600EF6F26 /* FontFamily.cpp */,
                                B2C3DA590D006CD600EF6F26 /* FontFamily.h */,
                                72626E010EF022FE00A07E20 /* FontFastPath.cpp */,
+                               4A6E9FC513C17D570046A7F8 /* FontFeatureSettings.cpp */,
+                               4A6E9FC613C17D570046A7F8 /* FontFeatureSettings.h */,
                                0845680712B90DA600960A9F /* FontMetrics.h */,
                                F7A034C3126BF6BE007DC19E /* FontOrientation.h */,
                                84B62684133138F90095A489 /* FontPlatformData.cpp */,
                                A80E6CC90A1989CA007FB8C5 /* FontFamilyValue.h */,
                                A80E6CC70A1989CA007FB8C5 /* FontValue.cpp */,
                                A80E6CC30A1989CA007FB8C5 /* FontValue.h */,
+                               4A6E9FC113C17D1D0046A7F8 /* FontFeatureValue.cpp */,
+                               4A6E9FC213C17D1D0046A7F8 /* FontFeatureValue.h */,
                                CD4E0AFA11F7BC27009D3811 /* fullscreen.css */,
                                CDBD93BA1333BD4B002570E3 /* fullscreenQuickTime.css */,
                                93CA4C9909DF93FA00DF8677 /* html.css */,
                                B2C3DA680D006CD600EF6F26 /* FontFallbackList.h in Headers */,
                                B2C3DA6A0D006CD600EF6F26 /* FontFamily.h in Headers */,
                                A80E6CF30A1989CA007FB8C5 /* FontFamilyValue.h in Headers */,
+                               4A6E9FC413C17D1D0046A7F8 /* FontFeatureValue.h in Headers */,
+                               4A6E9FC813C17D570046A7F8 /* FontFeatureSettings.h in Headers */,
                                0845680812B90DA600960A9F /* FontMetrics.h in Headers */,
                                F7A034C4126BF6BE007DC19E /* FontOrientation.h in Headers */,
                                B5320D6B122A24E9002D1440 /* FontPlatformData.h in Headers */,
                                B2C3DA690D006CD600EF6F26 /* FontFamily.cpp in Sources */,
                                A80E6CEC0A1989CA007FB8C5 /* FontFamilyValue.cpp in Sources */,
                                72626E020EF022FE00A07E20 /* FontFastPath.cpp in Sources */,
+                               4A6E9FC313C17D1D0046A7F8 /* FontFeatureValue.cpp in Sources */,
+                               4A6E9FC713C17D570046A7F8 /* FontFeatureSettings.cpp in Sources */,
                                B2AFFC800D00A5C10030074D /* FontMac.mm in Sources */,
                                84B62685133138F90095A489 /* FontPlatformData.cpp in Sources */,
                                B5320D6C122A24E9002D1440 /* FontPlatformDataCocoa.mm in Sources */,
index 5e710d7..6469f5a 100644 (file)
@@ -42,6 +42,8 @@
 #include "CSSValueList.h"
 #include "Document.h"
 #include "ExceptionCode.h"
+#include "FontFeatureSettings.h"
+#include "FontFeatureValue.h"
 #include "Rect.h"
 #include "RenderBox.h"
 #include "RenderLayer.h"
@@ -1141,6 +1143,18 @@ PassRefPtr<CSSValue> CSSComputedStyleDeclaration::getPropertyCSSValue(int proper
             }
             ASSERT_NOT_REACHED();
             return primitiveValueCache->createIdentifierValue(CSSValueNormal);
+        case CSSPropertyWebkitFontFeatureSettings: {
+            const FontFeatureSettings* featureSettings = style->fontDescription().featureSettings();
+            if (!featureSettings || !featureSettings->size())
+                return primitiveValueCache->createIdentifierValue(CSSValueNormal);
+            RefPtr<CSSValueList> list = CSSValueList::createCommaSeparated();
+            for (unsigned i = 0; i < featureSettings->size(); ++i) {
+                const FontFeature& feature = featureSettings->at(i);
+                RefPtr<FontFeatureValue> featureValue = FontFeatureValue::create(feature.tag(), feature.value());
+                list->append(featureValue.release());
+            }
+            return list.release();
+        }
         case CSSPropertyHeight:
             if (renderer)
                 return zoomAdjustedPixelValue(sizingBox(renderer).height(), style.get(), primitiveValueCache);
index 5d8fde4..c4fa911 100644 (file)
@@ -61,6 +61,7 @@
 #include "Document.h"
 #include "FloatConversion.h"
 #include "FontFamilyValue.h"
+#include "FontFeatureValue.h"
 #include "FontValue.h"
 #include "HTMLParserIdioms.h"
 #include "HashTools.h"
@@ -2084,6 +2085,12 @@ bool CSSParser::parseValue(int propId, bool important)
         else
             return parseLineBoxContain(important);
         break;
+    case CSSPropertyWebkitFontFeatureSettings:
+        if (id == CSSValueNormal)
+            validPrimitive = true;
+        else
+            return parseFontFeatureSettings(important);
+        break;
 
 #if ENABLE(CSS_EXCLUSIONS)
     case CSSPropertyWebkitWrapShape:
@@ -6302,6 +6309,67 @@ bool CSSParser::parseLineBoxContain(bool important)
     return true;
 }
 
+bool CSSParser::parseFontFeatureTag(CSSValueList* settings)
+{
+    // Feature tag name consists of 4-letter characters.
+    static const int tagNameLength = 4;
+
+    CSSParserValue* value = m_valueList->current();
+    // Feature tag name comes first
+    if (value->unit != CSSPrimitiveValue::CSS_STRING && value->unit != CSSPrimitiveValue::CSS_IDENT)
+        return false;
+    if (value->string.length != tagNameLength)
+        return false;
+    for (int i = 0; i < tagNameLength; ++i) {
+        // Limits the range of characters to 0x20-0x7E, following the tag name rules defiend in the OpenType specification.
+        UChar character = value->string.characters[i];
+        if (character < 0x20 || character > 0x7E)
+            return false;
+    }
+
+    String tag = value->string;
+    int tagValue = 1;
+    // Feature tag values could follow: <integer> | on | off
+    value = m_valueList->next();
+    if (value) {
+        if (value->unit == CSSPrimitiveValue::CSS_NUMBER && value->isInt && value->fValue >= 0) {
+            tagValue = value->fValue;
+            m_valueList->next();
+        } else if (value->id == CSSValueOn || value->id == CSSValueOff) {
+            tagValue = value->id == CSSValueOn;
+            m_valueList->next();
+        }
+    }
+    settings->append(FontFeatureValue::create(tag, tagValue));
+    return true;
+}
+
+bool CSSParser::parseFontFeatureSettings(bool important)
+{
+    if (m_valueList->size() == 1 && m_valueList->current()->id == CSSValueNormal) {
+        RefPtr<CSSPrimitiveValue> normalValue = primitiveValueCache()->createIdentifierValue(CSSValueNormal);
+        m_valueList->next();
+        addProperty(CSSPropertyWebkitFontFeatureSettings, normalValue.release(), important);
+        return true;
+    }
+
+    RefPtr<CSSValueList> settings = CSSValueList::createCommaSeparated();
+    for (CSSParserValue* value = m_valueList->current(); value; value = m_valueList->next()) {
+        if (!parseFontFeatureTag(settings.get()))
+            return false;
+
+        // If the list isn't parsed fully, the current value should be comma.
+        value = m_valueList->current();
+        if (value && !(value->unit == CSSParserValue::Operator && value->iValue == ','))
+            return false;
+    }
+    if (settings->length()) {
+        addProperty(CSSPropertyWebkitFontFeatureSettings, settings.release(), important);
+        return true;
+    }
+    return false;
+}
+
 static inline int yyerror(const char*) { return 1; }
 
 #define END_TOKEN 0
index bd1c746..109de05 100644 (file)
@@ -197,6 +197,9 @@ namespace WebCore {
 
         bool parseLineBoxContain(bool important);
 
+        bool parseFontFeatureTag(CSSValueList*);
+        bool parseFontFeatureSettings(bool important);
+
         int yyparse();
 
         CSSParserSelector* createFloatingSelector();
index d2d1e00..5bd3177 100644 (file)
@@ -20,6 +20,7 @@ font-style
 font-variant
 font-weight
 text-rendering
+-webkit-font-feature-settings
 -webkit-font-smoothing
 -webkit-locale
 -webkit-text-orientation
index 2482966..43c1b45 100644 (file)
@@ -56,6 +56,7 @@
 #include "Counter.h"
 #include "FocusController.h"
 #include "FontFamilyValue.h"
+#include "FontFeatureValue.h"
 #include "FontValue.h"
 #include "Frame.h"
 #include "FrameSelection.h"
@@ -3481,7 +3482,7 @@ void CSSStyleSelector::applyDeclarations(bool isImportant, int startIndex, int e
 
                 if (applyFirst) {
                     COMPILE_ASSERT(firstCSSProperty == CSSPropertyColor, CSS_color_is_first_property);
-                    COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 15, CSS_zoom_is_end_of_first_prop_range);
+                    COMPILE_ASSERT(CSSPropertyZoom == CSSPropertyColor + 16, CSS_zoom_is_end_of_first_prop_range);
                     COMPILE_ASSERT(CSSPropertyLineHeight == CSSPropertyZoom + 1, CSS_line_height_is_after_zoom);
 
                     // give special priority to font-xxx, color properties, etc
@@ -5081,6 +5082,32 @@ void CSSStyleSelector::applyProperty(int id, CSSValue *value)
         return;
 #endif
 
+    // CSS Fonts Module Level 3
+    case CSSPropertyWebkitFontFeatureSettings: {
+        if (primitiveValue && primitiveValue->getIdent() == CSSValueNormal) {
+            setFontDescription(m_style->fontDescription().makeNormalFeatureSettings());
+            return;
+        }
+
+        if (!value->isValueList())
+            return;
+
+        FontDescription fontDescription = m_style->fontDescription();
+        CSSValueList* list = static_cast<CSSValueList*>(value);
+        RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create();
+        int len = list->length();
+        for (int i = 0; i < len; ++i) {
+            CSSValue* item = list->itemWithoutBoundsCheck(i);
+            if (!item->isFontFeatureValue())
+                continue;
+            FontFeatureValue* feature = static_cast<FontFeatureValue*>(item);
+            settings->append(FontFeature(feature->tag(), feature->value()));
+        }
+        fontDescription.setFeatureSettings(settings.release());
+        setFontDescription(fontDescription);
+        return;
+    }
+
     // These properties are implemented in the CSSStyleApplyProperty lookup table.
     case CSSPropertyColor:
     case CSSPropertyDirection:
index 10ac35c..c535da2 100644 (file)
@@ -58,6 +58,7 @@ public:
     virtual bool isFlexValue() const { return false; }
 #endif
     virtual bool isFontFamilyValue() const { return false; }
+    virtual bool isFontFeatureValue() const { return false; }
     virtual bool isFontValue() const { return false; }
     virtual bool isImageGeneratorValue() const { return false; }
     virtual bool isImageValue() const { return false; }
index 0535b5b..06a6aa2 100644 (file)
@@ -806,6 +806,10 @@ glyphs
 inline-box
 replaced
 
+// -webkit-font-feature-settings
+on
+off
+
 // image-rendering
 //auto
 //optimizeSpeed
diff --git a/Source/WebCore/css/FontFeatureValue.cpp b/Source/WebCore/css/FontFeatureValue.cpp
new file mode 100644 (file)
index 0000000..ce684bf
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2011 Google 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 COMPUTER, 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 COMPUTER, 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 "FontFeatureValue.h"
+
+#include "CSSParser.h"
+#include "CSSValueKeywords.h"
+#include <wtf/text/StringBuilder.h>
+
+namespace WebCore {
+
+FontFeatureValue::FontFeatureValue(const String& tag, int value)
+    : m_tag(tag)
+    , m_value(value)
+{
+}
+
+String FontFeatureValue::cssText() const
+{
+    StringBuilder builder;
+    builder.append("'");
+    builder.append(m_tag);
+    builder.append("' ");
+    builder.append(String::number(m_value));
+    return builder.toString();
+}
+
+}
diff --git a/Source/WebCore/css/FontFeatureValue.h b/Source/WebCore/css/FontFeatureValue.h
new file mode 100644 (file)
index 0000000..55f4127
--- /dev/null
@@ -0,0 +1,55 @@
+/*
+ * Copyright (C) 2011 Google 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 COMPUTER, 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 COMPUTER, 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.
+ */
+
+#ifndef FontFeatureValue_h
+#define FontFeatureValue_h
+
+#include "CSSValue.h"
+#include "PlatformString.h"
+
+namespace WebCore {
+
+class FontFeatureValue : public CSSValue {
+public:
+    static PassRefPtr<FontFeatureValue> create(const String& tag, int value)
+    {
+        return adoptRef(new FontFeatureValue(tag, value));
+    }
+
+    const String& tag() const { return m_tag; }
+    int value() const { return m_value; }
+    virtual String cssText() const;
+
+private:
+    FontFeatureValue(const String&, int);
+    virtual bool isFontFeatureValue() const { return true; }
+
+    String m_tag;
+    const int m_value;
+};
+
+} // namespace
+
+#endif
index 58ddf81..46d108f 100644 (file)
@@ -98,4 +98,11 @@ FontTraitsMask FontDescription::traitsMask() const
     
 }
 
+FontDescription FontDescription::makeNormalFeatureSettings() const
+{
+    FontDescription normalDescription(*this);
+    normalDescription.setFeatureSettings(0);
+    return normalDescription;
+}
+
 } // namespace WebCore
index dd3cf3a..298176c 100644 (file)
@@ -26,6 +26,7 @@
 #define FontDescription_h
 
 #include "FontFamily.h"
+#include "FontFeatureSettings.h"
 #include "FontOrientation.h"
 #include "FontRenderingMode.h"
 #include "FontSmoothingMode.h"
@@ -35,6 +36,8 @@
 #include "TextRenderingMode.h"
 #include <wtf/MathExtras.h>
 
+#include <wtf/RefPtr.h>
+
 namespace WebCore {
 
 enum FontWeight {
@@ -116,6 +119,8 @@ public:
     FontOrientation orientation() const { return m_orientation; }
     TextOrientation textOrientation() const { return m_textOrientation; }
     FontWidthVariant widthVariant() const { return m_widthVariant; }
+    FontFeatureSettings* featureSettings() const { return m_featureSettings.get(); }
+    FontDescription makeNormalFeatureSettings() const;
 
     void setFamily(const FontFamily& family) { m_familyList = family; }
     void setComputedSize(float s) { ASSERT(isfinite(s)); m_computedSize = s; }
@@ -141,6 +146,7 @@ public:
     void setTextOrientation(TextOrientation textOrientation) { m_textOrientation = textOrientation; }
     void setWidthVariant(FontWidthVariant widthVariant) { m_widthVariant = widthVariant; }
     void setScript(UScriptCode s) { m_script = s; }
+    void setFeatureSettings(PassRefPtr<FontFeatureSettings> settings) { m_featureSettings = settings; }
 
 private:
     FontFamily m_familyList; // The list of font families to be used.
@@ -154,6 +160,8 @@ private:
 
     FontWidthVariant m_widthVariant;
 
+    RefPtr<FontFeatureSettings> m_featureSettings;
+
     unsigned m_italic : 1; // FontItalic
     unsigned m_smallCaps : 1; // FontSmallCaps
     bool m_isAbsoluteSize : 1;   // Whether or not CSS specified an explicit size
@@ -193,7 +201,8 @@ inline bool FontDescription::operator==(const FontDescription& other) const
         && m_orientation == other.m_orientation
         && m_textOrientation == other.m_textOrientation
         && m_widthVariant == other.m_widthVariant
-        && m_script == other.m_script;
+        && m_script == other.m_script
+        && m_featureSettings == other.m_featureSettings;
 }
 
 }
diff --git a/Source/WebCore/platform/graphics/FontFeatureSettings.cpp b/Source/WebCore/platform/graphics/FontFeatureSettings.cpp
new file mode 100644 (file)
index 0000000..3713322
--- /dev/null
@@ -0,0 +1,46 @@
+/*
+ * Copyright (C) 2011 Google 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 COMPUTER, 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 COMPUTER, 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 "FontFeatureSettings.h"
+
+namespace WebCore {
+
+FontFeature::FontFeature(const AtomicString& tag, int value)
+    : m_tag(tag)
+    , m_value(value)
+{
+}
+
+bool FontFeature::operator==(const FontFeature& other)
+{
+    return m_tag == other.m_tag && m_value == other.m_value;
+}
+
+FontFeatureSettings::FontFeatureSettings()
+{
+}
+
+}
diff --git a/Source/WebCore/platform/graphics/FontFeatureSettings.h b/Source/WebCore/platform/graphics/FontFeatureSettings.h
new file mode 100644 (file)
index 0000000..1bd9b33
--- /dev/null
@@ -0,0 +1,68 @@
+/*
+ * Copyright (C) 2011 Google 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 COMPUTER, 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 COMPUTER, 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.
+ */
+
+#ifndef FontFeatureSettings_h
+#define FontFeatureSettings_h
+
+#include <wtf/PassRefPtr.h>
+#include <wtf/RefCounted.h>
+#include <wtf/RefPtr.h>
+#include <wtf/Vector.h>
+#include <wtf/text/AtomicString.h>
+
+namespace WebCore {
+
+class FontFeature {
+public:
+    FontFeature(const AtomicString& tag, int value);
+    bool operator==(const FontFeature&);
+
+    const AtomicString& tag() const { return m_tag; }
+    int value() const { return m_value; }
+
+private:
+    AtomicString m_tag;
+    const int m_value;
+};
+
+class FontFeatureSettings : public RefCounted<FontFeatureSettings> {
+public:
+    static PassRefPtr<FontFeatureSettings> create()
+    {
+        return adoptRef(new FontFeatureSettings());
+    }
+    void append(const FontFeature& feature) { m_list.append(feature); }
+    size_t size() const { return m_list.size(); }
+    const FontFeature& operator[](int index) const { return m_list[index]; }
+    const FontFeature& at(size_t index) const { return m_list.at(index); }
+
+private:
+    FontFeatureSettings();
+    Vector<FontFeature> m_list;
+};
+
+}
+
+#endif // FontFeatureSettings_h