Index: Source/core/dom/Document.cpp |
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp |
index d305ffb3d2a566c0ec7c61d0db9b06639882d94a..1a443282ca2e175655cdfa4468cfc6c36f5b6e94 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,35 @@ void Document::open(Document* ownerDocument, ExceptionState& exceptionState) |
m_loadEventProgress = LoadEventNotRun; |
} |
+void Document::close() |
+{ |
+ if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedByScript() || !scriptableDocumentParser()->isParsing()) |
+ return; |
+ |
+ explicitClose(); |
+} |
+ |
+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) |
@@ -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 (!isHTMLDocument()) { |
+ exceptionState.throwDOMException(InvalidStateError, "XML document doesn't support write()."); |
philipj_slow
2015/06/29 15:02:38
I think this message should match those for open()
Habib Virji
2015/06/29 15:25:20
Added in the description and correct the message..
|
+ return; |
+ } |
+ |
NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth); |
m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionIsTooDeep; |
@@ -2717,7 +2744,7 @@ void Document::write(const SegmentedString& text, Document* ownerDocument, Excep |
} |
if (!hasInsertionPoint) |
- open(ownerDocument); |
+ open(ownerDocument, ASSERT_NO_EXCEPTION); |
ASSERT(m_parser); |
m_parser->insert(text); |
@@ -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; |