Backed out changeset 43b490ef9dab (bug 585877), a=beltzner GECKO20b4_20100817_RELBRANCH FIREFOX_4_0b4_BUILD2
authorGavin Sharp <gavin@gavinsharp.com>
Tue, 17 Aug 2010 15:27:06 -0400
branchGECKO20b4_20100817_RELBRANCH
changeset 50743 9aa39b619a19
parent 50739 96aa1d8d1f70
child 50745 54b5de2faf1d
push idunknown
push userunknown
push dateunknown
reviewersbeltzner
bugs585877
milestone2.0b4
backs out43b490ef9dab
Backed out changeset 43b490ef9dab (bug 585877), a=beltzner
content/html/document/src/nsHTMLDocument.cpp
dom/interfaces/html/nsIDOMNSHTMLDocument.idl
js/src/xpconnect/src/dom_quickstubs.qsconf
--- a/content/html/document/src/nsHTMLDocument.cpp
+++ b/content/html/document/src/nsHTMLDocument.cpp
@@ -2319,16 +2319,62 @@ nsHTMLDocument::RemovedForm()
 }
 
 PRInt32
 nsHTMLDocument::GetNumFormsSynchronous()
 {
   return mNumForms;
 }
 
+nsresult
+nsHTMLDocument::GetBodySize(PRInt32* aWidth,
+                            PRInt32* aHeight)
+{
+  *aWidth = *aHeight = 0;
+
+  FlushPendingNotifications(Flush_Layout);
+
+  // Find the <body> element: this is what we'll want to use for the
+  // document's width and height values.
+  Element* body = GetBodyElement();
+  if (!body) {
+    return NS_OK;
+  }
+
+  // Now grab its frame
+  nsIFrame* frame = body->GetPrimaryFrame();
+  if (!frame)
+    return NS_OK;
+  
+  nsSize size = frame->GetSize();
+
+  *aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width);
+  *aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height);
+
+  return NS_OK;
+}
+
+NS_IMETHODIMP
+nsHTMLDocument::GetWidth(PRInt32* aWidth)
+{
+  NS_ENSURE_ARG_POINTER(aWidth);
+
+  PRInt32 height;
+  return GetBodySize(aWidth, &height);
+}
+
+NS_IMETHODIMP
+nsHTMLDocument::GetHeight(PRInt32* aHeight)
+{
+  NS_ENSURE_ARG_POINTER(aHeight);
+
+  PRInt32 width;
+  return GetBodySize(&width, aHeight);
+}
+
 NS_IMETHODIMP
 nsHTMLDocument::GetAlinkColor(nsAString& aAlinkColor)
 {
   aAlinkColor.Truncate();
 
   nsCOMPtr<nsIDOMHTMLBodyElement> body = do_QueryInterface(GetBodyElement());
   if (body) {
     body->GetALink(aAlinkColor);
--- a/dom/interfaces/html/nsIDOMNSHTMLDocument.idl
+++ b/dom/interfaces/html/nsIDOMNSHTMLDocument.idl
@@ -34,19 +34,21 @@
  * and other provisions required by the GPL or the LGPL. If you do not delete
  * the provisions above, a recipient may use your version of this file under
  * the terms of any one of the MPL, the GPL or the LGPL.
  *
  * ***** END LICENSE BLOCK ***** */
 
 #include "domstubs.idl"
 
-[scriptable, uuid(386e9eee-1f06-40a6-a1a7-ed986646b793)]
+[scriptable, uuid(95cd5ad4-ae8a-4f0e-b168-35e03d5e0b9a)]
 interface nsIDOMNSHTMLDocument : nsISupports
 {
+  readonly attribute long                 width;
+  readonly attribute long                 height;
            attribute DOMString            alinkColor;
            attribute DOMString            linkColor;
            attribute DOMString            vlinkColor;
            attribute DOMString            bgColor;
            attribute DOMString            fgColor;
            attribute DOMString            domain;
 
   readonly attribute nsIDOMHTMLCollection embeds;
--- a/js/src/xpconnect/src/dom_quickstubs.qsconf
+++ b/js/src/xpconnect/src/dom_quickstubs.qsconf
@@ -325,16 +325,18 @@ members = [
     'nsIDOMHTMLTextAreaElement.value',
     'nsIDOMHTMLTextAreaElement.type',
     'nsIDOMHTMLTextAreaElement.select',
     'nsIDOMHTMLTitleElement.text',
     'nsIDOMHTMLCanvasElement.width',
     'nsIDOMHTMLCanvasElement.height',
     'nsIDOMHTMLCanvasElement.getContext',
     'nsIDOMHTMLCanvasElement.toDataURL',
+    'nsIDOMNSHTMLDocument.width',
+    'nsIDOMNSHTMLDocument.height',
     'nsIDOMNSHTMLDocument.domain',
     'nsIDOMNSHTMLDocument.getSelection',
     'nsIDOMNSHTMLDocument.designMode',
     'nsIDOMNSHTMLElement.contentEditable',
     'nsIDOMNSHTMLElement.isContentEditable',
     'nsIDOMNSHTMLElement.offsetParent',
     'nsIDOMNSHTMLElement.innerHTML',
     'nsIDOMNSHTMLElement.offsetLeft',