Fix crash in nsScrollBoxObject::::EnsureElementIsVisible. Bug 257607, patch by

Justin <justin@openaether.org>, r+sr=bzbarsky.
This commit is contained in:
bzbarsky%mit.edu 2004-09-12 04:15:44 +00:00
Родитель 143d798b09
Коммит 26e0feee63
1 изменённых файлов: 23 добавлений и 7 удалений

Просмотреть файл

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