diff --git a/layout/xul/base/src/nsScrollBoxObject.cpp b/layout/xul/base/src/nsScrollBoxObject.cpp index 9fd7b7040577..bd43e335c587 100644 --- a/layout/xul/base/src/nsScrollBoxObject.cpp +++ b/layout/xul/base/src/nsScrollBoxObject.cpp @@ -42,8 +42,8 @@ #include "nsIContent.h" #include "nsIDocument.h" #include "nsIDOMDocument.h" +#include "nsIDOMNSDocument.h" #include "nsIDOMElement.h" -#include "nsIDOMXULElement.h" #include "nsPresContext.h" #include "nsIFrame.h" #include "nsIScrollableView.h" @@ -229,6 +229,7 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToLine(PRInt32 line) /* void scrollToElement (in nsIDOMElement child); */ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child) { + NS_ENSURE_ARG_POINTER(child); nsIScrollableView* scrollableView = GetScrollableView(); if (!scrollableView) return NS_ERROR_FAILURE; @@ -242,9 +243,16 @@ NS_IMETHODIMP nsScrollBoxObject::ScrollToElement(nsIDOMElement *child) return NS_ERROR_FAILURE; nsRect rect, crect; - nsCOMPtr childDOMXULElement (do_QueryInterface(child)); - nsIBoxObject * childBoxObject; - childDOMXULElement->GetBoxObject(&childBoxObject); + nsCOMPtr doc; + child->GetOwnerDocument(getter_AddRefs(doc)); + nsCOMPtr nsDoc(do_QueryInterface(doc)); + if(!nsDoc) + return NS_ERROR_UNEXPECTED; + + nsCOMPtr childBoxObject; + nsDoc->GetBoxObjectFor(child, getter_AddRefs(childBoxObject)); + if(!childBoxObject) + return NS_ERROR_UNEXPECTED; PRInt32 x,y; childBoxObject->GetX(&x); @@ -302,6 +310,7 @@ NS_IMETHODIMP nsScrollBoxObject::GetScrolledSize(PRInt32 *width, PRInt32 *height /* void ensureElementIsVisible (in nsIDOMElement child); */ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child) { + NS_ENSURE_ARG_POINTER(child); nsIScrollableView* scrollableView = GetScrollableView(); if (!scrollableView) return NS_ERROR_FAILURE; @@ -315,9 +324,16 @@ NS_IMETHODIMP nsScrollBoxObject::EnsureElementIsVisible(nsIDOMElement *child) return NS_ERROR_FAILURE; nsRect rect, crect; - nsCOMPtr childDOMXULElement (do_QueryInterface(child)); - nsIBoxObject * childBoxObject; - childDOMXULElement->GetBoxObject(&childBoxObject); + nsCOMPtr doc; + child->GetOwnerDocument(getter_AddRefs(doc)); + nsCOMPtr nsDoc(do_QueryInterface(doc)); + if(!nsDoc) + return NS_ERROR_UNEXPECTED; + + nsCOMPtr childBoxObject; + nsDoc->GetBoxObjectFor(child, getter_AddRefs(childBoxObject)); + if(!childBoxObject) + return NS_ERROR_UNEXPECTED; PRInt32 x,y,width,height; childBoxObject->GetX(&x);