Diff
Modified: trunk/Source/WebCore/ChangeLog (188192 => 188193)
--- 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)
@@ -1,3 +1,31 @@
+2015-08-09 Andreas Kling <[email protected]>
+
+ 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:
+
2015-08-08 Commit Queue <[email protected]>
Unreviewed, rolling out r179871.
Modified: trunk/Source/WebCore/dom/DOMImplementation.cpp (188192 => 188193)
--- 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)
@@ -238,13 +238,13 @@
return doc;
}
-RefPtr<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media, ExceptionCode&)
+Ref<CSSStyleSheet> DOMImplementation::createCSSStyleSheet(const String&, const String& media, ExceptionCode&)
{
// FIXME: Title should be set.
// FIXME: Media could have wrong syntax, in which case we should generate an exception.
- auto sheet = CSSStyleSheet::create(StyleSheetContents::create());
- sheet.get().setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
- return WTF::move(sheet);
+ Ref<CSSStyleSheet> sheet = CSSStyleSheet::create(StyleSheetContents::create());
+ sheet->setMediaQueries(MediaQuerySet::createAllowingDescriptionSyntax(media));
+ return sheet;
}
static inline bool isValidXMLMIMETypeChar(UChar c)
@@ -289,18 +289,18 @@
return false;
}
-RefPtr<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
+Ref<HTMLDocument> DOMImplementation::createHTMLDocument(const String& title)
{
- RefPtr<HTMLDocument> d = HTMLDocument::create(0, URL());
- d->open();
- d->write("<!doctype html><html><body></body></html>");
+ Ref<HTMLDocument> doc = HTMLDocument::create(nullptr, URL());
+ doc->open();
+ doc->write("<!doctype html><html><body></body></html>");
if (!title.isNull())
- d->setTitle(title);
- d->setSecurityOriginPolicy(m_document.securityOriginPolicy());
- return d;
+ doc->setTitle(title);
+ doc->setSecurityOriginPolicy(m_document.securityOriginPolicy());
+ return doc;
}
-RefPtr<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
+Ref<Document> DOMImplementation::createDocument(const String& type, Frame* frame, const URL& url)
{
// Plugins cannot take HTML and XHTML from us, and we don't even need to initialize the plugin database for those.
if (type == "text/html")
Modified: trunk/Source/WebCore/dom/DOMImplementation.h (188192 => 188193)
--- 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)
@@ -58,13 +58,13 @@
DOMImplementation* getInterface(const String& feature);
// From the DOMImplementationCSS interface
- static RefPtr<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media, ExceptionCode&);
+ static Ref<CSSStyleSheet> createCSSStyleSheet(const String& title, const String& media, ExceptionCode&);
// From the HTMLDOMImplementation interface
- RefPtr<HTMLDocument> createHTMLDocument(const String& title);
+ Ref<HTMLDocument> createHTMLDocument(const String& title);
// Other methods (not part of DOM)
- static RefPtr<Document> createDocument(const String& MIMEType, Frame*, const URL&);
+ static Ref<Document> createDocument(const String& MIMEType, Frame*, const URL&);
WEBCORE_EXPORT static bool isXMLMIMEType(const String& MIMEType);
WEBCORE_EXPORT static bool isTextMIMEType(const String& MIMEType);
Modified: trunk/Source/WebCore/loader/DocumentWriter.cpp (188192 => 188193)
--- 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)
@@ -101,7 +101,7 @@
begin(URL());
}
-PassRefPtr<Document> DocumentWriter::createDocument(const URL& url)
+Ref<Document> DocumentWriter::createDocument(const URL& url)
{
if (!m_frame->loader().stateMachine().isDisplayingInitialEmptyDocument() && m_frame->loader().client().shouldAlwaysUsePluginDocument(m_mimeType))
return PluginDocument::create(m_frame, url);
@@ -123,7 +123,7 @@
// Create a new document before clearing the frame, because it may need to
// inherit an aliased security context.
- RefPtr<Document> document = createDocument(url);
+ Ref<Document> document = createDocument(url);
// If the new document is for a Plugin but we're supposed to be sandboxed from Plugins,
// then replace the document with one whose parser will ignore the incoming data (bug 39323)
@@ -138,7 +138,7 @@
else
document->createDOMWindow();
- m_frame->loader().clear(document.get(), !shouldReuseDefaultView, !shouldReuseDefaultView);
+ m_frame->loader().clear(document.ptr(), !shouldReuseDefaultView, !shouldReuseDefaultView);
clear();
if (!shouldReuseDefaultView)
Modified: trunk/Source/WebCore/loader/DocumentWriter.h (188192 => 188193)
--- 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)
@@ -68,7 +68,7 @@
void setDocumentWasLoadedAsPartOfNavigation();
private:
- PassRefPtr<Document> createDocument(const URL&);
+ Ref<Document> createDocument(const URL&);
void clear();
Frame* m_frame;
Modified: trunk/Source/WebCore/xml/DOMParser.cpp (188192 => 188193)
--- 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)
@@ -25,7 +25,7 @@
namespace WebCore {
-PassRefPtr<Document> DOMParser::parseFromString(const String& str, const String& contentType, ExceptionCode& ec)
+RefPtr<Document> DOMParser::parseFromString(const String& str, const String& contentType, ExceptionCode& ec)
{
if (contentType != "text/html"
&& contentType != "text/xml"
@@ -33,12 +33,12 @@
&& contentType != "application/xhtml+xml"
&& contentType != "image/svg+xml") {
ec = TypeError;
- return 0;
+ return nullptr;
}
- RefPtr<Document> doc = DOMImplementation::createDocument(contentType, 0, URL());
+ Ref<Document> doc = DOMImplementation::createDocument(contentType, nullptr, URL());
doc->setContent(str);
- return doc.release();
+ return WTF::move(doc);
}
} // namespace WebCore
Modified: trunk/Source/WebCore/xml/DOMParser.h (188192 => 188193)
--- 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)
@@ -32,7 +32,7 @@
public:
static Ref<DOMParser> create() { return adoptRef(*new DOMParser); }
- PassRefPtr<Document> parseFromString(const String&, const String& contentType, ExceptionCode&);
+ RefPtr<Document> parseFromString(const String&, const String& contentType, ExceptionCode&);
private:
DOMParser() { }
Modified: trunk/Source/WebCore/xml/XSLTProcessor.cpp (188192 => 188193)
--- 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)
@@ -68,7 +68,7 @@
ASSERT(!m_stylesheetRootNode || !m_stylesheet || m_stylesheet->hasOneRef());
}
-PassRefPtr<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
+Ref<Document> XSLTProcessor::createDocumentFromSource(const String& sourceString,
const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame)
{
Ref<Document> ownerDocument(sourceNode->document());
@@ -106,7 +106,7 @@
result->setContent(documentSource);
- return result.release();
+ return result.releaseNonNull();
}
PassRefPtr<Document> XSLTProcessor::transformToDocument(Node* sourceNode)
Modified: trunk/Source/WebCore/xml/XSLTProcessor.h (188192 => 188193)
--- 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)
@@ -46,7 +46,7 @@
void setXSLStyleSheet(PassRefPtr<XSLStyleSheet> styleSheet) { m_stylesheet = styleSheet; }
bool transformToString(Node& source, String& resultMIMEType, String& resultString, String& resultEncoding);
- PassRefPtr<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame);
+ Ref<Document> createDocumentFromSource(const String& source, const String& sourceEncoding, const String& sourceMIMEType, Node* sourceNode, Frame* frame);
// DOM methods
void importStylesheet(PassRefPtr<Node> style)