<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[188193] trunk/Source/WebCore</title>
</head>
<body>
<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; }
#msg dl a { font-weight: bold}
#msg dl a:link { color:#fc3; }
#msg dl a:active { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/188193">188193</a></dd>
<dt>Author</dt> <dd>akling@apple.com</dd>
<dt>Date</dt> <dd>2015-08-09 01:11:32 -0700 (Sun, 09 Aug 2015)</dd>
</dl>
<h3>Log Message</h3>
<pre>Ref-ify some functions that always succeed in constructing Documents.
<https://webkit.org/b/147552>
Reviewed by Sam Weinig.
Update some functions involved in the construction of new Document objects
to codify that they always construct objects.
Bonus: DOMImplementation::createCSSStyleSheet().
* dom/DOMImplementation.cpp:
(WebCore::DOMImplementation::createCSSStyleSheet):
(WebCore::DOMImplementation::createHTMLDocument):
(WebCore::DOMImplementation::createDocument):
* dom/DOMImplementation.h:
* loader/DocumentWriter.cpp:
(WebCore::DocumentWriter::createDocument):
(WebCore::DocumentWriter::begin):
* loader/DocumentWriter.h:
* xml/DOMParser.cpp:
(WebCore::DOMParser::parseFromString):
* xml/DOMParser.h:
* xml/XSLTProcessor.cpp:
(WebCore::XSLTProcessor::createDocumentFromSource):
* xml/XSLTProcessor.h:</pre>
<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCoredomDOMImplementationcpp">trunk/Source/WebCore/dom/DOMImplementation.cpp</a></li>
<li><a href="#trunkSourceWebCoredomDOMImplementationh">trunk/Source/WebCore/dom/DOMImplementation.h</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentWritercpp">trunk/Source/WebCore/loader/DocumentWriter.cpp</a></li>
<li><a href="#trunkSourceWebCoreloaderDocumentWriterh">trunk/Source/WebCore/loader/DocumentWriter.h</a></li>
<li><a href="#trunkSourceWebCorexmlDOMParsercpp">trunk/Source/WebCore/xml/DOMParser.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlDOMParserh">trunk/Source/WebCore/xml/DOMParser.h</a></li>
<li><a href="#trunkSourceWebCorexmlXSLTProcessorcpp">trunk/Source/WebCore/xml/XSLTProcessor.cpp</a></li>
<li><a href="#trunkSourceWebCorexmlXSLTProcessorh">trunk/Source/WebCore/xml/XSLTProcessor.h</a></li>
</ul>
</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/ChangeLog        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -1,3 +1,31 @@
</span><ins>+2015-08-09 Andreas Kling <akling@apple.com>
+
+ Ref-ify some functions that always succeed in constructing Documents.
+ <https://webkit.org/b/147552>
+
+ Reviewed by Sam Weinig.
+
+ Update some functions involved in the construction of new Document objects
+ to codify that they always construct objects.
+
+ Bonus: DOMImplementation::createCSSStyleSheet().
+
+ * dom/DOMImplementation.cpp:
+ (WebCore::DOMImplementation::createCSSStyleSheet):
+ (WebCore::DOMImplementation::createHTMLDocument):
+ (WebCore::DOMImplementation::createDocument):
+ * dom/DOMImplementation.h:
+ * loader/DocumentWriter.cpp:
+ (WebCore::DocumentWriter::createDocument):
+ (WebCore::DocumentWriter::begin):
+ * loader/DocumentWriter.h:
+ * xml/DOMParser.cpp:
+ (WebCore::DOMParser::parseFromString):
+ * xml/DOMParser.h:
+ * xml/XSLTProcessor.cpp:
+ (WebCore::XSLTProcessor::createDocumentFromSource):
+ * xml/XSLTProcessor.h:
+
</ins><span class="cx"> 2015-08-08 Commit Queue <commit-queue@webkit.org>
</span><span class="cx">
</span><span class="cx"> Unreviewed, rolling out r179871.
</span></span></pre></div>
<a id="trunkSourceWebCoredomDOMImplementationcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMImplementation.cpp        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/dom/DOMImplementation.cpp        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -238,13 +238,13 @@
</span><span class="cx"> return doc;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media, ExceptionCode&)
</del><ins>+Ref<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media, ExceptionCode&)
</ins><span class="cx"> {
</span><span class="cx"> // FIXME: Title should be set.
</span><span class="cx"> // FIXME: Media could have wrong syntax, in which case we should generate an exception.
</span><del>- auto sheet = CSSStyleSheet::create(StyleSheetContents::create());
- sheet.get().setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
- return WTF::move(sheet);
</del><ins>+ Ref<CSSStyleSheet> sheet = CSSStyleSheet::create(StyleSheetContents::create());
+ sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
+ return sheet;
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> static inline bool isValidXMLMIMETypeChar(UChar c)
</span><span class="lines">@@ -289,18 +289,18 @@
</span><span class="cx"> return false;
</span><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
</del><ins>+Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
</ins><span class="cx"> {
</span><del>- RefPtr<HTMLDocument> d = HTMLDocument::create(0, URL());
- d->open();
- d->write("<!doctype html><html><body></body></html>");
</del><ins>+ Ref<HTMLDocument> doc = HTMLDocument::create(nullptr, URL());
+ doc->open();
+ doc->write("<!doctype html><html><body></body></html>");
</ins><span class="cx"> if (!title.isNull())
</span><del>- d->setTitle(title);
- d->setSecurityOriginPolicy(m_document.securityOriginPolicy());
- return d;
</del><ins>+ doc->setTitle(title);
+ doc->setSecurityOriginPolicy(m_document.securityOriginPolicy());
+ return doc;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>-RefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
</del><ins>+Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
</ins><span class="cx"> {
</span><span class="cx"> // Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those.
</span><span class="cx"> if (type == "text/html")
</span></span></pre></div>
<a id="trunkSourceWebCoredomDOMImplementationh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/DOMImplementation.h (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/DOMImplementation.h        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/dom/DOMImplementation.h        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -58,13 +58,13 @@
</span><span class="cx"> DOMImplementation* getInterface(const String& feature);
</span><span class="cx">
</span><span class="cx"> // From the DOMImplementationCSS interface
</span><del>- static RefPtr<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media, ExceptionCode&);
</del><ins>+ static Ref<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media, ExceptionCode&);
</ins><span class="cx">
</span><span class="cx"> // From the HTMLDOMImplementation interface
</span><del>- RefPtr<HTMLDocument> createHTMLDocument(const String& title);
</del><ins>+ Ref<HTMLDocument> createHTMLDocument(const String& title);
</ins><span class="cx">
</span><span class="cx"> // Other methods (not part of DOM)
</span><del>- static RefPtr<Document> createDocument(const String& MIMEType, Frame*, const URL&);
</del><ins>+ static Ref<Document> createDocument(const String& MIMEType, Frame*, const URL&);
</ins><span class="cx">
</span><span class="cx"> WEBCORE_EXPORT static bool isXMLMIMEType(const String& MIMEType);
</span><span class="cx"> WEBCORE_EXPORT static bool isTextMIMEType(const String& MIMEType);
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentWritercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentWriter.cpp        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/loader/DocumentWriter.cpp        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -101,7 +101,7 @@
</span><span class="cx"> begin(URL());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<Document> DocumentWriter::createDocument(const URL& url)
</del><ins>+Ref<Document> DocumentWriter::createDocument(const URL& url)
</ins><span class="cx"> {
</span><span class="cx"> if (!m_frame->loader().stateMachine().isDisplayingInitialEmptyDocument() && m_frame->loader().client().shouldAlwaysUsePluginDocument(m_mimeType))
</span><span class="cx"> return PluginDocument::create(m_frame, url);
</span><span class="lines">@@ -123,7 +123,7 @@
</span><span class="cx">
</span><span class="cx"> // Create a new document before clearing the frame, because it may need to
</span><span class="cx"> // inherit an aliased security context.
</span><del>- RefPtr<Document> document = createDocument(url);
</del><ins>+ Ref<Document> document = createDocument(url);
</ins><span class="cx">
</span><span class="cx"> // If the new document is for a Plugin but we're supposed to be sandboxed from Plugins,
</span><span class="cx"> // then replace the document with one whose parser will ignore the incoming data (bug 39323)
</span><span class="lines">@@ -138,7 +138,7 @@
</span><span class="cx"> else
</span><span class="cx"> document->createDOMWindow();
</span><span class="cx">
</span><del>- m_frame->loader().clear(document.get(), !shouldReuseDefaultView, !shouldReuseDefaultView);
</del><ins>+ m_frame->loader().clear(document.ptr(), !shouldReuseDefaultView, !shouldReuseDefaultView);
</ins><span class="cx"> clear();
</span><span class="cx">
</span><span class="cx"> if (!shouldReuseDefaultView)
</span></span></pre></div>
<a id="trunkSourceWebCoreloaderDocumentWriterh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/loader/DocumentWriter.h (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/loader/DocumentWriter.h        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/loader/DocumentWriter.h        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> void setDocumentWasLoadedAsPartOfNavigation();
</span><span class="cx">
</span><span class="cx"> private:
</span><del>- PassRefPtr<Document> createDocument(const URL&);
</del><ins>+ Ref<Document> createDocument(const URL&);
</ins><span class="cx"> void clear();
</span><span class="cx">
</span><span class="cx"> Frame* m_frame;
</span></span></pre></div>
<a id="trunkSourceWebCorexmlDOMParsercpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/DOMParser.cpp (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/DOMParser.cpp        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/xml/DOMParser.cpp        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -25,7 +25,7 @@
</span><span class="cx">
</span><span class="cx"> namespace WebCore {
</span><span class="cx">
</span><del>-PassRefPtr<Document> DOMParser::parseFromString(const String& str, const String& contentType, ExceptionCode& ec)
</del><ins>+RefPtr<Document> DOMParser::parseFromString(const String& str, const String& contentType, ExceptionCode& ec)
</ins><span class="cx"> {
</span><span class="cx"> if (contentType != "text/html"
</span><span class="cx"> && contentType != "text/xml"
</span><span class="lines">@@ -33,12 +33,12 @@
</span><span class="cx"> && contentType != "application/xhtml+xml"
</span><span class="cx"> && contentType != "image/svg+xml") {
</span><span class="cx"> ec = TypeError;
</span><del>- return 0;
</del><ins>+ return nullptr;
</ins><span class="cx"> }
</span><span class="cx">
</span><del>- RefPtr<Document> doc = DOMImplementation::createDocument(contentType, 0, URL());
</del><ins>+ Ref<Document> doc = DOMImplementation::createDocument(contentType, nullptr, URL());
</ins><span class="cx"> doc->setContent(str);
</span><del>- return doc.release();
</del><ins>+ return WTF::move(doc);
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorexmlDOMParserh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/DOMParser.h (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/DOMParser.h        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/xml/DOMParser.h        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -32,7 +32,7 @@
</span><span class="cx"> public:
</span><span class="cx"> static Ref<DOMParser> create() { return adoptRef(*new DOMParser); }
</span><span class="cx">
</span><del>- PassRefPtr<Document> parseFromString(const String&, const String& contentType, ExceptionCode&);
</del><ins>+ RefPtr<Document> parseFromString(const String&, const String& contentType, ExceptionCode&);
</ins><span class="cx">
</span><span class="cx"> private:
</span><span class="cx"> DOMParser() { }
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXSLTProcessorcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XSLTProcessor.cpp (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XSLTProcessor.cpp        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/xml/XSLTProcessor.cpp        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -68,7 +68,7 @@
</span><span class="cx"> ASSERT(!m_stylesheetRootNode || !m_stylesheet || m_stylesheet->hasOneRef());
</span><span class="cx"> }
</span><span class="cx">
</span><del>-PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
</del><ins>+Ref<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
</ins><span class="cx"> const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)
</span><span class="cx"> {
</span><span class="cx"> Ref<Document> ownerDocument(sourceNode->document());
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx">
</span><span class="cx"> result->setContent(documentSource);
</span><span class="cx">
</span><del>- return result.release();
</del><ins>+ return result.releaseNonNull();
</ins><span class="cx"> }
</span><span class="cx">
</span><span class="cx"> PassRefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
</span></span></pre></div>
<a id="trunkSourceWebCorexmlXSLTProcessorh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/xml/XSLTProcessor.h (188192 => 188193)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/xml/XSLTProcessor.h        2015-08-09 02:06:07 UTC (rev 188192)
+++ trunk/Source/WebCore/xml/XSLTProcessor.h        2015-08-09 08:11:32 UTC (rev 188193)
</span><span class="lines">@@ -46,7 +46,7 @@
</span><span class="cx">
</span><span class="cx"> void setXSLStyleSheet(PassRefPtr<XSLStyleSheet> styleSheet) { m_stylesheet = styleSheet; }
</span><span class="cx"> bool transformToString(Node& source, String& resultMIMEType, String& resultString, String& resultEncoding);
</span><del>- PassRefPtr<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame);
</del><ins>+ Ref<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame);
</ins><span class="cx">
</span><span class="cx"> // DOM methods
</span><span class="cx"> void importStylesheet(PassRefPtr<Node> style)
</span></span></pre>
</div>
</div>
</body>
</html>