Bug 1817360 - Remove browser.display.show_loading_image_placeholder. r=tnikkel

This pref has been false since forever, completely untested, and I see
no references to it anywhere. I'm pretty sure having a loading image
placeholder wouldn't be web compatible, particularly in the current days
with all the lazy-loading shenanigans etc.

I propose just removing this code, and simplifying surrounding code for
clarity.

Differential Revision: https://phabricator.services.mozilla.com/D170158
This commit is contained in:
Emilio Cobos Álvarez 2023-02-17 09:25:20 +00:00
parent 631d4770aa
commit 5514dadfb2
4 changed files with 14 additions and 50 deletions

View file

@ -4,4 +4,3 @@
toolkit.jar: toolkit.jar:
res/broken-image.png (broken-image.png) res/broken-image.png (broken-image.png)
res/loading-image.png (loading-image.png)

Binary file not shown.

Before

Width:  |  Height:  |  Size: 160 B

View file

@ -213,7 +213,6 @@ class IconLoad final : public imgINotificationObserver {
nsTObserverArray<nsImageFrame*> mIconObservers; nsTObserverArray<nsImageFrame*> mIconObservers;
public: public:
RefPtr<imgRequestProxy> mLoadingImage;
RefPtr<imgRequestProxy> mBrokenImage; RefPtr<imgRequestProxy> mBrokenImage;
}; };
@ -303,6 +302,10 @@ bool nsImageFrame::ShouldShowBrokenImageIcon() const {
return false; return false;
} }
if (!StaticPrefs::browser_display_show_image_placeholders()) {
return false;
}
// <img alt=""> is special, and it shouldn't draw the broken image icon, // <img alt=""> is special, and it shouldn't draw the broken image icon,
// unlike the no-alt attribute or non-empty-alt-attribute case. // unlike the no-alt attribute or non-empty-alt-attribute case.
if (auto* image = HTMLImageElement::FromNode(mContent)) { if (auto* image = HTMLImageElement::FromNode(mContent)) {
@ -1734,8 +1737,7 @@ ImgDrawResult nsImageFrame::DisplayAltFeedback(gfxContext& aRenderingContext,
} }
// Paint the border // Paint the border
if (!isLoading || if (!isLoading) {
StaticPrefs::browser_display_show_loading_image_placeholder()) {
nsRecessedBorder recessedBorder(borderEdgeWidth, PresContext()); nsRecessedBorder recessedBorder(borderEdgeWidth, PresContext());
// Assert that we're not drawing a border-image here; if we were, we // Assert that we're not drawing a border-image here; if we were, we
@ -1764,18 +1766,14 @@ ImgDrawResult nsImageFrame::DisplayAltFeedback(gfxContext& aRenderingContext,
aRenderingContext.Clip(NSRectToSnappedRect( aRenderingContext.Clip(NSRectToSnappedRect(
inner, PresContext()->AppUnitsPerDevPixel(), *drawTarget)); inner, PresContext()->AppUnitsPerDevPixel(), *drawTarget));
ImgDrawResult result = ImgDrawResult::NOT_READY; ImgDrawResult result = ImgDrawResult::SUCCESS;
// Check if we should display image placeholders // Check if we should display image placeholders
if (!ShouldShowBrokenImageIcon() || if (ShouldShowBrokenImageIcon()) {
!StaticPrefs::browser_display_show_image_placeholders() || result = ImgDrawResult::NOT_READY;
(isLoading && StaticPrefs::browser_display_show_loading_image_placeholder())) {
result = ImgDrawResult::SUCCESS;
} else {
nscoord size = nsPresContext::CSSPixelsToAppUnits(ICON_SIZE); nscoord size = nsPresContext::CSSPixelsToAppUnits(ICON_SIZE);
imgIRequest* request = isLoading ? gIconLoad->mLoadingImage imgIRequest* request = gIconLoad->mBrokenImage;
: gIconLoad->mBrokenImage;
// If we weren't previously displaying an icon, register ourselves // If we weren't previously displaying an icon, register ourselves
// as an observer for load and animation updates and flag that we're // as an observer for load and animation updates and flag that we're
@ -1919,8 +1917,7 @@ ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer(
AutoSaveRestore autoSaveRestore(aBuilder, textDrawResult); AutoSaveRestore autoSaveRestore(aBuilder, textDrawResult);
// Paint the border // Paint the border
if (!isLoading || if (!isLoading) {
StaticPrefs::browser_display_show_loading_image_placeholder()) {
nsRecessedBorder recessedBorder(borderEdgeWidth, PresContext()); nsRecessedBorder recessedBorder(borderEdgeWidth, PresContext());
// Assert that we're not drawing a border-image here; if we were, we // Assert that we're not drawing a border-image here; if we were, we
// couldn't ignore the ImgDrawResult that PaintBorderWithStyleBorder // couldn't ignore the ImgDrawResult that PaintBorderWithStyleBorder
@ -1948,14 +1945,10 @@ ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer(
auto wrBounds = wr::ToLayoutRect(bounds); auto wrBounds = wr::ToLayoutRect(bounds);
// Check if we should display image placeholders // Check if we should display image placeholders
if (ShouldShowBrokenImageIcon() && if (ShouldShowBrokenImageIcon()) {
StaticPrefs::browser_display_show_image_placeholders() &&
(!isLoading ||
StaticPrefs::browser_display_show_loading_image_placeholder())) {
ImgDrawResult result = ImgDrawResult::NOT_READY; ImgDrawResult result = ImgDrawResult::NOT_READY;
nscoord size = nsPresContext::CSSPixelsToAppUnits(ICON_SIZE); nscoord size = nsPresContext::CSSPixelsToAppUnits(ICON_SIZE);
imgIRequest* request = imgIRequest* request = gIconLoad->mBrokenImage;
isLoading ? gIconLoad->mLoadingImage : gIconLoad->mBrokenImage;
// If we weren't previously displaying an icon, register ourselves // If we weren't previously displaying an icon, register ourselves
// as an observer for load and animation updates and flag that we're // as an observer for load and animation updates and flag that we're
@ -2784,35 +2777,15 @@ void nsImageFrame::GetLoadGroup(nsPresContext* aPresContext,
nsresult nsImageFrame::LoadIcons(nsPresContext* aPresContext) { nsresult nsImageFrame::LoadIcons(nsPresContext* aPresContext) {
NS_ASSERTION(!gIconLoad, "called LoadIcons twice"); NS_ASSERTION(!gIconLoad, "called LoadIcons twice");
constexpr auto loadingSrc = u"resource://gre-resources/loading-image.png"_ns;
constexpr auto brokenSrc = u"resource://gre-resources/broken-image.png"_ns; constexpr auto brokenSrc = u"resource://gre-resources/broken-image.png"_ns;
gIconLoad = new IconLoad(); gIconLoad = new IconLoad();
return LoadIcon(brokenSrc, aPresContext,
nsresult rv;
// create a loader and load the images
rv = LoadIcon(loadingSrc, aPresContext,
getter_AddRefs(gIconLoad->mLoadingImage));
if (NS_FAILED(rv)) {
return rv;
}
rv = LoadIcon(brokenSrc, aPresContext,
getter_AddRefs(gIconLoad->mBrokenImage)); getter_AddRefs(gIconLoad->mBrokenImage));
if (NS_FAILED(rv)) {
return rv;
}
return rv;
} }
NS_IMPL_ISUPPORTS(IconLoad, imgINotificationObserver) NS_IMPL_ISUPPORTS(IconLoad, imgINotificationObserver)
void IconLoad::Shutdown() { void IconLoad::Shutdown() {
if (mLoadingImage) {
mLoadingImage->CancelAndForgetObserver(NS_ERROR_FAILURE);
mLoadingImage = nullptr;
}
if (mBrokenImage) { if (mBrokenImage) {
mBrokenImage->CancelAndForgetObserver(NS_ERROR_FAILURE); mBrokenImage->CancelAndForgetObserver(NS_ERROR_FAILURE);
mBrokenImage = nullptr; mBrokenImage = nullptr;

View file

@ -1276,14 +1276,6 @@
value: true value: true
mirror: always mirror: always
# If browser.display.show_image_placeholders is true then this controls whether
# the loading image placeholder and border is shown or not.
# TODO(emilio): Consider removing some or most of these image prefs.
- name: browser.display.show_loading_image_placeholder
type: bool
value: false
mirror: always
# Whether we should always enable focus rings after focus was moved by keyboard. # Whether we should always enable focus rings after focus was moved by keyboard.
# #
# This behavior matches both historical and GTK / Windows focus behavior. # This behavior matches both historical and GTK / Windows focus behavior.