Bug 970404 - don't let users affect document colors for chrome images, r=bz

This commit is contained in:
Gijs Kruitbosch 2014-03-06 23:02:59 -05:00
parent d666458d4d
commit 4bc134f524
2 changed files with 26 additions and 10 deletions

View File

@ -68,6 +68,8 @@
#include "nsBidiUtils.h"
#include "nsServiceManagerUtils.h"
#include "URL.h"
using namespace mozilla;
using namespace mozilla::dom;
using namespace mozilla::layers;
@ -696,16 +698,28 @@ nsPresContext::GetDocumentColorPreferences()
int32_t useAccessibilityTheme = 0;
bool usePrefColors = true;
nsCOMPtr<nsIDocShellTreeItem> docShell(mContainer);
if (docShell) {
if (nsIDocShellTreeItem::typeChrome == docShell->ItemType()) {
usePrefColors = false;
} else {
useAccessibilityTheme =
LookAndFeel::GetInt(LookAndFeel::eIntID_UseAccessibilityTheme, 0);
usePrefColors = !useAccessibilityTheme;
}
bool isChromeDocShell = false;
nsIDocument* doc = mDocument->GetDisplayDocument();
if (doc && doc->GetDocShell()) {
isChromeDocShell = nsIDocShellTreeItem::typeChrome ==
doc->GetDocShell()->ItemType();
} else {
nsCOMPtr<nsIDocShellTreeItem> docShell(mContainer);
if (docShell) {
isChromeDocShell = nsIDocShellTreeItem::typeChrome == docShell->ItemType();
}
}
mIsChromeOriginImage = mDocument->IsBeingUsedAsImage() &&
IsChromeURI(mDocument->GetDocumentURI());
if (isChromeDocShell || mIsChromeOriginImage) {
usePrefColors = false;
} else {
useAccessibilityTheme =
LookAndFeel::GetInt(LookAndFeel::eIntID_UseAccessibilityTheme, 0);
usePrefColors = !useAccessibilityTheme;
}
if (usePrefColors) {
usePrefColors =

View File

@ -828,6 +828,7 @@ public:
// Is this presentation in a chrome docshell?
bool IsChrome() const { return mIsChrome; }
bool IsChromeOriginImage() const { return mIsChromeOriginImage; }
void UpdateIsChrome();
// Public API for native theme code to get style internals.
@ -835,7 +836,7 @@ public:
// Is it OK to let the page specify colors and backgrounds?
bool UseDocumentColors() const {
return GetCachedBoolPref(kPresContext_UseDocumentColors) || IsChrome();
return GetCachedBoolPref(kPresContext_UseDocumentColors) || IsChrome() || IsChromeOriginImage();
}
// Explicitly enable and disable paint flashing.
@ -1318,6 +1319,7 @@ protected:
unsigned mFireAfterPaintEvents : 1;
unsigned mIsChrome : 1;
unsigned mIsChromeOriginImage : 1;
// Should we paint flash in this context? Do not use this variable directly.
// Use GetPaintFlashing() method instead.