diff options
author | Moonchild <moonchild@palemoon.org> | 2020-05-12 18:28:25 +0000 |
---|---|---|
committer | Moonchild <moonchild@palemoon.org> | 2020-05-12 18:28:25 +0000 |
commit | 17b82aa8202fcd8a38e5c11e0108e3a8ae87c235 (patch) | |
tree | a5b0f68a33c749f150d6ef84f7c55de0d9bf13bb /layout/generic | |
parent | b9f14b0d618c63e5938389770c48642bdb57b341 (diff) | |
download | aura-central-17b82aa8202fcd8a38e5c11e0108e3a8ae87c235.tar.gz |
Issue mcp-graveyard/UXP%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.
Diffstat (limited to 'layout/generic')
-rw-r--r-- | layout/generic/nsImageFrame.cpp | 26 |
1 files changed, 9 insertions, 17 deletions
diff --git a/layout/generic/nsImageFrame.cpp b/layout/generic/nsImageFrame.cpp index aed50c4ea..b96af66b5 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 |