Title: [222949] trunk
Revision
222949
Author
[email protected]
Date
2017-10-05 18:25:01 -0700 (Thu, 05 Oct 2017)

Log Message

Add "display" to FontFace _javascript_ object
https://bugs.webkit.org/show_bug.cgi?id=175383
<rdar://problem/33813239>

Reviewed by Simon Fraser.

Source/WebCore:

We already have all the necessary infrastructure. Just hook it up to the .idl file!

Test: fast/text/font-loading-font-display.html

* css/CSSFontFace.h:
* css/CSSPrimitiveValueMappings.h:
* css/FontFace.cpp:
(WebCore::FontFace::create):
(WebCore::FontFace::setDisplay):
(WebCore::FontFace::display const):
* css/FontFace.h:
* css/FontFace.idl:

LayoutTests:

* fast/text/font-loading-font-display-expected.txt: Added.
* fast/text/font-loading-font-display.html: Added.

Modified Paths

Added Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (222948 => 222949)


--- trunk/LayoutTests/ChangeLog	2017-10-06 01:15:36 UTC (rev 222948)
+++ trunk/LayoutTests/ChangeLog	2017-10-06 01:25:01 UTC (rev 222949)
@@ -1,3 +1,14 @@
+2017-10-05  Myles C. Maxfield  <[email protected]>
+
+        Add "display" to FontFace _javascript_ object
+        https://bugs.webkit.org/show_bug.cgi?id=175383
+        <rdar://problem/33813239>
+
+        Reviewed by Simon Fraser.
+
+        * fast/text/font-loading-font-display-expected.txt: Added.
+        * fast/text/font-loading-font-display.html: Added.
+
 2017-10-05  John Wilander  <[email protected]>
 
         Storage Access API: Web process should ask UI process for grant/deny

Added: trunk/LayoutTests/fast/text/font-loading-font-display-expected.txt (0 => 222949)


--- trunk/LayoutTests/fast/text/font-loading-font-display-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/text/font-loading-font-display-expected.txt	2017-10-06 01:25:01 UTC (rev 222949)
@@ -0,0 +1,17 @@
+PASS fontFaceRule.style.getPropertyValue('font-display') is ""
+PASS fontFace.display is "auto"
+PASS fontFaceRule.style.getPropertyValue('font-display') is ""
+PASS fontFace.display is "auto"
+PASS fontFaceRule.style.getPropertyValue('font-display') is "block"
+PASS fontFace.display is "block"
+PASS fontFaceRule.style.getPropertyValue('font-display') is "swap"
+PASS fontFace.display is "swap"
+PASS fontFaceRule.style.getPropertyValue('font-display') is "fallback"
+PASS fontFace.display is "fallback"
+PASS fontFaceRule.style.getPropertyValue('font-display') is "optional"
+PASS fontFace.display is "optional"
+PASS fontFace.display = 'garbage' threw exception SyntaxError: The string did not match the expected pattern..
+PASS successfullyParsed is true
+
+TEST COMPLETE
+

Added: trunk/LayoutTests/fast/text/font-loading-font-display.html (0 => 222949)


--- trunk/LayoutTests/fast/text/font-loading-font-display.html	                        (rev 0)
+++ trunk/LayoutTests/fast/text/font-loading-font-display.html	2017-10-06 01:25:01 UTC (rev 222949)
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src=""
+<style id="styleElement">
+@font-face {
+    font-family: "WebFont";
+    src: url("garbage");
+}
+</style>
+</head>
+<body>
+<script>
+var styleElement = document.getElementById("styleElement");
+let fontFaceRule = styleElement.sheet.rules[0];
+let fontFace = document.fonts.entries().next().value;
+
+shouldBeEqualToString("fontFaceRule.style.getPropertyValue('font-display')", "");
+shouldBeEqualToString("fontFace.display", "auto");
+
+let values = ["auto", "block", "swap", "fallback", "optional"];
+for (let value of values) {
+    fontFace.display = value;
+    shouldBeEqualToString("fontFaceRule.style.getPropertyValue('font-display')", value == "auto" ? "" : value);
+    shouldBeEqualToString("fontFace.display", value);
+}
+shouldThrow("fontFace.display = 'garbage'");
+</script>
+<script src=""
+</body>
+</html>

Modified: trunk/Source/WebCore/ChangeLog (222948 => 222949)


--- trunk/Source/WebCore/ChangeLog	2017-10-06 01:15:36 UTC (rev 222948)
+++ trunk/Source/WebCore/ChangeLog	2017-10-06 01:25:01 UTC (rev 222949)
@@ -1,3 +1,24 @@
+2017-10-05  Myles C. Maxfield  <[email protected]>
+
+        Add "display" to FontFace _javascript_ object
+        https://bugs.webkit.org/show_bug.cgi?id=175383
+        <rdar://problem/33813239>
+
+        Reviewed by Simon Fraser.
+
+        We already have all the necessary infrastructure. Just hook it up to the .idl file!
+
+        Test: fast/text/font-loading-font-display.html
+
+        * css/CSSFontFace.h:
+        * css/CSSPrimitiveValueMappings.h:
+        * css/FontFace.cpp:
+        (WebCore::FontFace::create):
+        (WebCore::FontFace::setDisplay):
+        (WebCore::FontFace::display const):
+        * css/FontFace.h:
+        * css/FontFace.idl:
+
 2017-10-05  Jer Noble  <[email protected]>
 
         [Cocoa] Enable ENABLE_ENCRYPTED_MEDIA build-time setting

Modified: trunk/Source/WebCore/css/CSSFontFace.h (222948 => 222949)


--- trunk/Source/WebCore/css/CSSFontFace.h	2017-10-06 01:15:36 UTC (rev 222948)
+++ trunk/Source/WebCore/css/CSSFontFace.h	2017-10-06 01:25:01 UTC (rev 222949)
@@ -88,6 +88,7 @@
     const Vector<UnicodeRange>& ranges() const { return m_ranges; }
     const FontFeatureSettings& featureSettings() const { return m_featureSettings; }
     const FontVariantSettings& variantSettings() const { return m_variantSettings; }
+    FontLoadingBehavior loadingBehavior() const { return m_loadingBehavior; }
     void setVariantSettings(const FontVariantSettings& variantSettings) { m_variantSettings = variantSettings; }
     void setWeight(FontSelectionRange weight) { m_fontSelectionCapabilities.weight = weight; }
     void setStretch(FontSelectionRange stretch) { m_fontSelectionCapabilities.width = stretch; }

Modified: trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h (222948 => 222949)


--- trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2017-10-06 01:15:36 UTC (rev 222948)
+++ trunk/Source/WebCore/css/CSSPrimitiveValueMappings.h	2017-10-06 01:25:01 UTC (rev 222949)
@@ -5698,10 +5698,4 @@
     return FontLoadingBehavior::Auto;
 }
 
-/*
-enum class FontLoadingBehavior {
-    Auto, Block, Swap, Fallback, Optional
-};
-*/
-
 }

Modified: trunk/Source/WebCore/css/FontFace.cpp (222948 => 222949)


--- trunk/Source/WebCore/css/FontFace.cpp	2017-10-06 01:15:36 UTC (rev 222948)
+++ trunk/Source/WebCore/css/FontFace.cpp	2017-10-06 01:25:01 UTC (rev 222949)
@@ -31,6 +31,7 @@
 #include "CSSFontFeatureValue.h"
 #include "CSSFontStyleValue.h"
 #include "CSSParser.h"
+#include "CSSPrimitiveValueMappings.h"
 #include "CSSUnicodeRangeValue.h"
 #include "CSSValueList.h"
 #include "CSSValuePool.h"
@@ -104,6 +105,9 @@
     auto setFeatureSettingsResult = result->setFeatureSettings(descriptors.featureSettings.isEmpty() ? ASCIILiteral("normal") : descriptors.featureSettings);
     if (setFeatureSettingsResult.hasException())
         return setFeatureSettingsResult.releaseException();
+    auto setDisplayResult = result->setDisplay(descriptors.display.isEmpty() ? ASCIILiteral("auto") : descriptors.display);
+    if (setDisplayResult.hasException())
+        return setDisplayResult.releaseException();
 
     if (!dataRequiresAsynchronousLoading) {
         result->backing().load();
@@ -278,6 +282,19 @@
     return { };
 }
 
+ExceptionOr<void> FontFace::setDisplay(const String& display)
+{
+    if (display.isEmpty())
+        return Exception { SyntaxError };
+
+    if (auto value = parseString(display, CSSPropertyFontDisplay)) {
+        m_backing->setLoadingBehavior(*value);
+        return { };
+    }
+
+    return Exception { SyntaxError };
+}
+
 String FontFace::family() const
 {
     m_backing->updateStyleIfNeeded();
@@ -384,6 +401,12 @@
     return list->cssText();
 }
 
+String FontFace::display() const
+{
+    m_backing->updateStyleIfNeeded();
+    return CSSValuePool::singleton().createValue(m_backing->loadingBehavior())->cssText();
+}
+
 auto FontFace::status() const -> LoadStatus
 {
     switch (m_backing->status()) {

Modified: trunk/Source/WebCore/css/FontFace.h (222948 => 222949)


--- trunk/Source/WebCore/css/FontFace.h	2017-10-06 01:15:36 UTC (rev 222948)
+++ trunk/Source/WebCore/css/FontFace.h	2017-10-06 01:25:01 UTC (rev 222949)
@@ -47,6 +47,7 @@
         String unicodeRange;
         String variant;
         String featureSettings;
+        String display;
     };
     
     using Source = Variant<String, RefPtr<JSC::ArrayBuffer>, RefPtr<JSC::ArrayBufferView>>;
@@ -61,6 +62,7 @@
     ExceptionOr<void> setUnicodeRange(const String&);
     ExceptionOr<void> setVariant(const String&);
     ExceptionOr<void> setFeatureSettings(const String&);
+    ExceptionOr<void> setDisplay(const String&);
 
     String family() const;
     String style() const;
@@ -69,6 +71,7 @@
     String unicodeRange() const;
     String variant() const;
     String featureSettings() const;
+    String display() const;
 
     enum class LoadStatus { Unloaded, Loading, Loaded, Error };
     LoadStatus status() const;

Modified: trunk/Source/WebCore/css/FontFace.idl (222948 => 222949)


--- trunk/Source/WebCore/css/FontFace.idl	2017-10-06 01:15:36 UTC (rev 222948)
+++ trunk/Source/WebCore/css/FontFace.idl	2017-10-06 01:25:01 UTC (rev 222949)
@@ -39,6 +39,7 @@
     DOMString unicodeRange = "U+0-10FFFF";
     DOMString variant = "normal";
     DOMString featureSettings = "normal";
+    DOMString display = "auto";
 };
 
 [
@@ -53,6 +54,7 @@
     attribute DOMString unicodeRange;
     attribute DOMString variant;
     attribute DOMString featureSettings;
+    attribute DOMString display;
 
     readonly attribute FontFaceLoadStatus status;
 
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to