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

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: Created 5 years, 6 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
Index: Source/core/dom/Document.cpp
diff --git a/Source/core/dom/Document.cpp b/Source/core/dom/Document.cpp
index d305ffb3d2a566c0ec7c61d0db9b06639882d94a..09e5395fdb42d7d9920524a85e9d7d2b2cdb9407 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -2289,12 +2289,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()) {
@@ -2455,6 +2467,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;
@@ -2701,6 +2723,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;
@@ -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;

Powered by Google App Engine
This is Rietveld 408576698