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