Merge mozilla-central to mozilla-inbound
This commit is contained in:
@@ -652,23 +652,22 @@ ImageDocument::CreateSyntheticDocument()
|
||||
// the size of the paper and cannot break into continuations along
|
||||
// multiple pages.
|
||||
Element* head = GetHeadElement();
|
||||
if (!head) {
|
||||
NS_WARNING("no head on image document!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
NS_ENSURE_TRUE(head, NS_ERROR_FAILURE);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::style, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsRefPtr<nsGenericHTMLElement> styleContent = NS_NewHTMLStyleElement(nodeInfo.forget());
|
||||
if (!styleContent) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
if (nsContentUtils::IsChildOfSameType(this)) {
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::style, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsRefPtr<nsGenericHTMLElement> styleContent = NS_NewHTMLStyleElement(nodeInfo.forget());
|
||||
NS_ENSURE_TRUE(styleContent, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
styleContent->SetTextContent(NS_LITERAL_STRING("img { display: block; }"));
|
||||
head->AppendChildTo(styleContent, false);
|
||||
styleContent->SetTextContent(NS_LITERAL_STRING("img { display: block; }"));
|
||||
head->AppendChildTo(styleContent, false);
|
||||
} else {
|
||||
LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelImageDocument.css"));
|
||||
}
|
||||
|
||||
// Add the image element
|
||||
Element* body = GetBodyElement();
|
||||
|
||||
@@ -243,9 +243,7 @@ MediaDocument::CreateSyntheticDocument()
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> root = NS_NewHTMLHtmlElement(nodeInfo.forget());
|
||||
if (!root) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ENSURE_TRUE(root, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ASSERTION(GetChildCount() == 0, "Shouldn't have any kids");
|
||||
rv = AppendChildTo(root, false);
|
||||
@@ -258,20 +256,15 @@ MediaDocument::CreateSyntheticDocument()
|
||||
|
||||
// Create a <head> so our title has somewhere to live
|
||||
nsRefPtr<nsGenericHTMLElement> head = NS_NewHTMLHeadElement(nodeInfo.forget());
|
||||
if (!head) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ENSURE_TRUE(head, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsCOMPtr<nsINodeInfo> nodeInfoMeta;
|
||||
nodeInfoMeta = mNodeInfoManager->GetNodeInfo(nsGkAtoms::meta, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
NS_ENSURE_TRUE(nodeInfoMeta, NS_ERROR_OUT_OF_MEMORY);
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::meta, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> metaContent = NS_NewHTMLMetaElement(nodeInfoMeta.forget());
|
||||
if (!metaContent) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
nsRefPtr<nsGenericHTMLElement> metaContent = NS_NewHTMLMetaElement(nodeInfo.forget());
|
||||
NS_ENSURE_TRUE(metaContent, NS_ERROR_OUT_OF_MEMORY);
|
||||
metaContent->SetAttr(kNameSpaceID_None, nsGkAtoms::name,
|
||||
NS_LITERAL_STRING("viewport"),
|
||||
true);
|
||||
@@ -289,9 +282,7 @@ MediaDocument::CreateSyntheticDocument()
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> body = NS_NewHTMLBodyElement(nodeInfo.forget());
|
||||
if (!body) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ENSURE_TRUE(body, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
root->AppendChildTo(body, false);
|
||||
|
||||
@@ -354,6 +345,27 @@ MediaDocument::GetFileName(nsAString& aResult)
|
||||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
MediaDocument::LinkStylesheet(const nsAString& aStylesheet)
|
||||
{
|
||||
nsCOMPtr<nsINodeInfo> nodeInfo;
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::link, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
nsRefPtr<nsGenericHTMLElement> link = NS_NewHTMLLinkElement(nodeInfo.forget());
|
||||
NS_ENSURE_TRUE(link, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
link->SetAttr(kNameSpaceID_None, nsGkAtoms::rel,
|
||||
NS_LITERAL_STRING("stylesheet"), true);
|
||||
|
||||
link->SetAttr(kNameSpaceID_None, nsGkAtoms::href, aStylesheet, true);
|
||||
|
||||
Element* head = GetHeadElement();
|
||||
return head->AppendChildTo(link, false);
|
||||
}
|
||||
|
||||
void
|
||||
MediaDocument::UpdateTitleAndCharset(const nsACString& aTypeStr,
|
||||
const char* const* aFormatNames,
|
||||
|
||||
@@ -72,6 +72,8 @@ protected:
|
||||
|
||||
void GetFileName(nsAString& aResult);
|
||||
|
||||
nsresult LinkStylesheet(const nsAString& aStylesheet);
|
||||
|
||||
// |aFormatNames[]| needs to have four elements in the following order:
|
||||
// a format name with neither dimension nor file, a format name with
|
||||
// filename but w/o dimension, a format name with dimension but w/o filename,
|
||||
|
||||
@@ -134,24 +134,7 @@ VideoDocument::CreateSyntheticVideoDocument(nsIChannel* aChannel,
|
||||
NS_LITERAL_STRING("position:absolute; top:0; left:0; width:100%; height:100%"),
|
||||
true);
|
||||
} else {
|
||||
Element* head = GetHeadElement();
|
||||
if (!head) {
|
||||
NS_WARNING("no head on video document!");
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::style, nsnull,
|
||||
kNameSpaceID_XHTML,
|
||||
nsIDOMNode::ELEMENT_NODE);
|
||||
NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
|
||||
nsRefPtr<nsGenericHTMLElement> styleContent = NS_NewHTMLStyleElement(nodeInfo.forget());
|
||||
NS_ENSURE_TRUE(styleContent, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
styleContent->SetTextContent(
|
||||
NS_LITERAL_STRING("body { background: url(chrome://global/skin/icons/tabprompts-bgtexture.png) #333; height: 100%; width: 100%; margin: 0; padding: 0; } ") +
|
||||
NS_LITERAL_STRING("video { position: absolute; top: 0; right: 0; bottom: 0; left: 0; margin: auto; box-shadow: 0 0 15px #000; } ") +
|
||||
NS_LITERAL_STRING("video:focus { outline-width: 0; } "));
|
||||
head->AppendChildTo(styleContent, false);
|
||||
LinkStylesheet(NS_LITERAL_STRING("resource://gre/res/TopLevelVideoDocument.css"));
|
||||
}
|
||||
|
||||
return body->AppendChildTo(element, false);
|
||||
@@ -175,9 +158,7 @@ nsresult
|
||||
NS_NewVideoDocument(nsIDocument** aResult)
|
||||
{
|
||||
mozilla::dom::VideoDocument* doc = new mozilla::dom::VideoDocument();
|
||||
if (!doc) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
NS_ENSURE_TRUE(doc, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
NS_ADDREF(doc);
|
||||
nsresult rv = doc->Init();
|
||||
|
||||
@@ -2800,20 +2800,18 @@ HTMLContentSink::ProcessSCRIPTEndTag(nsGenericHTMLElement *content,
|
||||
mHTMLDocument->ScriptLoading(sele);
|
||||
|
||||
// Now tell the script that it's ready to go. This may execute the script
|
||||
// or return NS_ERROR_HTMLPARSER_BLOCK. Or neither if the script doesn't
|
||||
// need executing.
|
||||
nsresult rv = content->DoneAddingChildren(true);
|
||||
// or return true, or neither if the script doesn't need executing.
|
||||
bool block = sele->AttemptToExecute();
|
||||
|
||||
// If the act of insertion evaluated the script, we're fine.
|
||||
// Else, block the parser till the script has loaded.
|
||||
if (rv == NS_ERROR_HTMLPARSER_BLOCK) {
|
||||
if (block) {
|
||||
// If this append fails we'll never unblock the parser, but the UI will
|
||||
// still remain responsive. There are other ways to deal with this, but
|
||||
// the end result is always that the page gets botched, so there is no
|
||||
// real point in making it more complicated.
|
||||
mScriptElements.AppendObject(sele);
|
||||
}
|
||||
else {
|
||||
} else {
|
||||
// This may have already happened if the script executed, but in case
|
||||
// it didn't then remove the element so that it doesn't get stuck forever.
|
||||
mHTMLDocument->ScriptExecuted(sele);
|
||||
@@ -2822,10 +2820,10 @@ HTMLContentSink::ProcessSCRIPTEndTag(nsGenericHTMLElement *content,
|
||||
// If the parser got blocked, make sure to return the appropriate rv.
|
||||
// I'm not sure if this is actually needed or not.
|
||||
if (mParser && !mParser->IsParserEnabled()) {
|
||||
rv = NS_ERROR_HTMLPARSER_BLOCK;
|
||||
block = true;
|
||||
}
|
||||
|
||||
return rv;
|
||||
return block ? NS_ERROR_HTMLPARSER_BLOCK : NS_OK;
|
||||
}
|
||||
|
||||
// 3 ways to load a style sheet: inline, style src=, link tag
|
||||
|
||||
@@ -945,10 +945,8 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
||||
|
||||
// Set the parser as the stream listener for the document loader...
|
||||
if (mParser) {
|
||||
rv = mParser->GetStreamListener(aDocListener);
|
||||
if (NS_FAILED(rv)) {
|
||||
return rv;
|
||||
}
|
||||
nsCOMPtr<nsIStreamListener> listener = mParser->GetStreamListener();
|
||||
listener.forget(aDocListener);
|
||||
|
||||
#ifdef DEBUG_charset
|
||||
printf(" charset = %s source %d\n",
|
||||
|
||||
Reference in New Issue
Block a user