mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 22:01:30 +00:00
Continuing nsIPresContext deCOMtamination (bug 229371). Remove GetImageLoadFlags (unused). Make failure to fetch the LookAndFeel service cause Init() to fail, don't null check it after that, and inlined the getter. Move IOService caching to nsImageFrame, the only user of it. r+sr=bzbarsky.
This commit is contained in:
parent
7f195a8994
commit
ef5c330583
@ -812,7 +812,11 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mPresContext->Init(aDeviceContext);
|
||||
rv = mPresContext->Init(aDeviceContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
mPresContext = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
|
||||
makeCX = !GetIsPrintPreview(); // needs to be true except when we are already in PP
|
||||
@ -1393,7 +1397,11 @@ DocumentViewerImpl::Show(void)
|
||||
mPresContext = do_CreateInstance(kGalleyContextCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPresContext->Init(mDeviceContext);
|
||||
rv = mPresContext->Init(mDeviceContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
mPresContext = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsRect tbounds;
|
||||
mParentWidget->GetBounds(tbounds);
|
||||
|
@ -2603,7 +2603,11 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
|
||||
|
||||
|
||||
// init it with the DC
|
||||
(aPO->mPresContext)->Init(mPrt->mPrintDocDC);
|
||||
rv = aPO->mPresContext->Init(mPrt->mPrintDocDC);
|
||||
if (NS_FAILED(rv)) {
|
||||
aPO->mPresContext = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mDocViewerPrint->CreateStyleSet(aPO->mDocument, &aPO->mStyleSet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -330,13 +330,10 @@ static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor,
|
||||
else if (eCSSUnit_Integer == unit) {
|
||||
PRInt32 intValue = aValue.GetIntValue();
|
||||
if (0 <= intValue) {
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
||||
nsILookAndFeel::nsColorID colorID = (nsILookAndFeel::nsColorID) intValue;
|
||||
if (NS_SUCCEEDED(look->GetColor(colorID, aResult))) {
|
||||
result = PR_TRUE;
|
||||
}
|
||||
NS_RELEASE(look);
|
||||
nsILookAndFeel* look = aPresContext->LookAndFeel();
|
||||
nsILookAndFeel::nsColorID colorID = (nsILookAndFeel::nsColorID) intValue;
|
||||
if (NS_SUCCEEDED(look->GetColor(colorID, aResult))) {
|
||||
result = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -1366,8 +1366,7 @@ nsEventStateManager::GenerateDragGesture(nsIPresContext* aPresContext,
|
||||
static PRInt32 pixelThresholdY = 0;
|
||||
|
||||
if (!pixelThresholdX) {
|
||||
nsCOMPtr<nsILookAndFeel> lf;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lf));
|
||||
nsILookAndFeel *lf = aPresContext->LookAndFeel();
|
||||
lf->GetMetric(nsILookAndFeel::eMetric_DragThresholdX, pixelThresholdX);
|
||||
lf->GetMetric(nsILookAndFeel::eMetric_DragThresholdY, pixelThresholdY);
|
||||
if (!pixelThresholdX)
|
||||
|
@ -66,9 +66,12 @@
|
||||
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h"
|
||||
|
||||
class nsHTMLEditUtils;
|
||||
|
||||
static NS_DEFINE_CID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
// ==================================================================
|
||||
// DocumentResizeEventListener
|
||||
// ==================================================================
|
||||
@ -911,19 +914,12 @@ nsHTMLEditor::MouseMove(nsIDOMEvent* aMouseEvent)
|
||||
mouseEvent->GetClientX(&clientX);
|
||||
mouseEvent->GetClientY(&clientY);
|
||||
|
||||
nsCOMPtr<nsIPresShell> ps = do_QueryReferent(mPresShellWeak);
|
||||
if (!ps) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsIPresContext> pcontext;
|
||||
ps->GetPresContext(getter_AddRefs(pcontext));
|
||||
if (!pcontext) return NS_ERROR_NOT_INITIALIZED;
|
||||
nsCOMPtr<nsILookAndFeel> look;
|
||||
nsresult res = pcontext->GetLookAndFeel(getter_AddRefs(look));
|
||||
nsCOMPtr<nsILookAndFeel> look = do_GetService(kLookAndFeelCID);
|
||||
NS_ASSERTION(look, "Look and feel service must be implemented for this toolkit");
|
||||
|
||||
PRInt32 xThreshold=1, yThreshold=1;
|
||||
if (NS_SUCCEEDED(res) && look) {
|
||||
look->GetMetric(nsILookAndFeel::eMetric_DragThresholdX, xThreshold);
|
||||
look->GetMetric(nsILookAndFeel::eMetric_DragThresholdY, yThreshold);
|
||||
}
|
||||
look->GetMetric(nsILookAndFeel::eMetric_DragThresholdX, xThreshold);
|
||||
look->GetMetric(nsILookAndFeel::eMetric_DragThresholdY, yThreshold);
|
||||
|
||||
if (PR_ABS(clientX - mOriginalX ) * 2 >= xThreshold ||
|
||||
PR_ABS(clientY - mOriginalY ) * 2 >= yThreshold) {
|
||||
|
@ -219,10 +219,7 @@ nsNativeTheme::IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame* aFrame,
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if (!lookAndFeel)
|
||||
return PR_TRUE;
|
||||
nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
|
||||
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_BUTTON:
|
||||
|
@ -1067,10 +1067,7 @@ PRBool nsNativeThemeWin::IsWidgetStyled(nsIPresContext* aPresContext, nsIFrame*
|
||||
float p2t;
|
||||
aPresContext->GetPixelsToTwips(&p2t);
|
||||
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if (!lookAndFeel)
|
||||
return PR_TRUE;
|
||||
nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
|
||||
|
||||
switch (aWidgetType) {
|
||||
case NS_THEME_BUTTON: {
|
||||
|
@ -60,7 +60,6 @@
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h" // for NS_LOOKANDFEEL_CID
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
@ -115,12 +114,12 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell)
|
||||
NS_ASSERTION(mPresShell, "Hey, pres shell should support weak refs");
|
||||
|
||||
// get nsILookAndFeel from the pres context, which has one cached.
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
nsILookAndFeel *lookAndFeel = nsnull;
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
inPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext)
|
||||
presContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
lookAndFeel = presContext->LookAndFeel();
|
||||
if (lookAndFeel)
|
||||
{
|
||||
PRInt32 tempInt;
|
||||
|
@ -812,7 +812,11 @@ DocumentViewerImpl::InitInternal(nsIWidget* aParentWidget,
|
||||
if (NS_FAILED(rv))
|
||||
return rv;
|
||||
|
||||
mPresContext->Init(aDeviceContext);
|
||||
rv = mPresContext->Init(aDeviceContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
mPresContext = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
#if defined(NS_PRINTING) && defined(NS_PRINT_PREVIEW)
|
||||
makeCX = !GetIsPrintPreview(); // needs to be true except when we are already in PP
|
||||
@ -1393,7 +1397,11 @@ DocumentViewerImpl::Show(void)
|
||||
mPresContext = do_CreateInstance(kGalleyContextCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
mPresContext->Init(mDeviceContext);
|
||||
rv = mPresContext->Init(mDeviceContext);
|
||||
if (NS_FAILED(rv)) {
|
||||
mPresContext = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
nsRect tbounds;
|
||||
mParentWidget->GetBounds(tbounds);
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsCSSRendering.h"
|
||||
@ -171,12 +170,6 @@ nsPresContext::nsPresContext()
|
||||
|
||||
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
||||
mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(GetLookAndFeel(&look)) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowBackground, mDefaultBackgroundColor);
|
||||
NS_RELEASE(look);
|
||||
}
|
||||
|
||||
mUseDocumentColors = PR_TRUE;
|
||||
mUseDocumentFonts = PR_TRUE;
|
||||
@ -238,6 +231,7 @@ nsPresContext::~nsPresContext()
|
||||
#endif // IBMBIDI
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
@ -435,15 +429,12 @@ nsPresContext::GetDocumentColorPreferences()
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Without this here, checking the "use system colors" checkbox
|
||||
// has no affect until the constructor is called again
|
||||
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
||||
mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
||||
nsCOMPtr<nsILookAndFeel> look;
|
||||
if (NS_SUCCEEDED(GetLookAndFeel(getter_AddRefs(look))) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowBackground, mDefaultBackgroundColor);
|
||||
}
|
||||
mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowForeground,
|
||||
mDefaultColor);
|
||||
mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground,
|
||||
mDefaultBackgroundColor);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_document_colors", &boolPref))) {
|
||||
@ -632,6 +623,14 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
||||
mDeviceContext = aDeviceContext;
|
||||
NS_IF_ADDREF(mDeviceContext);
|
||||
|
||||
// Get the look and feel service here; default colors will be initialized
|
||||
// from calling GetUserPreferences() below.
|
||||
nsresult rv = CallGetService(kLookAndFeelCID, &mLookAndFeel);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("LookAndFeel service must be implemented for this toolkit");
|
||||
return rv;
|
||||
}
|
||||
|
||||
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
mPrefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (mPrefs) {
|
||||
@ -840,43 +839,6 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode)
|
||||
mImageAnimationMode = aMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* It is no longer necesary to hold on to presContext just to get a
|
||||
* nsILookAndFeel, which can now be obtained through the service
|
||||
* manager. However, this cached copy can be used when a pres context
|
||||
* is available, for faster performance.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetLookAndFeel(nsILookAndFeel** aLookAndFeel)
|
||||
{
|
||||
NS_PRECONDITION(aLookAndFeel, "null out param");
|
||||
if (! mLookAndFeel) {
|
||||
nsresult rv;
|
||||
mLookAndFeel = do_GetService(kLookAndFeelCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
*aLookAndFeel = mLookAndFeel;
|
||||
NS_ADDREF(*aLookAndFeel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the cached IO service, faster than the service manager could.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetIOService(nsIIOService** aIOService)
|
||||
{
|
||||
NS_PRECONDITION(aIOService, "null out param");
|
||||
if (! mIOService) {
|
||||
nsresult rv;
|
||||
mIOService = do_GetIOService(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
*aIOService = mIOService;
|
||||
NS_ADDREF(*aIOService);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBaseURL(nsIURI** aResult)
|
||||
{
|
||||
@ -1296,25 +1258,6 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags)
|
||||
{
|
||||
aLoadFlags = nsIRequest::LOAD_NORMAL;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
(void) mShell->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
if (doc) {
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
|
||||
|
||||
if (loadGroup) {
|
||||
loadGroup->GetLoadFlags(&aLoadFlags);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::LoadImage(nsIURI* aURL,
|
||||
nsIFrame* aTargetFrame,//may be null (precached image)
|
||||
|
@ -70,7 +70,6 @@ class nsString;
|
||||
class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
class nsIIOService;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsILanguageAtom;
|
||||
class nsITheme;
|
||||
@ -161,19 +160,10 @@ public:
|
||||
virtual void SetImageAnimationMode(PRUint16 aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get an special load flags for images for this context
|
||||
* Get cached look and feel service. This is faster than obtaining it
|
||||
* through the service manager.
|
||||
*/
|
||||
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags) = 0;
|
||||
|
||||
/**
|
||||
* Get cached look and feel service.
|
||||
*/
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel) = 0;
|
||||
|
||||
/**
|
||||
* Get cached IO service.
|
||||
*/
|
||||
NS_IMETHOD GetIOService(nsIIOService** aIOService) = 0;
|
||||
nsILookAndFeel* LookAndFeel() { return mLookAndFeel; }
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
@ -577,6 +567,7 @@ protected:
|
||||
// since there is no dependency
|
||||
// from gfx back to layout.
|
||||
nsIEventStateManager* mEventManager; // [STRONG]
|
||||
nsILookAndFeel* mLookAndFeel; // [STRONG]
|
||||
|
||||
nsCompatibility mCompatibilityMode;
|
||||
PRUint16 mImageAnimationMode;
|
||||
|
@ -7064,7 +7064,8 @@ PresShell::VerifyIncrementalReflow()
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
mPresContext->GetDeviceContext(getter_AddRefs(dc));
|
||||
cx->Init(dc);
|
||||
rv = cx->Init(dc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get our scrolling preference
|
||||
nsScrollPreference scrolling;
|
||||
|
@ -70,7 +70,6 @@ class nsString;
|
||||
class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
class nsIIOService;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsILanguageAtom;
|
||||
class nsITheme;
|
||||
@ -161,19 +160,10 @@ public:
|
||||
virtual void SetImageAnimationMode(PRUint16 aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get an special load flags for images for this context
|
||||
* Get cached look and feel service. This is faster than obtaining it
|
||||
* through the service manager.
|
||||
*/
|
||||
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags) = 0;
|
||||
|
||||
/**
|
||||
* Get cached look and feel service.
|
||||
*/
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel) = 0;
|
||||
|
||||
/**
|
||||
* Get cached IO service.
|
||||
*/
|
||||
NS_IMETHOD GetIOService(nsIIOService** aIOService) = 0;
|
||||
nsILookAndFeel* LookAndFeel() { return mLookAndFeel; }
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
@ -577,6 +567,7 @@ protected:
|
||||
// since there is no dependency
|
||||
// from gfx back to layout.
|
||||
nsIEventStateManager* mEventManager; // [STRONG]
|
||||
nsILookAndFeel* mLookAndFeel; // [STRONG]
|
||||
|
||||
nsCompatibility mCompatibilityMode;
|
||||
PRUint16 mImageAnimationMode;
|
||||
|
@ -70,7 +70,6 @@ class nsString;
|
||||
class nsIEventStateManager;
|
||||
class nsIURI;
|
||||
class nsILookAndFeel;
|
||||
class nsIIOService;
|
||||
class nsICSSPseudoComparator;
|
||||
class nsILanguageAtom;
|
||||
class nsITheme;
|
||||
@ -161,19 +160,10 @@ public:
|
||||
virtual void SetImageAnimationMode(PRUint16 aMode) = 0;
|
||||
|
||||
/**
|
||||
* Get an special load flags for images for this context
|
||||
* Get cached look and feel service. This is faster than obtaining it
|
||||
* through the service manager.
|
||||
*/
|
||||
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags) = 0;
|
||||
|
||||
/**
|
||||
* Get cached look and feel service.
|
||||
*/
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel) = 0;
|
||||
|
||||
/**
|
||||
* Get cached IO service.
|
||||
*/
|
||||
NS_IMETHOD GetIOService(nsIIOService** aIOService) = 0;
|
||||
nsILookAndFeel* LookAndFeel() { return mLookAndFeel; }
|
||||
|
||||
/**
|
||||
* Get base url for presentation
|
||||
@ -577,6 +567,7 @@ protected:
|
||||
// since there is no dependency
|
||||
// from gfx back to layout.
|
||||
nsIEventStateManager* mEventManager; // [STRONG]
|
||||
nsILookAndFeel* mLookAndFeel; // [STRONG]
|
||||
|
||||
nsCompatibility mCompatibilityMode;
|
||||
PRUint16 mImageAnimationMode;
|
||||
|
@ -60,7 +60,6 @@
|
||||
#include "nsIViewManager.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsWidgetsCID.h" // for NS_LOOKANDFEEL_CID
|
||||
#include "nsBlockFrame.h"
|
||||
#include "nsISelectionController.h"
|
||||
|
||||
@ -115,12 +114,12 @@ NS_IMETHODIMP nsCaret::Init(nsIPresShell *inPresShell)
|
||||
NS_ASSERTION(mPresShell, "Hey, pres shell should support weak refs");
|
||||
|
||||
// get nsILookAndFeel from the pres context, which has one cached.
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
nsILookAndFeel *lookAndFeel = nsnull;
|
||||
|
||||
nsCOMPtr<nsIPresContext> presContext;
|
||||
inPresShell->GetPresContext(getter_AddRefs(presContext));
|
||||
if (presContext)
|
||||
presContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
lookAndFeel = presContext->LookAndFeel();
|
||||
if (lookAndFeel)
|
||||
{
|
||||
PRInt32 tempInt;
|
||||
|
@ -61,7 +61,6 @@
|
||||
#include "nsContentPolicyUtils.h"
|
||||
#include "nsIScriptGlobalObject.h"
|
||||
#include "nsIDOMWindow.h"
|
||||
#include "nsNetUtil.h"
|
||||
#include "nsXPIDLString.h"
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsCSSRendering.h"
|
||||
@ -171,12 +170,6 @@ nsPresContext::nsPresContext()
|
||||
|
||||
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
||||
mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(GetLookAndFeel(&look)) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowBackground, mDefaultBackgroundColor);
|
||||
NS_RELEASE(look);
|
||||
}
|
||||
|
||||
mUseDocumentColors = PR_TRUE;
|
||||
mUseDocumentFonts = PR_TRUE;
|
||||
@ -238,6 +231,7 @@ nsPresContext::~nsPresContext()
|
||||
#endif // IBMBIDI
|
||||
|
||||
NS_IF_RELEASE(mDeviceContext);
|
||||
NS_IF_RELEASE(mLookAndFeel);
|
||||
}
|
||||
|
||||
NS_IMPL_ISUPPORTS2(nsPresContext, nsIPresContext, nsIObserver)
|
||||
@ -435,15 +429,12 @@ nsPresContext::GetDocumentColorPreferences()
|
||||
}
|
||||
}
|
||||
else {
|
||||
// Without this here, checking the "use system colors" checkbox
|
||||
// has no affect until the constructor is called again
|
||||
mDefaultColor = NS_RGB(0x00, 0x00, 0x00);
|
||||
mDefaultBackgroundColor = NS_RGB(0xFF, 0xFF, 0xFF);
|
||||
nsCOMPtr<nsILookAndFeel> look;
|
||||
if (NS_SUCCEEDED(GetLookAndFeel(getter_AddRefs(look))) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowForeground, mDefaultColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_WindowBackground, mDefaultBackgroundColor);
|
||||
}
|
||||
mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowForeground,
|
||||
mDefaultColor);
|
||||
mLookAndFeel->GetColor(nsILookAndFeel::eColor_WindowBackground,
|
||||
mDefaultBackgroundColor);
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(mPrefs->GetBoolPref("browser.display.use_document_colors", &boolPref))) {
|
||||
@ -632,6 +623,14 @@ nsPresContext::Init(nsIDeviceContext* aDeviceContext)
|
||||
mDeviceContext = aDeviceContext;
|
||||
NS_IF_ADDREF(mDeviceContext);
|
||||
|
||||
// Get the look and feel service here; default colors will be initialized
|
||||
// from calling GetUserPreferences() below.
|
||||
nsresult rv = CallGetService(kLookAndFeelCID, &mLookAndFeel);
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_ERROR("LookAndFeel service must be implemented for this toolkit");
|
||||
return rv;
|
||||
}
|
||||
|
||||
mLangService = do_GetService(NS_LANGUAGEATOMSERVICE_CONTRACTID);
|
||||
mPrefs = do_GetService(NS_PREF_CONTRACTID);
|
||||
if (mPrefs) {
|
||||
@ -840,43 +839,6 @@ nsPresContext::SetImageAnimationMode(PRUint16 aMode)
|
||||
mImageAnimationMode = aMode;
|
||||
}
|
||||
|
||||
/*
|
||||
* It is no longer necesary to hold on to presContext just to get a
|
||||
* nsILookAndFeel, which can now be obtained through the service
|
||||
* manager. However, this cached copy can be used when a pres context
|
||||
* is available, for faster performance.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetLookAndFeel(nsILookAndFeel** aLookAndFeel)
|
||||
{
|
||||
NS_PRECONDITION(aLookAndFeel, "null out param");
|
||||
if (! mLookAndFeel) {
|
||||
nsresult rv;
|
||||
mLookAndFeel = do_GetService(kLookAndFeelCID, &rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
*aLookAndFeel = mLookAndFeel;
|
||||
NS_ADDREF(*aLookAndFeel);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
/*
|
||||
* Get the cached IO service, faster than the service manager could.
|
||||
*/
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetIOService(nsIIOService** aIOService)
|
||||
{
|
||||
NS_PRECONDITION(aIOService, "null out param");
|
||||
if (! mIOService) {
|
||||
nsresult rv;
|
||||
mIOService = do_GetIOService(&rv);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
*aIOService = mIOService;
|
||||
NS_ADDREF(*aIOService);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetBaseURL(nsIURI** aResult)
|
||||
{
|
||||
@ -1296,25 +1258,6 @@ nsPresContext::GetDeviceContext(nsIDeviceContext** aResult) const
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags)
|
||||
{
|
||||
aLoadFlags = nsIRequest::LOAD_NORMAL;
|
||||
|
||||
nsCOMPtr<nsIDocument> doc;
|
||||
(void) mShell->GetDocument(getter_AddRefs(doc));
|
||||
|
||||
if (doc) {
|
||||
nsCOMPtr<nsILoadGroup> loadGroup = doc->GetDocumentLoadGroup();
|
||||
|
||||
if (loadGroup) {
|
||||
loadGroup->GetLoadFlags(&aLoadFlags);
|
||||
}
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPresContext::LoadImage(nsIURI* aURL,
|
||||
nsIFrame* aTargetFrame,//may be null (precached image)
|
||||
|
@ -49,8 +49,6 @@
|
||||
#include "nsIURL.h"
|
||||
#include "nsIEventStateManager.h"
|
||||
#include "nsIObserver.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsIIOService.h"
|
||||
#ifdef IBMBIDI
|
||||
#include "nsBidiUtils.h"
|
||||
#endif
|
||||
@ -73,9 +71,6 @@ public:
|
||||
NS_IMETHOD SetShell(nsIPresShell* aShell);
|
||||
virtual void SetCompatibilityMode(nsCompatibility aMode);
|
||||
virtual void SetImageAnimationMode(PRUint16 aMode);
|
||||
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags);
|
||||
NS_IMETHOD GetLookAndFeel(nsILookAndFeel** aLookAndFeel);
|
||||
NS_IMETHOD GetIOService(nsIIOService** aIOService);
|
||||
NS_IMETHOD GetBaseURL(nsIURI** aURLResult);
|
||||
NS_IMETHOD GetMedium(nsIAtom** aMediumResult) = 0;
|
||||
NS_IMETHOD ClearStyleDataAndReflow(void);
|
||||
@ -217,8 +212,6 @@ protected:
|
||||
nsLanguageSpecificTransformType mLanguageSpecificTransformType;
|
||||
nsILinkHandler* mLinkHandler; // [WEAK]
|
||||
nsWeakPtr mContainer;
|
||||
nsCOMPtr<nsILookAndFeel> mLookAndFeel;
|
||||
nsCOMPtr<nsIIOService> mIOService;
|
||||
|
||||
nsFont mDefaultVariableFont;
|
||||
nsFont mDefaultFixedFont;
|
||||
|
@ -59,7 +59,6 @@ public:
|
||||
PrintContext();
|
||||
~PrintContext();
|
||||
|
||||
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags);
|
||||
NS_IMETHOD GetMedium(nsIAtom** aMedium);
|
||||
NS_IMETHOD IsPaginated(PRBool* aResult);
|
||||
NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { return NS_ERROR_FAILURE; }
|
||||
@ -108,13 +107,6 @@ PrintContext::QueryInterface(REFNSIID aIID, void** aInstancePtr)
|
||||
return nsPresContext::QueryInterface(aIID, aInstancePtr);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PrintContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags)
|
||||
{
|
||||
aLoadFlags = nsIRequest::LOAD_FROM_CACHE | nsIRequest::VALIDATE_NEVER | nsIRequest::LOAD_NORMAL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PrintContext::GetMedium(nsIAtom** aResult)
|
||||
{
|
||||
|
@ -56,7 +56,6 @@ public:
|
||||
// another class. Only the base class should use NS_DECL_ISUPPORTS
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
|
||||
NS_IMETHOD GetImageLoadFlags(nsLoadFlags& aLoadFlags);
|
||||
NS_IMETHOD GetMedium(nsIAtom** aMedium);
|
||||
NS_IMETHOD IsPaginated(PRBool* aResult);
|
||||
NS_IMETHOD SetPaginatedScrolling(PRBool aResult) { mCanPaginatedScroll = aResult; return NS_OK; }
|
||||
@ -118,13 +117,6 @@ PrintPreviewContext::GetMedium(nsIAtom** aResult)
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PrintPreviewContext::GetImageLoadFlags(nsLoadFlags& aLoadFlags)
|
||||
{
|
||||
aLoadFlags = nsIRequest::LOAD_FROM_CACHE | nsIRequest::VALIDATE_NEVER | nsIRequest::LOAD_NORMAL;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
PrintPreviewContext::IsPaginated(PRBool* aResult)
|
||||
{
|
||||
|
@ -131,6 +131,7 @@
|
||||
#include "nsLayoutCID.h"
|
||||
#include "nsImageLoadingContent.h"
|
||||
#include "nsStyleSet.h"
|
||||
#include "nsImageFrame.h"
|
||||
|
||||
// view stuff
|
||||
#include "nsViewsCID.h"
|
||||
@ -348,6 +349,7 @@ Shutdown(nsIModule* aSelf)
|
||||
nsTextTransformer::Shutdown();
|
||||
nsSpaceManager::Shutdown();
|
||||
nsTextControlFrame::ReleaseGlobals();
|
||||
nsImageFrame::ReleaseGlobals();
|
||||
|
||||
NS_IF_RELEASE(nsContentDLF::gUAStyleSheet);
|
||||
NS_IF_RELEASE(nsRuleNode::gLangService);
|
||||
|
@ -871,10 +871,9 @@ nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeig
|
||||
nsRect screen;
|
||||
|
||||
PRBool dropdownCanOverlapOSBar = PR_FALSE;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if ( lookAndFeel )
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, dropdownCanOverlapOSBar);
|
||||
nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar,
|
||||
dropdownCanOverlapOSBar);
|
||||
if ( dropdownCanOverlapOSBar )
|
||||
context->GetRect ( screen );
|
||||
else
|
||||
|
@ -84,7 +84,6 @@
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsReflowPath.h"
|
||||
#include "nsITheme.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
@ -689,14 +688,10 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer
|
||||
|
||||
// set up back stop colors and then ask L&F service for the real colors
|
||||
nscolor color;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
mPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if (lookAndFeel){
|
||||
lookAndFeel->GetColor(lastItemIsSelected?nsILookAndFeel::eColor_WidgetSelectForeground:nsILookAndFeel::eColor_WidgetSelectBackground, color);
|
||||
} else {
|
||||
// Use some backstop colors if for some reason we don't have a L&F object
|
||||
color = lastItemIsSelected? NS_RGB(245,219,149) : NS_RGB(0,0,0);
|
||||
}
|
||||
mPresContext->LookAndFeel()->
|
||||
GetColor(lastItemIsSelected ?
|
||||
nsILookAndFeel::eColor_WidgetSelectForeground :
|
||||
nsILookAndFeel::eColor_WidgetSelectBackground, color);
|
||||
|
||||
float p2t;
|
||||
mPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
|
@ -123,6 +123,9 @@
|
||||
// - created if null, deleted if refcount goes to 0
|
||||
nsImageFrame::IconLoad* nsImageFrame::mIconLoad = nsnull;
|
||||
|
||||
// cached IO service for loading icons
|
||||
nsIIOService* nsImageFrame::sIOService;
|
||||
|
||||
// test if the width and height are fixed, looking at the style data
|
||||
static PRBool HaveFixedSize(const nsStylePosition* aStylePosition)
|
||||
{
|
||||
@ -1819,10 +1822,14 @@ nsImageFrame::LoadIcon(const nsAString& aSpec,
|
||||
nsresult rv = NS_OK;
|
||||
NS_PRECONDITION(!aSpec.IsEmpty(), "What happened??");
|
||||
|
||||
if (!sIOService) {
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
rv = CallGetService(kIOServiceCID, &sIOService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> realURI;
|
||||
nsCOMPtr<nsIIOService> ioService;
|
||||
aPresContext->GetIOService(getter_AddRefs(ioService));
|
||||
SpecToURI(aSpec, ioService, getter_AddRefs(realURI));
|
||||
SpecToURI(aSpec, sIOService, getter_AddRefs(realURI));
|
||||
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsAString.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "nsIIOService.h"
|
||||
|
||||
#include "nsTransform2D.h"
|
||||
#include "imgIRequest.h"
|
||||
@ -137,6 +138,8 @@ public:
|
||||
|
||||
NS_IMETHOD GetIntrinsicImageSize(nsSize& aSize);
|
||||
|
||||
static void ReleaseGlobals() { NS_IF_RELEASE(sIOService); }
|
||||
|
||||
protected:
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
@ -248,6 +251,8 @@ private:
|
||||
|
||||
nsIPresContext* mPresContext; // weak ref
|
||||
|
||||
static nsIIOService* sIOService;
|
||||
|
||||
/* loading / broken image icon support */
|
||||
|
||||
// XXXbz this should be handled by the prescontext, I think; that
|
||||
|
@ -568,12 +568,11 @@ public:
|
||||
// Get colors from look&feel
|
||||
mSelectionBGColor = NS_RGB(0, 0, 0);
|
||||
mSelectionTextColor = NS_RGB(255, 255, 255);
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, mSelectionBGColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectForeground, mSelectionTextColor);
|
||||
NS_RELEASE(look);
|
||||
}
|
||||
nsILookAndFeel* look = aPresContext->LookAndFeel();
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground,
|
||||
mSelectionBGColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectForeground,
|
||||
mSelectionTextColor);
|
||||
|
||||
// Get the word and letter spacing
|
||||
mWordSpacing = 0;
|
||||
@ -1021,15 +1020,15 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent,
|
||||
}
|
||||
|
||||
// Get background colors for disabled selection at attention-getting selection (used with type ahead find)
|
||||
nsCOMPtr<nsILookAndFeel> look;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(getter_AddRefs(look))) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundAttention, mAttentionColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundDisabled, mDisabledColor);
|
||||
mDisabledColor = EnsureDifferentColors(mDisabledColor, mOldStyle.mSelectionBGColor);
|
||||
mAttentionColor = EnsureDifferentColors(mAttentionColor, mOldStyle.mSelectionBGColor);
|
||||
}
|
||||
else
|
||||
mDisabledColor = mAttentionColor = mOldStyle.mSelectionBGColor;
|
||||
nsILookAndFeel *look = aPresContext->LookAndFeel();
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundAttention,
|
||||
mAttentionColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundDisabled,
|
||||
mDisabledColor);
|
||||
mDisabledColor = EnsureDifferentColors(mDisabledColor,
|
||||
mOldStyle.mSelectionBGColor);
|
||||
mAttentionColor = EnsureDifferentColors(mAttentionColor,
|
||||
mOldStyle.mSelectionBGColor);
|
||||
|
||||
if (!aSelDetails)
|
||||
{
|
||||
|
@ -123,6 +123,9 @@
|
||||
// - created if null, deleted if refcount goes to 0
|
||||
nsImageFrame::IconLoad* nsImageFrame::mIconLoad = nsnull;
|
||||
|
||||
// cached IO service for loading icons
|
||||
nsIIOService* nsImageFrame::sIOService;
|
||||
|
||||
// test if the width and height are fixed, looking at the style data
|
||||
static PRBool HaveFixedSize(const nsStylePosition* aStylePosition)
|
||||
{
|
||||
@ -1819,10 +1822,14 @@ nsImageFrame::LoadIcon(const nsAString& aSpec,
|
||||
nsresult rv = NS_OK;
|
||||
NS_PRECONDITION(!aSpec.IsEmpty(), "What happened??");
|
||||
|
||||
if (!sIOService) {
|
||||
static NS_DEFINE_CID(kIOServiceCID, NS_IOSERVICE_CID);
|
||||
rv = CallGetService(kIOServiceCID, &sIOService);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIURI> realURI;
|
||||
nsCOMPtr<nsIIOService> ioService;
|
||||
aPresContext->GetIOService(getter_AddRefs(ioService));
|
||||
SpecToURI(aSpec, ioService, getter_AddRefs(realURI));
|
||||
SpecToURI(aSpec, sIOService, getter_AddRefs(realURI));
|
||||
|
||||
nsCOMPtr<imgILoader> il(do_GetService("@mozilla.org/image/loader;1", &rv));
|
||||
if (NS_FAILED(rv)) return rv;
|
||||
|
@ -42,6 +42,7 @@
|
||||
#include "nsAString.h"
|
||||
#include "nsIPresContext.h"
|
||||
#include "nsIImageFrame.h"
|
||||
#include "nsIIOService.h"
|
||||
|
||||
#include "nsTransform2D.h"
|
||||
#include "imgIRequest.h"
|
||||
@ -137,6 +138,8 @@ public:
|
||||
|
||||
NS_IMETHOD GetIntrinsicImageSize(nsSize& aSize);
|
||||
|
||||
static void ReleaseGlobals() { NS_IF_RELEASE(sIOService); }
|
||||
|
||||
protected:
|
||||
// nsISupports
|
||||
NS_IMETHOD_(nsrefcnt) AddRef(void);
|
||||
@ -248,6 +251,8 @@ private:
|
||||
|
||||
nsIPresContext* mPresContext; // weak ref
|
||||
|
||||
static nsIIOService* sIOService;
|
||||
|
||||
/* loading / broken image icon support */
|
||||
|
||||
// XXXbz this should be handled by the prescontext, I think; that
|
||||
|
@ -7064,7 +7064,8 @@ PresShell::VerifyIncrementalReflow()
|
||||
NS_ASSERTION(NS_SUCCEEDED (rv), "failed to create presentation context");
|
||||
nsCOMPtr<nsIDeviceContext> dc;
|
||||
mPresContext->GetDeviceContext(getter_AddRefs(dc));
|
||||
cx->Init(dc);
|
||||
rv = cx->Init(dc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
// Get our scrolling preference
|
||||
nsScrollPreference scrolling;
|
||||
|
@ -568,12 +568,11 @@ public:
|
||||
// Get colors from look&feel
|
||||
mSelectionBGColor = NS_RGB(0, 0, 0);
|
||||
mSelectionTextColor = NS_RGB(255, 255, 255);
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, mSelectionBGColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectForeground, mSelectionTextColor);
|
||||
NS_RELEASE(look);
|
||||
}
|
||||
nsILookAndFeel* look = aPresContext->LookAndFeel();
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground,
|
||||
mSelectionBGColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectForeground,
|
||||
mSelectionTextColor);
|
||||
|
||||
// Get the word and letter spacing
|
||||
mWordSpacing = 0;
|
||||
@ -1021,15 +1020,15 @@ DrawSelectionIterator::DrawSelectionIterator(nsIContent *aContent,
|
||||
}
|
||||
|
||||
// Get background colors for disabled selection at attention-getting selection (used with type ahead find)
|
||||
nsCOMPtr<nsILookAndFeel> look;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(getter_AddRefs(look))) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundAttention, mAttentionColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundDisabled, mDisabledColor);
|
||||
mDisabledColor = EnsureDifferentColors(mDisabledColor, mOldStyle.mSelectionBGColor);
|
||||
mAttentionColor = EnsureDifferentColors(mAttentionColor, mOldStyle.mSelectionBGColor);
|
||||
}
|
||||
else
|
||||
mDisabledColor = mAttentionColor = mOldStyle.mSelectionBGColor;
|
||||
nsILookAndFeel *look = aPresContext->LookAndFeel();
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundAttention,
|
||||
mAttentionColor);
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackgroundDisabled,
|
||||
mDisabledColor);
|
||||
mDisabledColor = EnsureDifferentColors(mDisabledColor,
|
||||
mOldStyle.mSelectionBGColor);
|
||||
mAttentionColor = EnsureDifferentColors(mAttentionColor,
|
||||
mOldStyle.mSelectionBGColor);
|
||||
|
||||
if (!aSelDetails)
|
||||
{
|
||||
|
@ -871,10 +871,9 @@ nsFormControlFrame::GetScreenHeight(nsIPresContext* aPresContext, nscoord& aHeig
|
||||
nsRect screen;
|
||||
|
||||
PRBool dropdownCanOverlapOSBar = PR_FALSE;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if ( lookAndFeel )
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, dropdownCanOverlapOSBar);
|
||||
nsILookAndFeel *lookAndFeel = aPresContext->LookAndFeel();
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar,
|
||||
dropdownCanOverlapOSBar);
|
||||
if ( dropdownCanOverlapOSBar )
|
||||
context->GetRect ( screen );
|
||||
else
|
||||
|
@ -84,7 +84,6 @@
|
||||
#include "nsISelectElement.h"
|
||||
#include "nsIPrivateDOMEvent.h"
|
||||
#include "nsCSSRendering.h"
|
||||
#include "nsILookAndFeel.h"
|
||||
#include "nsReflowPath.h"
|
||||
#include "nsITheme.h"
|
||||
#include "nsIDOMMouseListener.h"
|
||||
@ -689,14 +688,10 @@ void nsListControlFrame::PaintFocus(nsIRenderingContext& aRC, nsFramePaintLayer
|
||||
|
||||
// set up back stop colors and then ask L&F service for the real colors
|
||||
nscolor color;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
mPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if (lookAndFeel){
|
||||
lookAndFeel->GetColor(lastItemIsSelected?nsILookAndFeel::eColor_WidgetSelectForeground:nsILookAndFeel::eColor_WidgetSelectBackground, color);
|
||||
} else {
|
||||
// Use some backstop colors if for some reason we don't have a L&F object
|
||||
color = lastItemIsSelected? NS_RGB(245,219,149) : NS_RGB(0,0,0);
|
||||
}
|
||||
mPresContext->LookAndFeel()->
|
||||
GetColor(lastItemIsSelected ?
|
||||
nsILookAndFeel::eColor_WidgetSelectForeground :
|
||||
nsILookAndFeel::eColor_WidgetSelectBackground, color);
|
||||
|
||||
float p2t;
|
||||
mPresContext->GetScaledPixelsToTwips(&p2t);
|
||||
|
@ -344,11 +344,9 @@ nsTableCellFrame::DecorateForSelection(nsIPresContext* aPresContext,
|
||||
bordercolor = NS_RGB(176,176,176);// disabled color
|
||||
}
|
||||
else {
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, bordercolor);
|
||||
NS_RELEASE(look);
|
||||
}
|
||||
aPresContext->LookAndFeel()->
|
||||
GetColor(nsILookAndFeel::eColor_TextSelectBackground,
|
||||
bordercolor);
|
||||
}
|
||||
float t2pfloat;
|
||||
if (NS_SUCCEEDED(aPresContext->GetPixelsToTwips(&t2pfloat)))
|
||||
|
@ -1953,14 +1953,11 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext,
|
||||
// paint the selection background -- beware MathML frames overlap a lot
|
||||
if (aSelectedRect && !aSelectedRect->IsEmpty()) {
|
||||
// get color to use for selection from the look&feel object
|
||||
nsCOMPtr<nsILookAndFeel> lf;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lf));
|
||||
if (lf) {
|
||||
nscolor bgColor = NS_RGB(0, 0, 0);
|
||||
lf->GetColor(nsILookAndFeel::eColor_TextSelectBackground, bgColor);
|
||||
aRenderingContext.SetColor(bgColor);
|
||||
aRenderingContext.FillRect(*aSelectedRect);
|
||||
}
|
||||
nscolor bgColor = NS_RGB(0, 0, 0);
|
||||
aPresContext->LookAndFeel()->
|
||||
GetColor(nsILookAndFeel::eColor_TextSelectBackground, bgColor);
|
||||
aRenderingContext.SetColor(bgColor);
|
||||
aRenderingContext.FillRect(*aSelectedRect);
|
||||
}
|
||||
else if (mRect.width && mRect.height) {
|
||||
const nsStyleBorder* border = styleContext->GetStyleBorder();
|
||||
@ -1993,11 +1990,8 @@ nsMathMLChar::Paint(nsIPresContext* aPresContext,
|
||||
nscolor fgColor = styleContext->GetStyleColor()->mColor;
|
||||
if (aSelectedRect && !aSelectedRect->IsEmpty()) {
|
||||
// get color to use for selection from the look&feel object
|
||||
nsCOMPtr<nsILookAndFeel> lf;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lf));
|
||||
if (lf) {
|
||||
lf->GetColor(nsILookAndFeel::eColor_TextSelectForeground, fgColor);
|
||||
}
|
||||
aPresContext->LookAndFeel()->
|
||||
GetColor(nsILookAndFeel::eColor_TextSelectForeground, fgColor);
|
||||
}
|
||||
aRenderingContext.SetColor(fgColor);
|
||||
|
||||
|
@ -2603,7 +2603,11 @@ nsPrintEngine::ReflowPrintObject(nsPrintObject * aPO, PRBool aDoCalcShrink)
|
||||
|
||||
|
||||
// init it with the DC
|
||||
(aPO->mPresContext)->Init(mPrt->mPrintDocDC);
|
||||
rv = aPO->mPresContext->Init(mPrt->mPrintDocDC);
|
||||
if (NS_FAILED(rv)) {
|
||||
aPO->mPresContext = nsnull;
|
||||
return rv;
|
||||
}
|
||||
|
||||
rv = mDocViewerPrint->CreateStyleSet(aPO->mDocument, &aPO->mStyleSet);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -330,13 +330,10 @@ static PRBool SetColor(const nsCSSValue& aValue, const nscolor aParentColor,
|
||||
else if (eCSSUnit_Integer == unit) {
|
||||
PRInt32 intValue = aValue.GetIntValue();
|
||||
if (0 <= intValue) {
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
||||
nsILookAndFeel::nsColorID colorID = (nsILookAndFeel::nsColorID) intValue;
|
||||
if (NS_SUCCEEDED(look->GetColor(colorID, aResult))) {
|
||||
result = PR_TRUE;
|
||||
}
|
||||
NS_RELEASE(look);
|
||||
nsILookAndFeel* look = aPresContext->LookAndFeel();
|
||||
nsILookAndFeel::nsColorID colorID = (nsILookAndFeel::nsColorID) intValue;
|
||||
if (NS_SUCCEEDED(look->GetColor(colorID, aResult))) {
|
||||
result = PR_TRUE;
|
||||
}
|
||||
}
|
||||
else {
|
||||
|
@ -344,11 +344,9 @@ nsTableCellFrame::DecorateForSelection(nsIPresContext* aPresContext,
|
||||
bordercolor = NS_RGB(176,176,176);// disabled color
|
||||
}
|
||||
else {
|
||||
nsILookAndFeel* look = nsnull;
|
||||
if (NS_SUCCEEDED(aPresContext->GetLookAndFeel(&look)) && look) {
|
||||
look->GetColor(nsILookAndFeel::eColor_TextSelectBackground, bordercolor);
|
||||
NS_RELEASE(look);
|
||||
}
|
||||
aPresContext->LookAndFeel()->
|
||||
GetColor(nsILookAndFeel::eColor_TextSelectBackground,
|
||||
bordercolor);
|
||||
}
|
||||
float t2pfloat;
|
||||
if (NS_SUCCEEDED(aPresContext->GetPixelsToTwips(&t2pfloat)))
|
||||
|
@ -78,8 +78,6 @@
|
||||
#include "nsISound.h"
|
||||
#endif
|
||||
|
||||
static NS_DEFINE_IID(kLookAndFeelCID, NS_LOOKANDFEEL_CID);
|
||||
|
||||
const PRInt32 kMaxZ = 0x7fffffff; //XXX: Shouldn't there be a define somewhere for MaxInt for PRInt32
|
||||
|
||||
|
||||
@ -173,13 +171,10 @@ nsMenuPopupFrame::Init(nsIPresContext* aPresContext,
|
||||
|
||||
// lookup if we're allowed to overlap the OS bar (menubar/taskbar) from the
|
||||
// look&feel object
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
aPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if ( lookAndFeel ) {
|
||||
PRBool tempBool;
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, tempBool);
|
||||
mMenuCanOverlapOSBar = tempBool;
|
||||
}
|
||||
PRBool tempBool;
|
||||
aPresContext->LookAndFeel()->
|
||||
GetMetric(nsILookAndFeel::eMetric_MenusCanOverlapOSBar, tempBool);
|
||||
mMenuCanOverlapOSBar = tempBool;
|
||||
|
||||
// XXX Hack
|
||||
mPresContext = aPresContext;
|
||||
@ -1481,12 +1476,8 @@ NS_IMETHODIMP nsMenuPopupFrame::SetCurrentMenuItem(nsIMenuFrame* aMenuItem)
|
||||
KillCloseTimer(); // Ensure we don't have another stray waiting closure.
|
||||
PRInt32 menuDelay = 300; // ms
|
||||
|
||||
nsILookAndFeel * lookAndFeel;
|
||||
if (NS_OK == nsComponentManager::CreateInstance(kLookAndFeelCID, nsnull,
|
||||
NS_GET_IID(nsILookAndFeel), (void**)&lookAndFeel)) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_SubmenuDelay, menuDelay);
|
||||
NS_RELEASE(lookAndFeel);
|
||||
}
|
||||
mPresContext->LookAndFeel()->
|
||||
GetMetric(nsILookAndFeel::eMetric_SubmenuDelay, menuDelay);
|
||||
|
||||
// Kick off the timer.
|
||||
mCloseTimer = do_CreateInstance("@mozilla.org/timer;1");
|
||||
|
@ -1655,10 +1655,7 @@ nsTreeBodyFrame::CreateTimer(const nsILookAndFeel::nsMetricID aID,
|
||||
// Get the delay from the look and feel service.
|
||||
PRInt32 delay = 0;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
mPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if (lookAndFeel) {
|
||||
lookAndFeel->GetMetric(aID, delay);
|
||||
}
|
||||
mPresContext->LookAndFeel()->GetMetric(aID, delay);
|
||||
|
||||
nsCOMPtr<nsITimer> timer;
|
||||
|
||||
@ -3758,15 +3755,11 @@ nsTreeBodyFrame::ComputeDropPosition(nsIDOMEvent* aEvent, PRInt32* aRow, PRInt16
|
||||
if (CanAutoScroll(*aRow)) {
|
||||
// Get the max value from the look and feel service.
|
||||
PRInt32 scrollLinesMax = 0;
|
||||
nsCOMPtr<nsILookAndFeel> lookAndFeel;
|
||||
mPresContext->GetLookAndFeel(getter_AddRefs(lookAndFeel));
|
||||
if (lookAndFeel) {
|
||||
lookAndFeel->GetMetric(nsILookAndFeel::eMetric_TreeScrollLinesMax,
|
||||
scrollLinesMax);
|
||||
scrollLinesMax--;
|
||||
if (scrollLinesMax < 0)
|
||||
scrollLinesMax = 0;
|
||||
}
|
||||
mPresContext->LookAndFeel()->
|
||||
GetMetric(nsILookAndFeel::eMetric_TreeScrollLinesMax, scrollLinesMax);
|
||||
scrollLinesMax--;
|
||||
if (scrollLinesMax < 0)
|
||||
scrollLinesMax = 0;
|
||||
|
||||
// Determine if we're w/in a margin of the top/bottom of the tree during a drag.
|
||||
// This will ultimately cause us to scroll, but that's done elsewhere.
|
||||
|
Loading…
Reference in New Issue
Block a user