From f82953355da325b55a1c5c5df77d5512073d59d7 Mon Sep 17 00:00:00 2001 From: "mkaply%us.ibm.com" Date: Sat, 9 Mar 2002 05:31:35 +0000 Subject: [PATCH] #41924 r=timeless, sr=attinasi, a=asa Display alt text if the user has blocked all images. --- layout/generic/nsImageFrame.cpp | 10 ++++++++-- layout/generic/nsImageFrame.h | 5 +++-- layout/html/base/src/nsImageFrame.cpp | 10 ++++++++-- layout/html/base/src/nsImageFrame.h | 5 +++-- 4 files changed, 22 insertions(+), 8 deletions(-) diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index 1d703dd48fce..a24dad0e1553 100644 --- a/layout/generic/nsImageFrame.cpp +++ b/layout/generic/nsImageFrame.cpp @@ -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 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; + } } } diff --git a/layout/generic/nsImageFrame.h b/layout/generic/nsImageFrame.h index 8f0d7dbc9d15..64e782fb8408 100644 --- a/layout/generic/nsImageFrame.h +++ b/layout/generic/nsImageFrame.h @@ -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 }; diff --git a/layout/html/base/src/nsImageFrame.cpp b/layout/html/base/src/nsImageFrame.cpp index 1d703dd48fce..a24dad0e1553 100644 --- a/layout/html/base/src/nsImageFrame.cpp +++ b/layout/html/base/src/nsImageFrame.cpp @@ -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 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; + } } } diff --git a/layout/html/base/src/nsImageFrame.h b/layout/html/base/src/nsImageFrame.h index 8f0d7dbc9d15..64e782fb8408 100644 --- a/layout/html/base/src/nsImageFrame.h +++ b/layout/html/base/src/nsImageFrame.h @@ -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 };