<!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.
&lt;https://webkit.org/b/147552&gt;

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  &lt;akling@apple.com&gt;
+
+        Ref-ify some functions that always succeed in constructing Documents.
+        &lt;https://webkit.org/b/147552&gt;
+
+        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  &lt;commit-queue@webkit.org&gt;
</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&lt;CSSStyleSheet&gt; DOMImplementation::createCSSStyleSheet(const String&amp;, const String&amp; media, ExceptionCode&amp;)
</del><ins>+Ref&lt;CSSStyleSheet&gt; DOMImplementation::createCSSStyleSheet(const String&amp;, const String&amp; media, ExceptionCode&amp;)
</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&lt;CSSStyleSheet&gt; sheet = CSSStyleSheet::create(StyleSheetContents::create());
+    sheet-&gt;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&lt;HTMLDocument&gt; DOMImplementation::createHTMLDocument(const String&amp; title)
</del><ins>+Ref&lt;HTMLDocument&gt; DOMImplementation::createHTMLDocument(const String&amp; title)
</ins><span class="cx"> {
</span><del>-    RefPtr&lt;HTMLDocument&gt; d = HTMLDocument::create(0, URL());
-    d-&gt;open();
-    d-&gt;write(&quot;&lt;!doctype html&gt;&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
</del><ins>+    Ref&lt;HTMLDocument&gt; doc = HTMLDocument::create(nullptr, URL());
+    doc-&gt;open();
+    doc-&gt;write(&quot;&lt;!doctype html&gt;&lt;html&gt;&lt;body&gt;&lt;/body&gt;&lt;/html&gt;&quot;);
</ins><span class="cx">     if (!title.isNull())
</span><del>-        d-&gt;setTitle(title);
-    d-&gt;setSecurityOriginPolicy(m_document.securityOriginPolicy());
-    return d;
</del><ins>+        doc-&gt;setTitle(title);
+    doc-&gt;setSecurityOriginPolicy(m_document.securityOriginPolicy());
+    return doc;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><del>-RefPtr&lt;Document&gt; DOMImplementation::createDocument(const String&amp; type, Frame* frame, const URL&amp; url)
</del><ins>+Ref&lt;Document&gt; DOMImplementation::createDocument(const String&amp; type, Frame* frame, const URL&amp; 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 == &quot;text/html&quot;)
</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&amp; feature);
</span><span class="cx"> 
</span><span class="cx">     // From the DOMImplementationCSS interface
</span><del>-    static RefPtr&lt;CSSStyleSheet&gt; createCSSStyleSheet(const String&amp; title, const String&amp; media, ExceptionCode&amp;);
</del><ins>+    static Ref&lt;CSSStyleSheet&gt; createCSSStyleSheet(const String&amp; title, const String&amp; media, ExceptionCode&amp;);
</ins><span class="cx"> 
</span><span class="cx">     // From the HTMLDOMImplementation interface
</span><del>-    RefPtr&lt;HTMLDocument&gt; createHTMLDocument(const String&amp; title);
</del><ins>+    Ref&lt;HTMLDocument&gt; createHTMLDocument(const String&amp; title);
</ins><span class="cx"> 
</span><span class="cx">     // Other methods (not part of DOM)
</span><del>-    static RefPtr&lt;Document&gt; createDocument(const String&amp; MIMEType, Frame*, const URL&amp;);
</del><ins>+    static Ref&lt;Document&gt; createDocument(const String&amp; MIMEType, Frame*, const URL&amp;);
</ins><span class="cx"> 
</span><span class="cx">     WEBCORE_EXPORT static bool isXMLMIMEType(const String&amp; MIMEType);
</span><span class="cx">     WEBCORE_EXPORT static bool isTextMIMEType(const String&amp; 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&lt;Document&gt; DocumentWriter::createDocument(const URL&amp; url)
</del><ins>+Ref&lt;Document&gt; DocumentWriter::createDocument(const URL&amp; url)
</ins><span class="cx"> {
</span><span class="cx">     if (!m_frame-&gt;loader().stateMachine().isDisplayingInitialEmptyDocument() &amp;&amp; m_frame-&gt;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&lt;Document&gt; document = createDocument(url);
</del><ins>+    Ref&lt;Document&gt; 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-&gt;createDOMWindow();
</span><span class="cx"> 
</span><del>-    m_frame-&gt;loader().clear(document.get(), !shouldReuseDefaultView, !shouldReuseDefaultView);
</del><ins>+    m_frame-&gt;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&lt;Document&gt; createDocument(const URL&amp;);
</del><ins>+    Ref&lt;Document&gt; createDocument(const URL&amp;);
</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&lt;Document&gt; DOMParser::parseFromString(const String&amp; str, const String&amp; contentType, ExceptionCode&amp; ec)
</del><ins>+RefPtr&lt;Document&gt; DOMParser::parseFromString(const String&amp; str, const String&amp; contentType, ExceptionCode&amp; ec)
</ins><span class="cx"> {
</span><span class="cx">     if (contentType != &quot;text/html&quot;
</span><span class="cx">         &amp;&amp; contentType != &quot;text/xml&quot;
</span><span class="lines">@@ -33,12 +33,12 @@
</span><span class="cx">         &amp;&amp; contentType != &quot;application/xhtml+xml&quot;
</span><span class="cx">         &amp;&amp; contentType != &quot;image/svg+xml&quot;) {
</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&lt;Document&gt; doc = DOMImplementation::createDocument(contentType, 0, URL());
</del><ins>+    Ref&lt;Document&gt; doc = DOMImplementation::createDocument(contentType, nullptr, URL());
</ins><span class="cx">     doc-&gt;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&lt;DOMParser&gt; create() { return adoptRef(*new DOMParser); }
</span><span class="cx"> 
</span><del>-    PassRefPtr&lt;Document&gt; parseFromString(const String&amp;, const String&amp; contentType, ExceptionCode&amp;);
</del><ins>+    RefPtr&lt;Document&gt; parseFromString(const String&amp;, const String&amp; contentType, ExceptionCode&amp;);
</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-&gt;hasOneRef());
</span><span class="cx"> }
</span><span class="cx"> 
</span><del>-PassRefPtr&lt;Document&gt; XSLTProcessor::createDocumentFromSource(const String&amp; sourceString,
</del><ins>+Ref&lt;Document&gt; XSLTProcessor::createDocumentFromSource(const String&amp; sourceString,
</ins><span class="cx">     const String&amp; sourceEncoding, const String&amp; sourceMIMEType, Node* sourceNode, Frame* frame)
</span><span class="cx"> {
</span><span class="cx">     Ref&lt;Document&gt; ownerDocument(sourceNode-&gt;document());
</span><span class="lines">@@ -106,7 +106,7 @@
</span><span class="cx"> 
</span><span class="cx">     result-&gt;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&lt;Document&gt; 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&lt;XSLStyleSheet&gt; styleSheet) { m_stylesheet = styleSheet; }
</span><span class="cx">     bool transformToString(Node&amp; source, String&amp; resultMIMEType, String&amp; resultString, String&amp; resultEncoding);
</span><del>-    PassRefPtr&lt;Document&gt; createDocumentFromSource(const String&amp; source, const String&amp; sourceEncoding, const String&amp; sourceMIMEType, Node* sourceNode, Frame* frame);
</del><ins>+    Ref&lt;Document&gt; createDocumentFromSource(const String&amp; source, const String&amp; sourceEncoding, const String&amp; sourceMIMEType, Node* sourceNode, Frame* frame);
</ins><span class="cx">     
</span><span class="cx">     // DOM methods
</span><span class="cx">     void importStylesheet(PassRefPtr&lt;Node&gt; style)
</span></span></pre>
</div>
</div>

</body>
</html>