mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 720799 - Don't use mDocShell in nsScreen. r=jst
This commit is contained in:
parent
d7b22aa947
commit
62a283786d
@ -55,6 +55,23 @@ using namespace mozilla::dom;
|
||||
/* static */ bool nsScreen::sAllowScreenEnabledProperty = false;
|
||||
/* static */ bool nsScreen::sAllowScreenBrightnessProperty = false;
|
||||
|
||||
namespace {
|
||||
|
||||
bool
|
||||
IsChromeType(nsIDocShell *aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
|
||||
if (!ds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PRInt32 itemType;
|
||||
ds->GetItemType(&itemType);
|
||||
return itemType == nsIDocShellTreeItem::typeChrome;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
/* static */ void
|
||||
nsScreen::Initialize()
|
||||
{
|
||||
@ -93,7 +110,7 @@ nsScreen::Create(nsPIDOMWindow* aWindow)
|
||||
|
||||
screen->mOwner = aWindow;
|
||||
screen->mScriptContext.swap(scriptContext);
|
||||
screen->mDocShell = aWindow->GetDocShell();
|
||||
screen->mIsChrome = IsChromeType(aWindow->GetDocShell());
|
||||
|
||||
hal::RegisterScreenOrientationObserver(screen);
|
||||
hal::GetCurrentScreenOrientation(&(screen->mOrientation));
|
||||
@ -254,7 +271,7 @@ nsScreen::GetAvailTop(PRInt32* aAvailTop)
|
||||
nsDeviceContext*
|
||||
nsScreen::GetDeviceContext()
|
||||
{
|
||||
return nsLayoutUtils::GetDeviceContextForScreenInfo(mDocShell);
|
||||
return nsLayoutUtils::GetDeviceContextForScreenInfo(mOwner);
|
||||
}
|
||||
|
||||
nsresult
|
||||
@ -295,27 +312,10 @@ nsScreen::GetAvailRect(nsRect& aRect)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
bool
|
||||
IsChromeType(nsIDocShell *aDocShell)
|
||||
{
|
||||
nsCOMPtr<nsIDocShellTreeItem> ds = do_QueryInterface(aDocShell);
|
||||
if (!ds) {
|
||||
return false;
|
||||
}
|
||||
|
||||
PRInt32 itemType;
|
||||
ds->GetItemType(&itemType);
|
||||
return itemType == nsIDocShellTreeItem::typeChrome;
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
nsresult
|
||||
nsScreen::GetMozEnabled(bool *aEnabled)
|
||||
{
|
||||
if (!sAllowScreenEnabledProperty || !IsChromeType(mDocShell)) {
|
||||
if (!sAllowScreenEnabledProperty || mIsChrome) {
|
||||
*aEnabled = true;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -327,7 +327,7 @@ nsScreen::GetMozEnabled(bool *aEnabled)
|
||||
nsresult
|
||||
nsScreen::SetMozEnabled(bool aEnabled)
|
||||
{
|
||||
if (!sAllowScreenEnabledProperty || !IsChromeType(mDocShell)) {
|
||||
if (!sAllowScreenEnabledProperty || mIsChrome) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
@ -340,7 +340,7 @@ nsScreen::SetMozEnabled(bool aEnabled)
|
||||
nsresult
|
||||
nsScreen::GetMozBrightness(double *aBrightness)
|
||||
{
|
||||
if (!sAllowScreenBrightnessProperty || !IsChromeType(mDocShell)) {
|
||||
if (!sAllowScreenBrightnessProperty || mIsChrome) {
|
||||
*aBrightness = 1;
|
||||
return NS_OK;
|
||||
}
|
||||
@ -352,7 +352,7 @@ nsScreen::GetMozBrightness(double *aBrightness)
|
||||
nsresult
|
||||
nsScreen::SetMozBrightness(double aBrightness)
|
||||
{
|
||||
if (!sAllowScreenBrightnessProperty || !IsChromeType(mDocShell)) {
|
||||
if (!sAllowScreenBrightnessProperty || mIsChrome) {
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -74,7 +74,7 @@ protected:
|
||||
nsresult GetRect(nsRect& aRect);
|
||||
nsresult GetAvailRect(nsRect& aRect);
|
||||
|
||||
nsIDocShell* mDocShell; // Weak Reference
|
||||
bool mIsChrome;
|
||||
|
||||
mozilla::dom::ScreenOrientation mOrientation;
|
||||
|
||||
|
@ -4005,9 +4005,9 @@ nsLayoutUtils::GetRectDifferenceStrips(const nsRect& aR1, const nsRect& aR2,
|
||||
}
|
||||
|
||||
nsDeviceContext*
|
||||
nsLayoutUtils::GetDeviceContextForScreenInfo(nsIDocShell* aDocShell)
|
||||
nsLayoutUtils::GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow)
|
||||
{
|
||||
nsCOMPtr<nsIDocShell> docShell = aDocShell;
|
||||
nsCOMPtr<nsIDocShell> docShell = aWindow->GetDocShell();
|
||||
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
|
||||
|
@ -1330,11 +1330,11 @@ public:
|
||||
|
||||
/**
|
||||
* Get a device context that can be used to get up-to-date device
|
||||
* dimensions for the given docshell. For some reason, this is more
|
||||
* dimensions for the given window. For some reason, this is more
|
||||
* complicated than it ought to be in multi-monitor situations.
|
||||
*/
|
||||
static nsDeviceContext*
|
||||
GetDeviceContextForScreenInfo(nsIDocShell* aDocShell);
|
||||
GetDeviceContextForScreenInfo(nsPIDOMWindow* aWindow);
|
||||
|
||||
/**
|
||||
* Some frames with 'position: fixed' (nsStylePosition::mDisplay ==
|
||||
|
Loading…
Reference in New Issue
Block a user