summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMoonchild <moonchild@palemoon.org>2020-05-12 18:28:25 +0000
committerMoonchild <moonchild@palemoon.org>2020-05-20 13:50:04 +0000
commita444b5cc390cbf522671e7a3f7c35fb4cadd3bb0 (patch)
tree265426c26f75a113cbda70a2864793a2de5cb3ac
parentd050188cd525b769d33e2a2d94454b32aaa0b622 (diff)
downloadUXP-a444b5cc390cbf522671e7a3f7c35fb4cadd3bb0.tar
UXP-a444b5cc390cbf522671e7a3f7c35fb4cadd3bb0.tar.gz
UXP-a444b5cc390cbf522671e7a3f7c35fb4cadd3bb0.tar.lz
UXP-a444b5cc390cbf522671e7a3f7c35fb4cadd3bb0.tar.xz
UXP-a444b5cc390cbf522671e7a3f7c35fb4cadd3bb0.zip
Issue #1543 - Follow-up: avoid displaying the Alt text if an image is loading.
This prevents the Alt text from briefly being shown before being replaced with the image.
-rw-r--r--layout/generic/nsImageFrame.cpp26
-rw-r--r--layout/style/res/html.css1
2 files changed, 9 insertions, 18 deletions
diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp
index 226cca2cf..03fcbd8e3 100644
--- a/layout/generic/nsImageFrame.cpp
+++ b/layout/generic/nsImageFrame.cpp
@@ -430,15 +430,11 @@ nsImageFrame::SourceRectToDest(const nsIntRect& aRect)
// that we'll construct image frames for them as needed if their display is
// toggled from "none" (though we won't paint them, unless their visibility
// is changed too).
-#define BAD_STATES (NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED | \
- NS_EVENT_STATE_LOADING)
+#define BAD_STATES (NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED)
-// This is a macro so that we don't evaluate the boolean last arg
-// unless we have to; it can be expensive
-#define IMAGE_OK(_state, _loadingOK) \
- (!(_state).HasAtLeastOneOfStates(BAD_STATES) || \
- (!(_state).HasAtLeastOneOfStates(NS_EVENT_STATE_BROKEN | NS_EVENT_STATE_USERDISABLED) && \
- (_state).HasState(NS_EVENT_STATE_LOADING) && (_loadingOK)))
+static bool ImageOk(EventStates aState) {
+ return !aState.HasAtLeastOneOfStates(BAD_STATES);
+}
static bool HasAltText(Element* aElement)
{
@@ -459,10 +455,8 @@ static bool HasAltText(Element* aElement)
nsImageFrame::ShouldCreateImageFrameFor(Element* aElement,
nsStyleContext* aStyleContext)
{
- EventStates state = aElement->State();
- if (IMAGE_OK(state,
- HaveSpecifiedSize(aStyleContext->StylePosition()))) {
- // Image is fine; do the image frame thing
+ if (ImageOk(aElement->State())) {
+ // Image is fine or loading; do the image frame thing
return true;
}
@@ -1016,8 +1010,7 @@ nsImageFrame::Reflow(nsPresContext* aPresContext,
}
aMetrics.SetOverflowAreasToDesiredBounds();
- EventStates contentState = mContent->AsElement()->State();
- bool imageOK = IMAGE_OK(contentState, true);
+ bool imageOK = ImageOk(mContent->AsElement()->State());
// Determine if the size is available
bool haveSize = false;
@@ -1336,7 +1329,7 @@ nsImageFrame::DisplayAltFeedback(nsRenderingContext& aRenderingContext,
MOZ_ASSERT(gIconLoad, "How did we succeed in Init then?");
// Whether we draw the broken or loading icon.
- bool isLoading = IMAGE_OK(GetContent()->AsElement()->State(), true);
+ bool isLoading = ImageOk(mContent->AsElement()->State());
// Calculate the inner area
nsRect inner = GetInnerArea() + aPt;
@@ -1756,8 +1749,7 @@ nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
getter_AddRefs(currentRequest));
}
- EventStates contentState = mContent->AsElement()->State();
- bool imageOK = IMAGE_OK(contentState, true);
+ bool imageOK = ImageOk(mContent->AsElement()->State());
// XXX(seth): The SizeIsAvailable check here should not be necessary - the
// intention is that a non-null mImage means we have a size, but there is
diff --git a/layout/style/res/html.css b/layout/style/res/html.css
index 1f572467f..44e41c8d0 100644
--- a/layout/style/res/html.css
+++ b/layout/style/res/html.css
@@ -637,7 +637,6 @@ hr[size="1"] {
img:-moz-broken::before, input:-moz-broken::before,
img:-moz-user-disabled::before, input:-moz-user-disabled::before,
-img:-moz-loading::before, input:-moz-loading::before,
applet:-moz-empty-except-children-with-localname(param):-moz-broken::before,
applet:-moz-empty-except-children-with-localname(param):-moz-user-disabled::before {
content: -moz-alt-content !important;