author | Xidorn Quan <me@upsuper.org> |
Wed, 26 Jul 2017 19:47:18 +1000 | |
changeset 371292 | e0a391cfa6d6d97f0e6c5b59ca3fa550ace414a5 |
parent 371291 | d2b2de8c314b98c466ab8309d32eb9114ab36c69 |
child 371293 | 558d00335f144dce9bacf6ebc9762cdde63e4a42 |
push id | 93049 |
push user | cbook@mozilla.com |
push date | Thu, 27 Jul 2017 09:30:07 +0000 |
treeherder | mozilla-inbound@5e9f7561c2eb [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | bz |
bugs | 1384162 |
milestone | 56.0a1 |
first release with | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
last release without | nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
|
--- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -8182,18 +8182,17 @@ nsDocShell::CreateAboutBlankContentViewe principal = NullPrincipal::CreateWithInheritedAttributes(aPrincipal); } else { principal = NullPrincipal::CreateWithInheritedAttributes(this); } } else { principal = aPrincipal; } // generate (about:blank) document to load - nsContentDLF::CreateBlankDocument(mLoadGroup, principal, - getter_AddRefs(blankDoc)); + blankDoc = nsContentDLF::CreateBlankDocument(mLoadGroup, principal); if (blankDoc) { // Hack: set the base URI manually, since this document never // got Reset() with a channel. blankDoc->SetBaseURI(aBaseURI); blankDoc->SetContainer(this); // Copy our sandbox flags to the document. These are immutable
--- a/layout/build/nsContentDLF.cpp +++ b/layout/build/nsContentDLF.cpp @@ -258,88 +258,73 @@ nsContentDLF::CreateInstanceForDocument( nsCOMPtr<nsIContentViewer> contentViewer = NS_NewContentViewer(); // Bind the document to the Content Viewer contentViewer->LoadStart(aDocument); contentViewer.forget(aContentViewer); return NS_OK; } -/* static */ nsresult +/* static */ already_AddRefed<nsIDocument> nsContentDLF::CreateBlankDocument(nsILoadGroup* aLoadGroup, - nsIPrincipal* aPrincipal, - nsIDocument** aDocument) + nsIPrincipal* aPrincipal) { - *aDocument = nullptr; - - nsresult rv = NS_ERROR_FAILURE; - // create a new blank HTML document nsCOMPtr<nsIDocument> blankDoc(do_CreateInstance(kHTMLDocumentCID)); - if (blankDoc) { - // initialize - nsCOMPtr<nsIURI> uri; - NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank")); - if (uri) { - blankDoc->ResetToURI(uri, aLoadGroup, aPrincipal); - rv = NS_OK; - } + if (!blankDoc) { + return nullptr; } + // initialize + nsCOMPtr<nsIURI> uri; + NS_NewURI(getter_AddRefs(uri), NS_LITERAL_CSTRING("about:blank")); + if (!uri) { + return nullptr; + } + blankDoc->ResetToURI(uri, aLoadGroup, aPrincipal); + // add some simple content structure - if (NS_SUCCEEDED(rv)) { - rv = NS_ERROR_FAILURE; + nsNodeInfoManager *nim = blankDoc->NodeInfoManager(); - nsNodeInfoManager *nim = blankDoc->NodeInfoManager(); - - RefPtr<mozilla::dom::NodeInfo> htmlNodeInfo; + RefPtr<mozilla::dom::NodeInfo> htmlNodeInfo; - // generate an html html element - htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML, - nsIDOMNode::ELEMENT_NODE); - nsCOMPtr<nsIContent> htmlElement = - NS_NewHTMLHtmlElement(htmlNodeInfo.forget()); + // generate an html html element + htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::html, 0, kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + nsCOMPtr<nsIContent> htmlElement = + NS_NewHTMLHtmlElement(htmlNodeInfo.forget()); - // generate an html head element - htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::head, 0, kNameSpaceID_XHTML, - nsIDOMNode::ELEMENT_NODE); - nsCOMPtr<nsIContent> headElement = - NS_NewHTMLHeadElement(htmlNodeInfo.forget()); + // generate an html head element + htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::head, 0, kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + nsCOMPtr<nsIContent> headElement = + NS_NewHTMLHeadElement(htmlNodeInfo.forget()); - // generate an html body elemment - htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::body, 0, kNameSpaceID_XHTML, - nsIDOMNode::ELEMENT_NODE); - nsCOMPtr<nsIContent> bodyElement = - NS_NewHTMLBodyElement(htmlNodeInfo.forget()); + // generate an html body elemment + htmlNodeInfo = nim->GetNodeInfo(nsGkAtoms::body, 0, kNameSpaceID_XHTML, + nsIDOMNode::ELEMENT_NODE); + nsCOMPtr<nsIContent> bodyElement = + NS_NewHTMLBodyElement(htmlNodeInfo.forget()); - // blat in the structure - if (htmlElement && headElement && bodyElement) { - NS_ASSERTION(blankDoc->GetChildCount() == 0, - "Shouldn't have children"); - rv = blankDoc->AppendChildTo(htmlElement, false); - if (NS_SUCCEEDED(rv)) { - rv = htmlElement->AppendChildTo(headElement, false); - - if (NS_SUCCEEDED(rv)) { - // XXXbz Why not notifying here? - htmlElement->AppendChildTo(bodyElement, false); - } - } - } + // blat in the structure + NS_ASSERTION(blankDoc->GetChildCount() == 0, + "Shouldn't have children"); + if (!htmlElement || !headElement || !bodyElement || + NS_FAILED(blankDoc->AppendChildTo(htmlElement, false)) || + NS_FAILED(htmlElement->AppendChildTo(headElement, false)) || + // XXXbz Why not notifying here? + NS_FAILED(htmlElement->AppendChildTo(bodyElement, false))) { + return nullptr; } // add a nice bow - if (NS_SUCCEEDED(rv)) { - blankDoc->SetDocumentCharacterSetSource(kCharsetFromDocTypeDefault); - blankDoc->SetDocumentCharacterSet(UTF_8_ENCODING); - - blankDoc.forget(aDocument); - } - return rv; + blankDoc->SetDocumentCharacterSetSource(kCharsetFromDocTypeDefault); + blankDoc->SetDocumentCharacterSet(UTF_8_ENCODING); + return blankDoc.forget(); } nsresult nsContentDLF::CreateDocument(const char* aCommand, nsIChannel* aChannel, nsILoadGroup* aLoadGroup, nsIDocShell* aContainer,
--- a/layout/build/nsContentDLF.h +++ b/layout/build/nsContentDLF.h @@ -46,19 +46,18 @@ public: nsIStreamListener** aDocListener, nsIContentViewer** aContentViewer); /** * Create a blank document using the given loadgroup and given * principal. aPrincipal is allowed to be null, in which case the * new document will get the about:blank codebase principal. */ - static nsresult CreateBlankDocument(nsILoadGroup* aLoadGroup, - nsIPrincipal* aPrincipal, - nsIDocument** aDocument); + static already_AddRefed<nsIDocument> + CreateBlankDocument(nsILoadGroup* aLoadGroup, nsIPrincipal* aPrincipal); private: static nsresult EnsureUAStyleSheet(); static bool IsImageContentType(const char* aContentType); }; nsresult NS_NewContentDocumentLoaderFactory(nsIDocumentLoaderFactory** aResult);