| Index: Source/core/dom/Document.cpp
|
| diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
|
| index d305ffb3d2a566c0ec7c61d0db9b06639882d94a..43e50df6f79833fe8de67539d49c7283834c0775 100644
|
| --- a/Source/core/dom/Document.cpp
|
| +++ b/Source/core/dom/Document.cpp
|
| @@ -2282,18 +2282,9 @@ ScriptableDocumentParser* Document::scriptableDocumentParser() const
|
| return parser() ? parser()->asScriptableDocumentParser() : 0;
|
| }
|
|
|
| -void Document::open(Document* ownerDocument, ExceptionState& exceptionState)
|
| +void Document::open()
|
| {
|
| - if (importLoader()) {
|
| - exceptionState.throwDOMException(InvalidStateError, "Imported document doesn't support open().");
|
| - return;
|
| - }
|
| -
|
| - if (ownerDocument) {
|
| - setURL(ownerDocument->url());
|
| - m_cookieURL = ownerDocument->cookieURL();
|
| - setSecurityOrigin(ownerDocument->securityOrigin());
|
| - }
|
| + ASSERT(!importLoader());
|
|
|
| if (m_frame) {
|
| if (ScriptableDocumentParser* parser = scriptableDocumentParser()) {
|
| @@ -2322,6 +2313,27 @@ void Document::open(Document* ownerDocument, ExceptionState& exceptionState)
|
| m_loadEventProgress = LoadEventNotRun;
|
| }
|
|
|
| +void Document::open(Document* ownerDocument, ExceptionState& exceptionState)
|
| +{
|
| + if (importLoader()) {
|
| + exceptionState.throwDOMException(InvalidStateError, "Imported document doesn't support open().");
|
| + return;
|
| + }
|
| +
|
| + if (!isHTMLDocument()) {
|
| + exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support open().");
|
| + return;
|
| + }
|
| +
|
| + if (ownerDocument) {
|
| + setURL(ownerDocument->url());
|
| + m_cookieURL = ownerDocument->cookieURL();
|
| + setSecurityOrigin(ownerDocument->securityOrigin());
|
| + }
|
| +
|
| + open();
|
| +}
|
| +
|
| void Document::detachParser()
|
| {
|
| if (!m_parser)
|
| @@ -2445,6 +2457,14 @@ Element* Document::viewportDefiningElement(const ComputedStyle* rootStyle) const
|
| return rootElement;
|
| }
|
|
|
| +void Document::close()
|
| +{
|
| + if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedByScript() || !scriptableDocumentParser()->isParsing())
|
| + return;
|
| +
|
| + explicitClose();
|
| +}
|
| +
|
| void Document::close(ExceptionState& exceptionState)
|
| {
|
| // FIXME: We should follow the specification more closely:
|
| @@ -2455,10 +2475,12 @@ void Document::close(ExceptionState& exceptionState)
|
| return;
|
| }
|
|
|
| - if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedByScript() || !scriptableDocumentParser()->isParsing())
|
| + if (!isHTMLDocument()) {
|
| + exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support close().");
|
| return;
|
| + }
|
|
|
| - explicitClose();
|
| + close();
|
| }
|
|
|
| void Document::explicitClose()
|
| @@ -2701,6 +2723,11 @@ void Document::write(const SegmentedString& text, Document* ownerDocument, Excep
|
| return;
|
| }
|
|
|
| + if (isXMLDocument()) {
|
| + exceptionState.throwDOMException(InvalidStateError, "XML document doesn't support write().");
|
| + return;
|
| + }
|
| +
|
| NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth);
|
|
|
| m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionIsTooDeep;
|
| @@ -2736,6 +2763,24 @@ void Document::writeln(const String& text, Document* ownerDocument, ExceptionSta
|
| write("\n", ownerDocument);
|
| }
|
|
|
| +void Document::write(LocalDOMWindow* callingWindow, const Vector<String>& text, ExceptionState& exceptionState)
|
| +{
|
| + ASSERT(callingWindow);
|
| + StringBuilder builder;
|
| + for (const String& string : text)
|
| + builder.append(string);
|
| + write(builder.toString(), callingWindow->document(), exceptionState);
|
| +}
|
| +
|
| +void Document::writeln(LocalDOMWindow* callingWindow, const Vector<String>& text, ExceptionState& exceptionState)
|
| +{
|
| + ASSERT(callingWindow);
|
| + StringBuilder builder;
|
| + for (const String& string : text)
|
| + builder.append(string);
|
| + writeln(builder.toString(), callingWindow->document(), exceptionState);
|
| +}
|
| +
|
| const KURL& Document::virtualURL() const
|
| {
|
| return m_url;
|
|
|