Commit dbf9d787 authored by Robert O'Callahan's avatar Robert O'Callahan
Browse files

Bug 594140. Make window.open width/height parameters respect opener's...

Bug 594140. Make window.open width/height parameters respect opener's CSS-pixel-to-device-pixel ratio. r=tnikkel,a=jst
parent a10bd5f2
Loading
Loading
Loading
Loading
+13 −17
Original line number Diff line number Diff line
@@ -91,6 +91,8 @@
#include "nsPIDOMStorage.h"
#include "nsIWidget.h"
#include "nsFocusManager.h"
#include "nsIPresShell.h"
#include "nsPresContext.h"

#include "nsIPrefBranch.h"
#include "nsIPrefService.h"
@@ -1903,23 +1905,17 @@ nsWindowWatcher::SizeOpenedDocShellItem(nsIDocShellTreeItem *aDocShellItem,
    return;
    
  float devPixelsPerCSSPixel = 1.0;
  nsCOMPtr<nsIWidget> mainWidget;
  treeOwnerAsWin->GetMainWidget(getter_AddRefs(mainWidget));
  if (!mainWidget) {
    // Some embedding clients don't support nsIDocShellTreeOwner's
    // GetMainWidget, so try going through nsIBaseWindow's GetParentWidget
    nsCOMPtr<nsIBaseWindow> shellWindow(do_QueryInterface(aDocShellItem));
    if (shellWindow)
      shellWindow->GetParentWidget(getter_AddRefs(mainWidget));
  }
  if (mainWidget) {
    nsCOMPtr<nsIDeviceContext> ctx = mainWidget->GetDeviceContext();
    /* we might be called by an extension after mainWidget::OnDestroy() */
    if (ctx) {
      PRInt32 unitsPerDevPixel = ctx->AppUnitsPerDevPixel();
      if (unitsPerDevPixel) {
        devPixelsPerCSSPixel = float(ctx->AppUnitsPerCSSPixel()) /
                                     unitsPerDevPixel;
  if (aParent) {
    nsCOMPtr<nsIDOMDocument> openerDoc;
    aParent->GetDocument(getter_AddRefs(openerDoc));
    if (openerDoc) {
      nsCOMPtr<nsIDocument> doc = do_QueryInterface(openerDoc);
      nsIPresShell* shell = doc->GetShell();
      if (shell) {
        nsPresContext* presContext = shell->GetPresContext();
        if (presContext) {
          devPixelsPerCSSPixel = presContext->CSSPixelsToDevPixels(1.0f);
        }
      }
    }
  }
+1 −0
Original line number Diff line number Diff line
@@ -51,6 +51,7 @@ _TEST_FILES = \
	bug449141_page.html \
	test_bug499115.html \
	test_nsFind.html \
	test_window_open_units.html \
	$(NULL)

libs:: $(_TEST_FILES)