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

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: Introduced open and close methods without arguments to handle internal calls. 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 770524fd52e9b5655e3be6c233914a6481137d15..947d41b331cd2797ab50bc868f63498f911d6e57 100644
--- a/Source/core/dom/Document.cpp
+++ b/Source/core/dom/Document.cpp
@@ -2281,19 +2281,8 @@ 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());
- }
-
if (m_frame) {
if (ScriptableDocumentParser* parser = scriptableDocumentParser()) {
if (parser->isParsing()) {
@@ -2321,6 +2310,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().");
philipj_slow 2015/06/24 11:52:19 Is an import document also an HTML document? If no
Habib Virji 2015/06/25 13:09:46 Changed as suggested and it is do important added
philipj_slow 2015/06/27 21:42:56 Can you link to http://w3c.github.io/webcomponents
Habib Virji 2015/06/29 12:17:41 Done.
+ return;
+ }
+
+ if (isXHTMLDocument()) {
tkent 2015/06/23 23:42:17 Why do you check isXHTMLDocument(), not isXMLDocum
philipj_slow 2015/06/24 11:52:19 The spec says "If the Document object is not flagg
Habib Virji 2015/06/25 13:09:46 I find spec in-consistent. What you mentioned is
philipj_slow 2015/06/27 21:42:56 The note is non-normative, so !isHTMLDocument() is
Habib Virji 2015/06/29 12:17:42 Done.
+ exceptionState.throwDOMException(InvalidStateError, "XHTML doesn't support open().");
+ return;
+ }
+
+ if (ownerDocument) {
+ setURL(ownerDocument->url());
+ m_cookieURL = ownerDocument->cookieURL();
+ setSecurityOrigin(ownerDocument->securityOrigin());
+ }
+
+ open();
+}
+
void Document::detachParser()
{
if (!m_parser)
@@ -2444,6 +2454,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:
@@ -2454,10 +2472,12 @@ void Document::close(ExceptionState& exceptionState)
return;
}
- if (!scriptableDocumentParser() || !scriptableDocumentParser()->wasCreatedByScript() || !scriptableDocumentParser()->isParsing())
+ if (isXHTMLDocument()) {
philipj_slow 2015/06/24 11:52:19 Spec says "If the Document object is not flagged a
Habib Virji 2015/06/25 13:09:47 Since !isHTMLDocument() != isXMLDocument() (as exp
+ exceptionState.throwDOMException(InvalidStateError, "XHTML doesn't support close().");
return;
+ }
- explicitClose();
+ close();
}
void Document::explicitClose()
@@ -2700,6 +2720,11 @@ void Document::write(const SegmentedString& text, Document* ownerDocument, Excep
return;
}
+ if (isXHTMLDocument()) {
philipj_slow 2015/06/24 11:52:19 Here the spec actually says "If the method was inv
Habib Virji 2015/06/25 13:09:46 isXMLDocument() relies on value of DocumentClass,
philipj_slow 2015/06/27 21:42:56 Does write() need to be supported for Image, Plugi
Habib Virji 2015/06/29 12:17:42 It should not. I agree it should throw for !isHTML
+ exceptionState.throwDOMException(InvalidStateError, "XHTML doesn't support write().");
+ return;
+ }
+
NestingLevelIncrementer nestingLevelIncrementer(m_writeRecursionDepth);
m_writeRecursionIsTooDeep = (m_writeRecursionDepth > 1) && m_writeRecursionIsTooDeep;
@@ -2716,7 +2741,7 @@ void Document::write(const SegmentedString& text, Document* ownerDocument, Excep
}
if (!hasInsertionPoint)
- open(ownerDocument);
+ open(ownerDocument, exceptionState);
philipj_slow 2015/06/24 11:52:19 It looks like it's impossible for this to throw an
Habib Virji 2015/06/25 13:09:46 The reason for adding was it relied on ASSERT_NO_E
ASSERT(m_parser);
m_parser->insert(text);
@@ -2735,6 +2760,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