From 77f5e06d8fa629774ebe4753d2bb2073edc7096b Mon Sep 17 00:00:00 2001 From: John Daggett Date: Mon, 20 May 2013 12:47:32 +0900 Subject: [PATCH] Bug 549861 - add missing files from reland patch. r=bustage --- .../css/nsIDOMCSSFontFeatureValuesRule.idl | 48 +++ gfx/thebes/gfxFontFeatures.cpp | 81 ++++ .../font-features/alternates-order-ref.html | 27 ++ .../font-features/alternates-order.html | 116 ++++++ .../font-features/annotations-ref.html | 71 ++++ .../reftests/font-features/annotations.html | 51 +++ .../font-features/font-features-order-3.html | 22 ++ .../font-features/font-features-order-4.html | 22 ++ .../font-features/font-features-order-5.html | 24 ++ .../font-features/font-kerning-1.html | 26 ++ .../font-features/font-kerning-2.html | 26 ++ .../font-features/font-kerning-3.html | 23 ++ .../font-features/font-kerning-auto.html | 23 ++ .../font-features/font-kerning-kern.html | 23 ++ .../font-features/font-kerning-nokern.html | 23 ++ .../font-features/font-kerning-none.html | 23 ++ .../font-features/font-kerning-normal.html | 23 ++ .../font-kerning-table-none.html | 24 ++ .../font-kerning-table-normal.html | 23 ++ .../font-variant-alternates-ref.html | 20 + .../font-variant-alternates.html | 20 + .../font-features/font-variant-caps-ref.html | 16 + .../font-features/font-variant-caps.html | 16 + .../font-features/font-variant-debug.html | 16 + .../font-variant-east-asian-ref.html | 16 + .../font-variant-east-asian.html | 16 + .../font-features/font-variant-features.css | 63 ++++ .../font-features/font-variant-features.js | 220 +++++++++++ .../font-variant-ligatures-ref.html | 16 + .../font-features/font-variant-ligatures.html | 16 + .../font-variant-numeric-ref.html | 16 + .../font-features/font-variant-numeric.html | 16 + .../font-variant-position-ref.html | 16 + .../font-features/font-variant-position.html | 16 + .../test_font_feature_values_parsing.html | 356 ++++++++++++++++++ 35 files changed, 1554 insertions(+) create mode 100644 dom/interfaces/css/nsIDOMCSSFontFeatureValuesRule.idl create mode 100644 gfx/thebes/gfxFontFeatures.cpp create mode 100644 layout/reftests/font-features/alternates-order-ref.html create mode 100644 layout/reftests/font-features/alternates-order.html create mode 100644 layout/reftests/font-features/annotations-ref.html create mode 100644 layout/reftests/font-features/annotations.html create mode 100644 layout/reftests/font-features/font-features-order-3.html create mode 100644 layout/reftests/font-features/font-features-order-4.html create mode 100644 layout/reftests/font-features/font-features-order-5.html create mode 100644 layout/reftests/font-features/font-kerning-1.html create mode 100644 layout/reftests/font-features/font-kerning-2.html create mode 100644 layout/reftests/font-features/font-kerning-3.html create mode 100644 layout/reftests/font-features/font-kerning-auto.html create mode 100644 layout/reftests/font-features/font-kerning-kern.html create mode 100644 layout/reftests/font-features/font-kerning-nokern.html create mode 100644 layout/reftests/font-features/font-kerning-none.html create mode 100644 layout/reftests/font-features/font-kerning-normal.html create mode 100644 layout/reftests/font-features/font-kerning-table-none.html create mode 100644 layout/reftests/font-features/font-kerning-table-normal.html create mode 100644 layout/reftests/font-features/font-variant-alternates-ref.html create mode 100644 layout/reftests/font-features/font-variant-alternates.html create mode 100644 layout/reftests/font-features/font-variant-caps-ref.html create mode 100644 layout/reftests/font-features/font-variant-caps.html create mode 100644 layout/reftests/font-features/font-variant-debug.html create mode 100644 layout/reftests/font-features/font-variant-east-asian-ref.html create mode 100644 layout/reftests/font-features/font-variant-east-asian.html create mode 100644 layout/reftests/font-features/font-variant-features.css create mode 100644 layout/reftests/font-features/font-variant-features.js create mode 100644 layout/reftests/font-features/font-variant-ligatures-ref.html create mode 100644 layout/reftests/font-features/font-variant-ligatures.html create mode 100644 layout/reftests/font-features/font-variant-numeric-ref.html create mode 100644 layout/reftests/font-features/font-variant-numeric.html create mode 100644 layout/reftests/font-features/font-variant-position-ref.html create mode 100644 layout/reftests/font-features/font-variant-position.html create mode 100644 layout/style/test/test_font_feature_values_parsing.html diff --git a/dom/interfaces/css/nsIDOMCSSFontFeatureValuesRule.idl b/dom/interfaces/css/nsIDOMCSSFontFeatureValuesRule.idl new file mode 100644 index 000000000000..1347d5a1c386 --- /dev/null +++ b/dom/interfaces/css/nsIDOMCSSFontFeatureValuesRule.idl @@ -0,0 +1,48 @@ +/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ +/* ***** BEGIN LICENSE BLOCK ***** + * Version: MPL 1.1/GPL 2.0/LGPL 2.1 + * + * The contents of this file are subject to the Mozilla Public License Version + * 1.1 (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at + * http://www.mozilla.org/MPL/ + * + * Software distributed under the License is distributed on an "AS IS" basis, + * WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License + * for the specific language governing rights and limitations under the + * License. + * + * The Original Code is mozilla.org code. + * + * The Initial Developer of the Original Code is the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2004 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * John Daggett (original author) + * + * Alternatively, the contents of this file may be used under the terms of + * either the GNU General Public License Version 2 or later (the "GPL"), or + * the GNU Lesser General Public License Version 2.1 or later (the "LGPL"), + * in which case the provisions of the GPL or the LGPL are applicable instead + * of those above. If you wish to allow use of your version of this file only + * under the terms of either the GPL or the LGPL, and not to allow others to + * use your version of this file under the terms of the MPL, indicate your + * decision by deleting the provisions above and replace them with the notice + * and other provisions required by the GPL or the LGPL. If you do not delete + * the provisions above, a recipient may use your version of this file under + * the terms of any one of the MPL, the GPL or the LGPL. + * + * ***** END LICENSE BLOCK ***** */ + +#include "nsIDOMCSSRule.idl" + +[scriptable, uuid(f4cb1776-389d-4f52-a4d8-68bea5bd00c1)] +interface nsIDOMCSSFontFeatureValuesRule : nsIDOMCSSRule +{ + attribute DOMString fontFamily; + // raises(DOMException) on setting + + attribute DOMString valueText; + // raises(DOMException) on setting +}; diff --git a/gfx/thebes/gfxFontFeatures.cpp b/gfx/thebes/gfxFontFeatures.cpp new file mode 100644 index 000000000000..55e866eab3f1 --- /dev/null +++ b/gfx/thebes/gfxFontFeatures.cpp @@ -0,0 +1,81 @@ +/* -*- Mode: C++; tab-width: 20; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * This Source Code Form is subject to the terms of the Mozilla Public + * License, v. 2.0. If a copy of the MPL was not distributed with this + * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ + +#include "gfxFontFeatures.h" +#include "nsUnicharUtils.h" +#include "nsHashKeys.h" + +using namespace mozilla; + +gfxFontFeatureValueSet::gfxFontFeatureValueSet() +{ + mFontFeatureValues.Init(10); +} + +bool +gfxFontFeatureValueSet::GetFontFeatureValuesFor(const nsAString& aFamily, + uint32_t aVariantProperty, + const nsAString& aName, + nsTArray& aValues) +{ + nsAutoString family(aFamily), name(aName); + ToLowerCase(family); + ToLowerCase(name); + FeatureValueHashKey key(family, aVariantProperty, name); + + aValues.Clear(); + FeatureValueHashEntry *entry = mFontFeatureValues.GetEntry(key); + if (entry) { + NS_ASSERTION(entry->mValues.Length() > 0, + "null array of font feature values"); + aValues.AppendElements(entry->mValues); + return true; + } + + return false; +} + + +void +gfxFontFeatureValueSet::AddFontFeatureValues(const nsAString& aFamily, + const nsTArray& aValues) +{ + nsAutoString family(aFamily); + ToLowerCase(family); + + uint32_t i, numFeatureValues = aValues.Length(); + for (i = 0; i < numFeatureValues; i++) { + const FeatureValues& fv = aValues.ElementAt(i); + uint32_t alternate = fv.alternate; + uint32_t j, numValues = fv.valuelist.Length(); + for (j = 0; j < numValues; j++) { + const ValueList& v = fv.valuelist.ElementAt(j); + nsAutoString name(v.name); + ToLowerCase(name); + FeatureValueHashKey key(family, alternate, name); + FeatureValueHashEntry *entry = mFontFeatureValues.PutEntry(key); + entry->mKey = key; + entry->mValues = v.featureSelectors; + } + } +} + +bool +gfxFontFeatureValueSet::FeatureValueHashEntry::KeyEquals( + const KeyTypePointer aKey) const +{ + return aKey->mPropVal == mKey.mPropVal && + aKey->mFamily.Equals(mKey.mFamily) && + aKey->mName.Equals(mKey.mName); +} + +PLDHashNumber +gfxFontFeatureValueSet::FeatureValueHashEntry::HashKey( + const KeyTypePointer aKey) +{ + return HashString(aKey->mFamily) + HashString(aKey->mName) + + aKey->mPropVal * uint32_t(0xdeadbeef); +} + diff --git a/layout/reftests/font-features/alternates-order-ref.html b/layout/reftests/font-features/alternates-order-ref.html new file mode 100644 index 000000000000..a235981072c9 --- /dev/null +++ b/layout/reftests/font-features/alternates-order-ref.html @@ -0,0 +1,27 @@ + + + + + + +
W W W
+
W W W
+
W W W
+ + diff --git a/layout/reftests/font-features/alternates-order.html b/layout/reftests/font-features/alternates-order.html new file mode 100644 index 000000000000..c20c15df97f2 --- /dev/null +++ b/layout/reftests/font-features/alternates-order.html @@ -0,0 +1,116 @@ + + + + + + +
W W W
+
W W W
+
W W W
+ + diff --git a/layout/reftests/font-features/annotations-ref.html b/layout/reftests/font-features/annotations-ref.html new file mode 100644 index 000000000000..c3418bfd642f --- /dev/null +++ b/layout/reftests/font-features/annotations-ref.html @@ -0,0 +1,71 @@ + + + +Annotations test + + + + + + +
1 2 3
+ + \ No newline at end of file diff --git a/layout/reftests/font-features/annotations.html b/layout/reftests/font-features/annotations.html new file mode 100644 index 000000000000..24574cf54beb --- /dev/null +++ b/layout/reftests/font-features/annotations.html @@ -0,0 +1,51 @@ + + + +Annotations test + + + + + + +
1 2 3
+ + \ No newline at end of file diff --git a/layout/reftests/font-features/font-features-order-3.html b/layout/reftests/font-features/font-features-order-3.html new file mode 100644 index 000000000000..8b70771be87e --- /dev/null +++ b/layout/reftests/font-features/font-features-order-3.html @@ -0,0 +1,22 @@ + + + + + + +fastest firefox + + diff --git a/layout/reftests/font-features/font-features-order-4.html b/layout/reftests/font-features/font-features-order-4.html new file mode 100644 index 000000000000..b8656e2d97bf --- /dev/null +++ b/layout/reftests/font-features/font-features-order-4.html @@ -0,0 +1,22 @@ + + + + + + +fastest firefox + + diff --git a/layout/reftests/font-features/font-features-order-5.html b/layout/reftests/font-features/font-features-order-5.html new file mode 100644 index 000000000000..52a8f0ba7f96 --- /dev/null +++ b/layout/reftests/font-features/font-features-order-5.html @@ -0,0 +1,24 @@ + + + + + + +fastest firefox + + diff --git a/layout/reftests/font-features/font-kerning-1.html b/layout/reftests/font-features/font-kerning-1.html new file mode 100644 index 000000000000..a8450644fb28 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-1.html @@ -0,0 +1,26 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-2.html b/layout/reftests/font-features/font-kerning-2.html new file mode 100644 index 000000000000..1c230d28a5fd --- /dev/null +++ b/layout/reftests/font-features/font-kerning-2.html @@ -0,0 +1,26 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-3.html b/layout/reftests/font-features/font-kerning-3.html new file mode 100644 index 000000000000..86208f041648 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-3.html @@ -0,0 +1,23 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-auto.html b/layout/reftests/font-features/font-kerning-auto.html new file mode 100644 index 000000000000..4be9251b0e08 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-auto.html @@ -0,0 +1,23 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-kern.html b/layout/reftests/font-features/font-kerning-kern.html new file mode 100644 index 000000000000..a37ca038a5f5 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-kern.html @@ -0,0 +1,23 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-nokern.html b/layout/reftests/font-features/font-kerning-nokern.html new file mode 100644 index 000000000000..87044b89b285 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-nokern.html @@ -0,0 +1,23 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-none.html b/layout/reftests/font-features/font-kerning-none.html new file mode 100644 index 000000000000..b8e66c07caf9 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-none.html @@ -0,0 +1,23 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-normal.html b/layout/reftests/font-features/font-kerning-normal.html new file mode 100644 index 000000000000..c368f016b1bd --- /dev/null +++ b/layout/reftests/font-features/font-kerning-normal.html @@ -0,0 +1,23 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-table-none.html b/layout/reftests/font-features/font-kerning-table-none.html new file mode 100644 index 000000000000..81ce583324b7 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-table-none.html @@ -0,0 +1,24 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-kerning-table-normal.html b/layout/reftests/font-features/font-kerning-table-normal.html new file mode 100644 index 000000000000..fe1ad57e89d9 --- /dev/null +++ b/layout/reftests/font-features/font-kerning-table-normal.html @@ -0,0 +1,23 @@ + + + + + + +
Ta To
+
AVA
+
AWAY
+ + diff --git a/layout/reftests/font-features/font-variant-alternates-ref.html b/layout/reftests/font-features/font-variant-alternates-ref.html new file mode 100644 index 000000000000..cd3dd4da6532 --- /dev/null +++ b/layout/reftests/font-features/font-variant-alternates-ref.html @@ -0,0 +1,20 @@ + + + +font-variant-alternates test + + + + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-alternates.html b/layout/reftests/font-features/font-variant-alternates.html new file mode 100644 index 000000000000..49653055163b --- /dev/null +++ b/layout/reftests/font-features/font-variant-alternates.html @@ -0,0 +1,20 @@ + + + +font-variant-alternates test + + + + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-caps-ref.html b/layout/reftests/font-features/font-variant-caps-ref.html new file mode 100644 index 000000000000..1eacf1bf6074 --- /dev/null +++ b/layout/reftests/font-features/font-variant-caps-ref.html @@ -0,0 +1,16 @@ + + + +font-variant-caps test + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-caps.html b/layout/reftests/font-features/font-variant-caps.html new file mode 100644 index 000000000000..7fa6bf94b10e --- /dev/null +++ b/layout/reftests/font-features/font-variant-caps.html @@ -0,0 +1,16 @@ + + + +font-variant-caps test + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-debug.html b/layout/reftests/font-features/font-variant-debug.html new file mode 100644 index 000000000000..9a3953bde489 --- /dev/null +++ b/layout/reftests/font-features/font-variant-debug.html @@ -0,0 +1,16 @@ + + + +font-variant test + + + + + + +
+ + + \ No newline at end of file diff --git a/layout/reftests/font-features/font-variant-east-asian-ref.html b/layout/reftests/font-features/font-variant-east-asian-ref.html new file mode 100644 index 000000000000..be2def6d9a76 --- /dev/null +++ b/layout/reftests/font-features/font-variant-east-asian-ref.html @@ -0,0 +1,16 @@ + + + +font-variant-east-asian test + + + + + + +
+ + + \ No newline at end of file diff --git a/layout/reftests/font-features/font-variant-east-asian.html b/layout/reftests/font-features/font-variant-east-asian.html new file mode 100644 index 000000000000..15578245a7de --- /dev/null +++ b/layout/reftests/font-features/font-variant-east-asian.html @@ -0,0 +1,16 @@ + + + +font-variant-east-asian test + + + + + + +
+ + + \ No newline at end of file diff --git a/layout/reftests/font-features/font-variant-features.css b/layout/reftests/font-features/font-variant-features.css new file mode 100644 index 000000000000..6b7915da0979 --- /dev/null +++ b/layout/reftests/font-features/font-variant-features.css @@ -0,0 +1,63 @@ +body { margin: 10px; } + +@font-face { + font-family: gsub-test; + src: url(../fonts/gsubtest/gsubtest-lookup3.otf); +} + +td.prop { + font-family: Menlo, monospace; + font-weight: normal; + text-align: left; + font-size: 80%; +} + +td.features { + font-family: gsub-test; +} + +.invalid { + color: red; +} + +@font-feature-values gsub-test { + @styleset { ok-alt-a: 1 3 5; ok-alt-b: 19; } + @character-variant { ok-1: 78 2; } + @character-variant { ok-3: 23; } + @character-variant { not-good: 0 2; } + @annotation { ok-4: 1; } + @annotation { bogus-font-doesnt-support: 23; } + @annotation { circled: 1; } + @character-variant { multi-def: 4; } + @annotation { multi-def: 3; } + @styleset { multi-def2: 3 4 5; } + @styleset { MULTI-def2: 2 6; } + @styleset { out-of-bounds1: 0; out-of-bounds2: 100; } +} + +@font-feature-values bogus-family { + @styleset { bogus: 3 4 7; } +} + +@font-feature-values GSUB-tEsT { + @styleset { mixed-case: 3 4 7; } +} + +@font-feature-values gSuB-tEsT { + @styleset { 3blah: 1 3; } +} + +@font-feature-values gSuB-tEsT { + @styleset { moxie: 14; } + @styleset { 3blah: 1; } +} + +@font-feature-values gSUB-TeST { + @styleset { moxie2: 14; } + @bongo { blah: 1; } +} + +@font-feature-values gSUB-TEst { + @bongo { blah2: 1; } + @styleset { moxie3: 14; } +} diff --git a/layout/reftests/font-features/font-variant-features.js b/layout/reftests/font-features/font-variant-features.js new file mode 100644 index 000000000000..53167cd2931b --- /dev/null +++ b/layout/reftests/font-features/font-variant-features.js @@ -0,0 +1,220 @@ + +// data associated with gsubtest test font for testing font features + +// prefix +gPrefix = ""; + +// equivalent properties +// setting prop: value should match the specific feature settings listed +// +// each of these tests evaluate whether a given feature is enabled as required +// and also whether features that shouldn't be enabled are or not. +var gPropertyData = [ + // font-variant-caps + // valid values + { prop: "font-variant-caps", value: "normal", features: {"smcp": 0} }, + { prop: "font-variant-caps", value: "small-caps", features: {"smcp": 1, "c2sc": 0} }, + { prop: "font-variant-caps", value: "all-small-caps", features: {"smcp": 1, "c2sc": 1, "pcap": 0} }, + { prop: "font-variant-caps", value: "petite-caps", features: {"pcap": 1, "smcp": 0} }, + { prop: "font-variant-caps", value: "all-petite-caps", features: {"c2pc": 1, "pcap": 1, "smcp": 0} }, + { prop: "font-variant-caps", value: "titling-caps", features: {"titl": 1, "smcp": 0} }, + { prop: "font-variant-caps", value: "unicase", features: {"unic": 1, "titl": 0} }, + + // invalid values + { prop: "font-variant-caps", value: "normal small-caps", features: {"smcp": 0}, invalid: true }, + { prop: "font-variant-caps", value: "small-caps potato", features: {"smcp": 0}, invalid: true }, + { prop: "font-variant-caps", value: "small-caps petite-caps", features: {"smcp": 0, "pcap": 0}, invalid: true }, + { prop: "font-variant-caps", value: "small-caps all-small-caps", features: {"smcp": 0, "c2sc": 0}, invalid: true }, + { prop: "font-variant-caps", value: "small-cap", features: {"smcp": 0}, invalid: true }, + + // font-variant-east-asian + // valid values + { prop: "font-variant-east-asian", value: "jis78", features: {"jp78": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "jis83", features: {"jp83": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "jis90", features: {"jp90": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "jis04", features: {"jp04": 1, "jp78": 0} }, + { prop: "font-variant-east-asian", value: "simplified", features: {"smpl": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "traditional", features: {"trad": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "full-width", features: {"fwid": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "proportional-width", features: {"pwid": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "ruby", features: {"ruby": 1, "jp04": 0} }, + { prop: "font-variant-east-asian", value: "jis78 full-width", features: {"jp78": 1, "fwid": 1, "jp83": 0} }, + { prop: "font-variant-east-asian", value: "jis78 full-width ruby", features: {"jp78": 1, "fwid": 1, "jp83": 0, "ruby": 1} }, + { prop: "font-variant-east-asian", value: "simplified proportional-width", features: {"smpl": 1, "pwid": 1, "jp83": 0} }, + { prop: "font-variant-east-asian", value: "ruby simplified", features: {"ruby": 1, "smpl": 1, "trad": 0} }, + + // invalid values + { prop: "font-variant-east-asian", value: "ruby normal", features: {"ruby": 0}, invalid: true }, + { prop: "font-variant-east-asian", value: "jis90 jis04", features: {"jp90": 0, "jp04": 0}, invalid: true }, + { prop: "font-variant-east-asian", value: "simplified traditional", features: {"smpl": 0, "trad": 0}, invalid: true }, + { prop: "font-variant-east-asian", value: "full-width proportional-width", features: {"fwid": 0, "pwid": 0}, invalid: true }, + { prop: "font-variant-east-asian", value: "ruby simplified ruby", features: {"ruby": 0, "smpl": 0, "jp04": 0}, invalid: true }, + { prop: "font-variant-east-asian", value: "jis78 ruby simplified", features: {"ruby": 0, "smpl": 0, "jp78": 0}, invalid: true }, + + // font-variant-ligatures + // valid values + { prop: "font-variant-ligatures", value: "normal", features: {"liga": 1, "dlig": 0} }, + { prop: "font-variant-ligatures", value: "common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "no-common-ligatures", features: {"liga": 0, "clig": 0, "dlig": 0, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "discretionary-ligatures", features: {"liga": 1, "clig": 1, "dlig": 1, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "no-discretionary-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "historical-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 1, "calt": 1} }, + { prop: "font-variant-ligatures", value: "no-historical-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "contextual", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "no-contextual", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0, "calt": 0} }, + { prop: "font-variant-ligatures", value: "common-ligatures no-discretionary-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "historical-ligatures no-common-ligatures", features: {"clig": 0, "liga": 0, "dlig": 0, "hlig": 1, "calt": 1} }, + { prop: "font-variant-ligatures", value: "no-historical-ligatures discretionary-ligatures", features: {"liga": 1, "clig": 1, "dlig": 1, "hlig": 0, "calt": 1} }, + { prop: "font-variant-ligatures", value: "common-ligatures no-discretionary-ligatures historical-ligatures no-contextual", features: {"clig": 1, "dlig": 0, "hlig": 1, "liga": 1, "calt": 0} }, + + // invalid values + { prop: "font-variant-ligatures", value: "common-ligatures normal", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, + { prop: "font-variant-ligatures", value: "common-ligatures no-common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, + { prop: "font-variant-ligatures", value: "common-ligatures common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, + { prop: "font-variant-ligatures", value: "no-historical-ligatures historical-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0}, invalid: true }, + { prop: "font-variant-ligatures", value: "no-contextual contextual", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0}, invalid: true }, + { prop: "font-variant-ligatures", value: "no-discretionary-ligatures discretionary-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, + { prop: "font-variant-ligatures", value: "common-ligatures no-discretionary-ligatures no-common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0}, invalid: true }, + + // font-variant-numeric + // valid values + { prop: "font-variant-numeric", value: "normal", features: {"lnum": 0, "tnum": 0, "pnum": 0, "onum": 0} }, + { prop: "font-variant-numeric", value: "lining-nums", features: {"lnum": 1, "onum": 0, "pnum": 0} }, + { prop: "font-variant-numeric", value: "oldstyle-nums", features: {"lnum": 0, "onum": 1, "pnum": 0} }, + { prop: "font-variant-numeric", value: "proportional-nums", features: {"lnum": 0, "onum": 0, "pnum": 1, "tnum": 0} }, + { prop: "font-variant-numeric", value: "proportional-nums oldstyle-nums", features: {"lnum": 0, "onum": 1, "pnum": 1, "tnum": 0} }, + { prop: "font-variant-numeric", value: "tabular-nums", features: {"tnum": 1, "onum": 0, "pnum": 0} }, + { prop: "font-variant-numeric", value: "diagonal-fractions", features: {"frac": 1, "afrc": 0, "pnum": 0} }, + { prop: "font-variant-numeric", value: "stacked-fractions", features: {"frac": 0, "afrc": 1, "pnum": 0} }, + { prop: "font-variant-numeric", value: "slashed-zero", features: {"zero": 1, "pnum": 0} }, + { prop: "font-variant-numeric", value: "ordinal", features: {"ordn": 1, "pnum": 0} }, + { prop: "font-variant-numeric", value: "lining-nums diagonal-fractions", features: {"frac": 1, "afrc": 0, "lnum": 1} }, + { prop: "font-variant-numeric", value: "tabular-nums stacked-fractions", features: {"frac": 0, "afrc": 1, "tnum": 1} }, + { prop: "font-variant-numeric", value: "tabular-nums slashed-zero stacked-fractions", features: {"frac": 0, "afrc": 1, "tnum": 1, "zero": 1} }, + { prop: "font-variant-numeric", value: "proportional-nums slashed-zero diagonal-fractions oldstyle-nums ordinal", features: {"frac": 1, "afrc": 0, "tnum": 0, "pnum": 1, "onum": 1, "ordn": 1, "zero": 1} }, + + // invalid values + { prop: "font-variant-numeric", value: "lining-nums normal", features: {"lnum": 0, "onum": 0}, invalid: true }, + { prop: "font-variant-numeric", value: "lining-nums oldstyle-nums", features: {"lnum": 0, "onum": 0}, invalid: true }, + { prop: "font-variant-numeric", value: "lining-nums normal slashed-zero ordinal", features: {"lnum": 0, "onum": 0, "zero": 0}, invalid: true }, + { prop: "font-variant-numeric", value: "proportional-nums tabular-nums", features: {"pnum": 0, "tnum": 0}, invalid: true }, + { prop: "font-variant-numeric", value: "diagonal-fractions stacked-fractions", features: {"frac": 0, "afrc": 0}, invalid: true }, + { prop: "font-variant-numeric", value: "slashed-zero diagonal-fractions slashed-zero", features: {"frac": 0, "afrc": 0, "zero": 0}, invalid: true }, + { prop: "font-variant-numeric", value: "lining-nums slashed-zero diagonal-fractions oldstyle-nums", features: {"frac": 0, "afrc": 0, "zero": 0, "onum": 0}, invalid: true }, + + // font-variant-position + // valid values + { prop: "font-variant-position", value: "normal", features: {"subs": 0, "sups": 0} }, + { prop: "font-variant-position", value: "super", features: {"subs": 0, "sups": 1} }, + { prop: "font-variant-position", value: "sub", features: {"subs": 1, "sups": 0} }, + + // invalid values + { prop: "font-variant-position", value: "super sub", features: {"subs": 0, "sups": 0}, invalid: true }, +]; + +// note: the code below requires an array "gFeatures" from : +// layout/reftests/fonts/gsubtest/gsubtest-features.js + +// The font defines feature lookups for all OpenType features for a +// specific set of PUA codepoints, as listed in the gFeatures array. +// Using these codepoints and feature combinations, tests can be +// constructed to detect when certain features are enabled or not. + +// return a created table containing tests for a given property +// +// Ex: { prop: "font-variant-ligatures", value: "common-ligatures", features: {"liga": 1, "clig": 1, "dlig": 0, "hlig": 0} } +// +// This means that for the property 'font-variant-ligatures' with the value 'common-ligatures', the features listed should +// either be explicitly enabled or disabled. + +// propData is the prop/value list with corresponding feature assertions +// whichProp is either "all" or a specific subproperty (i.e. "font-variant-position") +// isRef is true when this is the reference +// debug outputs the prop/value pair along with the tests + +function createFeatureTestTable(propData, whichProp, isRef, debug) +{ + var table = document.createElement("table"); + + if (typeof(isRef) == "undefined") { + isRef = false; + } + + if (typeof(debug) == "undefined") { + debug = false; + } + + var doAll = (whichProp == "all"); + for (var i in propData) { + var data = propData[i]; + + if (!doAll && data.prop != whichProp) continue; + + var row = document.createElement("tr"); + var invalid = false; + if ("invalid" in data) { + invalid = true; + row.className = "invalid"; + } + + var cell = document.createElement("td"); + cell.className = "prop"; + var styledecl = gPrefix + data.prop + ": " + data.value + ";"; + cell.innerHTML = styledecl; + row.appendChild(cell); + if (debug) { + table.appendChild(row); + } + + row = document.createElement("tr"); + if (invalid) { + row.className = "invalid"; + } + + cell = document.createElement("td"); + cell.className = "features"; + if (!isRef) { + cell.style.cssText = styledecl; + } + + for (var f in data.features) { + var feature = data.features[f]; + + var cp, unsupported = "F".charCodeAt(0); + var basecp = gFeatures[f]; + + if (typeof(basecp) == "undefined") { + cp = unsupported; + } else { + switch(feature) { + case 0: + cp = basecp; + break; + case 1: + cp = basecp + 1; + break; + case 2: + cp = basecp + 2; + break; + case 3: + cp = basecp + 3; + break; + default: + cp = basecp + 1; + break; + } + } + + var span = document.createElement("span"); + span.innerHTML = (isRef ? "P " : "&#x" + cp.toString(16) + "; "); + span.title = f + "=" + feature; + cell.appendChild(span); + } + row.appendChild(cell); + table.appendChild(row); + } + + return table; +} + + diff --git a/layout/reftests/font-features/font-variant-ligatures-ref.html b/layout/reftests/font-features/font-variant-ligatures-ref.html new file mode 100644 index 000000000000..525f8d50b29f --- /dev/null +++ b/layout/reftests/font-features/font-variant-ligatures-ref.html @@ -0,0 +1,16 @@ + + + +font-variant-ligatures test + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-ligatures.html b/layout/reftests/font-features/font-variant-ligatures.html new file mode 100644 index 000000000000..7547c48c6338 --- /dev/null +++ b/layout/reftests/font-features/font-variant-ligatures.html @@ -0,0 +1,16 @@ + + + +font-variant-ligatures test + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-numeric-ref.html b/layout/reftests/font-features/font-variant-numeric-ref.html new file mode 100644 index 000000000000..795216b24b73 --- /dev/null +++ b/layout/reftests/font-features/font-variant-numeric-ref.html @@ -0,0 +1,16 @@ + + + +font-variant-numeric test + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-numeric.html b/layout/reftests/font-features/font-variant-numeric.html new file mode 100644 index 000000000000..5d40163bacf9 --- /dev/null +++ b/layout/reftests/font-features/font-variant-numeric.html @@ -0,0 +1,16 @@ + + + +font-variant-numeric test + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-position-ref.html b/layout/reftests/font-features/font-variant-position-ref.html new file mode 100644 index 000000000000..aaf18aec6fe8 --- /dev/null +++ b/layout/reftests/font-features/font-variant-position-ref.html @@ -0,0 +1,16 @@ + + + +font-variant-position test + + + + + + +
+ + + diff --git a/layout/reftests/font-features/font-variant-position.html b/layout/reftests/font-features/font-variant-position.html new file mode 100644 index 000000000000..f0d63ddb949f --- /dev/null +++ b/layout/reftests/font-features/font-variant-position.html @@ -0,0 +1,16 @@ + + + +font-variant-position test + + + + + + +
+ + + diff --git a/layout/style/test/test_font_feature_values_parsing.html b/layout/style/test/test_font_feature_values_parsing.html new file mode 100644 index 000000000000..a5d4a6834062 --- /dev/null +++ b/layout/style/test/test_font_feature_values_parsing.html @@ -0,0 +1,356 @@ + + + + + @font-feature-values rule parsing tests + + + + + + + + + +
+

+
+
+
+