From 45f17dde36202fc140a89588fd5579cf7a7c6524 Mon Sep 17 00:00:00 2001 From: "bryner%brianryner.com" Date: Sat, 8 Apr 2006 01:46:06 +0000 Subject: [PATCH] Back out patch for bug 332640 to fix regression bug 333051. r+sr-bzbarsky --- dom/src/base/nsScreen.cpp | 28 +++++++++++++--------------- 1 file changed, 13 insertions(+), 15 deletions(-) diff --git a/dom/src/base/nsScreen.cpp b/dom/src/base/nsScreen.cpp index 67008d937f9c..9f64555283be 100644 --- a/dom/src/base/nsScreen.cpp +++ b/dom/src/base/nsScreen.cpp @@ -42,10 +42,10 @@ #include "nsIScriptGlobalObject.h" #include "nsIDocShell.h" #include "nsIDeviceContext.h" +#include "nsPresContext.h" #include "nsCOMPtr.h" +#include "nsIDocumentViewer.h" #include "nsDOMClassInfo.h" -#include "nsIBaseWindow.h" -#include "nsIWidget.h" // @@ -201,23 +201,21 @@ nsScreen::GetDeviceContext() if(!mDocShell) return nsnull; - nsCOMPtr baseWindow = do_QueryInterface(mDocShell); - if (!baseWindow) + nsCOMPtr contentViewer; + mDocShell->GetContentViewer(getter_AddRefs(contentViewer)); + + nsCOMPtr docViewer(do_QueryInterface(contentViewer)); + if(!docViewer) return nsnull; - nsCOMPtr widget; - baseWindow->GetMainWidget(getter_AddRefs(widget)); - if (!widget) - return nsnull; + nsCOMPtr presContext; + docViewer->GetPresContext(getter_AddRefs(presContext)); - // nsIWidget::GetDeviceContext addrefs, this method doesn't. - // Release before returning the pointer. - nsIDeviceContext *dc = widget->GetDeviceContext(); - if (!dc) - return nsnull; + nsIDeviceContext* context = nsnull; + if(presContext) + context = presContext->DeviceContext(); - dc->Release(); - return dc; + return context; } nsresult