mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-05 07:18:39 +09:00
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.
This commit is contained in:
parent
9e7397ac71
commit
4ac82173d9
2 changed files with 9 additions and 18 deletions
|
|
@ -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
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue