Diff
Modified: trunk/LayoutTests/ChangeLog (188055 => 188056)
--- trunk/LayoutTests/ChangeLog 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/LayoutTests/ChangeLog 2015-08-06 20:45:50 UTC (rev 188056)
@@ -1,3 +1,15 @@
+2015-08-06 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Font feature settings comparisons are order-dependent and case-dependent
+ https://bugs.webkit.org/show_bug.cgi?id=147719
+
+ Reviewed by Benjamin Poulain.
+
+ Make the test insensitive to order and case.
+
+ * css3/font-feature-settings-parsing-expected.txt:
+ * css3/font-feature-settings-parsing.html:
+
2015-08-06 Doug Russell <d_russ...@apple.com>
AX: AXLoadComplete that comes before AX API access won't fire
Modified: trunk/LayoutTests/css3/font-feature-settings-parsing-expected.txt (188055 => 188056)
--- trunk/LayoutTests/css3/font-feature-settings-parsing-expected.txt 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/LayoutTests/css3/font-feature-settings-parsing-expected.txt 2015-08-06 20:45:50 UTC (rev 188056)
@@ -4,17 +4,17 @@
- 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_unusual_tag") is "'!@#$' 1"
-PASS parseResultOf("valid_tag_space") is "'a bc' 1"
-PASS parseResultOf("valid_composite") is "'dlig' 1, 'smcp' 1, 'lig ' 0"
+PASS canonicalize(parseResultOf("valid_normal")) is "normal"
+PASS canonicalize(parseResultOf("valid_value_1")) is "'dlig' 1"
+PASS canonicalize(parseResultOf("valid_value_2")) is "'swsh' 2"
+PASS canonicalize(parseResultOf("valid_value_on")) is "'smcp' 1"
+PASS canonicalize(parseResultOf("valid_value_off")) is "'liga' 0"
+PASS canonicalize(parseResultOf("valid_value_omit")) is "'c2sc' 1"
+PASS canonicalize(parseResultOf("valid_valuelist")) is "'hist' 1, 'tnum' 1"
+PASS canonicalize(parseResultOf("valid_singlequote")) is "'pkrn' 1"
+PASS canonicalize(parseResultOf("valid_unusual_tag")) is "'!@#$' 1"
+PASS canonicalize(parseResultOf("valid_tag_space")) is "'a bc' 1"
+PASS canonicalize(parseResultOf("valid_composite")) is "'dlig' 1, 'lig ' 0, 'smcp' 1"
- Tests invalid inputs. Results should be "normal".
PASS parseResultOf("invalid_ident") is "normal"
PASS parseResultOf("invalid_cases") is "normal"
@@ -34,10 +34,10 @@
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"
+PASS canonicalize(parseResultOf("outer")) is "'dlig' 1"
+PASS canonicalize(parseResultOf("inner")) is "'dlig' 1"
- Tests @font-face.
-PASS fontFaceRuleValid is "'liga' 1"
+PASS canonicalize(fontFaceRuleValid) is "'liga' 1"
PASS fontFaceRuleInvalid is ""
PASS successfullyParsed is true
Modified: trunk/LayoutTests/css3/font-feature-settings-parsing.html (188055 => 188056)
--- trunk/LayoutTests/css3/font-feature-settings-parsing.html 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/LayoutTests/css3/font-feature-settings-parsing.html 2015-08-06 20:45:50 UTC (rev 188056)
@@ -168,23 +168,32 @@
<script>
description('Test parsing of the CSS3 font-feature-settings property.');
+function canonicalize(fontFeatureSettingsString) {
+ var pieces = fontFeatureSettingsString.split(", ");
+ var lowered = pieces.map(function(piece) {
+ return piece.toLowerCase();
+ });
+ var sorted = lowered.sort();
+ return sorted.join(", ");
+}
+
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_unusual_tag")', "'!@#$' 1");
-shouldBeEqualToString('parseResultOf("valid_tag_space")', "'a bc' 1");
-shouldBeEqualToString('parseResultOf("valid_composite")', "'dlig' 1, 'smcp' 1, 'lig ' 0");
+shouldBeEqualToString('canonicalize(parseResultOf("valid_normal"))', canonicalize("normal"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_value_1"))', canonicalize("'dlig' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_value_2"))', canonicalize("'swsh' 2"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_value_on"))', canonicalize("'smcp' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_value_off"))', canonicalize("'liga' 0"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_value_omit"))', canonicalize("'c2sc' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_valuelist"))', canonicalize("'tnum' 1, 'hist' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_singlequote"))', canonicalize("'PKRN' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_unusual_tag"))', canonicalize("'!@#$' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_tag_space"))', canonicalize("'a bc' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("valid_composite"))', canonicalize("'dlig' 1, 'smcp' 1, 'lig ' 0"));
debug('- Tests invalid inputs. Results should be "normal".');
shouldBe('parseResultOf("invalid_ident")', '"normal"');
@@ -206,13 +215,13 @@
shouldBe('parseResultOf("invalid_0")', '"normal"');
debug('- Tests inherit.');
-shouldBeEqualToString('parseResultOf("outer")', "'dlig' 1");
-shouldBeEqualToString('parseResultOf("inner")', "'dlig' 1");
+shouldBeEqualToString('canonicalize(parseResultOf("outer"))', canonicalize("'dlig' 1"));
+shouldBeEqualToString('canonicalize(parseResultOf("inner"))', canonicalize("'dlig' 1"));
debug('- Tests @font-face.');
var fontFaceRuleValid = document.styleSheets[1].cssRules[0].style['-webkit-font-feature-settings'];
var fontFaceRuleInvalid = document.styleSheets[1].cssRules[1].style['-webkit-font-feature-settings'];
-shouldBeEqualToString('fontFaceRuleValid', "'liga' 1");
+shouldBeEqualToString('canonicalize(fontFaceRuleValid)', canonicalize("'liga' 1"));
shouldBeEqualToString('fontFaceRuleInvalid', "");
</script>
Modified: trunk/Source/WebCore/ChangeLog (188055 => 188056)
--- trunk/Source/WebCore/ChangeLog 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/Source/WebCore/ChangeLog 2015-08-06 20:45:50 UTC (rev 188056)
@@ -1,3 +1,30 @@
+2015-08-06 Myles C. Maxfield <mmaxfi...@apple.com>
+
+ Font feature settings comparisons are order-dependent and case-dependent
+ https://bugs.webkit.org/show_bug.cgi?id=147719
+
+ Reviewed by Benjamin Poulain.
+
+ We should make our settings vector order-independent and case-independent.
+
+ Test: css3/font-feature-settings-parsing.html
+
+ * css/CSSParser.cpp:
+ (WebCore::CSSParser::parseFontFeatureTag):
+ * css/StyleBuilderConverter.h:
+ (WebCore::StyleBuilderConverter::convertFontFeatureSettings):
+ * platform/graphics/FontFeatureSettings.cpp:
+ (WebCore::FontFeature::FontFeature):
+ (WebCore::FontFeature::operator==):
+ (WebCore::FontFeatureSettings::FontFeatureSettings):
+ * platform/graphics/FontFeatureSettings.h:
+ (WebCore::FontFeature::FontFeature):
+ (WebCore::FontFeature::operator==):
+ (WebCore::FontFeature::operator<):
+ (WebCore::FontFeatureSettings::insert):
+ (WebCore::FontFeatureSettings::FontFeatureSettings):
+ (WebCore::FontFeatureSettings::append): Deleted.
+
2015-08-06 Doug Russell <d_russ...@apple.com>
AX: AXLoadComplete that comes before AX API access won't fire
Modified: trunk/Source/WebCore/css/CSSParser.cpp (188055 => 188056)
--- trunk/Source/WebCore/css/CSSParser.cpp 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/Source/WebCore/css/CSSParser.cpp 2015-08-06 20:45:50 UTC (rev 188056)
@@ -10378,7 +10378,7 @@
return false;
}
- String tag = value->string;
+ String tag = String(value->string).convertToASCIILowercase();
int tagValue = 1;
// Feature tag values could follow: <integer> | on | off
value = m_valueList->next();
Modified: trunk/Source/WebCore/css/StyleBuilderConverter.h (188055 => 188056)
--- trunk/Source/WebCore/css/StyleBuilderConverter.h 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/Source/WebCore/css/StyleBuilderConverter.h 2015-08-06 20:45:50 UTC (rev 188056)
@@ -1014,7 +1014,7 @@
RefPtr<FontFeatureSettings> settings = FontFeatureSettings::create();
for (auto& item : downcast<CSSValueList>(value)) {
auto& feature = downcast<CSSFontFeatureValue>(item.get());
- settings->append(FontFeature(feature.tag(), feature.value()));
+ settings->insert(FontFeature(feature.tag(), feature.value()));
}
return WTF::move(settings);
}
Modified: trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp (188055 => 188056)
--- trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/Source/WebCore/platform/graphics/FontFeatureSettings.cpp 2015-08-06 20:45:50 UTC (rev 188056)
@@ -34,13 +34,30 @@
{
}
-bool FontFeature::operator==(const FontFeature& other)
+bool FontFeature::operator==(const FontFeature& other) const
{
return m_tag == other.m_tag && m_value == other.m_value;
}
-FontFeatureSettings::FontFeatureSettings()
+bool FontFeature::operator<(const FontFeature& other) const
{
+ return (m_tag.impl() < other.m_tag.impl()) || (m_tag.impl() == other.m_tag.impl() && m_value < other.m_value);
}
+Ref<FontFeatureSettings> FontFeatureSettings::create()
+{
+ return adoptRef(*new FontFeatureSettings);
}
+
+void FontFeatureSettings::insert(FontFeature&& feature)
+{
+ // This vector will almost always have 0 or 1 items in it. Don't bother with the overhead of a binary search or a hash set.
+ size_t i;
+ for (i = 0; i < m_list.size(); ++i) {
+ if (feature < m_list[i])
+ break;
+ }
+ m_list.insert(i, WTF::move(feature));
+}
+
+}
Modified: trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h (188055 => 188056)
--- trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h 2015-08-06 20:40:35 UTC (rev 188055)
+++ trunk/Source/WebCore/platform/graphics/FontFeatureSettings.h 2015-08-06 20:45:50 UTC (rev 188056)
@@ -37,29 +37,30 @@
class FontFeature {
public:
FontFeature(const AtomicString& tag, int value);
- bool operator==(const FontFeature&);
+ bool operator==(const FontFeature& other) const;
+ bool operator<(const FontFeature& other) const;
+
const AtomicString& tag() const { return m_tag; }
int value() const { return m_value; }
private:
AtomicString m_tag;
- const int m_value;
+ const int m_value { 0 };
};
class FontFeatureSettings : public RefCounted<FontFeatureSettings> {
public:
- static Ref<FontFeatureSettings> create()
- {
- return adoptRef(*new FontFeatureSettings);
- }
- void append(const FontFeature& feature) { m_list.append(feature); }
+ static Ref<FontFeatureSettings> create();
+
+ void insert(FontFeature&&);
+
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();
+ FontFeatureSettings() { }
Vector<FontFeature> m_list;
};