Commit 7cddfd74 authored by Timothy Nikkel's avatar Timothy Nikkel
Browse files

Bug 445765. In getting the device context from a docshell don't go through...

Bug 445765. In getting the device context from a docshell don't go through nsIBaseWindow::GetMainWidget because that always returns the device context for the primary screen when called on toplevel docshell.  r=dbaron
parent daa82e9d
Loading
Loading
Loading
Loading
+8 −7
Original line number Diff line number Diff line
@@ -88,6 +88,7 @@
#include "imgIRequest.h"
#include "imgIContainer.h"
#include "nsIImageLoadingContent.h"
#include "nsCOMPtr.h"

#ifdef MOZ_SVG
#include "nsSVGUtils.h"
@@ -3151,13 +3152,13 @@ nsLayoutUtils::GetDeviceContextForScreenInfo(nsIDocShell* aDocShell)

    win->EnsureSizeUpToDate();

    nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(docShell);
    NS_ENSURE_TRUE(baseWindow, nsnull);

    nsCOMPtr<nsIWidget> mainWidget;
    baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
    if (mainWidget) {
      return mainWidget->GetDeviceContext();
    nsRefPtr<nsPresContext> presContext;
    docShell->GetPresContext(getter_AddRefs(presContext));
    if (presContext) {
      nsIDeviceContext* context = presContext->DeviceContext();
      if (context) {
        return context;
      }
    }

    nsCOMPtr<nsIDocShellTreeItem> curItem = do_QueryInterface(docShell);