Title: [285112] trunk
Revision
285112
Author
cdu...@apple.com
Date
2021-11-01 10:04:09 -0700 (Mon, 01 Nov 2021)

Log Message

Align XSLTProcessor with Blink and get closer to Gecko in the process
https://bugs.webkit.org/show_bug.cgi?id=232485

Reviewed by Alex Christensen.

LayoutTests/imported/w3c:

Rebaseline WPT test now that more checks are passing.

* web-platform-tests/dom/idlharness.window-expected.txt:

Source/WebCore:

Align XSLTProcessor with Blink and get closer to Gecko (and the specification [1]) in the process.
The changes include making the parameters mandatory and non-nullable, as well as treating null
as the empty string for some parameters.

[1] https://dom.spec.whatwg.org/#xsltprocessor

No new tests, rebaselined existing test.

* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::transformToDocument):
(WebCore::XSLTProcessor::transformToFragment):
* xml/XSLTProcessor.h:
(WebCore::XSLTProcessor::importStylesheet):
* xml/XSLTProcessor.idl:

Modified Paths

Diff

Modified: trunk/LayoutTests/fast/xsl/xslt-processor-expected.txt (285111 => 285112)


--- trunk/LayoutTests/fast/xsl/xslt-processor-expected.txt	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/LayoutTests/fast/xsl/xslt-processor-expected.txt	2021-11-01 17:04:09 UTC (rev 285112)
@@ -47,7 +47,7 @@
 </body>
 </html>
 1.3 Import undefined stylesheet:
-****Failure**** (expected exception, instead got result: "undefined")
+Success
 1.4 Import undefined stylesheet:
 ****Failure**** (expected exception, instead got result: "undefined")
 1.5 Don't import stylesheet:
@@ -56,7 +56,7 @@
 2.0 DOMDocumentFragment transformToFragment(in DOMNode source, in DOMDocument output):
 
 2.1 fragment with undefined source:
-****Failure**** (expected exception, instead got result: "null")
+Success
 2.2 fragment with undefined output document:
 Success
 2.3 use non-DOMDocument output parameter:
@@ -70,8 +70,8 @@
 
 3.0 DOMDocument transformToDocument(in DOMNode source):
 
-3.1 use non-DOMDocument output parameter:
-****Failure**** (expected exception, instead got result: "null")
+3.1 document from undefined source:
+Success
 3.2 transform twice:
 Success
 
@@ -89,7 +89,7 @@
 5.0 Value getParameter(in DOMString namespaceURI, in DOMString localName):
 
 5.1 pass getParameter an undefined name:
-****Failure**** (expected exception, instead got result: "null")
+****Failure**** (expected exception, instead got result: "Success")
 5.2 pass getParameter a name which has not been set:
 Success
 5.3 verify getParameter actually gets (and set sets):

Modified: trunk/LayoutTests/fast/xsl/xslt-processor.html (285111 => 285112)


--- trunk/LayoutTests/fast/xsl/xslt-processor.html	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/LayoutTests/fast/xsl/xslt-processor.html	2021-11-01 17:04:09 UTC (rev 285112)
@@ -26,7 +26,7 @@
 	testId = 0;
 }
 
-function addResultExpectException(name, func) {
+function addResultExpectException(testname, func) {
 	try {
 		var result = func();
 		addStringResult(testname, "****Failure**** (expected exception, instead got result: \"" + result + "\")", "failure");
@@ -136,7 +136,9 @@
 
 
 // 2.0 DOMDocumentFragment transformToFragment(in DOMNode source, in DOMDocument output);
+
 addSectionHeader("DOMDocumentFragment transformToFragment(in DOMNode source, in DOMDocument output)");
+
 // 2.1 fragment with undefined source
 
 processor.reset();
@@ -147,9 +149,8 @@
 
 // 2.2 fragment with undefined output document
 
-ownerDocument = document.implementation.createDocument("", "test", null);
-newFragment = processor.transformToFragment(xml, undefined);
-addResultExpectValueWhenSerialized("fragment with undefined output document", newFragment, undefined);
+var testName = "fragment with undefined output document"
+addResultExpectException(testName, () => { processor.transformToFragment(xml, undefined); });
 
 // 2.3 use non-DOMDocument output parameter
 
@@ -274,7 +275,7 @@
 processor.setParameter(undefined, "undefined", "Success");
 processor.removeParameter(undefined, undefined);
 var testname = "pass removeParameter undefined name";
-addResultExpectValue(testname, processor.getParameter(undefined, "undefined"), "Success");
+addResultExpectValue(testname, processor.getParameter(undefined, "undefined"), null);
 
 // 6.4 pass removeParameter a name which has not been set
 
@@ -318,4 +319,4 @@
 </script>
 
 </body>
-</html>
\ No newline at end of file
+</html>

Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285111 => 285112)


--- trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/LayoutTests/imported/w3c/ChangeLog	2021-11-01 17:04:09 UTC (rev 285112)
@@ -1,3 +1,14 @@
+2021-11-01  Chris Dumez  <cdu...@apple.com>
+
+        Align XSLTProcessor with Blink and get closer to Gecko in the process
+        https://bugs.webkit.org/show_bug.cgi?id=232485
+
+        Reviewed by Alex Christensen.
+
+        Rebaseline WPT test now that more checks are passing.
+
+        * web-platform-tests/dom/idlharness.window-expected.txt:
+
 2021-10-31  Antti Koivisto  <an...@apple.com>
 
         Fix :host invalidation when combined with pseudo classes in descendant position

Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.window-expected.txt (285111 => 285112)


--- trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.window-expected.txt	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/dom/idlharness.window-expected.txt	2021-11-01 17:04:09 UTC (rev 285112)
@@ -1871,9 +1871,9 @@
 PASS XSLTProcessor interface: existence and properties of interface prototype object
 PASS XSLTProcessor interface: existence and properties of interface prototype object's "constructor" property
 PASS XSLTProcessor interface: existence and properties of interface prototype object's @@unscopables property
-FAIL XSLTProcessor interface: operation importStylesheet(Node) assert_equals: property has wrong .length expected 1 but got 0
-FAIL XSLTProcessor interface: operation transformToFragment(Node, Document) assert_equals: property has wrong .length expected 2 but got 0
-FAIL XSLTProcessor interface: operation transformToDocument(Node) assert_equals: property has wrong .length expected 1 but got 0
+PASS XSLTProcessor interface: operation importStylesheet(Node)
+PASS XSLTProcessor interface: operation transformToFragment(Node, Document)
+PASS XSLTProcessor interface: operation transformToDocument(Node)
 PASS XSLTProcessor interface: operation setParameter(DOMString, DOMString, any)
 PASS XSLTProcessor interface: operation getParameter(DOMString, DOMString)
 PASS XSLTProcessor interface: operation removeParameter(DOMString, DOMString)
@@ -1882,17 +1882,11 @@
 PASS XSLTProcessor must be primary interface of new XSLTProcessor()
 PASS Stringification of new XSLTProcessor()
 PASS XSLTProcessor interface: new XSLTProcessor() must inherit property "importStylesheet(Node)" with the proper type
-FAIL XSLTProcessor interface: calling importStylesheet(Node) on new XSLTProcessor() with too few arguments must throw TypeError assert_throws_js: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS XSLTProcessor interface: calling importStylesheet(Node) on new XSLTProcessor() with too few arguments must throw TypeError
 PASS XSLTProcessor interface: new XSLTProcessor() must inherit property "transformToFragment(Node, Document)" with the proper type
-FAIL XSLTProcessor interface: calling transformToFragment(Node, Document) on new XSLTProcessor() with too few arguments must throw TypeError assert_throws_js: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS XSLTProcessor interface: calling transformToFragment(Node, Document) on new XSLTProcessor() with too few arguments must throw TypeError
 PASS XSLTProcessor interface: new XSLTProcessor() must inherit property "transformToDocument(Node)" with the proper type
-FAIL XSLTProcessor interface: calling transformToDocument(Node) on new XSLTProcessor() with too few arguments must throw TypeError assert_throws_js: Called with 0 arguments function "function () {
-            fn.apply(obj, args);
-        }" did not throw
+PASS XSLTProcessor interface: calling transformToDocument(Node) on new XSLTProcessor() with too few arguments must throw TypeError
 PASS XSLTProcessor interface: new XSLTProcessor() must inherit property "setParameter(DOMString, DOMString, any)" with the proper type
 PASS XSLTProcessor interface: calling setParameter(DOMString, DOMString, any) on new XSLTProcessor() with too few arguments must throw TypeError
 PASS XSLTProcessor interface: new XSLTProcessor() must inherit property "getParameter(DOMString, DOMString)" with the proper type

Modified: trunk/Source/WebCore/ChangeLog (285111 => 285112)


--- trunk/Source/WebCore/ChangeLog	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/Source/WebCore/ChangeLog	2021-11-01 17:04:09 UTC (rev 285112)
@@ -1,3 +1,25 @@
+2021-11-01  Chris Dumez  <cdu...@apple.com>
+
+        Align XSLTProcessor with Blink and get closer to Gecko in the process
+        https://bugs.webkit.org/show_bug.cgi?id=232485
+
+        Reviewed by Alex Christensen.
+
+        Align XSLTProcessor with Blink and get closer to Gecko (and the specification [1]) in the process.
+        The changes include making the parameters mandatory and non-nullable, as well as treating null
+        as the empty string for some parameters.
+
+        [1] https://dom.spec.whatwg.org/#xsltprocessor
+
+        No new tests, rebaselined existing test.
+
+        * xml/XSLTProcessor.cpp:
+        (WebCore::XSLTProcessor::transformToDocument):
+        (WebCore::XSLTProcessor::transformToFragment):
+        * xml/XSLTProcessor.h:
+        (WebCore::XSLTProcessor::importStylesheet):
+        * xml/XSLTProcessor.idl:
+
 2021-11-01  Ayumi Kojima  <ayumi_koj...@apple.com>
 
         Unreviewed, reverting r285055.

Modified: trunk/Source/WebCore/xml/XSLTProcessor.cpp (285111 => 285112)


--- trunk/Source/WebCore/xml/XSLTProcessor.cpp	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/Source/WebCore/xml/XSLTProcessor.cpp	2021-11-01 17:04:09 UTC (rev 285112)
@@ -107,35 +107,29 @@
     return result.releaseNonNull();
 }
 
-RefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
+RefPtr<Document> XSLTProcessor::transformToDocument(Node& sourceNode)
 {
-    if (!sourceNode)
-        return nullptr;
-
     String resultMIMEType;
     String resultString;
     String resultEncoding;
-    if (!transformToString(*sourceNode, resultMIMEType, resultString, resultEncoding))
+    if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncoding))
         return nullptr;
-    return createDocumentFromSource(resultString, resultEncoding, resultMIMEType, sourceNode, 0);
+    return createDocumentFromSource(resultString, resultEncoding, resultMIMEType, &sourceNode, nullptr);
 }
 
-RefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node* sourceNode, Document* outputDoc)
+RefPtr<DocumentFragment> XSLTProcessor::transformToFragment(Node& sourceNode, Document& outputDocument)
 {
-    if (!sourceNode || !outputDoc)
-        return nullptr;
-
     String resultMIMEType;
     String resultString;
     String resultEncoding;
 
     // If the output document is HTML, default to HTML method.
-    if (outputDoc->isHTMLDocument())
+    if (outputDocument.isHTMLDocument())
         resultMIMEType = "text/html";
 
-    if (!transformToString(*sourceNode, resultMIMEType, resultString, resultEncoding))
+    if (!transformToString(sourceNode, resultMIMEType, resultString, resultEncoding))
         return nullptr;
-    return createFragmentForTransformToFragment(*outputDoc, resultString, resultMIMEType);
+    return createFragmentForTransformToFragment(outputDocument, resultString, resultMIMEType);
 }
 
 void XSLTProcessor::setParameter(const String& /*namespaceURI*/, const String& localName, const String& value)

Modified: trunk/Source/WebCore/xml/XSLTProcessor.h (285111 => 285112)


--- trunk/Source/WebCore/xml/XSLTProcessor.h	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/Source/WebCore/xml/XSLTProcessor.h	2021-11-01 17:04:09 UTC (rev 285112)
@@ -47,13 +47,12 @@
     Ref<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame);
     
     // DOM methods
-    void importStylesheet(RefPtr<Node>&& style)
+    void importStylesheet(Ref<Node>&& style)
     {
-        if (style)
-            m_stylesheetRootNode = WTFMove(style);
+        m_stylesheetRootNode = WTFMove(style);
     }
-    RefPtr<DocumentFragment> transformToFragment(Node* source, Document* ouputDoc);
-    RefPtr<Document> transformToDocument(Node* source);
+    RefPtr<DocumentFragment> transformToFragment(Node& source, Document& ouputDocument);
+    RefPtr<Document> transformToDocument(Node& source);
     
     void setParameter(const String& namespaceURI, const String& localName, const String& value);
     String getParameter(const String& namespaceURI, const String& localName) const;
@@ -68,7 +67,7 @@
     // Only for libXSLT callbacks
     XSLStyleSheet* xslStylesheet() const { return m_stylesheet.get(); }
 
-    typedef HashMap<String, String> ParameterMap;
+    using ParameterMap = HashMap<String, String>;
 
 private:
     XSLTProcessor() = default;

Modified: trunk/Source/WebCore/xml/XSLTProcessor.idl (285111 => 285112)


--- trunk/Source/WebCore/xml/XSLTProcessor.idl	2021-11-01 16:43:10 UTC (rev 285111)
+++ trunk/Source/WebCore/xml/XSLTProcessor.idl	2021-11-01 17:04:09 UTC (rev 285112)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2008, 2010 Apple Inc. All rights reserved.
+ * Copyright (C) 2008-2021 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
@@ -26,10 +26,7 @@
  * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-// Eventually we should implement XSLTException:
-// http://lxr.mozilla.org/seamonkey/source/content/xsl/public/nsIXSLTException.idl
-// http://bugs.webkit.org/show_bug.cgi?id=5446
-
+// https://dom.spec.whatwg.org/#xsltprocessor
 [
     Conditional=XSLT,
     ImplementationLacksVTable,
@@ -37,13 +34,20 @@
 ] interface XSLTProcessor {
     constructor();
 
-    undefined importStylesheet(optional Node? stylesheet = null);
-    DocumentFragment transformToFragment(optional Node? source = null, optional Document? docVal = null);
-    Document transformToDocument(optional Node? source = null);
+    undefined importStylesheet(Node style);
 
-    undefined setParameter(DOMString? namespaceURI, DOMString? localName, DOMString? value);
-    DOMString? getParameter(DOMString? namespaceURI, DOMString? localName);
-    undefined removeParameter(DOMString? namespaceURI, DOMString? localName);
+    // FIXME: In Gecko and the specification, those 2 operations do not return nullable types and instead throw an nsIXSLTException
+    // in case of error.
+    [CEReactions] DocumentFragment? transformToFragment(Node source, Document output);
+    [CEReactions] Document? transformToDocument(Node source);
+
+    // FIXME: Per the specification, value should have type 'any', not 'DOMString'.
+    undefined setParameter([LegacyNullToEmptyString] DOMString namespaceURI, DOMString localName, DOMString value);
+
+    // FIXME: Per specification, this should return a type 'any', not 'DOMString?'.
+    DOMString? getParameter([LegacyNullToEmptyString] DOMString namespaceURI, DOMString localName);
+
+    undefined removeParameter([LegacyNullToEmptyString] DOMString namespaceURI, DOMString localName);
     undefined clearParameters();
 
     undefined reset();
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to