Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(763)

Unified Diff: Source/core/dom/Document.cpp

Issue 1176013002: Move attributes and methods from HTMLDocument to Document (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Updated to latest master Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index 57a1e7e46a99cb124236c8e2816472661fef02c3..90830089c25f9b34227bd49cf3861366e1105a5b 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -2352,12 +2352,24 @@ void Document::open(Document* ownerDocument, ExceptionState& exceptionState)
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::open()
+{
+ ASSERT(!importLoader());
+
if (m_frame) {
if (ScriptableDocumentParser* parser = scriptableDocumentParser()) {
if (parser->isParsing()) {
@@ -2518,6 +2530,16 @@ void Document::close(ExceptionState& exceptionState)
return;
}
+ if (!isHTMLDocument()) {
+ exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support close().");
+ return;
+ }
+
+ close();
+}
+
+void Document::close()
+{
if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedByScript() || !scriptableDocumentParser()->isParsing())
return;
@@ -2764,6 +2786,11 @@ void Document::write(const SegmentedString& text, Document* ownerDocument, Excep
return;
}
+ if (!isHTMLDocument()) {
+ exceptionState.throwDOMException(InvalidStateError, "Only HTML documents support write().");
+ return;
+ }
+
NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth);
m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionIsTooDeep;
@@ -2780,7 +2807,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);
@@ -2799,6 +2826,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;
« no previous file with comments | « Source/core/dom/Document.h ('k') | Source/core/dom/Document.idl » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698