diff --git a/content/html/content/src/nsHTMLTableRowElement.cpp b/content/html/content/src/nsHTMLTableRowElement.cpp index d8bd9f273fb3..2ff0deec60ba 100644 --- a/content/html/content/src/nsHTMLTableRowElement.cpp +++ b/content/html/content/src/nsHTMLTableRowElement.cpp @@ -49,11 +49,6 @@ #include "nsHTMLParts.h" #include "nsRuleData.h" -// temporary -#include "nsIDocument.h" -#include "nsIPresShell.h" -#include "nsIFrame.h" - class nsHTMLTableRowElement : public nsGenericHTMLElement, public nsIDOMHTMLTableRowElement { @@ -93,31 +88,6 @@ protected: nsRefPtr mCells; }; -#ifdef XXX_debugging -static -void DebugList(nsIDOMHTMLTableElement* aTable) { - nsCOMPtr content = do_QueryInterface(aTable); - if (content) { - nsCOMPtr doc; - result = content->GetDocument(getter_AddRefs(doc)); - if (doc) { - nsCOMPtr root; - doc->GetRootContent(getter_AddRefs(root)); - if (root) { - root->List(); - } - nsIPresShell *shell = doc->GetPrimaryShell(); - if (shell) { - nsIFrame* rootFrame = shell->FrameManager()->GetRootFrame(); - if (rootFrame) { - rootFrame->List(stdout, 0); - } - } - } - } -} -#endif - NS_IMPL_NS_NEW_HTML_ELEMENT(TableRow) diff --git a/content/html/document/src/nsHTMLContentSink.cpp b/content/html/document/src/nsHTMLContentSink.cpp index 57033c85cc0b..6b01770d1d2d 100644 --- a/content/html/document/src/nsHTMLContentSink.cpp +++ b/content/html/document/src/nsHTMLContentSink.cpp @@ -52,15 +52,11 @@ #include "nsScriptLoader.h" #include "nsIURI.h" #include "nsNetUtil.h" -#include "nsIPresShell.h" -#include "nsIViewManager.h" -#include "nsIWidget.h" #include "nsIContentViewer.h" #include "nsIMarkupDocumentViewer.h" #include "nsINodeInfo.h" #include "nsHTMLTokens.h" #include "nsIAppShell.h" -#include "nsWidgetsCID.h" #include "nsCRT.h" #include "prtime.h" #include "prlog.h" @@ -89,7 +85,6 @@ #include "nsGkAtoms.h" #include "nsContentUtils.h" -#include "nsIFrame.h" #include "nsIChannel.h" #include "nsIHttpChannel.h" #include "nsIDocShell.h" diff --git a/content/html/document/src/nsHTMLDocument.cpp b/content/html/document/src/nsHTMLDocument.cpp index 346154eca204..3b24aed96182 100644 --- a/content/html/document/src/nsHTMLDocument.cpp +++ b/content/html/document/src/nsHTMLDocument.cpp @@ -81,8 +81,6 @@ #include "nsDOMError.h" #include "nsIPrincipal.h" #include "nsIScriptSecurityManager.h" -#include "nsIScrollableView.h" -#include "nsIView.h" #include "nsAttrName.h" #include "nsNodeUtils.h" @@ -2731,14 +2729,18 @@ nsHTMLDocument::GetNumFormsSynchronous() } nsresult -nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell, - PRInt32* aWidth, - PRInt32* aHeight) +nsHTMLDocument::GetBodySize(PRInt32* aWidth, + PRInt32* aHeight) { *aWidth = *aHeight = 0; FlushPendingNotifications(Flush_Layout); + nsCOMPtr shell = GetPrimaryShell(); + + if (!shell) + return NS_OK; + // Find the element: this is what we'll want to use for the // document's width and height values. if (!mBodyContent && !GetBodyContent()) { @@ -2748,32 +2750,14 @@ nsHTMLDocument::GetPixelDimensions(nsIPresShell* aShell, nsCOMPtr body = do_QueryInterface(mBodyContent); // Now grab its frame - nsIFrame* frame = aShell->GetPrimaryFrameFor(body); - if (frame) { - nsSize size; - nsIView* view = frame->GetView(); + nsIFrame* frame = shell->GetPrimaryFrameFor(body); + if (!frame) + return NS_OK; + + nsSize size = frame->GetSize(); - // If we have a view check if it's scrollable. If not, - // just use the view size itself - if (view) { - nsIScrollableView* scrollableView = view->ToScrollableView(); - - if (scrollableView) { - scrollableView->GetScrolledView(view); - } - - nsRect r = view->GetBounds(); - size.height = r.height; - size.width = r.width; - } - // If we don't have a view, use the frame size - else { - size = frame->GetSize(); - } - - *aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width); - *aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height); - } + *aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width); + *aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height); return NS_OK; } @@ -2782,44 +2766,18 @@ NS_IMETHODIMP nsHTMLDocument::GetWidth(PRInt32* aWidth) { NS_ENSURE_ARG_POINTER(aWidth); - *aWidth = 0; - // We make the assumption that the first presentation shell - // is the one for which we need information. - // Since GetPixelDimensions flushes and flushing can destroy - // our shell, hold a strong ref to it. - nsCOMPtr shell = GetPrimaryShell(); - if (!shell) { - return NS_OK; - } - - PRInt32 dummy; - - // GetPixelDimensions() does the flushing for us, no need to flush - // here too - return GetPixelDimensions(shell, aWidth, &dummy); + PRInt32 height; + return GetBodySize(aWidth, &height); } NS_IMETHODIMP nsHTMLDocument::GetHeight(PRInt32* aHeight) { NS_ENSURE_ARG_POINTER(aHeight); - *aHeight = 0; - // We make the assumption that the first presentation shell - // is the one for which we need information. - // Since GetPixelDimensions flushes and flushing can destroy - // our shell, hold a strong ref to it. - nsCOMPtr shell = GetPrimaryShell(); - if (!shell) { - return NS_OK; - } - - PRInt32 dummy; - - // GetPixelDimensions() does the flushing for us, no need to flush - // here too - return GetPixelDimensions(shell, &dummy, aHeight); + PRInt32 width; + return GetBodySize(&width, aHeight); } NS_IMETHODIMP diff --git a/content/html/document/src/nsHTMLDocument.h b/content/html/document/src/nsHTMLDocument.h index 84edc84442d5..a419601af1bc 100644 --- a/content/html/document/src/nsHTMLDocument.h +++ b/content/html/document/src/nsHTMLDocument.h @@ -210,9 +210,8 @@ public: NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED_NO_UNLINK(nsHTMLDocument, nsDocument) protected: - nsresult GetPixelDimensions(nsIPresShell* aShell, - PRInt32* aWidth, - PRInt32* aHeight); + nsresult GetBodySize(PRInt32* aWidth, + PRInt32* aHeight); nsresult RegisterNamedItems(nsIContent *aContent); nsresult UnregisterNamedItems(nsIContent *aContent); diff --git a/content/xul/document/src/nsXULDocument.cpp b/content/xul/document/src/nsXULDocument.cpp index 57cf1ed7c890..4240f766fd0b 100644 --- a/content/xul/document/src/nsXULDocument.cpp +++ b/content/xul/document/src/nsXULDocument.cpp @@ -1371,46 +1371,25 @@ nsXULDocument::Persist(nsIContent* aElement, PRInt32 aNameSpaceID, nsresult -nsXULDocument::GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth, - PRInt32* aHeight) +nsXULDocument::GetViewportSize(PRInt32* aWidth, + PRInt32* aHeight) { - nsresult result = NS_OK; - nsSize size; + *aWidth = *aHeight = 0; FlushPendingNotifications(Flush_Layout); - nsIFrame* frame = - mRootContent ? aShell->GetPrimaryFrameFor(mRootContent) : nsnull; - if (frame) { - nsIView* view = frame->GetView(); - // If we have a view check if it's scrollable. If not, - // just use the view size itself - if (view) { - nsIScrollableView* scrollableView = view->ToScrollableView(); + nsIPresShell *shell = GetPrimaryShell(); + NS_ENSURE_TRUE(shell, NS_ERROR_FAILURE); - if (scrollableView) { - scrollableView->GetScrolledView(view); - } + nsIFrame* frame = shell->GetRootFrame(); + NS_ENSURE_TRUE(frame, NS_ERROR_FAILURE); - nsRect r = view->GetBounds(); - size.height = r.height; - size.width = r.width; - } - // If we don't have a view, use the frame size - else { - size = frame->GetSize(); - } + nsSize size = frame->GetSize(); - *aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width); - *aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height); - } - else { - *aWidth = 0; - *aHeight = 0; - result = NS_ERROR_FAILURE; - } + *aWidth = nsPresContext::AppUnitsToIntCSSPixels(size.width); + *aHeight = nsPresContext::AppUnitsToIntCSSPixels(size.height); - return result; + return NS_OK; } NS_IMETHODIMP @@ -1418,20 +1397,8 @@ nsXULDocument::GetWidth(PRInt32* aWidth) { NS_ENSURE_ARG_POINTER(aWidth); - nsresult rv = NS_OK; - - // We make the assumption that the first presentation shell - // is the one for which we need information. - nsIPresShell *shell = GetPrimaryShell(); - if (shell) { - PRInt32 width, height; - - rv = GetPixelDimensions(shell, &width, &height); - *aWidth = width; - } else - *aWidth = 0; - - return rv; + PRInt32 height; + return GetViewportSize(aWidth, &height); } NS_IMETHODIMP @@ -1439,20 +1406,8 @@ nsXULDocument::GetHeight(PRInt32* aHeight) { NS_ENSURE_ARG_POINTER(aHeight); - nsresult rv = NS_OK; - - // We make the assumption that the first presentation shell - // is the one for which we need information. - nsIPresShell *shell = GetPrimaryShell(); - if (shell) { - PRInt32 width, height; - - rv = GetPixelDimensions(shell, &width, &height); - *aHeight = height; - } else - *aHeight = 0; - - return rv; + PRInt32 width; + return GetViewportSize(&width, aHeight); } //---------------------------------------------------------------------- diff --git a/content/xul/document/src/nsXULDocument.h b/content/xul/document/src/nsXULDocument.h index 86ba5812880d..6870c58764de 100644 --- a/content/xul/document/src/nsXULDocument.h +++ b/content/xul/document/src/nsXULDocument.h @@ -188,8 +188,7 @@ protected: nsresult RemoveElementFromMap(nsIContent* aElement); - nsresult GetPixelDimensions(nsIPresShell* aShell, PRInt32* aWidth, - PRInt32* aHeight); + nsresult GetViewportSize(PRInt32* aWidth, PRInt32* aHeight); static PRIntn RemoveElementsFromMapByContent(const PRUnichar* aID,