зеркало из https://github.com/mozilla/gecko-dev.git
Bug 594140. Make window.open width/height parameters respect opener's CSS-pixel-to-device-pixel ratio. r=tnikkel,a=jst
This commit is contained in:
Родитель
a10bd5f22b
Коммит
dbf9d787ed
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ _TEST_FILES = \
|
|||
bug449141_page.html \
|
||||
test_bug499115.html \
|
||||
test_nsFind.html \
|
||||
test_window_open_units.html \
|
||||
$(NULL)
|
||||
|
||||
libs:: $(_TEST_FILES)
|
||||
|
|
Загрузка…
Ссылка в новой задаче