Diff
Modified: trunk/LayoutTests/ChangeLog (196603 => 196604)
--- trunk/LayoutTests/ChangeLog 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/ChangeLog 2016-02-15 23:39:02 UTC (rev 196604)
@@ -1,3 +1,20 @@
+2016-02-15 Myles C. Maxfield <[email protected]>
+
+ [Font Loading] Implement FontFace _javascript_ object
+ https://bugs.webkit.org/show_bug.cgi?id=153345
+
+ Reviewed by Antti Koivisto.
+
+ * fast/text/font-face-_javascript_-expected.txt: Added.
+ * fast/text/font-face-_javascript_.html: Added.
+ * js/dom/global-constructors-attributes-expected.txt:
+ * platform/efl/js/dom/global-constructors-attributes-expected.txt:
+ * platform/gtk/js/dom/global-constructors-attributes-expected.txt:
+ * platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt:
+ * platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt:
+ * platform/mac/js/dom/global-constructors-attributes-expected.txt:
+ * platform/win/js/dom/global-constructors-attributes-expected.txt:
+
2016-02-15 Chris Dumez <[email protected]>
XMLHttpRequest / XMLHttpRequestUpload should inherit XMLHttpRequestEventTarget
Added: trunk/LayoutTests/fast/text/font-face-_javascript_-expected.txt (0 => 196604)
--- trunk/LayoutTests/fast/text/font-face-_javascript_-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-_javascript_-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -0,0 +1,54 @@
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).family is "family_name"
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).style is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).weight is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).stretch is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).unicodeRange is "U+0-10FFFF"
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).variant is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).featureSettings is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'style': 'normal'}).style is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'style': 'inherit'}).style threw exception Error: SyntaxError: DOM Exception 12.
+PASS new FontFace('family_name', 'url(\'asdf\')', {'style': 'italic'}).style is "italic"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'style': 'oblique'}).style is "italic"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'style': 'asdf'}) threw exception Error: SyntaxError: DOM Exception 12.
+PASS new FontFace('family_name', 'url(\'asdf\')', {'weight': 'normal'}).weight is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'weight': '200'}).weight is "200"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'weight': 'bold'}).weight is "bold"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'weight': 'bolder'}).weight is "bold"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'weight': 'lighter'}).weight is "200"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'weight': 'inherit'}).weight threw exception Error: SyntaxError: DOM Exception 12.
+PASS new FontFace('family_name', 'url(\'asdf\')', {'stretch': 'stretch_name'}).stretch is "normal"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'unicodeRange': 'U+26'}).unicodeRange is "U+26-26"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'unicodeRange': 'U+0-7F'}).unicodeRange is "U+0-7f"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'variant': 'variant_name'}).variant threw exception Error: SyntaxError: DOM Exception 12.
+PASS new FontFace('family_name', 'url(\'asdf\')', {'variant': 'small-caps'}).variant is "small-caps"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'variant': 'small-caps common-ligatures'}).variant is "common-ligatures small-caps"
+PASS new FontFace('family_name', 'url(\'asdf\')', {'featureSettings': '\'titl\''}).featureSettings is "'titl' 1"
+PASS everything.style is "italic"
+PASS everything.weight is "bold"
+PASS everything.stretch is "normal"
+PASS everything.unicodeRange is "U+26-26"
+PASS everything.variant is "small-caps"
+PASS everything.featureSettings is "'titl' 1"
+PASS everything.family is "other_family_name"
+PASS everything.style is "normal"
+PASS everything.weight is "300"
+PASS everything.stretch is "normal"
+PASS everything.unicodeRange is "U+0-7f"
+PASS everything.variant is "stacked-fractions"
+PASS everything.featureSettings is "'smcp' 1"
+PASS new FontFace('family_name', 'url(\'asdf\')', {}).status is "unloaded"
+PASS promise1 is promise2
+PASS promise1 is promise3
+PASS promise1 is promise4
+PASS promise1 is promise5
+PASS promiseEqualityCheck.status is "loading"
+PASS oldFontFace.code is oldFontFace.NETWORK_ERR
+PASS promiseEqualityCheck.status is "error"
+PASS newFontFace is oldFontFace
+PASS newFontFace.status is "loaded"
+PASS newFontFace is oldFontFace
+PASS newFontFace.status is "loaded"
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/text/font-face-_javascript_.html (0 => 196604)
--- trunk/LayoutTests/fast/text/font-face-_javascript_.html (rev 0)
+++ trunk/LayoutTests/fast/text/font-face-_javascript_.html 2016-02-15 23:39:02 UTC (rev 196604)
@@ -0,0 +1,115 @@
+<!DOCTYPE html>
+<head>
+<script src=""
+</head>
+<body>
+<script>
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).family", "family_name");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).style", "normal");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).weight", "normal");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).stretch", "normal");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).unicodeRange", "U+0-10FFFF");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).variant", "normal");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).featureSettings", "normal");
+
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'style': 'normal'}).style", "normal");
+shouldThrow("new FontFace('family_name', 'url(\\'asdf\\')', {'style': 'inherit'}).style");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'style': 'italic'}).style", "italic");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'style': 'oblique'}).style", "italic");
+shouldThrow("new FontFace('family_name', 'url(\\'asdf\\')', {'style': 'asdf'})");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'weight': 'normal'}).weight", "normal");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'weight': '200'}).weight", "200");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'weight': 'bold'}).weight", "bold");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'weight': 'bolder'}).weight", "bold");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'weight': 'lighter'}).weight", "200");
+shouldThrow("new FontFace('family_name', 'url(\\'asdf\\')', {'weight': 'inherit'}).weight");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'stretch': 'stretch_name'}).stretch", "normal");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'unicodeRange': 'U+26'}).unicodeRange", "U+26-26");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'unicodeRange': 'U+0-7F'}).unicodeRange", "U+0-7f");
+shouldThrow("new FontFace('family_name', 'url(\\'asdf\\')', {'variant': 'variant_name'}).variant");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'variant': 'small-caps'}).variant", "small-caps");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'variant': 'small-caps common-ligatures'}).variant", "common-ligatures small-caps");
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {'featureSettings': '\\'titl\\''}).featureSettings", "'titl' 1");
+
+var everything = new FontFace('family_name', 'url(\'asdf\')', {'style': 'italic', 'weight': 'bold', 'stretch': 'stretch_name', 'unicodeRange': 'U+26', 'variant': 'small-caps', 'featureSettings': '\'titl\''});
+shouldBeEqualToString("everything.style", "italic");
+shouldBeEqualToString("everything.weight", "bold");
+shouldBeEqualToString("everything.stretch", "normal");
+shouldBeEqualToString("everything.unicodeRange", "U+26-26");
+shouldBeEqualToString("everything.variant", "small-caps");
+shouldBeEqualToString("everything.featureSettings", "'titl' 1");
+
+everything.family = "other_family_name";
+shouldBeEqualToString("everything.family", "other_family_name");
+everything.style = "normal";
+shouldBeEqualToString("everything.style", "normal");
+everything.weight = "300";
+shouldBeEqualToString("everything.weight", "300");
+everything.stretch = "other_stretch_name";
+shouldBeEqualToString("everything.stretch", "normal");
+everything.unicodeRange = "U+0-7F";
+shouldBeEqualToString("everything.unicodeRange", "U+0-7f");
+everything.variant = "stacked-fractions";
+shouldBeEqualToString("everything.variant", "stacked-fractions");
+everything.featureSettings = "'smcp'";
+shouldBeEqualToString("everything.featureSettings", "'smcp' 1");
+
+/*shouldNotThrow("new FontFace('family_name', 'url(\\'asdf\\')', {})");
+var newArrayBuffer = new ArrayBuffer(100);
+shouldNotThrow("new FontFace('family_name', newArrayBuffer, {})");
+shouldNotThrow("new FontFace('family_name', new DataView(newArrayBuffer), {})");
+shouldNotThrow("new FontFace('family_name', new Uint8Array(newArrayBuffer), {})");
+shouldThrow("new FontFace('family_name', 5, {})");
+shouldThrow("new FontFace('family_name', {}, {})");
+shouldThrow("new FontFace('family_name', new Array(), {})");*/
+
+shouldBeEqualToString("new FontFace('family_name', 'url(\\'asdf\\')', {}).status", "unloaded");
+
+var promiseEqualityCheck = new FontFace('family_name', 'url(\'asdf\')', {});
+var promise1 = promiseEqualityCheck.loaded;
+var promise2 = promiseEqualityCheck.loaded;
+var promise3 = promiseEqualityCheck.load();
+var promise4 = promiseEqualityCheck.loaded;
+var promise5 = promiseEqualityCheck.load();
+shouldBe("promise1", "promise2");
+shouldBe("promise1", "promise3");
+shouldBe("promise1", "promise4");
+shouldBe("promise1", "promise5");
+shouldBeEqualToString("promiseEqualityCheck.status", "loading");
+
+var oldFontFace;
+var newFontFace;
+self.jsTestIsAsync = true;
+promiseEqualityCheck.loaded.then(function(x) {
+ testFailed("Bogus URL should not load");
+ finishJSTest();
+}, function(y) {
+ oldFontFace = y;
+ shouldBe("oldFontFace.code", "oldFontFace.NETWORK_ERR");
+ shouldBeEqualToString("promiseEqualityCheck.status", "error");
+ oldFontFace = new FontFace('family_name', 'url(\'../../resources/Ahem.ttf\')', {});
+ return oldFontFace.load();
+}).then(function(x) {
+ newFontFace = x;
+ shouldBe("newFontFace", "oldFontFace");
+ shouldBeEqualToString("newFontFace.status", "loaded");
+ // Test behavior when the font is in the cache.
+ oldFontFace = new FontFace('family_name', 'url(\'../../resources/Ahem.ttf\')', {});
+ return oldFontFace.load();
+}, function(y) {
+ testFailed("Legit URL should load");
+ finishJSTest();
+}).then(function(x) {
+ newFontFace = x;
+ shouldBe("newFontFace", "oldFontFace");
+ shouldBeEqualToString("newFontFace.status", "loaded");
+ finishJSTest();
+}, function(y) {
+ testFailed("Legit URL should load");
+ finishJSTest();
+});
+
+</script>
+<script src=""
+</body>
+</html>
Modified: trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt (196603 => 196604)
--- trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/js/dom/global-constructors-attributes-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -363,6 +363,11 @@
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').value is FontFace
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'FormData').value is FormData
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('set') is false
Modified: trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt (196603 => 196604)
--- trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/platform/efl/js/dom/global-constructors-attributes-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -368,6 +368,11 @@
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').value is FontFace
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'FormData').value is FormData
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('set') is false
Modified: trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt (196603 => 196604)
--- trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/platform/gtk/js/dom/global-constructors-attributes-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -373,6 +373,11 @@
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').value is FontFace
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'FormData').value is FormData
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('set') is false
Modified: trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt (196603 => 196604)
--- trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/platform/mac/js/dom/global-constructors-attributes-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -408,6 +408,11 @@
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').value is FontFace
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'FormData').value is FormData
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('set') is false
Modified: trunk/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt (196603 => 196604)
--- trunk/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/platform/mac-mavericks/js/dom/global-constructors-attributes-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -363,6 +363,11 @@
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').value is FontFace
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'FormData').value is FormData
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('set') is false
Modified: trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt (196603 => 196604)
--- trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/platform/mac-yosemite/js/dom/global-constructors-attributes-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -408,6 +408,11 @@
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').value is FontFace
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'FormData').value is FormData
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('set') is false
Modified: trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt (196603 => 196604)
--- trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/LayoutTests/platform/win/js/dom/global-constructors-attributes-expected.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -293,6 +293,11 @@
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').hasOwnProperty('set') is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').enumerable is false
PASS Object.getOwnPropertyDescriptor(global, 'FocusEvent').configurable is true
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').value is FontFace
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('get') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').hasOwnProperty('set') is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').enumerable is false
+PASS Object.getOwnPropertyDescriptor(global, 'FontFace').configurable is true
PASS Object.getOwnPropertyDescriptor(global, 'FormData').value is FormData
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('get') is false
PASS Object.getOwnPropertyDescriptor(global, 'FormData').hasOwnProperty('set') is false
Modified: trunk/Source/WebCore/CMakeLists.txt (196603 => 196604)
--- trunk/Source/WebCore/CMakeLists.txt 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/CMakeLists.txt 2016-02-15 23:39:02 UTC (rev 196604)
@@ -330,6 +330,7 @@
css/CSSValueList.idl
css/Counter.idl
css/DOMWindowCSS.idl
+ css/FontFace.idl
css/FontLoader.idl
css/MediaList.idl
css/MediaQueryList.idl
@@ -1108,6 +1109,7 @@
bindings/js/JSCSSRuleCustom.cpp
bindings/js/JSCSSRuleListCustom.cpp
bindings/js/JSCSSStyleDeclarationCustom.cpp
+ bindings/js/JSFontFaceCustom.cpp
bindings/js/JSCSSValueCustom.cpp
bindings/js/JSCallbackData.cpp
bindings/js/JSCanvasRenderingContext2DCustom.cpp
Modified: trunk/Source/WebCore/ChangeLog (196603 => 196604)
--- trunk/Source/WebCore/ChangeLog 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/ChangeLog 2016-02-15 23:39:02 UTC (rev 196604)
@@ -1,3 +1,85 @@
+2016-02-15 Myles C. Maxfield <[email protected]>
+
+ [Font Loading] Implement FontFace _javascript_ object
+ https://bugs.webkit.org/show_bug.cgi?id=153345
+
+ Reviewed by Antti Koivisto.
+
+ Test: fast/text/font-face-_javascript_.html
+
+ This patch implements the FontFace _javascript_ object. This object mostly consists of
+ style getters / setters, which we implement by parsing input strings and generating
+ output strings similarly to getComputedStyle(). This object also has a load() function
+ which returns a promise which will be fulfilled or rejected depending on the load.
+ There is also a "loaded" attribute which exposes this promise directly. Also, a status
+ field is exposed so script knows what the state of the load is.
+
+ Currently, loading depends on our CachedResourceLoader which is part of the Document,
+ so this API is not available in a non-document context.
+
+ Another caveat is that immediate-mode font loading (where the content provides an
+ ArrayBuffer containing the bytes of the font file) is forthcoming. This requires
+ changing the relationship between CSSFontFaceSource and CachedFont.
+
+ CSSFontFace has been modified to keep a strong reference to the CSSFontSelector. This
+ is because the lifetime of the CSSFontFace can now outlive the CSSFontSelector. When
+ the CSSFontSelector is removed from the Document, it explicitly clears its constituent
+ CSSFontFaces, thereby breaking the reference cycle.
+
+ Test: fast/text/font-face-_javascript_-expected.html
+
+ * CMakeLists.txt: Add new files.
+ * DerivedSources.cpp: Ditto.
+ * DerivedSources.make: Ditto.
+ * WebCore.vcxproj/WebCore.vcxproj: Ditto.
+ * WebCore.vcxproj/WebCore.vcxproj.filters: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * bindings/js/JSDOMPromise.cpp:
+ (WebCore::DeferredWrapper::globalObject): Remove whitespace.
+ (WebCore::DeferredWrapper::deferred): Allow access to the inner JSC object.
+ * bindings/js/JSDOMPromise.h:
+ (WebCore::DOMPromise::deferred): Ditto.
+ * bindings/js/JSFontFaceCustom.cpp: Copied from Source/WebCore/bindings/js/JSDOMPromise.cpp.
+ (WebCore::JSFontFace::loaded):
+ (WebCore::JSFontFace::load):
+ * css/CSSFontFace.cpp:
+ (WebCore::CSSFontFace::CSSFontFace):
+ (WebCore::CSSFontFace::adoptSource):
+ (WebCore::CSSFontFace::updateStatus): Enforce the state machine's transitions.
+ (WebCore::CSSFontFace::fontLoaded):
+ (WebCore::CSSFontFace::pump):
+ (WebCore::CSSFontFace::load):
+ * css/CSSFontFace.h:
+ (WebCore::CSSFontFaceClient::~CSSFontFaceClient):
+ (WebCore::CSSFontFace::create):
+ (WebCore::CSSFontFace::status):
+ * css/CSSFontSelector.cpp:
+ (WebCore::CSSFontSelector::appendSources): Update for new CSSFontFace API.
+ (WebCore::CSSFontSelector::registerLocalFontFacesForFamily): Ditto.
+ (WebCore::CSSFontSelector::addFontFaceRule): Ditto.
+ (WebCore::CSSFontSelector::kick): Ditto.
+ (WebCore::appendSources): Deleted.
+ (WebCore::registerLocalFontFacesForFamily): Deleted.
+ * css/CSSFontSelector.h:
+ * css/CSSUnicodeRangeValue.cpp: Use for serializing the "unicodeRange" property.
+ * css/FontFace.cpp:
+ (WebCore::createPromise): Implement the remaining _javascript_ API functions.
+ (WebCore::valueFromDictionary):
+ (WebCore::FontFace::create):
+ (WebCore::FontFace::FontFace):
+ (WebCore::FontFace::parseString):
+ (WebCore::FontFace::status):
+ (WebCore::FontFace::kick):
+ (WebCore::FontFace::load):
+ (WebCore::FontFace::fulfillPromise):
+ (WebCore::FontFace::rejectPromise):
+ (WebCore::parseString): Deleted.
+ * css/FontFace.h:
+ (WebCore::FontFace::promise):
+ (WebCore::FontFace::backing):
+ (WebCore::FontFace::create): Deleted.
+ * css/FontFace.idl: Copied from Source/WebCore/bindings/js/JSDOMPromise.cpp.
+
2016-02-15 Jer Noble <[email protected]>
Null-deref crash in DefaultAudioDestinationNode::suspend()
Modified: trunk/Source/WebCore/DerivedSources.cpp (196603 => 196604)
--- trunk/Source/WebCore/DerivedSources.cpp 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/DerivedSources.cpp 2016-02-15 23:39:02 UTC (rev 196604)
@@ -166,6 +166,7 @@
#if ENABLE(FONT_LOAD_EVENTS)
#include "JSFontLoader.cpp"
#endif
+#include "JSFontFace.cpp"
#include "JSGeolocation.cpp"
#include "JSGeoposition.cpp"
#include "JSHashChangeEvent.cpp"
Modified: trunk/Source/WebCore/DerivedSources.make (196603 => 196604)
--- trunk/Source/WebCore/DerivedSources.make 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/DerivedSources.make 2016-02-15 23:39:02 UTC (rev 196604)
@@ -241,6 +241,7 @@
$(WebCore)/css/CSSValueList.idl \
$(WebCore)/css/Counter.idl \
$(WebCore)/css/DOMWindowCSS.idl \
+ $(WebCore)/css/FontFace.idl \
$(WebCore)/css/FontLoader.idl \
$(WebCore)/css/MediaList.idl \
$(WebCore)/css/MediaQueryList.idl \
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (196603 => 196604)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj 2016-02-15 23:39:02 UTC (rev 196604)
@@ -1971,6 +1971,20 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontFace.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontLoader.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -17726,6 +17740,20 @@
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
</ClCompile>
+ <ClCompile Include="..\bindings\js\JSFontFaceCustom.cpp">
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
+ <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
+ </ClCompile>
<ClCompile Include="..\bindings\js\JSCSSStyleDeclarationCustom.cpp">
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
<ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -19957,6 +19985,7 @@
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFileReader.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFileReaderSync.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontLoader.h" />
+ <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontFace.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepad.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepadButton.h" />
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSGamepadEvent.h" />
Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (196603 => 196604)
--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters 2016-02-15 23:39:02 UTC (rev 196604)
@@ -4262,6 +4262,9 @@
<ClCompile Include="..\bindings\js\JSCSSRuleListCustom.cpp">
<Filter>bindings\js</Filter>
</ClCompile>
+ <ClCompile Include="..\bindings\js\JSFontFaceCustom.cpp">
+ <Filter>bindings\js</Filter>
+ </ClCompile>
<ClCompile Include="..\bindings\js\JSCSSStyleDeclarationCustom.cpp">
<Filter>bindings\js</Filter>
</ClCompile>
@@ -5271,6 +5274,9 @@
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFileReaderSync.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
+ <ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontFace.cpp">
+ <Filter>DerivedSources</Filter>
+ </ClCompile>
<ClCompile Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontLoader.cpp">
<Filter>DerivedSources</Filter>
</ClCompile>
@@ -12696,6 +12702,9 @@
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFileReaderSync.h">
<Filter>DerivedSources</Filter>
</ClInclude>
+ <ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontFace.h">
+ <Filter>DerivedSources</Filter>
+ </ClInclude>
<ClInclude Include="$(ConfigurationBuildDir)\obj$(PlatformArchitecture)\$(ProjectName)\DerivedSources\JSFontLoader.h">
<Filter>DerivedSources</Filter>
</ClInclude>
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (196603 => 196604)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2016-02-15 23:39:02 UTC (rev 196604)
@@ -5909,6 +5909,9 @@
C105DA620F3AA68F001DD44F /* TextEncodingDetectorICU.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C105DA610F3AA68F001DD44F /* TextEncodingDetectorICU.cpp */; };
C105DA640F3AA6B8001DD44F /* TextEncodingDetector.h in Headers */ = {isa = PBXBuildFile; fileRef = C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */; };
C2015C0A1BE6FEB200822389 /* FontVariantBuilder.h in Headers */ = {isa = PBXBuildFile; fileRef = C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */; };
+ C280833F1C6DC26F001451B6 /* JSFontFace.h in Headers */ = {isa = PBXBuildFile; fileRef = C280833E1C6DC22C001451B6 /* JSFontFace.h */; };
+ C28083401C6DC275001451B6 /* JSFontFace.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C280833D1C6DC22C001451B6 /* JSFontFace.cpp */; };
+ C28083421C6DC96A001451B6 /* JSFontFaceCustom.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C28083411C6DC96A001451B6 /* JSFontFaceCustom.cpp */; };
C330A22313EC196B0000B45B /* ColorChooser.h in Headers */ = {isa = PBXBuildFile; fileRef = C330A22113EC196B0000B45B /* ColorChooser.h */; settings = {ATTRIBUTES = (Private, ); }; };
C33EE5C414FB49610002095A /* BaseClickableWithKeyInputType.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C33EE5C214FB49610002095A /* BaseClickableWithKeyInputType.cpp */; };
C33EE5C514FB49610002095A /* BaseClickableWithKeyInputType.h in Headers */ = {isa = PBXBuildFile; fileRef = C33EE5C314FB49610002095A /* BaseClickableWithKeyInputType.h */; };
@@ -13819,6 +13822,10 @@
C105DA630F3AA6B8001DD44F /* TextEncodingDetector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TextEncodingDetector.h; sourceTree = "<group>"; };
C2015C091BE6FE2C00822389 /* FontVariantBuilder.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = FontVariantBuilder.h; sourceTree = "<group>"; };
C24685131A148E1800811792 /* CoreGraphicsSPI.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CoreGraphicsSPI.h; sourceTree = "<group>"; };
+ C280833C1C6DB194001451B6 /* FontFace.idl */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text; path = FontFace.idl; sourceTree = "<group>"; };
+ C280833D1C6DC22C001451B6 /* JSFontFace.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFontFace.cpp; sourceTree = "<group>"; };
+ C280833E1C6DC22C001451B6 /* JSFontFace.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JSFontFace.h; sourceTree = "<group>"; };
+ C28083411C6DC96A001451B6 /* JSFontFaceCustom.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = JSFontFaceCustom.cpp; sourceTree = "<group>"; };
C2C4CB1D161A131200D214DA /* WebSafeIncrementalSweeperIOS.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WebSafeIncrementalSweeperIOS.h; sourceTree = "<group>"; };
C330A22113EC196B0000B45B /* ColorChooser.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ColorChooser.h; sourceTree = "<group>"; };
C33EE5C214FB49610002095A /* BaseClickableWithKeyInputType.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BaseClickableWithKeyInputType.cpp; sourceTree = "<group>"; };
@@ -17535,6 +17542,8 @@
656580EC09D12B20000E61D7 /* Derived Sources */ = {
isa = PBXGroup;
children = (
+ C280833D1C6DC22C001451B6 /* JSFontFace.cpp */,
+ C280833E1C6DC22C001451B6 /* JSFontFace.h */,
9908B0F31BCACFFE00ED0F65 /* ByteLengthQueuingStrategyBuiltins.cpp */,
9908B0F51BCAD07D00ED0F65 /* ByteLengthQueuingStrategyBuiltins.h */,
656581AC09D14EE6000E61D7 /* CharsetData.cpp */,
@@ -22442,6 +22451,7 @@
BC348BBD0DB7F531004ABAB9 /* JSXMLHttpRequestCustom.cpp */,
A1C7FAA1133A5D3500D6732D /* JSXPathResultCustom.cpp */,
BCEFE1E40DCA5F3300739219 /* JSXSLTProcessorCustom.cpp */,
+ C28083411C6DC96A001451B6 /* JSFontFaceCustom.cpp */,
);
name = Custom;
sourceTree = "<group>";
@@ -23742,6 +23752,7 @@
1C3249101C6D6A3B007EDB32 /* FontVariantBuilder.cpp */,
1C66260E1C6E7CA600AB527C /* FontFace.cpp */,
1C66260F1C6E7CA600AB527C /* FontFace.h */,
+ C280833C1C6DB194001451B6 /* FontFace.idl */,
);
path = css;
sourceTree = "<group>";
@@ -26365,6 +26376,7 @@
975CA2A21303679D00E99AD9 /* JSCrypto.h in Headers */,
E157A8F118185425009F821D /* JSCryptoAlgorithmBuilder.h in Headers */,
E1C657131815F9DD00256CDD /* JSCryptoAlgorithmDictionary.h in Headers */,
+ C280833F1C6DC26F001451B6 /* JSFontFace.h in Headers */,
E157A8E11817331C009F821D /* JSCryptoKey.h in Headers */,
E1F80B8E183172B5007885C3 /* JSCryptoKeyPair.h in Headers */,
E125F85218283A5600D84CD9 /* JSCryptoKeySerializationJWK.h in Headers */,
@@ -29464,6 +29476,7 @@
85526CD30AB0B7DA000302EA /* DOMTreeWalker.mm in Sources */,
85C7F4920AAF79DC004014DD /* DOMUIEvent.mm in Sources */,
FED13D2B0CEA91DF00D89466 /* DOMUIKitExtensions.mm in Sources */,
+ C28083401C6DC275001451B6 /* JSFontFace.cpp in Sources */,
2E37DFDA12DBAFB800A6B233 /* DOMURL.cpp in Sources */,
CD9DE18117AAD6A400EA386D /* DOMURLMediaSource.cpp in Sources */,
15FCC9FC1B4DF7F200E72326 /* DOMURLMediaStream.cpp in Sources */,
@@ -29803,6 +29816,7 @@
D66817FA166FE6D700FA07B4 /* HTMLTemplateElement.cpp in Sources */,
A81369D7097374F600D74463 /* HTMLTextAreaElement.cpp in Sources */,
9BC6C21C13CCC97B008E0337 /* HTMLTextFormControlElement.cpp in Sources */,
+ C28083421C6DC96A001451B6 /* JSFontFaceCustom.cpp in Sources */,
830519951BB0F11000F3772E /* HTMLTimeElement.cpp in Sources */,
A871DC290A15205700B12A68 /* HTMLTitleElement.cpp in Sources */,
977B3877122883E900B81FF8 /* HTMLTokenizer.cpp in Sources */,
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp (196603 => 196604)
--- trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp 2016-02-15 23:39:02 UTC (rev 196604)
@@ -43,8 +43,14 @@
{
ASSERT(m_globalObject);
return *m_globalObject.get();
-}
+}
+JSC::JSPromiseDeferred& DeferredWrapper::deferred() const
+{
+ ASSERT(m_deferred);
+ return *m_deferred.get();
+}
+
void DeferredWrapper::callFunction(ExecState& exec, JSValue function, JSValue resolution)
{
CallData callData;
Modified: trunk/Source/WebCore/bindings/js/JSDOMPromise.h (196603 => 196604)
--- trunk/Source/WebCore/bindings/js/JSDOMPromise.h 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/bindings/js/JSDOMPromise.h 2016-02-15 23:39:02 UTC (rev 196604)
@@ -44,6 +44,7 @@
void reject(const RejectResultType&);
JSDOMGlobalObject& globalObject() const;
+ JSC::JSPromiseDeferred& deferred() const;
private:
void callFunction(JSC::ExecState&, JSC::JSValue function, JSC::JSValue resolution);
@@ -73,12 +74,14 @@
DOMPromise(DeferredWrapper&& wrapper) : m_wrapper(WTFMove(wrapper)) { }
DOMPromise(DOMPromise&& promise) : m_wrapper(WTFMove(promise.m_wrapper)) { }
- DOMPromise(const DOMPromise&)= delete;
- DOMPromise& operator=(DOMPromise const&) = delete;
+ DOMPromise(const DOMPromise&) = default;
+ DOMPromise& operator=(DOMPromise const&) = default;
void resolve(const Value& value) { m_wrapper.resolve<Value>(value); }
void reject(const Error& error) { m_wrapper.reject<Error>(error); }
+ JSC::JSPromiseDeferred& deferred() const { return m_wrapper.deferred(); }
+
private:
DeferredWrapper m_wrapper;
};
Copied: trunk/Source/WebCore/bindings/js/JSFontFaceCustom.cpp (from rev 196603, trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp) (0 => 196604)
--- trunk/Source/WebCore/bindings/js/JSFontFaceCustom.cpp (rev 0)
+++ trunk/Source/WebCore/bindings/js/JSFontFaceCustom.cpp 2016-02-15 23:39:02 UTC (rev 196604)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include "config.h"
+#include "JSFontFace.h"
+
+#include "CSSFontSelector.h"
+#include "CSSValue.h"
+#include "CSSValueList.h"
+#include "Dictionary.h"
+#include "ExceptionCode.h"
+#include "JSDOMConstructor.h"
+
+namespace WebCore {
+
+JSC::JSValue JSFontFace::loaded(JSC::ExecState&) const
+{
+ auto& promise = wrapped().promise();
+ return promise.deferred().promise();
+}
+
+JSC::JSValue JSFontFace::load(JSC::ExecState& state)
+{
+ wrapped().load();
+ return loaded(state);
+}
+
+}
Modified: trunk/Source/WebCore/css/CSSFontFace.cpp (196603 => 196604)
--- trunk/Source/WebCore/css/CSSFontFace.cpp 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/css/CSSFontFace.cpp 2016-02-15 23:39:02 UTC (rev 196604)
@@ -45,8 +45,10 @@
namespace WebCore {
-CSSFontFace::CSSFontFace(bool isLocalFallback)
- : m_isLocalFallback(isLocalFallback)
+CSSFontFace::CSSFontFace(CSSFontFaceClient& client, CSSFontSelector& fontSelector, bool isLocalFallback)
+ : m_fontSelector(fontSelector)
+ , m_client(client)
+ , m_isLocalFallback(isLocalFallback)
{
}
@@ -82,7 +84,8 @@
styleMask = FontStyleItalicMask;
break;
default:
- return false;
+ styleMask = FontStyleNormalMask;
+ break;
}
m_traitsMask = static_cast<FontTraitsMask>((static_cast<unsigned>(m_traitsMask) & (~FontStyleMask)) | styleMask);
@@ -97,6 +100,7 @@
unsigned weightMask = 0;
switch (downcast<CSSPrimitiveValue>(weight).getValueID()) {
case CSSValueBold:
+ case CSSValueBolder:
case CSSValue700:
weightMask = FontWeight700Mask;
break;
@@ -119,6 +123,7 @@
case CSSValue300:
weightMask = FontWeight300Mask;
break;
+ case CSSValueLighter:
case CSSValue200:
weightMask = FontWeight200Mask;
break;
@@ -126,6 +131,7 @@
weightMask = FontWeight100Mask;
break;
default:
+ weightMask = FontWeight400Mask;
break;
}
@@ -237,33 +243,113 @@
void CSSFontFace::adoptSource(std::unique_ptr<CSSFontFaceSource>&& source)
{
m_sources.append(WTFMove(source));
+
+ // We should never add sources in the middle of loading.
+ ASSERT(!m_sourcesPopulated);
}
+void CSSFontFace::setStatus(Status newStatus)
+{
+ switch (newStatus) {
+ case Status::Pending:
+ ASSERT_NOT_REACHED();
+ break;
+ case Status::Loading:
+ ASSERT(m_status == Status::Pending);
+ break;
+ case Status::TimedOut:
+ ASSERT(m_status == Status::Loading);
+ break;
+ case Status::Success:
+ ASSERT(m_status == Status::Loading || m_status == Status::TimedOut);
+ break;
+ case Status::Failure:
+ ASSERT(m_status == Status::Loading || m_status == Status::TimedOut);
+ break;
+ }
+
+ m_status = newStatus;
+
+ if (m_status == Status::Success || m_status == Status::Failure)
+ m_client.kick(*this);
+}
+
void CSSFontFace::fontLoaded(CSSFontFaceSource&)
{
- // FIXME: Can we assert that m_segmentedFontFaces is not empty? That may
- // require stopping in-progress font loading when the last
- // CSSSegmentedFontFace is removed.
+ // If the font is already in the cache, CSSFontFaceSource may report it's loaded before it is added here as a source.
+ // Let's not pump the state machine until we've got all our sources. font() and load() are smart enough to act correctly
+ // when a source is failed or succeeded before we have asked it to load.
+ if (m_sourcesPopulated)
+ pump();
+
if (m_segmentedFontFaces.isEmpty())
return;
- (*m_segmentedFontFaces.begin())->fontSelector().fontLoaded();
+ m_fontSelector->fontLoaded();
for (auto* face : m_segmentedFontFaces)
face->fontLoaded(*this);
}
+size_t CSSFontFace::pump()
+{
+ size_t i;
+ for (i = 0; i < m_sources.size(); ++i) {
+ auto& source = m_sources[i];
+
+ if (source->status() == CSSFontFaceSource::Status::Pending) {
+ ASSERT(m_status == Status::Pending || m_status == Status::Loading || m_status == Status::TimedOut);
+ if (m_status == Status::Pending)
+ setStatus(Status::Loading);
+ source->load(m_fontSelector.get());
+ }
+
+ switch (source->status()) {
+ case CSSFontFaceSource::Status::Pending:
+ ASSERT_NOT_REACHED();
+ break;
+ case CSSFontFaceSource::Status::Loading:
+ ASSERT(m_status == Status::Pending || m_status == Status::Loading);
+ if (m_status == Status::Pending)
+ setStatus(Status::Loading);
+ return i;
+ case CSSFontFaceSource::Status::Success:
+ ASSERT(m_status == Status::Pending || m_status == Status::Loading || m_status == Status::TimedOut || m_status == Status::Success);
+ if (m_status == Status::Pending)
+ setStatus(Status::Loading);
+ if (m_status == Status::Loading || m_status == Status::TimedOut)
+ setStatus(Status::Success);
+ return i;
+ case CSSFontFaceSource::Status::Failure:
+ if (m_status == Status::Pending)
+ setStatus(Status::Loading);
+ break;
+ }
+ }
+ if (m_status == Status::Loading || m_status == Status::TimedOut)
+ setStatus(Status::Failure);
+ return m_sources.size();
+}
+
+void CSSFontFace::load()
+{
+ pump();
+}
+
RefPtr<Font> CSSFontFace::font(const FontDescription& fontDescription, bool syntheticBold, bool syntheticItalic)
{
if (allSourcesFailed())
return nullptr;
- ASSERT(!m_segmentedFontFaces.isEmpty());
- CSSFontSelector& fontSelector = (*m_segmentedFontFaces.begin())->fontSelector();
-
- for (auto& source : m_sources) {
+ // Our status is derived from the first non-failed source. However, this source may
+ // return null from font(), which means we need to continue looping through the remainder
+ // of the sources to try to find a font to use. These subsequent tries should not affect
+ // our own state, though.
+ size_t startIndex = pump();
+ for (size_t i = startIndex; i < m_sources.size(); ++i) {
+ auto& source = m_sources[i];
if (source->status() == CSSFontFaceSource::Status::Pending)
- source->load(fontSelector);
+ source->load(m_fontSelector.get());
switch (source->status()) {
case CSSFontFaceSource::Status::Pending:
Modified: trunk/Source/WebCore/css/CSSFontFace.h (196603 => 196604)
--- trunk/Source/WebCore/css/CSSFontFace.h 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/css/CSSFontFace.h 2016-02-15 23:39:02 UTC (rev 196604)
@@ -45,9 +45,15 @@
class FontDescription;
class Font;
+class CSSFontFaceClient {
+public:
+ virtual ~CSSFontFaceClient() { }
+ virtual void kick(CSSFontFace&) = 0;
+};
+
class CSSFontFace : public RefCounted<CSSFontFace> {
public:
- static Ref<CSSFontFace> create(bool isLocalFallback = false) { return adoptRef(*new CSSFontFace(isLocalFallback)); }
+ static Ref<CSSFontFace> create(CSSFontFaceClient& client, CSSFontSelector& fontSelector, bool isLocalFallback = false) { return adoptRef(*new CSSFontFace(client, fontSelector, isLocalFallback)); }
virtual ~CSSFontFace();
bool setFamilies(CSSValue&);
@@ -62,6 +68,7 @@
bool setVariantEastAsian(CSSValue&);
bool setFeatureSettings(CSSValue&);
+ enum class Status;
struct UnicodeRange;
const CSSValueList* families() const { return m_families.get(); }
FontTraitsMask traitsMask() const { return m_traitsMask; }
@@ -71,6 +78,7 @@
void setVariantSettings(const FontVariantSettings& variantSettings) { m_variantSettings = variantSettings; }
void setTraitsMask(FontTraitsMask traitsMask) { m_traitsMask = traitsMask; }
bool isLocalFallback() const { return m_isLocalFallback; }
+ Status status() const { return m_status; }
void addedToSegmentedFontFace(CSSSegmentedFontFace&);
void removedFromSegmentedFontFace(CSSSegmentedFontFace&);
@@ -78,11 +86,30 @@
bool allSourcesFailed() const;
void adoptSource(std::unique_ptr<CSSFontFaceSource>&&);
+ void sourcesPopulated() { m_sourcesPopulated = true; }
void fontLoaded(CSSFontFaceSource&);
+ void load();
RefPtr<Font> font(const FontDescription&, bool syntheticBold, bool syntheticItalic);
+ // Pending => Loading => TimedOut
+ // || \\ // ||
+ // || \\ // ||
+ // || \\// ||
+ // || // ||
+ // || //\\ ||
+ // || // \\ ||
+ // \/ \/ \/ \/
+ // Success Failure
+ enum class Status {
+ Pending,
+ Loading,
+ TimedOut,
+ Success,
+ Failure
+ };
+
struct UnicodeRange {
UnicodeRange(UChar32 from, UChar32 to)
: m_from(from)
@@ -103,16 +130,23 @@
#endif
private:
- CSSFontFace(bool isLocalFallback);
+ CSSFontFace(CSSFontFaceClient&, CSSFontSelector&, bool isLocalFallback);
+ size_t pump();
+ void setStatus(Status);
+
RefPtr<CSSValueList> m_families;
- FontTraitsMask m_traitsMask;
+ FontTraitsMask m_traitsMask { static_cast<FontTraitsMask>(FontStyleNormalMask | FontWeight400Mask) };
Vector<UnicodeRange> m_ranges;
- HashSet<CSSSegmentedFontFace*> m_segmentedFontFaces;
+ HashSet<CSSSegmentedFontFace*> m_segmentedFontFaces; // FIXME: Refactor this (in favor of CSSFontFaceClient) when implementing FontFaceSet.
+ Ref<CSSFontSelector> m_fontSelector;
+ CSSFontFaceClient& m_client;
FontFeatureSettings m_featureSettings;
FontVariantSettings m_variantSettings;
Vector<std::unique_ptr<CSSFontFaceSource>> m_sources;
- bool m_isLocalFallback;
+ Status m_status { Status::Pending };
+ bool m_isLocalFallback { false };
+ bool m_sourcesPopulated { false };
};
}
Modified: trunk/Source/WebCore/css/CSSFontSelector.cpp (196603 => 196604)
--- trunk/Source/WebCore/css/CSSFontSelector.cpp 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/css/CSSFontSelector.cpp 2016-02-15 23:39:02 UTC (rev 196604)
@@ -88,7 +88,7 @@
return m_fonts.isEmpty();
}
-static void appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Document* document, bool isInitiatingElementInUserAgentShadowTree)
+void CSSFontSelector::appendSources(CSSFontFace& fontFace, CSSValueList& srcList, Document* document, bool isInitiatingElementInUserAgentShadowTree)
{
for (auto& src : srcList) {
// An item in the list either specifies a string (local font name) or a URL (remote font to download).
@@ -114,6 +114,7 @@
if (source)
fontFace.adoptSource(WTFMove(source));
}
+ fontFace.sourcesPopulated();
}
static String familyNameFromPrimitive(const CSSPrimitiveValue& value)
@@ -143,9 +144,9 @@
}
}
-static void registerLocalFontFacesForFamily(const String& familyName, HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash>& locallyInstalledFontFaces)
+void CSSFontSelector::registerLocalFontFacesForFamily(const String& familyName)
{
- ASSERT(!locallyInstalledFontFaces.contains(familyName));
+ ASSERT(!m_locallyInstalledFontFaces.contains(familyName));
Vector<FontTraitsMask> traitsMasks = FontCache::singleton().getTraitsInFamily(familyName);
if (traitsMasks.isEmpty())
@@ -153,13 +154,17 @@
Vector<Ref<CSSFontFace>> faces = { };
for (auto mask : traitsMasks) {
- Ref<CSSFontFace> face = CSSFontFace::create(true);
+ Ref<CSSFontFace> face = CSSFontFace::create(*this, *this, true);
+
+ RefPtr<CSSValueList> familyList = CSSValueList::createCommaSeparated();
+ familyList->append(CSSValuePool::singleton().createFontFamilyValue(familyName));
+ face->setFamilies(*familyList);
face->setTraitsMask(mask);
face->adoptSource(std::make_unique<CSSFontFaceSource>(face.get(), familyName));
ASSERT(!face->allSourcesFailed());
faces.append(WTFMove(face));
}
- locallyInstalledFontFaces.add(familyName, WTFMove(faces));
+ m_locallyInstalledFontFaces.add(familyName, WTFMove(faces));
}
void CSSFontSelector::addFontFaceRule(const StyleRuleFontFace& fontFaceRule, bool isInitiatingElementInUserAgentShadowTree)
@@ -196,7 +201,7 @@
if (!srcList.length())
return;
- Ref<CSSFontFace> fontFace = CSSFontFace::create();
+ Ref<CSSFontFace> fontFace = CSSFontFace::create(*this, *this);
if (!fontFace->setFamilies(*fontFamily))
return;
@@ -233,7 +238,7 @@
auto addResult = m_fontFaces.add(familyName, Vector<Ref<CSSFontFace>>());
auto& familyFontFaces = addResult.iterator->value;
if (addResult.isNewEntry) {
- registerLocalFontFacesForFamily(familyName, m_locallyInstalledFontFaces);
+ registerLocalFontFacesForFamily(familyName);
familyFontFaces = { };
}
@@ -447,6 +452,12 @@
m_fontsToBeginLoading.clear();
m_document = nullptr;
+
+ // FIXME: This object should outlive the Document.
+ m_fontFaces.clear();
+ m_locallyInstalledFontFaces.clear();
+ m_fonts.clear();
+ m_clients.clear();
}
void CSSFontSelector::beginLoadingFontSoon(CachedFont* font)
@@ -484,6 +495,11 @@
m_document->frame()->loader().checkLoadComplete();
}
+
+void CSSFontSelector::kick(CSSFontFace&)
+{
+}
+
size_t CSSFontSelector::fallbackFontCount()
{
if (!m_document)
Modified: trunk/Source/WebCore/css/CSSFontSelector.h (196603 => 196604)
--- trunk/Source/WebCore/css/CSSFontSelector.h 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/css/CSSFontSelector.h 2016-02-15 23:39:02 UTC (rev 196604)
@@ -26,6 +26,7 @@
#ifndef CSSFontSelector_h
#define CSSFontSelector_h
+#include "CSSFontFace.h"
#include "CachedResourceHandle.h"
#include "Font.h"
#include "FontSelector.h"
@@ -39,14 +40,14 @@
namespace WebCore {
-class CSSFontFace;
class CSSFontFaceRule;
class CSSSegmentedFontFace;
+class CSSValueList;
class CachedFont;
class Document;
class StyleRuleFontFace;
-class CSSFontSelector final : public FontSelector {
+class CSSFontSelector final : public FontSelector, public CSSFontFaceClient {
public:
static Ref<CSSFontSelector> create(Document& document)
{
@@ -64,6 +65,7 @@
void clearDocument();
+ static void appendSources(CSSFontFace&, CSSValueList&, Document*, bool isInitiatingElementInUserAgentShadowTree);
void addFontFaceRule(const StyleRuleFontFace&, bool isInitiatingElementInUserAgentShadowTree);
void fontLoaded();
@@ -85,6 +87,10 @@
void beginLoadTimerFired();
+ void registerLocalFontFacesForFamily(const String&);
+
+ void kick(CSSFontFace&) override;
+
Document* m_document;
HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_fontFaces;
HashMap<String, Vector<Ref<CSSFontFace>>, ASCIICaseInsensitiveHash> m_locallyInstalledFontFaces;
Modified: trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp (196603 => 196604)
--- trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/css/CSSUnicodeRangeValue.cpp 2016-02-15 23:39:02 UTC (rev 196604)
@@ -32,9 +32,7 @@
String CSSUnicodeRangeValue::customCSSText() const
{
- String result;
- // FIXME: Implement.
- return result;
+ return String::format("U+%x-%x", m_from, m_to);
}
bool CSSUnicodeRangeValue::equals(const CSSUnicodeRangeValue& other) const
Modified: trunk/Source/WebCore/css/FontFace.cpp (196603 => 196604)
--- trunk/Source/WebCore/css/FontFace.cpp 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/css/FontFace.cpp 2016-02-15 23:39:02 UTC (rev 196604)
@@ -28,24 +28,99 @@
#include "CSSFontFace.h"
#include "CSSFontFeatureValue.h"
+#include "CSSFontSelector.h"
#include "CSSUnicodeRangeValue.h"
#include "CSSValue.h"
+#include "CSSValuePool.h"
+#include "Dictionary.h"
+#include "Document.h"
+#include "ExceptionCodeDescription.h"
#include "FontVariantBuilder.h"
+#include "JSDOMCoreException.h"
+#include "JSFontFace.h"
+#include "ScriptExecutionContext.h"
#include "StyleProperties.h"
#include <wtf/text/StringBuilder.h>
namespace WebCore {
-FontFace::FontFace()
- : m_backing(CSSFontFace::create())
+static FontFace::Promise createPromise(JSC::ExecState& exec)
{
+ JSDOMGlobalObject& globalObject = *JSC::jsCast<JSDOMGlobalObject*>(exec.lexicalGlobalObject());
+ return FontFace::Promise(DeferredWrapper(&exec, &globalObject, JSC::JSPromiseDeferred::create(&exec, &globalObject)));
}
+static inline Optional<String> valueFromDictionary(const Dictionary& dictionary, const char* key)
+{
+ String result;
+ dictionary.get(key, result);
+ return result.isNull() ? Nullopt : Optional<String>(result);
+}
+
+RefPtr<FontFace> FontFace::create(JSC::ExecState& execState, ScriptExecutionContext& context, const String& family, const Deprecated::ScriptValue& source, const Dictionary& descriptors, ExceptionCode& ec)
+{
+ if (!context.isDocument()) {
+ ec = TypeError;
+ return nullptr;
+ }
+
+ Ref<FontFace> result = adoptRef(*new FontFace(execState, downcast<Document>(context).fontSelector()));
+
+ result->setFamily(family, ec);
+ if (ec)
+ return nullptr;
+
+ if (source.jsValue().isString()) {
+ String sourceString = source.jsValue().toString(&execState)->value(&execState);
+ auto value = FontFace::parseString(sourceString, CSSPropertySrc);
+ if (is<CSSValueList>(value.get())) {
+ CSSValueList& srcList = downcast<CSSValueList>(*value);
+ CSSFontSelector::appendSources(result->backing(), srcList, &downcast<Document>(context), false);
+ } else {
+ ec = SYNTAX_ERR;
+ return nullptr;
+ }
+ }
+
+ if (auto style = valueFromDictionary(descriptors, "style"))
+ result->setStyle(style.value(), ec);
+ if (ec)
+ return nullptr;
+ if (auto style = valueFromDictionary(descriptors, "weight"))
+ result->setWeight(style.value(), ec);
+ if (ec)
+ return nullptr;
+ if (auto style = valueFromDictionary(descriptors, "stretch"))
+ result->setStretch(style.value(), ec);
+ if (ec)
+ return nullptr;
+ if (auto style = valueFromDictionary(descriptors, "unicodeRange"))
+ result->setUnicodeRange(style.value(), ec);
+ if (ec)
+ return nullptr;
+ if (auto style = valueFromDictionary(descriptors, "variant"))
+ result->setVariant(style.value(), ec);
+ if (ec)
+ return nullptr;
+ if (auto style = valueFromDictionary(descriptors, "featureSettings"))
+ result->setFeatureSettings(style.value(), ec);
+ if (ec)
+ return nullptr;
+
+ return result.ptr();
+}
+
+FontFace::FontFace(JSC::ExecState& execState, CSSFontSelector& fontSelector)
+ : m_backing(CSSFontFace::create(*this, fontSelector))
+ , m_promise(createPromise(execState))
+{
+}
+
FontFace::~FontFace()
{
}
-static inline RefPtr<CSSValue> parseString(const String& string, CSSPropertyID propertyID)
+RefPtr<CSSValue> FontFace::parseString(const String& string, CSSPropertyID propertyID)
{
Ref<MutableStyleProperties> style = MutableStyleProperties::create();
auto result = CSSParser::parseValue(style.ptr(), propertyID, string, true, CSSStrictMode, nullptr);
@@ -101,19 +176,38 @@
auto result = CSSParser::parseValue(style.ptr(), CSSPropertyFontVariant, variant, true, CSSStrictMode, nullptr);
if (result != CSSParser::ParseResult::Error) {
FontVariantSettings backup = m_backing->variantSettings();
+ auto normal = CSSValuePool::singleton().createIdentifierValue(CSSValueNormal);
bool success = true;
if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantLigatures))
success &= m_backing->setVariantLigatures(*value);
+ else
+ m_backing->setVariantLigatures(normal);
+
if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantPosition))
success &= m_backing->setVariantPosition(*value);
+ else
+ m_backing->setVariantPosition(normal);
+
if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantCaps))
success &= m_backing->setVariantCaps(*value);
+ else
+ m_backing->setVariantCaps(normal);
+
if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantNumeric))
success &= m_backing->setVariantNumeric(*value);
+ else
+ m_backing->setVariantNumeric(normal);
+
if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantAlternates))
success &= m_backing->setVariantAlternates(*value);
+ else
+ m_backing->setVariantAlternates(normal);
+
if (auto value = style->getPropertyCSSValue(CSSPropertyFontVariantEastAsian))
success &= m_backing->setVariantEastAsian(*value);
+ else
+ m_backing->setVariantEastAsian(normal);
+
if (success)
return;
m_backing->setVariantSettings(backup);
@@ -180,6 +274,8 @@
String FontFace::unicodeRange() const
{
+ if (!m_backing->ranges().size())
+ return "U+0-10FFFF";
RefPtr<CSSValueList> values = CSSValueList::createCommaSeparated();
for (auto& range : m_backing->ranges())
values->append(CSSUnicodeRangeValue::create(range.from(), range.to()));
@@ -201,4 +297,67 @@
return list->cssText();
}
+String FontFace::status() const
+{
+ switch (m_backing->status()) {
+ case CSSFontFace::Status::Pending:
+ return String("unloaded", String::ConstructFromLiteral);
+ case CSSFontFace::Status::Loading:
+ return String("loading", String::ConstructFromLiteral);
+ case CSSFontFace::Status::TimedOut:
+ return String("error", String::ConstructFromLiteral);
+ case CSSFontFace::Status::Success:
+ return String("loaded", String::ConstructFromLiteral);
+ case CSSFontFace::Status::Failure:
+ return String("error", String::ConstructFromLiteral);
+ }
+ ASSERT_NOT_REACHED();
+ return String("error", String::ConstructFromLiteral);
}
+
+void FontFace::kick(CSSFontFace& face)
+{
+ ASSERT_UNUSED(face, &face == m_backing.ptr());
+ switch (m_backing->status()) {
+ case CSSFontFace::Status::TimedOut:
+ rejectPromise(NETWORK_ERR);
+ return;
+ case CSSFontFace::Status::Success:
+ fulfillPromise();
+ return;
+ case CSSFontFace::Status::Failure:
+ rejectPromise(NETWORK_ERR);
+ return;
+ default:
+ return;
+ }
+}
+
+void FontFace::load()
+{
+ m_backing->load();
+}
+
+void FontFace::fulfillPromise()
+{
+ // Normally, DeferredWrapper::callFunction resets the reference to the promise.
+ // However, API semantics require our promise to live for the entire lifetime of the FontFace.
+ // Let's make sure it stays alive.
+
+ Promise guard(m_promise);
+ m_promise.resolve(*this);
+ m_promise = guard;
+}
+
+void FontFace::rejectPromise(ExceptionCode code)
+{
+ // Normally, DeferredWrapper::callFunction resets the reference to the promise.
+ // However, API semantics require our promise to live for the entire lifetime of the FontFace.
+ // Let's make sure it stays alive.
+
+ Promise guard(m_promise);
+ m_promise.reject(DOMCoreException::create(ExceptionCodeDescription(code)).get());
+ m_promise = guard;
+}
+
+}
Modified: trunk/Source/WebCore/css/FontFace.h (196603 => 196604)
--- trunk/Source/WebCore/css/FontFace.h 2016-02-15 22:37:53 UTC (rev 196603)
+++ trunk/Source/WebCore/css/FontFace.h 2016-02-15 23:39:02 UTC (rev 196604)
@@ -26,18 +26,28 @@
#ifndef FontFace_h
#define FontFace_h
+#include "CSSFontFace.h"
+#include "CSSPropertyNames.h"
+#include "DOMCoreException.h"
#include "ExceptionCode.h"
+#include "JSDOMPromise.h"
#include <wtf/RefCounted.h>
#include <wtf/RefPtr.h>
#include <wtf/text/WTFString.h>
+namespace Deprecated {
+class ScriptValue;
+}
+
namespace WebCore {
class CSSFontFace;
+class CSSValue;
+class Dictionary;
-class FontFace : public RefCounted<FontFace> {
+class FontFace : public RefCounted<FontFace>, public CSSFontFaceClient {
public:
- static Ref<FontFace> create() { return adoptRef(*new FontFace()); }
+ static RefPtr<FontFace> create(JSC::ExecState&, ScriptExecutionContext&, const String& family, const Deprecated::ScriptValue& source, const Dictionary& descriptors, ExceptionCode&);
virtual ~FontFace();
void setFamily(const String&, ExceptionCode&);
@@ -55,11 +65,27 @@
String unicodeRange() const;
String variant() const;
String featureSettings() const;
+ String status() const;
+ typedef DOMPromise<FontFace&, DOMCoreException&> Promise;
+ Promise& promise() { return m_promise; }
+
+ void load();
+
+ CSSFontFace& backing() { return m_backing; }
+
+ static RefPtr<CSSValue> parseString(const String&, CSSPropertyID);
+
private:
- FontFace();
+ FontFace(JSC::ExecState&, CSSFontSelector&);
+ void kick(CSSFontFace&) override;
+
+ void fulfillPromise();
+ void rejectPromise(ExceptionCode);
+
Ref<CSSFontFace> m_backing;
+ Promise m_promise;
};
}
Copied: trunk/Source/WebCore/css/FontFace.idl (from rev 196603, trunk/Source/WebCore/bindings/js/JSDOMPromise.cpp) (0 => 196604)
--- trunk/Source/WebCore/css/FontFace.idl (rev 0)
+++ trunk/Source/WebCore/css/FontFace.idl 2016-02-15 23:39:02 UTC (rev 196604)
@@ -0,0 +1,50 @@
+/*
+ * Copyright (C) 2016 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+enum FontFaceLoadStatus {
+ "unloaded",
+ "loading",
+ "loaded",
+ "error"
+};
+
+[
+ ConstructorCallWith=ScriptExecutionContext&ScriptState,
+ ConstructorRaisesException,
+ Constructor(DOMString family, any source, Dictionary descriptors)
+] interface FontFace {
+ [SetterRaisesException] attribute DOMString family;
+ [SetterRaisesException] attribute DOMString style;
+ [SetterRaisesException] attribute DOMString weight;
+ [SetterRaisesException] attribute DOMString stretch;
+ [SetterRaisesException] attribute DOMString unicodeRange;
+ [SetterRaisesException] attribute DOMString variant;
+ [SetterRaisesException] attribute DOMString featureSettings;
+
+ readonly attribute FontFaceLoadStatus status;
+
+ [Custom] Promise load();
+ [CachedAttribute, CustomGetter] readonly attribute Object loaded;
+};