r=timeless, sr=attinasi, a=asa
Display alt text if the user has blocked all images.
This commit is contained in:
mkaply%us.ibm.com 2002-03-09 05:31:35 +00:00
parent ed63cc7b74
commit f82953355d
4 changed files with 22 additions and 8 deletions

View File

@ -1256,7 +1256,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
// indicating the status (unless image is blocked, in which case we show nothing)
#ifndef SUPPRESS_LOADING_ICON
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
!mImageBlocked) {
(!mImageBlocked || mIconLoad->mPrefAllImagesBlocked)) {
#else
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
mInitialLoadCompleted) {
@ -2132,7 +2132,7 @@ void nsImageFrame::InvalidateIcon(nsIPresContext *aPresContext)
Invalidate(aPresContext, rect, PR_FALSE);
}
void nsImageFrame::IconLoad::GetAltModePref(nsIPresContext *aPresContext)
void nsImageFrame::IconLoad::GetPrefs(nsIPresContext *aPresContext)
{
NS_ASSERTION(aPresContext, "null presContext is not allowed in GetAltModePref");
// NOTE: the presContext could be used to fetch a cached pref if needed, but is not for now
@ -2140,11 +2140,17 @@ void nsImageFrame::IconLoad::GetAltModePref(nsIPresContext *aPresContext)
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
PRBool boolPref;
PRInt32 intPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
mPrefForceInlineAltText = boolPref;
} else {
mPrefForceInlineAltText = PR_FALSE;
}
if (NS_SUCCEEDED(prefs->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
mPrefAllImagesBlocked = PR_TRUE;
} else {
mPrefAllImagesBlocked = PR_FALSE;
}
}
}

View File

@ -265,15 +265,16 @@ private:
// private class that wraps the data and logic needed for
// broken image and loading image icons
public:
IconLoad(nsIPresContext *aPresContext):mRefCount(0),mIconsLoaded(PR_FALSE) { GetAltModePref(aPresContext); }
IconLoad(nsIPresContext *aPresContext):mRefCount(0),mIconsLoaded(PR_FALSE) { GetPrefs(aPresContext); }
void AddRef(void) { ++mRefCount; }
PRBool Release(void) { return --mRefCount == 0; }
void GetAltModePref(nsIPresContext *aPresContext);
void GetPrefs(nsIPresContext *aPresContext);
PRUint32 mRefCount;
struct ImageLoad mIconLoads[2]; // 0 is for the 'loading' icon, 1 is for the 'broken' icon
PRPackedBool mIconsLoaded;
PRPackedBool mPrefForceInlineAltText;
PRPackedBool mPrefAllImagesBlocked;
};
static IconLoad* mIconLoad; // singleton patern: one LoadIcons instance is used
};

View File

@ -1256,7 +1256,7 @@ nsImageFrame::Paint(nsIPresContext* aPresContext,
// indicating the status (unless image is blocked, in which case we show nothing)
#ifndef SUPPRESS_LOADING_ICON
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
!mImageBlocked) {
(!mImageBlocked || mIconLoad->mPrefAllImagesBlocked)) {
#else
if (NS_FRAME_PAINT_LAYER_BACKGROUND == aWhichLayer &&
mInitialLoadCompleted) {
@ -2132,7 +2132,7 @@ void nsImageFrame::InvalidateIcon(nsIPresContext *aPresContext)
Invalidate(aPresContext, rect, PR_FALSE);
}
void nsImageFrame::IconLoad::GetAltModePref(nsIPresContext *aPresContext)
void nsImageFrame::IconLoad::GetPrefs(nsIPresContext *aPresContext)
{
NS_ASSERTION(aPresContext, "null presContext is not allowed in GetAltModePref");
// NOTE: the presContext could be used to fetch a cached pref if needed, but is not for now
@ -2140,11 +2140,17 @@ void nsImageFrame::IconLoad::GetAltModePref(nsIPresContext *aPresContext)
nsCOMPtr<nsIPref> prefs = do_GetService(NS_PREF_CONTRACTID);
if (prefs) {
PRBool boolPref;
PRInt32 intPref;
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.force_inline_alttext", &boolPref))) {
mPrefForceInlineAltText = boolPref;
} else {
mPrefForceInlineAltText = PR_FALSE;
}
if (NS_SUCCEEDED(prefs->GetIntPref("network.image.imageBehavior", &intPref)) && intPref == 2) {
mPrefAllImagesBlocked = PR_TRUE;
} else {
mPrefAllImagesBlocked = PR_FALSE;
}
}
}

View File

@ -265,15 +265,16 @@ private:
// private class that wraps the data and logic needed for
// broken image and loading image icons
public:
IconLoad(nsIPresContext *aPresContext):mRefCount(0),mIconsLoaded(PR_FALSE) { GetAltModePref(aPresContext); }
IconLoad(nsIPresContext *aPresContext):mRefCount(0),mIconsLoaded(PR_FALSE) { GetPrefs(aPresContext); }
void AddRef(void) { ++mRefCount; }
PRBool Release(void) { return --mRefCount == 0; }
void GetAltModePref(nsIPresContext *aPresContext);
void GetPrefs(nsIPresContext *aPresContext);
PRUint32 mRefCount;
struct ImageLoad mIconLoads[2]; // 0 is for the 'loading' icon, 1 is for the 'broken' icon
PRPackedBool mIconsLoaded;
PRPackedBool mPrefForceInlineAltText;
PRPackedBool mPrefAllImagesBlocked;
};
static IconLoad* mIconLoad; // singleton patern: one LoadIcons instance is used
};