Bug 681443 - Fennec does not resize document properly in portrait mode; f=mbrubeck r=jst
authorOleg Romashin <romaxa@gmail.com>
Thu, 01 Sep 2011 22:16:13 +0100
changeset 76420 e6fc4594c22eff5fb29eaf616129f81b1022bbb4
parent 76419 9ef862cbcc5e8968887f67250dfbd8aa301c9a78
child 76421 4e76b1e5c1d1e28ee14779e8c3b32e9a1c7d4057
push id3
push userfelipc@gmail.com
push dateFri, 30 Sep 2011 20:09:13 +0000
reviewersjst
bugs681443
milestone9.0a1
Bug 681443 - Fennec does not resize document properly in portrait mode; f=mbrubeck r=jst
content/html/document/src/MediaDocument.cpp
--- a/content/html/document/src/MediaDocument.cpp
+++ b/content/html/document/src/MediaDocument.cpp
@@ -257,16 +257,35 @@ MediaDocument::CreateSyntheticDocument()
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   // 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;
   }
 
+  nsCOMPtr<nsINodeInfo> nodeInfoMeta;
+  nodeInfoMeta = mNodeInfoManager->GetNodeInfo(nsGkAtoms::meta, nsnull,
+                                               kNameSpaceID_XHTML,
+                                               nsIDOMNode::ELEMENT_NODE);
+  NS_ENSURE_TRUE(nodeInfoMeta, NS_ERROR_OUT_OF_MEMORY);
+
+  nsRefPtr<nsGenericHTMLElement> metaContent = NS_NewHTMLMetaElement(nodeInfoMeta.forget());
+  if (!metaContent) {
+    return NS_ERROR_OUT_OF_MEMORY;
+  }
+  metaContent->SetAttr(kNameSpaceID_None, nsGkAtoms::name,
+                       NS_LITERAL_STRING("viewport"),
+                       PR_TRUE);
+
+  metaContent->SetAttr(kNameSpaceID_None, nsGkAtoms::content,
+                       NS_LITERAL_STRING("width=device-width; height=device-height;"),
+                       PR_TRUE);
+  head->AppendChildTo(metaContent, PR_FALSE);
+
   root->AppendChildTo(head, PR_FALSE);
 
   nodeInfo = mNodeInfoManager->GetNodeInfo(nsGkAtoms::body, nsnull,
                                            kNameSpaceID_XHTML,
                                            nsIDOMNode::ELEMENT_NODE);
   NS_ENSURE_TRUE(nodeInfo, NS_ERROR_OUT_OF_MEMORY);
 
   nsRefPtr<nsGenericHTMLElement> body = NS_NewHTMLBodyElement(nodeInfo.forget());