[WebIDL] Remove custom bindings for HTMLDocument
authorweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jun 2017 01:19:28 +0000 (01:19 +0000)
committerweinig@apple.com <weinig@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 17 Jun 2017 01:19:28 +0000 (01:19 +0000)
https://bugs.webkit.org/show_bug.cgi?id=173444

Reviewed by Darin Adler.

LayoutTests/imported/w3c:

* web-platform-tests/html/dom/dynamic-markup-insertion/closing-the-input-stream/document.close-01-expected.txt:
* web-platform-tests/html/dom/dynamic-markup-insertion/document-write/document.write-01-expected.txt:
* web-platform-tests/html/dom/dynamic-markup-insertion/document-writeln/document.writeln-01-expected.txt:
* web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-01-expected.txt:
* web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-02-expected.txt:
Update now passing results.

Source/WebCore:

* bindings/js/JSDOMBindingSecurity.cpp:
(WebCore::canAccessDocument):
(WebCore::BindingSecurity::shouldAllowAccessToFrame):
(WebCore::BindingSecurity::shouldAllowAccessToDOMWindow):
* bindings/js/JSDOMWindowCustom.cpp:
(WebCore::JSDOMWindow::showModalDialog):
Pass ExecState by reference to window accessors.

* bindings/js/JSDOMWindowBase.cpp:
(WebCore::incumbentDOMWindow):
(WebCore::activeDOMWindow):
(WebCore::firstDOMWindow):
(WebCore::callerDocument):
* bindings/js/JSDOMWindowBase.h:
Pass ExecState by reference to window accessors and add callerDocument.

* bindings/js/JSHTMLDocumentCustom.cpp:
(WebCore::JSHTMLDocument::getOwnPropertySlot): Deleted.
(WebCore::JSHTMLDocument::all): Deleted.
(WebCore::JSHTMLDocument::setAll): Deleted.
(WebCore::findCallingDocument): Deleted.
(WebCore::JSHTMLDocument::open): Deleted.
(WebCore::documentWrite): Deleted.
(WebCore::JSHTMLDocument::write): Deleted.
Remove custom bindings.

* bindings/scripts/CodeGeneratorJS.pm:
(GenerateCallWith):
Add support CallWith=CallerDocument

* bindings/scripts/IDLAttributes.json:
Remove CallerWindow, which has not been supported for a while. CallerDocument, despite
having it's support removed in the past, was still listed, so keep it.

* bindings/scripts/test/JS/JSTestObj.cpp:
Update test results.

* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createHTMLDocument):
Update for new signature of Document.write().

* dom/Document.h:
* dom/Document.idl:
* dom/Document.cpp:
(WebCore::Document::open):
Add DOMWindow returning overload that calls through to the DOMWindow.
Add return value and currently not utilized parameters to the Document returning overload.
Update to return exceptions as specified.

(WebCore::Document::close):
Update to return exceptions as specified.

(WebCore::Document::write):
(WebCore::Document::writeln):
Update to take a Vector<String> argument and the caller Document first
as per convention and return exceptions as specified.

(WebCore::Document::bgColor):
(WebCore::Document::setBgColor):
(WebCore::Document::fgColor):
(WebCore::Document::setFgColor):
(WebCore::Document::alinkColor):
(WebCore::Document::setAlinkColor):
(WebCore::Document::linkColorForBindings):
(WebCore::Document::setLinkColorForBindings):
(WebCore::Document::vlinkColor):
(WebCore::Document::setVlinkColor):
(WebCore::Document::clear):
(WebCore::Document::captureEvents):
(WebCore::Document::releaseEvents):
Move from HTMLDocument.

* html/HTMLDocument.cpp:
(WebCore::HTMLDocument::bgColor): Deleted.
(WebCore::HTMLDocument::setBgColor): Deleted.
(WebCore::HTMLDocument::fgColor): Deleted.
(WebCore::HTMLDocument::setFgColor): Deleted.
(WebCore::HTMLDocument::alinkColor): Deleted.
(WebCore::HTMLDocument::setAlinkColor): Deleted.
(WebCore::HTMLDocument::linkColor): Deleted.
(WebCore::HTMLDocument::setLinkColor): Deleted.
(WebCore::HTMLDocument::vlinkColor): Deleted.
(WebCore::HTMLDocument::setVlinkColor): Deleted.
(WebCore::HTMLDocument::clear): Deleted.
(WebCore::HTMLDocument::captureEvents): Deleted.
(WebCore::HTMLDocument::releaseEvents): Deleted.
* html/HTMLDocument.h:
* html/HTMLDocument.idl:
Moved operations and attributes to Document.

* inspector/DOMPatchSupport.cpp:
(WebCore::DOMPatchSupport::patchDocument):
Update for new signature of Document.write().

* page/DOMWindow.cpp:
(WebCore::DOMWindow::postMessage):
(WebCore::DOMWindow::focus):
* page/DOMWindow.h:
Use the term incumbentWindow, matching IDL, and so not to be confused
with the callerWindow, which is slightly different.

Source/WebKit/mac:

* DOM/DOMHTMLDocument.mm:
(-[DOMHTMLDocument linkColor]):
(-[DOMHTMLDocument setLinkColor:]):
(-[DOMHTMLDocument write:]):
(-[DOMHTMLDocument writeln:]):
Update for new signature of write/writeln and rename of linkColor to linkColorForBindings.

Source/WebKit/win:

* DOMHTMLClasses.cpp:
(DOMHTMLDocument::write):
(DOMHTMLDocument::writeln):
Update for new signature of write/writeln.

Source/WebKit2:

* WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLDocument.cpp:
(webkit_dom_html_document_get_link_color):
(webkit_dom_html_document_set_link_color):
Update for rename of linkColor to linkColorForBindings.

LayoutTests:

* dom/xhtml/level2/html/HTMLDocument17-expected.txt:
* dom/xhtml/level2/html/HTMLDocument18-expected.txt:
* dom/xhtml/level2/html/HTMLDocument19-expected.txt:
* dom/xhtml/level2/html/HTMLDocument20-expected.txt:
* dom/xhtml/level2/html/HTMLDocument21-expected.txt:
Update test results for correct exception being thrown.

* fast/dom/frame-deleted-in-document-open-expected.txt: Removed.
* fast/dom/frame-deleted-in-document-open.html: Removed.
* http/tests/security/isolatedWorld/document-open-expected.txt: Removed.
* http/tests/security/isolatedWorld/document-open.html: Removed.
Remove two tests that were testing the behavior of document.open using javascript
to call the window.open operation. This is not how it is specified and no
longer how it is implemented.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@218437 268f45cc-cd09-0410-ab3c-d52691b4dbfc

42 files changed:
LayoutTests/ChangeLog
LayoutTests/dom/xhtml/level2/html/HTMLDocument17-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLDocument18-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLDocument19-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLDocument20-expected.txt
LayoutTests/dom/xhtml/level2/html/HTMLDocument21-expected.txt
LayoutTests/fast/dom/frame-deleted-in-document-open-expected.txt [deleted file]
LayoutTests/fast/dom/frame-deleted-in-document-open.html [deleted file]
LayoutTests/http/tests/security/isolatedWorld/document-open-expected.txt [deleted file]
LayoutTests/http/tests/security/isolatedWorld/document-open.html [deleted file]
LayoutTests/imported/w3c/ChangeLog
LayoutTests/imported/w3c/web-platform-tests/html/dom/dynamic-markup-insertion/closing-the-input-stream/document.close-01-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/dom/dynamic-markup-insertion/document-write/document.write-01-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/dom/dynamic-markup-insertion/document-writeln/document.writeln-01-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-01-expected.txt
LayoutTests/imported/w3c/web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-02-expected.txt
LayoutTests/js/dom/dom-attributes-on-mismatch-type-expected.txt
Source/WebCore/ChangeLog
Source/WebCore/bindings/js/JSDOMBindingSecurity.cpp
Source/WebCore/bindings/js/JSDOMWindowBase.cpp
Source/WebCore/bindings/js/JSDOMWindowBase.h
Source/WebCore/bindings/js/JSDOMWindowCustom.cpp
Source/WebCore/bindings/js/JSHTMLDocumentCustom.cpp
Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
Source/WebCore/bindings/scripts/IDLAttributes.json
Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
Source/WebCore/dom/DOMImplementation.cpp
Source/WebCore/dom/Document.cpp
Source/WebCore/dom/Document.h
Source/WebCore/dom/Document.idl
Source/WebCore/html/HTMLDocument.cpp
Source/WebCore/html/HTMLDocument.h
Source/WebCore/html/HTMLDocument.idl
Source/WebCore/inspector/DOMPatchSupport.cpp
Source/WebCore/page/DOMWindow.cpp
Source/WebCore/page/DOMWindow.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/DOM/DOMHTMLDocument.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/DOMHTMLClasses.cpp
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLDocument.cpp

index a8020c9..5f8e6cf 100644 (file)
@@ -1,3 +1,25 @@
+2017-06-16  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for HTMLDocument
+        https://bugs.webkit.org/show_bug.cgi?id=173444
+
+        Reviewed by Darin Adler.
+
+        * dom/xhtml/level2/html/HTMLDocument17-expected.txt:
+        * dom/xhtml/level2/html/HTMLDocument18-expected.txt:
+        * dom/xhtml/level2/html/HTMLDocument19-expected.txt:
+        * dom/xhtml/level2/html/HTMLDocument20-expected.txt:
+        * dom/xhtml/level2/html/HTMLDocument21-expected.txt:
+        Update test results for correct exception being thrown.
+
+        * fast/dom/frame-deleted-in-document-open-expected.txt: Removed.
+        * fast/dom/frame-deleted-in-document-open.html: Removed.
+        * http/tests/security/isolatedWorld/document-open-expected.txt: Removed.
+        * http/tests/security/isolatedWorld/document-open.html: Removed.
+        Remove two tests that were testing the behavior of document.open using javascript
+        to call the window.open operation. This is not how it is specified and no
+        longer how it is implemented.
+
 2017-06-16  Youenn Fablet  <youenn@apple.com>
 
         WebRTC sockets should be closed at destruction time if not closed explicitly
index ad67872..61ede78 100644 (file)
@@ -1,3 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLDocument17
 Status error
-Message        Line 96: TypeError
+Message        Line 96: InvalidStateError
index 7b05732..d0f5de4 100644 (file)
@@ -1,3 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLDocument18
 Status error
-Message        Line 93: TypeError
+Message        Line 93: InvalidStateError
index 067859f..8898fde 100644 (file)
@@ -1,3 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLDocument19
 Status error
-Message        Line 97: TypeError
+Message        Line 97: InvalidStateError
index ce6a538..4c22778 100644 (file)
@@ -1,3 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLDocument20
 Status error
-Message        Line 97: TypeError
+Message        Line 97: InvalidStateError
index 0551f9e..59c462a 100644 (file)
@@ -1,3 +1,3 @@
 Test   http://www.w3.org/2001/DOM-Test-Suite/level2/html/HTMLDocument21
 Status error
-Message        Line 101: TypeError
+Message        Line 101: InvalidStateError
diff --git a/LayoutTests/fast/dom/frame-deleted-in-document-open-expected.txt b/LayoutTests/fast/dom/frame-deleted-in-document-open-expected.txt
deleted file mode 100644 (file)
index 730ebf6..0000000
+++ /dev/null
@@ -1 +0,0 @@
-This test passes if it doesn't crash.
diff --git a/LayoutTests/fast/dom/frame-deleted-in-document-open.html b/LayoutTests/fast/dom/frame-deleted-in-document-open.html
deleted file mode 100644 (file)
index 6a5b189..0000000
+++ /dev/null
@@ -1,23 +0,0 @@
-<html>
-<head>
-<script>
-if (window.testRunner)
-    testRunner.dumpAsText();
-
-window.onload = function()
-{
-    frame = document.body.appendChild(document.createElement("iframe"));
-
-    frame.contentWindow.open = null;
-    frame.contentWindow.__defineGetter__("open", function() {
-        document.body.removeChild(frame);
-        return function() { };
-    });
-    frame.contentDocument.open(1, 1, 1, 1, 1);
-}
-</script>
-</head>
-<body>
-This test passes if it doesn't crash.
-</body>
-</html>
diff --git a/LayoutTests/http/tests/security/isolatedWorld/document-open-expected.txt b/LayoutTests/http/tests/security/isolatedWorld/document-open-expected.txt
deleted file mode 100644 (file)
index 9c70321..0000000
+++ /dev/null
@@ -1,2 +0,0 @@
-ALERT: PASS
-
diff --git a/LayoutTests/http/tests/security/isolatedWorld/document-open.html b/LayoutTests/http/tests/security/isolatedWorld/document-open.html
deleted file mode 100644 (file)
index 0d88576..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-<!DOCTYPE html>
-<html>
-<body>
-<div id="console"></div>
-<script>
-window.open = function () { alert("FAIL: Visible in isolated world."); };
-if (window.testRunner) {
-  testRunner.dumpAsText();
-  testRunner.evaluateScriptInIsolatedWorld(
-    0,
-    "window.open = function () { alert('PASS'); };\n" +
-    "document.open(1, 2, 3);");
-}
-</script>
-</body>
-</html>
index 124d7c2..864d118 100644 (file)
@@ -1,3 +1,17 @@
+2017-06-16  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for HTMLDocument
+        https://bugs.webkit.org/show_bug.cgi?id=173444
+
+        Reviewed by Darin Adler.
+
+        * web-platform-tests/html/dom/dynamic-markup-insertion/closing-the-input-stream/document.close-01-expected.txt:
+        * web-platform-tests/html/dom/dynamic-markup-insertion/document-write/document.write-01-expected.txt:
+        * web-platform-tests/html/dom/dynamic-markup-insertion/document-writeln/document.writeln-01-expected.txt:
+        * web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-01-expected.txt:
+        * web-platform-tests/html/dom/dynamic-markup-insertion/opening-the-input-stream/document.open-02-expected.txt:
+        Update now passing results.
+
 2017-06-15  Youenn Fablet  <youenn@apple.com>
 
         RTCPeerConnection returns RTCSessionDescription where RTCSessionDescriptionInit would be appropriate
index e788d9b..9207b45 100644 (file)
@@ -1,5 +1,3 @@
 
-FAIL document.close in XHTML assert_throws: document.close in XHTML should throw an INVALID_STATE_ERR  function "function () {
-    document.close();
-  }" threw object "TypeError: document.close is not a function. (In 'document.close()', 'document.close' is undefined)" that is not a DOMException INVALID_STATE_ERR: property "code" is equal to undefined, expected 11
+PASS document.close in XHTML 
 
index 0295c97..e826a31 100644 (file)
@@ -1,5 +1,3 @@
 
-FAIL document.write in XHTML assert_throws: document.write in XHTML should throw an INVALID_STATE_ERR  function "function () {
-    document.write("Failure: document.write actually worked");
-  }" threw object "TypeError: document.write is not a function. (In 'document.write("Failure: document.write actually worked")', 'document.write' is undefined)" that is not a DOMException INVALID_STATE_ERR: property "code" is equal to undefined, expected 11
+PASS document.write in XHTML 
 
index 8d05021..5aa05a4 100644 (file)
@@ -1,5 +1,3 @@
 
-FAIL document.writeln in XHTML assert_throws: document.writeln in XHTML should throw an INVALID_STATE_ERR  function "function () {
-    document.writeln("Failure: document.writeln actually worked");
-  }" threw object "TypeError: document.writeln is not a function. (In 'document.writeln("Failure: document.writeln actually worked")', 'document.writeln' is undefined)" that is not a DOMException INVALID_STATE_ERR: property "code" is equal to undefined, expected 11
+PASS document.writeln in XHTML 
 
index 6082fe3..623e71c 100644 (file)
@@ -1,5 +1,3 @@
 
-FAIL document.open in XHTML assert_throws: document.open in XHTML should throw an INVALID_STATE_ERR  function "function () {
-    document.open();
-  }" threw object "TypeError: document.open is not a function. (In 'document.open()', 'document.open' is undefined)" that is not a DOMException INVALID_STATE_ERR: property "code" is equal to undefined, expected 11
+PASS document.open in XHTML 
 
index e88c56b..d2eb94e 100644 (file)
@@ -1,6 +1,4 @@
 
-FAIL document.open should redirect to window.open when called with three arguments assert_unreached: The call should be redirected to the real window.open Reached unreachable code
-FAIL document.open should throw when it has no window and is called with three arguments assert_throws: function "function () {
-    doc.open("/resources/testharness.js", "", "");
-  }" did not throw
+PASS document.open should redirect to window.open when called with three arguments 
+PASS document.open should throw when it has no window and is called with three arguments 
 
index d98248f..d6988e6 100644 (file)
@@ -3,7 +3,7 @@ Make sure DOM attributes handle different types of |this| properly
 On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 
 
-PASS objectWithDocumentAsPrototype.all threw exception TypeError: The HTMLDocument.all getter can only be used on instances of HTMLDocument.
+PASS objectWithDocumentAsPrototype.all threw exception TypeError: The Document.all getter can only be used on instances of Document.
 See what happens if we put the anchor prototype on a div
 PASS testDiv instanceof HTMLAnchorElement is true
 PASS testDiv.href threw exception TypeError: The HTMLAnchorElement.href getter can only be used on instances of HTMLAnchorElement.
index e6216b9..dea32cc 100644 (file)
@@ -1,3 +1,111 @@
+2017-06-16  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for HTMLDocument
+        https://bugs.webkit.org/show_bug.cgi?id=173444
+
+        Reviewed by Darin Adler.
+
+        * bindings/js/JSDOMBindingSecurity.cpp:
+        (WebCore::canAccessDocument):
+        (WebCore::BindingSecurity::shouldAllowAccessToFrame):
+        (WebCore::BindingSecurity::shouldAllowAccessToDOMWindow):
+        * bindings/js/JSDOMWindowCustom.cpp:
+        (WebCore::JSDOMWindow::showModalDialog):
+        Pass ExecState by reference to window accessors.
+
+        * bindings/js/JSDOMWindowBase.cpp:
+        (WebCore::incumbentDOMWindow):
+        (WebCore::activeDOMWindow):
+        (WebCore::firstDOMWindow):
+        (WebCore::callerDocument):
+        * bindings/js/JSDOMWindowBase.h:
+        Pass ExecState by reference to window accessors and add callerDocument.
+    
+        * bindings/js/JSHTMLDocumentCustom.cpp:
+        (WebCore::JSHTMLDocument::getOwnPropertySlot): Deleted.
+        (WebCore::JSHTMLDocument::all): Deleted.
+        (WebCore::JSHTMLDocument::setAll): Deleted.
+        (WebCore::findCallingDocument): Deleted.
+        (WebCore::JSHTMLDocument::open): Deleted.
+        (WebCore::documentWrite): Deleted.
+        (WebCore::JSHTMLDocument::write): Deleted.
+        Remove custom bindings.
+
+        * bindings/scripts/CodeGeneratorJS.pm:
+        (GenerateCallWith):
+        Add support CallWith=CallerDocument
+
+        * bindings/scripts/IDLAttributes.json:
+        Remove CallerWindow, which has not been supported for a while. CallerDocument, despite 
+        having it's support removed in the past, was still listed, so keep it.
+
+        * bindings/scripts/test/JS/JSTestObj.cpp:
+        Update test results.
+
+        * dom/DOMImplementation.cpp:
+        (WebCore::DOMImplementation::createHTMLDocument):
+        Update for new signature of Document.write().
+
+        * dom/Document.h:
+        * dom/Document.idl:
+        * dom/Document.cpp:
+        (WebCore::Document::open):
+        Add DOMWindow returning overload that calls through to the DOMWindow.
+        Add return value and currently not utilized parameters to the Document returning overload.
+        Update to return exceptions as specified.
+
+        (WebCore::Document::close):
+        Update to return exceptions as specified.
+
+        (WebCore::Document::write):
+        (WebCore::Document::writeln):
+        Update to take a Vector<String> argument and the caller Document first
+        as per convention and return exceptions as specified.
+
+        (WebCore::Document::bgColor):
+        (WebCore::Document::setBgColor):
+        (WebCore::Document::fgColor):
+        (WebCore::Document::setFgColor):
+        (WebCore::Document::alinkColor):
+        (WebCore::Document::setAlinkColor):
+        (WebCore::Document::linkColorForBindings):
+        (WebCore::Document::setLinkColorForBindings):
+        (WebCore::Document::vlinkColor):
+        (WebCore::Document::setVlinkColor):
+        (WebCore::Document::clear):
+        (WebCore::Document::captureEvents):
+        (WebCore::Document::releaseEvents):
+        Move from HTMLDocument.
+
+        * html/HTMLDocument.cpp:
+        (WebCore::HTMLDocument::bgColor): Deleted.
+        (WebCore::HTMLDocument::setBgColor): Deleted.
+        (WebCore::HTMLDocument::fgColor): Deleted.
+        (WebCore::HTMLDocument::setFgColor): Deleted.
+        (WebCore::HTMLDocument::alinkColor): Deleted.
+        (WebCore::HTMLDocument::setAlinkColor): Deleted.
+        (WebCore::HTMLDocument::linkColor): Deleted.
+        (WebCore::HTMLDocument::setLinkColor): Deleted.
+        (WebCore::HTMLDocument::vlinkColor): Deleted.
+        (WebCore::HTMLDocument::setVlinkColor): Deleted.
+        (WebCore::HTMLDocument::clear): Deleted.
+        (WebCore::HTMLDocument::captureEvents): Deleted.
+        (WebCore::HTMLDocument::releaseEvents): Deleted.
+        * html/HTMLDocument.h:
+        * html/HTMLDocument.idl:
+        Moved operations and attributes to Document.
+
+        * inspector/DOMPatchSupport.cpp:
+        (WebCore::DOMPatchSupport::patchDocument):
+        Update for new signature of Document.write().
+
+        * page/DOMWindow.cpp:
+        (WebCore::DOMWindow::postMessage):
+        (WebCore::DOMWindow::focus):
+        * page/DOMWindow.h:
+        Use the term incumbentWindow, matching IDL, and so not to be confused
+        with the callerWindow, which is slightly different.
+
 2017-06-16  Daniel Bates  <dabates@apple.com>
 
         Remove header OptionSet.h from FrameLoaderTypes.h
index 4eefc86..16ee7cc 100644 (file)
@@ -49,7 +49,7 @@ static inline bool canAccessDocument(JSC::ExecState* state, Document* targetDocu
     if (!targetDocument)
         return false;
 
-    DOMWindow& active = activeDOMWindow(state);
+    DOMWindow& active = activeDOMWindow(*state);
 
     if (active.document()->securityOrigin().canAccess(targetDocument->securityOrigin()))
         return true;
@@ -72,7 +72,7 @@ bool BindingSecurity::shouldAllowAccessToFrame(ExecState& state, Frame& frame, S
 {
     if (BindingSecurity::shouldAllowAccessToFrame(&state, &frame, DoNotReportSecurityError))
         return true;
-    message = frame.document()->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(&state));
+    message = frame.document()->domWindow()->crossDomainAccessErrorMessage(activeDOMWindow(state));
     return false;
 }
 
@@ -80,7 +80,7 @@ bool BindingSecurity::shouldAllowAccessToDOMWindow(ExecState& state, DOMWindow&
 {
     if (BindingSecurity::shouldAllowAccessToDOMWindow(&state, globalObject, DoNotReportSecurityError))
         return true;
-    message = globalObject.crossDomainAccessErrorMessage(activeDOMWindow(&state));
+    message = globalObject.crossDomainAccessErrorMessage(activeDOMWindow(state));
     return false;
 }
 
index aa5e1c9..8aeaa84 100644 (file)
@@ -284,7 +284,7 @@ JSDOMWindow* toJSDOMWindow(JSC::VM& vm, JSValue value)
     return nullptr;
 }
 
-DOMWindow& incumbentDOMWindow(ExecState* exec)
+DOMWindow& incumbentDOMWindow(ExecState& state)
 {
     class GetCallerGlobalObjectFunctor {
     public:
@@ -318,18 +318,28 @@ DOMWindow& incumbentDOMWindow(ExecState* exec)
     };
 
     GetCallerGlobalObjectFunctor iter;
-    exec->iterate(iter);
-    return iter.globalObject() ? asJSDOMWindow(iter.globalObject())->wrapped() : firstDOMWindow(exec);
+    state.iterate(iter);
+    return iter.globalObject() ? asJSDOMWindow(iter.globalObject())->wrapped() : firstDOMWindow(state);
 }
 
-DOMWindow& activeDOMWindow(ExecState* exec)
+DOMWindow& activeDOMWindow(ExecState& state)
 {
-    return asJSDOMWindow(exec->lexicalGlobalObject())->wrapped();
+    return asJSDOMWindow(state.lexicalGlobalObject())->wrapped();
 }
 
-DOMWindow& firstDOMWindow(ExecState* exec)
+DOMWindow& firstDOMWindow(ExecState& state)
 {
-    return asJSDOMWindow(exec->vmEntryGlobalObject())->wrapped();
+    return asJSDOMWindow(state.vmEntryGlobalObject())->wrapped();
+}
+
+Document* responsibleDocument(ExecState& state)
+{
+    CallerFunctor functor;
+    state.iterate(functor);
+    auto* callerFrame = functor.callerFrame();
+    if (!callerFrame)
+        return nullptr;
+    return asJSDOMWindow(callerFrame->lexicalGlobalObject())->wrapped().document();
 }
 
 void JSDOMWindowBase::fireFrameClearedWatchpointsForWindow(DOMWindow* window)
index d5ff703..076cb63 100644 (file)
@@ -104,9 +104,16 @@ WEBCORE_EXPORT JSDOMWindow* toJSDOMWindow(JSC::VM&, JSC::JSValue);
 // (<https://html.spec.whatwg.org/multipage/webappapis.html#concept-incumbent-everything>, 27 April 2017)
 // FIXME: Make this work for an "author function or script that originally scheduled the currently-running callback."
 // See <https://bugs.webkit.org/show_bug.cgi?id=163412>.
-DOMWindow& incumbentDOMWindow(JSC::ExecState*);
+DOMWindow& incumbentDOMWindow(JSC::ExecState&);
 
-DOMWindow& activeDOMWindow(JSC::ExecState*);
-DOMWindow& firstDOMWindow(JSC::ExecState*);
+DOMWindow& activeDOMWindow(JSC::ExecState&);
+DOMWindow& firstDOMWindow(JSC::ExecState&);
+
+// FIXME: This should probably be removed in favor of one of the other DOMWindow accessors. It is intended
+//        to provide the document specfied as the 'responsible document' in the algorithm for document.open()
+//        (https://html.spec.whatwg.org/multipage/dynamic-markup-insertion.html#document-open-steps steps 4
+//        and 23 and https://html.spec.whatwg.org/multipage/webappapis.html#responsible-document). It is only
+//        used by JSDocument.
+Document* responsibleDocument(JSC::ExecState&);
 
 } // namespace WebCore
index 69c0a1e..af4aa10 100644 (file)
@@ -518,7 +518,7 @@ JSValue JSDOMWindow::showModalDialog(ExecState& state)
 
     DialogHandler handler(state);
 
-    wrapped().showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(&state), firstDOMWindow(&state), [&handler](DOMWindow& dialog) {
+    wrapped().showModalDialog(urlString, dialogFeaturesString, activeDOMWindow(state), firstDOMWindow(state), [&handler](DOMWindow& dialog) {
         handler.dialogCreated(dialog);
     });
 
index d2a1d60..98cde4a 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright (C) 2007-2016 Apple Inc. All rights reserved.
+ * Copyright (C) 2007-2017 Apple Inc. All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
  * modification, are permitted provided that the following conditions
 #include "config.h"
 #include "JSHTMLDocument.h"
 
-#include "JSDOMAbstractOperations.h"
-#include "JSDOMConvertInterface.h"
-#include "JSDOMConvertUnion.h"
-#include "JSDOMWindowCustom.h"
-#include "JSHTMLCollection.h"
-#include "SegmentedString.h"
-#include <runtime/Lookup.h>
-
 using namespace JSC;
 
 namespace WebCore {
 
-using namespace HTMLNames;
-
 JSValue toJSNewlyCreated(ExecState* state, JSDOMGlobalObject* globalObject, Ref<HTMLDocument>&& passedDocument)
 {
     auto& document = passedDocument.get();
@@ -55,116 +45,4 @@ JSValue toJS(ExecState* state, JSDOMGlobalObject* globalObject, HTMLDocument& do
     return toJSNewlyCreated(state, globalObject, Ref<HTMLDocument>(document));
 }
 
-bool JSHTMLDocument::getOwnPropertySlot(JSObject* object, ExecState* state, PropertyName propertyName, PropertySlot& slot)
-{
-    auto* thisObject = jsCast<JSHTMLDocument*>(object);
-    ASSERT_GC_OBJECT_INHERITS(thisObject, info());
-    
-    if (propertyName == "open") {
-        if (Base::getOwnPropertySlot(thisObject, state, propertyName, slot))
-            return true;
-        slot.setCustom(thisObject, ReadOnly | DontDelete | DontEnum, nonCachingStaticFunctionGetter<jsHTMLDocumentPrototypeFunctionOpen, 2>);
-        return true;
-    }
-
-    using GetterIDLType = IDLUnion<IDLInterface<DOMWindow>, IDLInterface<Element>, IDLInterface<HTMLCollection>>;
-    auto getterFunctor = [] (auto& thisObject, auto propertyName) -> std::optional<typename GetterIDLType::ImplementationType> {
-        auto result = thisObject.wrapped().namedItem(propertyNameToAtomicString(propertyName));
-        if (!GetterIDLType::isNullValue(result))
-            return typename GetterIDLType::ImplementationType { GetterIDLType::extractValueFromNullable(result) };
-        return std::nullopt;
-    };
-    if (auto namedProperty = accessVisibleNamedProperty<OverrideBuiltins::Yes>(*state, *thisObject, propertyName, getterFunctor)) {
-        slot.setValue(thisObject, ReadOnly, toJS<GetterIDLType>(*state, *thisObject->globalObject(), WTFMove(namedProperty.value())));
-        return true;
-    }
-    return JSObject::getOwnPropertySlot(object, state, propertyName, slot);
-}
-
-// Custom attributes
-
-JSValue JSHTMLDocument::all(ExecState& state) const
-{
-    // If "all" has been overwritten, return the overwritten value
-    if (auto overwrittenValue = getDirect(state.vm(), Identifier::fromString(&state, "all")))
-        return overwrittenValue;
-
-    return toJS(&state, globalObject(), wrapped().all());
-}
-
-void JSHTMLDocument::setAll(ExecState& state, JSValue value)
-{
-    // Add "all" to the property map.
-    putDirect(state.vm(), Identifier::fromString(&state, "all"), value);
-}
-
-static inline Document* findCallingDocument(ExecState& state)
-{
-    CallerFunctor functor;
-    state.iterate(functor);
-    auto* callerFrame = functor.callerFrame();
-    if (!callerFrame)
-        return nullptr;
-    return asJSDOMWindow(callerFrame->lexicalGlobalObject())->wrapped().document();
-}
-
-// Custom functions
-
-JSValue JSHTMLDocument::open(ExecState& state)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    // For compatibility with other browsers, pass open calls with more than 2 parameters to the window.
-    if (state.argumentCount() > 2) {
-        if (auto* frame = wrapped().frame()) {
-            if (auto* wrapper = toJSDOMWindowProxy(frame, currentWorld(&state))) {
-                auto function = wrapper->get(&state, Identifier::fromString(&state, "open"));
-                CallData callData;
-                auto callType = ::getCallData(function, callData);
-                if (callType == CallType::None)
-                    return throwTypeError(&state, scope);
-                return JSC::call(&state, function, callType, callData, wrapper, ArgList(&state));
-            }
-        }
-        return jsUndefined();
-    }
-
-    // Calling document.open clobbers the security context of the document and aliases it with the active security context.
-    // FIXME: Is it correct that this does not use findCallingDocument as the write function below does?
-    wrapped().open(asJSDOMWindow(state.lexicalGlobalObject())->wrapped().document());
-    // FIXME: Why do we return the document instead of returning undefined?
-    return this;
-}
-
-enum NewlineRequirement { DoNotAddNewline, DoAddNewline };
-
-static inline JSValue documentWrite(ExecState& state, JSHTMLDocument& document, NewlineRequirement addNewline)
-{
-    VM& vm = state.vm();
-    auto scope = DECLARE_THROW_SCOPE(vm);
-
-    SegmentedString segmentedString;
-    size_t argumentCount = state.argumentCount();
-    for (size_t i = 0; i < argumentCount; ++i) {
-        segmentedString.append(state.uncheckedArgument(i).toWTFString(&state));
-        RETURN_IF_EXCEPTION(scope, { });
-    }
-    if (addNewline)
-        segmentedString.append(String { "\n" });
-
-    document.wrapped().write(WTFMove(segmentedString), findCallingDocument(state));
-    return jsUndefined();
-}
-
-JSValue JSHTMLDocument::write(ExecState& state)
-{
-    return documentWrite(state, *this, DoNotAddNewline);
-}
-
-JSValue JSHTMLDocument::writeln(ExecState& state)
-{
-    return documentWrite(state, *this, DoAddNewline);
-}
-
 } // namespace WebCore
index f7b7c32..848e401 100644 (file)
@@ -5332,7 +5332,7 @@ sub GenerateCallWith
         push(@callWithArgs, "*context");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "Document")) {
-        $implIncludes{"Document.h"} = 1;
+        AddToImplIncludes("Document.h");
         push(@$outputArray, "    auto* context = ${scriptExecutionContextAccessor}->scriptExecutionContext();\n");
         push(@$outputArray, "    if (UNLIKELY(!context))\n");
         push(@$outputArray, "        return" . ($contextMissing ? " " . $contextMissing : "") . ";\n");
@@ -5341,30 +5341,33 @@ sub GenerateCallWith
         push(@callWithArgs, "document");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "IncumbentDocument")) {
-        $implIncludes{"Document.h"} = 1;
-        $implIncludes{"JSDOMWindowBase.h"} = 1;
-        push(@$outputArray, "    auto* document = incumbentDOMWindow($statePointer).document();\n");
-        push(@$outputArray, "    if (!document)\n");
+        AddToImplIncludes("JSDOMWindowBase.h");
+        push(@$outputArray, "    auto* incumbentDocument = incumbentDOMWindow($stateReference).document();\n");
+        push(@$outputArray, "    if (!incumbentDocument)\n");
         push(@$outputArray, "        return" . ($returnValue ? " " . $returnValue : "") . ";\n");
-        push(@callWithArgs, "*document");
+        push(@callWithArgs, "*incumbentDocument");
+    }
+    if ($codeGenerator->ExtendedAttributeContains($callWith, "ResponsibleDocument")) {
+        AddToImplIncludes("JSDOMWindowBase.h");
+        push(@callWithArgs, "responsibleDocument($stateReference)");
     }
     if ($operation and $codeGenerator->ExtendedAttributeContains($callWith, "ScriptArguments")) {
+        AddToImplIncludes("<inspector/ScriptArguments.h>");
+        AddToImplIncludes("<inspector/ScriptCallStackFactory.h>");
         push(@$outputArray, "    Ref<Inspector::ScriptArguments> scriptArguments(Inspector::createScriptArguments($statePointer, " . @{$operation->arguments} . "));\n");
-        $implIncludes{"<inspector/ScriptArguments.h>"} = 1;
-        $implIncludes{"<inspector/ScriptCallStackFactory.h>"} = 1;
         push(@callWithArgs, "WTFMove(scriptArguments)");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "ActiveWindow")) {
-        $implIncludes{"JSDOMWindowBase.h"} = 1;
-        push(@callWithArgs, "activeDOMWindow($statePointer)");
+        AddToImplIncludes("JSDOMWindowBase.h");
+        push(@callWithArgs, "activeDOMWindow($stateReference)");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "FirstWindow")) {
-        $implIncludes{"JSDOMWindowBase.h"} = 1;
-        push(@callWithArgs, "firstDOMWindow($statePointer)");
+        AddToImplIncludes("JSDOMWindowBase.h");
+        push(@callWithArgs, "firstDOMWindow($stateReference)");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "IncumbentWindow")) {
-        $implIncludes{"JSDOMWindowBase.h"} = 1;
-        push(@callWithArgs, "incumbentDOMWindow($statePointer)");
+        AddToImplIncludes("JSDOMWindowBase.h");
+        push(@callWithArgs, "incumbentDOMWindow($stateReference)");
     }
     if ($codeGenerator->ExtendedAttributeContains($callWith, "RuntimeFlags")) {
         push(@callWithArgs, "${globalObject}->runtimeFlags()");
index 94717ec..cd4415a 100644 (file)
@@ -36,7 +36,7 @@
         },
         "CallWith": {
             "contextsAllowed": ["attribute", "operation"],
-            "values": ["Document", "ScriptExecutionContext", "ScriptState", "ScriptArguments", "CallStack", "GlobalObject", "ActiveWindow", "FirstWindow", "CallerDocument", "CallerWindow"]
+            "values": ["Document", "ScriptExecutionContext", "ScriptState", "ScriptArguments", "CallStack", "GlobalObject", "ActiveWindow", "FirstWindow", "ResponsibleDocument"]
         },
         "CheckSecurity": {
             "contextsAllowed": ["interface"]
index 69787bc..deca6f9 100644 (file)
@@ -3840,7 +3840,7 @@ static inline bool setJSTestObjWithCallWithAndSetterCallWithAttributeSetter(Exec
     auto& impl = thisObject.wrapped();
     auto nativeValue = convert<IDLLong>(state, value);
     RETURN_IF_EXCEPTION(throwScope, false);
-    impl.setWithCallWithAndSetterCallWithAttribute(state, activeDOMWindow(&state), firstDOMWindow(&state), WTFMove(nativeValue));
+    impl.setWithCallWithAndSetterCallWithAttribute(state, activeDOMWindow(state), firstDOMWindow(state), WTFMove(nativeValue));
     return true;
 }
 
@@ -5852,10 +5852,10 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionWithCallerDocumentAr
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    auto* document = incumbentDOMWindow(state).document();
-    if (!document)
+    auto* incumbentDocument = incumbentDOMWindow(*state).document();
+    if (!incumbentDocument)
         return JSValue::encode(jsUndefined());
-    impl.withCallerDocumentArgument(*document);
+    impl.withCallerDocumentArgument(*incumbentDocument);
     return JSValue::encode(jsUndefined());
 }
 
@@ -5869,7 +5869,7 @@ static inline JSC::EncodedJSValue jsTestObjPrototypeFunctionWithCallerWindowArgu
     UNUSED_PARAM(state);
     UNUSED_PARAM(throwScope);
     auto& impl = castedThis->wrapped();
-    impl.withCallerWindowArgument(incumbentDOMWindow(state));
+    impl.withCallerWindowArgument(incumbentDOMWindow(*state));
     return JSValue::encode(jsUndefined());
 }
 
index 84ac574..9f32aa0 100644 (file)
@@ -141,7 +141,7 @@ Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
 {
     auto document = HTMLDocument::create(nullptr, URL());
     document->open();
-    document->write("<!doctype html><html><head></head><body></body></html>");
+    document->write(nullptr, { ASCIILiteral("<!doctype html><html><head></head><body></body></html>") });
     if (!title.isNull()) {
         auto titleElement = HTMLTitleElement::create(titleTag, document);
         titleElement->appendChild(document->createTextNode(title));
index ed086b4..3ab6007 100644 (file)
@@ -2497,15 +2497,35 @@ ScriptableDocumentParser* Document::scriptableDocumentParser() const
     return parser() ? parser()->asScriptableDocumentParser() : nullptr;
 }
 
-void Document::open(Document* ownerDocument)
+ExceptionOr<RefPtr<DOMWindow>> Document::openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features)
+{
+    if (!m_domWindow)
+        return Exception { INVALID_ACCESS_ERR };
+
+    return m_domWindow->open(activeWindow, firstWindow, url, name, features);
+}
+
+// FIXME: Add support for the 'type' and 'replace' parameters.
+ExceptionOr<Document&> Document::openForBindings(Document* responsibleDocument, const String&, const String&)
+{
+    if (!isHTMLDocument())
+        return Exception { INVALID_STATE_ERR };
+
+    // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".
+
+    open(responsibleDocument);
+    return *this;
+}
+
+void Document::open(Document* responsibleDocument)
 {
     if (m_ignoreOpensDuringUnloadCount)
         return;
 
-    if (ownerDocument) {
-        setURL(ownerDocument->url());
-        setCookieURL(ownerDocument->cookieURL());
-        setSecurityOriginPolicy(ownerDocument->securityOriginPolicy());
+    if (responsibleDocument) {
+        setURL(responsibleDocument->url());
+        setCookieURL(responsibleDocument->cookieURL());
+        setSecurityOriginPolicy(responsibleDocument->securityOriginPolicy());
     }
 
     if (m_frame) {
@@ -2620,11 +2640,22 @@ HTMLHeadElement* Document::head()
     return nullptr;
 }
 
-void Document::close()
+ExceptionOr<void> Document::closeForBindings()
 {
     // FIXME: We should follow the specification more closely:
     //        http://www.whatwg.org/specs/web-apps/current-work/#dom-document-close
 
+    if (!isHTMLDocument())
+        return Exception { INVALID_STATE_ERR };
+
+    // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".
+
+    close();
+    return { };
+}
+
+void Document::close()
+{
     if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedByScript() || !scriptableDocumentParser()->isParsing())
         return;
 
@@ -2819,7 +2850,7 @@ Seconds Document::timeSinceDocumentCreation() const
     return MonotonicTime::now() - m_documentCreationTime;
 }
 
-void Document::write(SegmentedString&& text, Document* ownerDocument)
+void Document::write(Document* responsibleDocument, SegmentedString&& text)
 {
     NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth);
 
@@ -2834,22 +2865,43 @@ void Document::write(SegmentedString&& text, Document* ownerDocument)
         return;
 
     if (!hasInsertionPoint)
-        open(ownerDocument);
+        open(responsibleDocument);
 
     ASSERT(m_parser);
     m_parser->insert(WTFMove(text));
 }
 
-void Document::write(const String& text, Document* ownerDocument)
+ExceptionOr<void> Document::write(Document* responsibleDocument, Vector<String>&& strings)
 {
-    write(SegmentedString { text }, ownerDocument);
+    if (!isHTMLDocument())
+        return Exception { INVALID_STATE_ERR };
+
+    // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".
+
+    SegmentedString text;
+    for (auto& string : strings)
+        text.append(WTFMove(string));
+
+    write(responsibleDocument, WTFMove(text));
+
+    return { };
 }
 
-void Document::writeln(const String& text, Document* ownerDocument)
+ExceptionOr<void> Document::writeln(Document* responsibleDocument, Vector<String>&& strings)
 {
-    SegmentedString textWithNewline { text };
-    textWithNewline.append(String { "\n" });
-    write(WTFMove(textWithNewline), ownerDocument);
+    if (!isHTMLDocument())
+        return Exception { INVALID_STATE_ERR };
+
+    // FIXME: This should also throw if "document's throw-on-dynamic-markup-insertion counter is greater than 0".
+
+    SegmentedString text;
+    for (auto& string : strings)
+        text.append(WTFMove(string));
+
+    text.append(ASCIILiteral { "\n" });
+    write(responsibleDocument, WTFMove(text));
+
+    return { };
 }
 
 Seconds Document::minimumDOMTimerInterval() const
@@ -7118,4 +7170,74 @@ void Document::mediaStreamCaptureStateChanged()
 }
 #endif
 
+const AtomicString& Document::bgColor() const
+{
+    auto* bodyElement = body();
+    if (!bodyElement)
+        return emptyAtom;
+    return bodyElement->attributeWithoutSynchronization(bgcolorAttr);
+}
+
+void Document::setBgColor(const String& value)
+{
+    if (auto* bodyElement = body())
+        bodyElement->setAttributeWithoutSynchronization(bgcolorAttr, value);
+}
+
+const AtomicString& Document::fgColor() const
+{
+    auto* bodyElement = body();
+    if (!bodyElement)
+        return emptyAtom;
+    return bodyElement->attributeWithoutSynchronization(textAttr);
+}
+
+void Document::setFgColor(const String& value)
+{
+    if (auto* bodyElement = body())
+        bodyElement->setAttributeWithoutSynchronization(textAttr, value);
+}
+
+const AtomicString& Document::alinkColor() const
+{
+    auto* bodyElement = body();
+    if (!bodyElement)
+        return emptyAtom;
+    return bodyElement->attributeWithoutSynchronization(alinkAttr);
+}
+
+void Document::setAlinkColor(const String& value)
+{
+    if (auto* bodyElement = body())
+        bodyElement->setAttributeWithoutSynchronization(alinkAttr, value);
+}
+
+const AtomicString& Document::linkColorForBindings() const
+{
+    auto* bodyElement = body();
+    if (!bodyElement)
+        return emptyAtom;
+    return bodyElement->attributeWithoutSynchronization(linkAttr);
+}
+
+void Document::setLinkColorForBindings(const String& value)
+{
+    if (auto* bodyElement = body())
+        bodyElement->setAttributeWithoutSynchronization(linkAttr, value);
+}
+
+const AtomicString& Document::vlinkColor() const
+{
+    auto* bodyElement = body();
+    if (!bodyElement)
+        return emptyAtom;
+    return bodyElement->attributeWithoutSynchronization(vlinkAttr);
+}
+
+void Document::setVlinkColor(const String& value)
+{
+    if (auto* bodyElement = body())
+        bodyElement->setAttributeWithoutSynchronization(vlinkAttr, value);
+}
+
 } // namespace WebCore
index 04f24fa..6df1186 100644 (file)
@@ -596,10 +596,16 @@ public:
     
     WEBCORE_EXPORT DocumentLoader* loader() const;
 
-    WEBCORE_EXPORT void open(Document* ownerDocument = nullptr);
+    WEBCORE_EXPORT ExceptionOr<RefPtr<DOMWindow>> openForBindings(DOMWindow& activeWindow, DOMWindow& firstWindow, const String& url, const AtomicString& name, const String& features);
+    WEBCORE_EXPORT ExceptionOr<Document&> openForBindings(Document* responsibleDocument, const String& type, const String& replace);
+
+    // FIXME: We should rename this at some point and give back the name 'open' to the HTML specified ones.
+    WEBCORE_EXPORT void open(Document* responsibleDocument = nullptr);
     void implicitOpen();
 
-    // close() is the DOM API document.close()
+    WEBCORE_EXPORT ExceptionOr<void> closeForBindings();
+
+    // FIXME: We should rename this at some point and give back the name 'close' to the HTML specified one.
     WEBCORE_EXPORT void close();
     // In some situations (see the code), we ignore document.close().
     // explicitClose() bypass these checks and actually tries to close the
@@ -610,9 +616,9 @@ public:
 
     void cancelParsing();
 
-    void write(SegmentedString&& text, Document* ownerDocument = nullptr);
-    WEBCORE_EXPORT void write(const String& text, Document* ownerDocument = nullptr);
-    WEBCORE_EXPORT void writeln(const String& text, Document* ownerDocument = nullptr);
+    void write(Document* responsibleDocument, SegmentedString&&);
+    WEBCORE_EXPORT ExceptionOr<void> write(Document* responsibleDocument, Vector<String>&&);
+    WEBCORE_EXPORT ExceptionOr<void> writeln(Document* responsibleDocument, Vector<String>&&);
 
     bool wellFormed() const { return m_wellFormed; }
 
@@ -1323,6 +1329,24 @@ public:
     void orientationChanged(int orientation);
     OrientationNotifier& orientationNotifier() { return m_orientationNotifier; }
 
+    WEBCORE_EXPORT const AtomicString& bgColor() const;
+    WEBCORE_EXPORT void setBgColor(const String&);
+    WEBCORE_EXPORT const AtomicString& fgColor() const;
+    WEBCORE_EXPORT void setFgColor(const String&);
+    WEBCORE_EXPORT const AtomicString& alinkColor() const;
+    WEBCORE_EXPORT void setAlinkColor(const String&);
+    WEBCORE_EXPORT const AtomicString& linkColorForBindings() const;
+    WEBCORE_EXPORT void setLinkColorForBindings(const String&);
+    WEBCORE_EXPORT const AtomicString& vlinkColor() const;
+    WEBCORE_EXPORT void setVlinkColor(const String&);
+
+    // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-clear, this method does nothing.
+    void clear() { }
+    // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-captureevents, this method does nothing.
+    void captureEvents() { }
+    // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-releaseevents, this method does nothing.
+    void releaseEvents() { }
+
 protected:
     enum ConstructionFlags { Synthesized = 1, NonRenderedPlaceholder = 1 << 1 };
     Document(Frame*, const URL&, unsigned = DefaultDocumentClass, unsigned constructionFlags = 0);
index 492935c..0ccec70 100644 (file)
     NodeList getElementsByName([AtomicString] DOMString elementName);
     readonly attribute HTMLScriptElement? currentScript; // FIXME: Should return a HTMLOrSVGScriptElement.
 
+    // dynamic markup insertion
+    // FIXME: The HTML spec says this should consult the "responsible document". We should ensure
+    // that the caller document matches those semantics. It is possible we should replace it with
+    // the existing 'incumbent document' concept.
+    [CEReactions, CallWith=ResponsibleDocument, ImplementedAs=openForBindings, MayThrowException] Document open(optional DOMString type = "text/html", optional DOMString replace = "");
+    [CallWith=ActiveWindow&FirstWindow, ImplementedAs=openForBindings, MayThrowException] DOMWindow open(USVString url, DOMString name, DOMString features);
+    [CEReactions, ImplementedAs=closeForBindings, MayThrowException] void close();
+    [CEReactions, CallWith=ResponsibleDocument, MayThrowException] void write(DOMString... text);
+    [CEReactions, CallWith=ResponsibleDocument, MayThrowException] void writeln(DOMString... text);
+
     // User interaction.
     readonly attribute DOMWindow? defaultView;
     boolean hasFocus();
     readonly attribute VisibilityState visibilityState;
     attribute EventHandler onvisibilitychange;
 
-    // FIXME: Those have been dropped from the HTML specification.
-    readonly attribute HTMLCollection applets;
-    readonly attribute HTMLCollection anchors;
-
     // FIXME: Those were dropped from the CSSOM specification.
     readonly attribute DOMString? preferredStylesheetSet;
     attribute DOMString? selectedStylesheetSet;
         optional unrestricted float webkitRotationAngle = NaN, optional unrestricted float webkitForce = NaN);
     [NewObject, Custom] TouchList createTouchList(Touch... touches);
 #endif
+
+
+    // Obsolete features from https://html.spec.whatwg.org/multipage/obsolete.html
+
+    [CEReactions] attribute [TreatNullAs=EmptyString] DOMString fgColor;
+    [CEReactions, ImplementedAs=linkColorForBindings] attribute [TreatNullAs=EmptyString] DOMString linkColor;
+    [CEReactions] attribute [TreatNullAs=EmptyString] DOMString vlinkColor;
+    [CEReactions] attribute [TreatNullAs=EmptyString] DOMString alinkColor;
+    [CEReactions] attribute [TreatNullAs=EmptyString] DOMString bgColor;
+
+    readonly attribute HTMLCollection anchors; /* [SameObject] */
+    readonly attribute HTMLCollection applets; /* [SameObject] */
+
+    void clear();
+    void captureEvents();
+    void releaseEvents();
+
+    [Replaceable] readonly attribute HTMLAllCollection all; /* [SameObject] */
 };
 
 // FIXME: Missing "unloaded" value (https://www.w3.org/TR/page-visibility/#sec-document-interface).
index e605424..f0dee3d 100644 (file)
@@ -106,91 +106,6 @@ int HTMLDocument::height()
     return frameView ? frameView->contentsHeight() : 0;
 }
 
-const AtomicString& HTMLDocument::bgColor() const
-{
-    auto* bodyElement = body();
-    if (!bodyElement)
-        return emptyAtom;
-    return bodyElement->attributeWithoutSynchronization(bgcolorAttr);
-}
-
-void HTMLDocument::setBgColor(const String& value)
-{
-    if (auto* bodyElement = body())
-        bodyElement->setAttributeWithoutSynchronization(bgcolorAttr, value);
-}
-
-const AtomicString& HTMLDocument::fgColor() const
-{
-    auto* bodyElement = body();
-    if (!bodyElement)
-        return emptyAtom;
-    return bodyElement->attributeWithoutSynchronization(textAttr);
-}
-
-void HTMLDocument::setFgColor(const String& value)
-{
-    if (auto* bodyElement = body())
-        bodyElement->setAttributeWithoutSynchronization(textAttr, value);
-}
-
-const AtomicString& HTMLDocument::alinkColor() const
-{
-    auto* bodyElement = body();
-    if (!bodyElement)
-        return emptyAtom;
-    return bodyElement->attributeWithoutSynchronization(alinkAttr);
-}
-
-void HTMLDocument::setAlinkColor(const String& value)
-{
-    if (auto* bodyElement = body())
-        bodyElement->setAttributeWithoutSynchronization(alinkAttr, value);
-}
-
-const AtomicString& HTMLDocument::linkColor() const
-{
-    auto* bodyElement = body();
-    if (!bodyElement)
-        return emptyAtom;
-    return bodyElement->attributeWithoutSynchronization(linkAttr);
-}
-
-void HTMLDocument::setLinkColor(const String& value)
-{
-    if (auto* bodyElement = body())
-        bodyElement->setAttributeWithoutSynchronization(linkAttr, value);
-}
-
-const AtomicString& HTMLDocument::vlinkColor() const
-{
-    auto* bodyElement = body();
-    if (!bodyElement)
-        return emptyAtom;
-    return bodyElement->attributeWithoutSynchronization(vlinkAttr);
-}
-
-void HTMLDocument::setVlinkColor(const String& value)
-{
-    if (auto* bodyElement = body())
-        bodyElement->setAttributeWithoutSynchronization(vlinkAttr, value);
-}
-
-void HTMLDocument::clear()
-{
-    // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-clear, this method does nothing.
-}
-
-void HTMLDocument::captureEvents()
-{
-    // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-captureevents, this method does nothing.
-}
-
-void HTMLDocument::releaseEvents()
-{
-    // Per https://html.spec.whatwg.org/multipage/obsolete.html#dom-document-releaseevents, this method does nothing.
-}
-
 Ref<DocumentParser> HTMLDocument::createParser()
 {
     return HTMLDocumentParser::create(*this);
index 1b341d6..23de4dc 100644 (file)
@@ -42,21 +42,6 @@ public:
 
     WEBCORE_EXPORT int width();
     WEBCORE_EXPORT int height();
-
-    WEBCORE_EXPORT const AtomicString& bgColor() const;
-    WEBCORE_EXPORT void setBgColor(const String&);
-    WEBCORE_EXPORT const AtomicString& fgColor() const;
-    WEBCORE_EXPORT void setFgColor(const String&);
-    WEBCORE_EXPORT const AtomicString& alinkColor() const;
-    WEBCORE_EXPORT void setAlinkColor(const String&);
-    WEBCORE_EXPORT const AtomicString& linkColor() const;
-    WEBCORE_EXPORT void setLinkColor(const String&);
-    WEBCORE_EXPORT const AtomicString& vlinkColor() const;
-    WEBCORE_EXPORT void setVlinkColor(const String&);
-    
-    WEBCORE_EXPORT void clear();
-    WEBCORE_EXPORT void captureEvents();
-    WEBCORE_EXPORT void releaseEvents();
     
     std::optional<Variant<RefPtr<DOMWindow>, RefPtr<Element>, RefPtr<HTMLCollection>>> namedItem(const AtomicString&);
     Vector<AtomicString> supportedPropertyNames() const;
index c02c896..127f264 100644 (file)
  */
 
 [
-    CustomGetOwnPropertySlot,
     CustomToJSObject,
     NewImpurePropertyFiresWatchpoints,
     OverrideBuiltins,
-] interface HTMLDocument : Document {
-    [CEReactions, Custom, ForwardDeclareInHeader] void open();
-    void close();
-    [CEReactions, Custom] void write(optional DOMString text);
-    [CEReactions, Custom] void writeln(optional DOMString text);
-    
+] interface HTMLDocument : Document {    
     getter (DOMWindow or Element or HTMLCollection) (DOMString name);
-    
-    [Custom, Replaceable] readonly attribute HTMLAllCollection all;
-
-    void clear();
-    void captureEvents();
-    void releaseEvents();
-
-    // Deprecated attributes.
-    attribute [TreatNullAs=EmptyString] DOMString bgColor;
-    attribute [TreatNullAs=EmptyString] DOMString fgColor;
-    attribute [TreatNullAs=EmptyString] DOMString alinkColor;
-    attribute [TreatNullAs=EmptyString] DOMString linkColor;
-    attribute [TreatNullAs=EmptyString] DOMString vlinkColor;
 };
index b13aa07..07ff5c7 100644 (file)
@@ -100,7 +100,7 @@ void DOMPatchSupport::patchDocument(const String& markup)
 
     if (innerPatchNode(*oldInfo, *newInfo).hasException()) {
         // Fall back to rewrite.
-        m_document.write(markup);
+        m_document.write(nullptr, markup);
         m_document.close();
     }
 }
index 374ed92..5ba5210 100644 (file)
@@ -936,12 +936,12 @@ ExceptionOr<Storage*> DOMWindow::localStorage() const
     return m_localStorage.get();
 }
 
-ExceptionOr<void> DOMWindow::postMessage(JSC::ExecState& state, DOMWindow& callerWindow, JSC::JSValue messageValue, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&& transfer)
+ExceptionOr<void> DOMWindow::postMessage(JSC::ExecState& state, DOMWindow& incumbentWindow, JSC::JSValue messageValue, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&& transfer)
 {
     if (!isCurrentlyDisplayedInFrame())
         return { };
 
-    Document* sourceDocument = callerWindow.document();
+    Document* sourceDocument = incumbentWindow.document();
 
     // Compute the target origin.  We need to do this synchronously in order
     // to generate the SYNTAX_ERR exception correctly.
@@ -979,7 +979,7 @@ ExceptionOr<void> DOMWindow::postMessage(JSC::ExecState& state, DOMWindow& calle
         stackTrace = createScriptCallStack(JSMainThreadExecState::currentState(), ScriptCallStack::maxCallStackSizeToCapture);
 
     // Schedule the message.
-    auto* timer = new PostMessageTimer(*this, message.releaseReturnValue(), sourceOrigin, callerWindow, channels.releaseReturnValue(), WTFMove(target), WTFMove(stackTrace));
+    auto* timer = new PostMessageTimer(*this, message.releaseReturnValue(), sourceOrigin, incumbentWindow, channels.releaseReturnValue(), WTFMove(target), WTFMove(stackTrace));
     timer->startOneShot(0_s);
 
     return { };
@@ -1024,9 +1024,9 @@ Element* DOMWindow::frameElement() const
     return m_frame->ownerElement();
 }
 
-void DOMWindow::focus(DOMWindow& callerWindow)
+void DOMWindow::focus(DOMWindow& incumbentWindow)
 {
-    focus(opener() && opener() != this && &callerWindow == opener());
+    focus(opener() && opener() != this && &incumbentWindow == opener());
 }
 
 void DOMWindow::focus(bool allowFocus)
index 661ac46..3aef0eb 100644 (file)
@@ -142,7 +142,7 @@ public:
     Element* frameElement() const;
 
     WEBCORE_EXPORT void focus(bool allowFocus = false);
-    void focus(DOMWindow& callerWindow);
+    void focus(DOMWindow& incumbentWindow);
     void blur();
     WEBCORE_EXPORT void close();
     void close(Document&);
@@ -221,7 +221,7 @@ public:
     void printErrorMessage(const String&);
     String crossDomainAccessErrorMessage(const DOMWindow& activeWindow);
 
-    ExceptionOr<void> postMessage(JSC::ExecState&, DOMWindow& callerWindow, JSC::JSValue message, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&&);
+    ExceptionOr<void> postMessage(JSC::ExecState&, DOMWindow& incumbentWindow, JSC::JSValue message, const String& targetOrigin, Vector<JSC::Strong<JSC::JSObject>>&&);
     void postMessageTimerFired(PostMessageTimer&);
 
     void languagesChanged();
index 465d1ab..2e2ef46 100644 (file)
@@ -1,3 +1,17 @@
+2017-06-16  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for HTMLDocument
+        https://bugs.webkit.org/show_bug.cgi?id=173444
+
+        Reviewed by Darin Adler.
+
+        * DOM/DOMHTMLDocument.mm:
+        (-[DOMHTMLDocument linkColor]):
+        (-[DOMHTMLDocument setLinkColor:]):
+        (-[DOMHTMLDocument write:]):
+        (-[DOMHTMLDocument writeln:]):
+        Update for new signature of write/writeln and rename of linkColor to linkColorForBindings.
+
 2017-06-16  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         [iOS DnD] Upstream iOS drag and drop implementation into OpenSource WebKit
index f9fd962..7d8dac7 100644 (file)
 - (NSString *)linkColor
 {
     WebCore::JSMainThreadNullState state;
-    return IMPL->linkColor();
+    return IMPL->linkColorForBindings();
 }
 
 - (void)setLinkColor:(NSString *)newLinkColor
 {
     WebCore::JSMainThreadNullState state;
-    IMPL->setLinkColor(newLinkColor);
+    IMPL->setLinkColorForBindings(newLinkColor);
 }
 
 - (NSString *)vlinkColor
 - (void)write:(NSString *)text
 {
     WebCore::JSMainThreadNullState state;
-    IMPL->write(text);
+    IMPL->write(nullptr, { String { text } });
 }
 
 - (void)writeln:(NSString *)text
 {
     WebCore::JSMainThreadNullState state;
-    IMPL->writeln(text);
+    IMPL->writeln(nullptr, { String { text} });
 }
 
 - (void)clear
index 2fb4a99..4e5dc0c 100644 (file)
@@ -1,3 +1,15 @@
+2017-06-16  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for HTMLDocument
+        https://bugs.webkit.org/show_bug.cgi?id=173444
+
+        Reviewed by Darin Adler.
+
+        * DOMHTMLClasses.cpp:
+        (DOMHTMLDocument::write):
+        (DOMHTMLDocument::writeln):
+        Update for new signature of write/writeln.
+
 2017-06-16  Daniel Bates  <dabates@apple.com>
 
         Cleanup: WebContextMenuClient::searchWithGoogle() should parse URL using URL { URL { }, ... }
index d1fea35..3cf38b4 100644 (file)
@@ -372,8 +372,7 @@ HRESULT DOMHTMLDocument::write(_In_ BSTR text)
     if (!m_document)
         return E_FAIL;
 
-    String string(text);
-    m_document->write(string);
+    m_document->write(nullptr, { String { text } });
     return S_OK;
 }
     
@@ -382,8 +381,7 @@ HRESULT DOMHTMLDocument::writeln(_In_ BSTR text)
     if (!m_document)
         return E_FAIL;
 
-    String string(text);
-    m_document->writeln(string);
+    m_document->writeln(nullptr, { String { text } });
     return S_OK;
 }
     
index 9590dc7..48bd036 100644 (file)
@@ -1,3 +1,15 @@
+2017-06-16  Sam Weinig  <sam@webkit.org>
+
+        [WebIDL] Remove custom bindings for HTMLDocument
+        https://bugs.webkit.org/show_bug.cgi?id=173444
+
+        Reviewed by Darin Adler.
+
+        * WebProcess/InjectedBundle/API/gtk/DOM/WebKitDOMHTMLDocument.cpp:
+        (webkit_dom_html_document_get_link_color):
+        (webkit_dom_html_document_set_link_color):
+        Update for rename of linkColor to linkColorForBindings.
+
 2017-06-16  Daniel Bates  <dabates@apple.com>
 
         Cleanup: WebContextMenuClient::searchWithGoogle() should parse URL using URL { URL { }, ... }
index 0ecfae9..99f01a8 100644 (file)
@@ -393,7 +393,7 @@ gchar* webkit_dom_html_document_get_link_color(WebKitDOMHTMLDocument* self)
     WebCore::JSMainThreadNullState state;
     g_return_val_if_fail(WEBKIT_DOM_IS_HTML_DOCUMENT(self), 0);
     WebCore::HTMLDocument* item = WebKit::core(self);
-    gchar* result = convertToUTF8String(item->linkColor());
+    gchar* result = convertToUTF8String(item->linkColorForBindings());
     return result;
 }
 
@@ -404,7 +404,7 @@ void webkit_dom_html_document_set_link_color(WebKitDOMHTMLDocument* self, const
     g_return_if_fail(value);
     WebCore::HTMLDocument* item = WebKit::core(self);
     WTF::String convertedValue = WTF::String::fromUTF8(value);
-    item->setLinkColor(convertedValue);
+    item->setLinkColorForBindings(convertedValue);
 }
 
 gchar* webkit_dom_html_document_get_vlink_color(WebKitDOMHTMLDocument* self)