зеркало из https://github.com/mozilla/gecko-dev.git
bug 136382 r=rjesup@wgate.com sr=tor
preference to disable image placeholders
This commit is contained in:
Родитель
a2dc8bc7ee
Коммит
898fb53814
|
@ -1184,46 +1184,51 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
|
|||
aRenderingContext.PushState();
|
||||
aRenderingContext.SetClipRect(inner, nsClipCombine_kIntersect, clipState);
|
||||
|
||||
PRInt32 size = NSIntPixelsToTwips(ICON_SIZE, p2t);
|
||||
PRBool dispIcon = mIconLoad ? mIconLoad->mPrefShowPlaceholders : PR_TRUE;
|
||||
|
||||
PRBool iconUsed = PR_FALSE;
|
||||
// Check if we should display image placeholders
|
||||
if (dispIcon) {
|
||||
PRInt32 size = NSIntPixelsToTwips(ICON_SIZE, p2t);
|
||||
|
||||
// see if the icon images are present...
|
||||
if (mIconLoad && mIconLoad->mIconsLoaded) {
|
||||
// pick the correct image
|
||||
NS_ASSERTION( aIconId == NS_ICON_LOADING_IMAGE ||
|
||||
aIconId == NS_ICON_BROKEN_IMAGE, "Invalid Icon ID in DisplayAltFeedback");
|
||||
PRBool iconUsed = PR_FALSE;
|
||||
|
||||
nsCOMPtr<imgIContainer> imgCon;
|
||||
if (mIconLoad->mIconLoads[aIconId].mRequest) {
|
||||
mIconLoad->mIconLoads[aIconId].mRequest->GetImage(getter_AddRefs(imgCon));
|
||||
}
|
||||
if (imgCon) {
|
||||
// draw it
|
||||
nsPoint p(inner.x, inner.y);
|
||||
nsRect r(0,0,size,size);
|
||||
aRenderingContext.DrawImage(imgCon, &r, &p);
|
||||
iconUsed = PR_TRUE;
|
||||
// see if the icon images are present...
|
||||
if (mIconLoad && mIconLoad->mIconsLoaded) {
|
||||
// pick the correct image
|
||||
NS_ASSERTION( aIconId == NS_ICON_LOADING_IMAGE ||
|
||||
aIconId == NS_ICON_BROKEN_IMAGE, "Invalid Icon ID in DisplayAltFeedback");
|
||||
|
||||
nsCOMPtr<imgIContainer> imgCon;
|
||||
if (mIconLoad->mIconLoads[aIconId].mRequest) {
|
||||
mIconLoad->mIconLoads[aIconId].mRequest->GetImage(getter_AddRefs(imgCon));
|
||||
}
|
||||
if (imgCon) {
|
||||
// draw it
|
||||
nsPoint p(inner.x, inner.y);
|
||||
nsRect r(0,0,size,size);
|
||||
aRenderingContext.DrawImage(imgCon, &r, &p);
|
||||
iconUsed = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// if we could not draw the image, then just draw some grafitti
|
||||
if (!iconUsed) {
|
||||
nscolor oldColor;
|
||||
aRenderingContext.DrawRect(0,0,size,size);
|
||||
aRenderingContext.GetColor(oldColor);
|
||||
aRenderingContext.SetColor( aIconId == NS_ICON_BROKEN_IMAGE ? NS_RGB(0xFF,0,0) : NS_RGB(0,0xFF,0));
|
||||
aRenderingContext.FillEllipse(NS_STATIC_CAST(int,size/2),NS_STATIC_CAST(int,size/2),
|
||||
NS_STATIC_CAST(int,(size/2)-(2*p2t)),NS_STATIC_CAST(int,(size/2)-(2*p2t)));
|
||||
aRenderingContext.SetColor(oldColor);
|
||||
}
|
||||
|
||||
// Reduce the inner rect by the width of the icon, and leave an
|
||||
// additional ICON_PADDING pixels for padding
|
||||
PRInt32 iconWidth = NSIntPixelsToTwips(ICON_SIZE + ICON_PADDING, p2t);
|
||||
inner.x += iconWidth;
|
||||
inner.width -= iconWidth;
|
||||
}
|
||||
|
||||
// if we could not draw the image, then just draw some grafitti
|
||||
if (!iconUsed) {
|
||||
nscolor oldColor;
|
||||
aRenderingContext.DrawRect(0,0,size,size);
|
||||
aRenderingContext.GetColor(oldColor);
|
||||
aRenderingContext.SetColor( aIconId == NS_ICON_BROKEN_IMAGE ? NS_RGB(0xFF,0,0) : NS_RGB(0,0xFF,0));
|
||||
aRenderingContext.FillEllipse(NS_STATIC_CAST(int,size/2),NS_STATIC_CAST(int,size/2),
|
||||
NS_STATIC_CAST(int,(size/2)-(2*p2t)),NS_STATIC_CAST(int,(size/2)-(2*p2t)));
|
||||
aRenderingContext.SetColor(oldColor);
|
||||
}
|
||||
|
||||
// Reduce the inner rect by the width of the icon, and leave an
|
||||
// additional ICON_PADDING pixels for padding
|
||||
PRInt32 iconWidth = NSIntPixelsToTwips(ICON_SIZE + ICON_PADDING, p2t);
|
||||
inner.x += iconWidth;
|
||||
inner.width -= iconWidth;
|
||||
|
||||
// If there's still room, display the alt-text
|
||||
if (!inner.IsEmpty()) {
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
@ -2232,6 +2237,11 @@ void nsImageFrame::IconLoad::GetPrefs(nsIPresContext *aPresContext)
|
|||
} else {
|
||||
mPrefAllImagesBlocked = PR_FALSE;
|
||||
}
|
||||
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
|
||||
mPrefShowPlaceholders = boolPref;
|
||||
} else {
|
||||
mPrefShowPlaceholders = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -276,6 +276,7 @@ private:
|
|||
PRPackedBool mIconsLoaded;
|
||||
PRPackedBool mPrefForceInlineAltText;
|
||||
PRPackedBool mPrefAllImagesBlocked;
|
||||
PRPackedBool mPrefShowPlaceholders;
|
||||
};
|
||||
static IconLoad* mIconLoad; // singleton patern: one LoadIcons instance is used
|
||||
};
|
||||
|
|
|
@ -1184,46 +1184,51 @@ nsImageFrame::DisplayAltFeedback(nsIPresContext* aPresContext,
|
|||
aRenderingContext.PushState();
|
||||
aRenderingContext.SetClipRect(inner, nsClipCombine_kIntersect, clipState);
|
||||
|
||||
PRInt32 size = NSIntPixelsToTwips(ICON_SIZE, p2t);
|
||||
PRBool dispIcon = mIconLoad ? mIconLoad->mPrefShowPlaceholders : PR_TRUE;
|
||||
|
||||
PRBool iconUsed = PR_FALSE;
|
||||
// Check if we should display image placeholders
|
||||
if (dispIcon) {
|
||||
PRInt32 size = NSIntPixelsToTwips(ICON_SIZE, p2t);
|
||||
|
||||
// see if the icon images are present...
|
||||
if (mIconLoad && mIconLoad->mIconsLoaded) {
|
||||
// pick the correct image
|
||||
NS_ASSERTION( aIconId == NS_ICON_LOADING_IMAGE ||
|
||||
aIconId == NS_ICON_BROKEN_IMAGE, "Invalid Icon ID in DisplayAltFeedback");
|
||||
PRBool iconUsed = PR_FALSE;
|
||||
|
||||
nsCOMPtr<imgIContainer> imgCon;
|
||||
if (mIconLoad->mIconLoads[aIconId].mRequest) {
|
||||
mIconLoad->mIconLoads[aIconId].mRequest->GetImage(getter_AddRefs(imgCon));
|
||||
}
|
||||
if (imgCon) {
|
||||
// draw it
|
||||
nsPoint p(inner.x, inner.y);
|
||||
nsRect r(0,0,size,size);
|
||||
aRenderingContext.DrawImage(imgCon, &r, &p);
|
||||
iconUsed = PR_TRUE;
|
||||
// see if the icon images are present...
|
||||
if (mIconLoad && mIconLoad->mIconsLoaded) {
|
||||
// pick the correct image
|
||||
NS_ASSERTION( aIconId == NS_ICON_LOADING_IMAGE ||
|
||||
aIconId == NS_ICON_BROKEN_IMAGE, "Invalid Icon ID in DisplayAltFeedback");
|
||||
|
||||
nsCOMPtr<imgIContainer> imgCon;
|
||||
if (mIconLoad->mIconLoads[aIconId].mRequest) {
|
||||
mIconLoad->mIconLoads[aIconId].mRequest->GetImage(getter_AddRefs(imgCon));
|
||||
}
|
||||
if (imgCon) {
|
||||
// draw it
|
||||
nsPoint p(inner.x, inner.y);
|
||||
nsRect r(0,0,size,size);
|
||||
aRenderingContext.DrawImage(imgCon, &r, &p);
|
||||
iconUsed = PR_TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
// if we could not draw the image, then just draw some grafitti
|
||||
if (!iconUsed) {
|
||||
nscolor oldColor;
|
||||
aRenderingContext.DrawRect(0,0,size,size);
|
||||
aRenderingContext.GetColor(oldColor);
|
||||
aRenderingContext.SetColor( aIconId == NS_ICON_BROKEN_IMAGE ? NS_RGB(0xFF,0,0) : NS_RGB(0,0xFF,0));
|
||||
aRenderingContext.FillEllipse(NS_STATIC_CAST(int,size/2),NS_STATIC_CAST(int,size/2),
|
||||
NS_STATIC_CAST(int,(size/2)-(2*p2t)),NS_STATIC_CAST(int,(size/2)-(2*p2t)));
|
||||
aRenderingContext.SetColor(oldColor);
|
||||
}
|
||||
|
||||
// Reduce the inner rect by the width of the icon, and leave an
|
||||
// additional ICON_PADDING pixels for padding
|
||||
PRInt32 iconWidth = NSIntPixelsToTwips(ICON_SIZE + ICON_PADDING, p2t);
|
||||
inner.x += iconWidth;
|
||||
inner.width -= iconWidth;
|
||||
}
|
||||
|
||||
// if we could not draw the image, then just draw some grafitti
|
||||
if (!iconUsed) {
|
||||
nscolor oldColor;
|
||||
aRenderingContext.DrawRect(0,0,size,size);
|
||||
aRenderingContext.GetColor(oldColor);
|
||||
aRenderingContext.SetColor( aIconId == NS_ICON_BROKEN_IMAGE ? NS_RGB(0xFF,0,0) : NS_RGB(0,0xFF,0));
|
||||
aRenderingContext.FillEllipse(NS_STATIC_CAST(int,size/2),NS_STATIC_CAST(int,size/2),
|
||||
NS_STATIC_CAST(int,(size/2)-(2*p2t)),NS_STATIC_CAST(int,(size/2)-(2*p2t)));
|
||||
aRenderingContext.SetColor(oldColor);
|
||||
}
|
||||
|
||||
// Reduce the inner rect by the width of the icon, and leave an
|
||||
// additional ICON_PADDING pixels for padding
|
||||
PRInt32 iconWidth = NSIntPixelsToTwips(ICON_SIZE + ICON_PADDING, p2t);
|
||||
inner.x += iconWidth;
|
||||
inner.width -= iconWidth;
|
||||
|
||||
// If there's still room, display the alt-text
|
||||
if (!inner.IsEmpty()) {
|
||||
nsCOMPtr<nsIContent> content;
|
||||
|
@ -2232,6 +2237,11 @@ void nsImageFrame::IconLoad::GetPrefs(nsIPresContext *aPresContext)
|
|||
} else {
|
||||
mPrefAllImagesBlocked = PR_FALSE;
|
||||
}
|
||||
if (NS_SUCCEEDED(prefs->GetBoolPref("browser.display.show_image_placeholders", &boolPref))) {
|
||||
mPrefShowPlaceholders = boolPref;
|
||||
} else {
|
||||
mPrefShowPlaceholders = PR_TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -276,6 +276,7 @@ private:
|
|||
PRPackedBool mIconsLoaded;
|
||||
PRPackedBool mPrefForceInlineAltText;
|
||||
PRPackedBool mPrefAllImagesBlocked;
|
||||
PRPackedBool mPrefShowPlaceholders;
|
||||
};
|
||||
static IconLoad* mIconLoad; // singleton patern: one LoadIcons instance is used
|
||||
};
|
||||
|
|
|
@ -79,6 +79,7 @@ pref("browser.display.use_system_colors", false);
|
|||
pref("browser.display.foreground_color", "#000000");
|
||||
pref("browser.display.background_color", "#FFFFFF");
|
||||
pref("browser.display.force_inline_alttext", false); // true = force ALT text for missing images to be layed out inline
|
||||
pref("browser.display.show_image_placeholders", true); // true = show image placeholders while image is loaded and when image is broken
|
||||
pref("browser.anchor_color", "#0000EE");
|
||||
pref("browser.visited_color", "#551A8B");
|
||||
pref("browser.underline_anchors", true);
|
||||
|
|
Загрузка…
Ссылка в новой задаче