зеркало из https://github.com/mozilla/pjs.git
Search docshell ancestors for a device context if it can't be found on the current one. b=377539 r+sr=bzbarsky
This commit is contained in:
Родитель
bff6f902af
Коммит
bfbaf21d7a
|
@ -39,12 +39,13 @@
|
||||||
#include "nscore.h"
|
#include "nscore.h"
|
||||||
#include "nsScreen.h"
|
#include "nsScreen.h"
|
||||||
#include "nsPIDOMWindow.h"
|
#include "nsPIDOMWindow.h"
|
||||||
#include "nsIScriptGlobalObject.h"
|
#include "nsIBaseWindow.h"
|
||||||
#include "nsIDocShell.h"
|
#include "nsIDocShell.h"
|
||||||
|
#include "nsIDocShellTreeItem.h"
|
||||||
#include "nsIDeviceContext.h"
|
#include "nsIDeviceContext.h"
|
||||||
|
#include "nsIWidget.h"
|
||||||
#include "nsPresContext.h"
|
#include "nsPresContext.h"
|
||||||
#include "nsCOMPtr.h"
|
#include "nsCOMPtr.h"
|
||||||
#include "nsIDocumentViewer.h"
|
|
||||||
#include "nsDOMClassInfo.h"
|
#include "nsDOMClassInfo.h"
|
||||||
#include "nsIInterfaceRequestorUtils.h"
|
#include "nsIInterfaceRequestorUtils.h"
|
||||||
|
|
||||||
|
@ -198,36 +199,36 @@ nsScreen::GetAvailTop(PRInt32* aAvailTop)
|
||||||
nsIDeviceContext*
|
nsIDeviceContext*
|
||||||
nsScreen::GetDeviceContext()
|
nsScreen::GetDeviceContext()
|
||||||
{
|
{
|
||||||
if(!mDocShell)
|
nsCOMPtr<nsIDocShell> docShell = mDocShell;
|
||||||
return nsnull;
|
while (docShell) {
|
||||||
|
// Now make sure our size is up to date. That will mean that the device
|
||||||
|
// context does the right thing on multi-monitor systems when we return it to
|
||||||
|
// the caller. It will also make sure that our prescontext has been created,
|
||||||
|
// if we're supposed to have one.
|
||||||
|
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(docShell);
|
||||||
|
if (!win) {
|
||||||
|
// No reason to go on
|
||||||
|
return nsnull;
|
||||||
|
}
|
||||||
|
|
||||||
// Now make sure our size is up to date. That will mean that the device
|
win->EnsureSizeUpToDate();
|
||||||
// context does the right thing on multi-monitor systems when we return it to
|
|
||||||
// the caller. It will also make sure that our prescontext has been created,
|
nsCOMPtr<nsIBaseWindow> baseWindow = do_QueryInterface(docShell);
|
||||||
// if we're supposed to have one.
|
NS_ENSURE_TRUE(baseWindow, nsnull);
|
||||||
nsCOMPtr<nsPIDOMWindow> win = do_GetInterface(mDocShell);
|
|
||||||
if (!win) {
|
nsCOMPtr<nsIWidget> mainWidget;
|
||||||
// No reason to go on
|
baseWindow->GetMainWidget(getter_AddRefs(mainWidget));
|
||||||
return nsnull;
|
if (mainWidget) {
|
||||||
|
return mainWidget->GetDeviceContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> curItem = do_QueryInterface(docShell);
|
||||||
|
nsCOMPtr<nsIDocShellTreeItem> parentItem;
|
||||||
|
curItem->GetParent(getter_AddRefs(parentItem));
|
||||||
|
docShell = do_QueryInterface(parentItem);
|
||||||
}
|
}
|
||||||
|
|
||||||
win->EnsureSizeUpToDate();
|
return nsnull;
|
||||||
|
|
||||||
nsCOMPtr<nsIContentViewer> contentViewer;
|
|
||||||
mDocShell->GetContentViewer(getter_AddRefs(contentViewer));
|
|
||||||
|
|
||||||
nsCOMPtr<nsIDocumentViewer> docViewer(do_QueryInterface(contentViewer));
|
|
||||||
if(!docViewer)
|
|
||||||
return nsnull;
|
|
||||||
|
|
||||||
nsCOMPtr<nsPresContext> presContext;
|
|
||||||
docViewer->GetPresContext(getter_AddRefs(presContext));
|
|
||||||
|
|
||||||
nsIDeviceContext* context = nsnull;
|
|
||||||
if(presContext)
|
|
||||||
context = presContext->DeviceContext();
|
|
||||||
|
|
||||||
return context;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
nsresult
|
nsresult
|
||||||
|
|
Загрузка…
Ссылка в новой задаче