зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1815229 - Rename nsImageFrame::Kind::ImageElement to ImageLoadingContent. r=tnikkel,layout-reviewers
We are about to introduce a kind for <xul:image> elements, so this makes the naming less confusing. Differential Revision: https://phabricator.services.mozilla.com/D169981
This commit is contained in:
Родитель
845d0abe27
Коммит
d75756ca11
|
@ -309,7 +309,7 @@ void nsImageLoadingContent::OnImageIsAnimated(imgIRequest* aRequest) {
|
|||
|
||||
static bool IsOurImageFrame(nsIFrame* aFrame) {
|
||||
if (nsImageFrame* f = do_QueryFrame(aFrame)) {
|
||||
return f->IsForElement();
|
||||
return f->IsForImageLoadingContent();
|
||||
}
|
||||
return aFrame->IsSVGImageFrame() || aFrame->IsSVGFEImageFrame();
|
||||
}
|
||||
|
|
|
@ -240,7 +240,7 @@ static bool SizeDependsOnIntrinsicSize(const ReflowInput& aReflowInput) {
|
|||
|
||||
nsIFrame* NS_NewImageFrame(PresShell* aPresShell, ComputedStyle* aStyle) {
|
||||
return new (aPresShell) nsImageFrame(aStyle, aPresShell->GetPresContext(),
|
||||
nsImageFrame::Kind::ImageElement);
|
||||
nsImageFrame::Kind::ImageLoadingContent);
|
||||
}
|
||||
|
||||
nsIFrame* NS_NewImageFrameForContentProperty(PresShell* aPresShell,
|
||||
|
@ -266,7 +266,7 @@ bool nsImageFrame::ShouldShowBrokenImageIcon() const {
|
|||
// NOTE(emilio, https://github.com/w3c/csswg-drafts/issues/2832): WebKit and
|
||||
// Blink behave differently here for content: url(..), for now adapt to
|
||||
// Blink's behavior.
|
||||
if (mKind != Kind::ImageElement) {
|
||||
if (mKind != Kind::ImageLoadingContent) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -370,7 +370,7 @@ void nsImageFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
|||
|
||||
MOZ_ASSERT(mListener);
|
||||
|
||||
if (mKind == Kind::ImageElement) {
|
||||
if (mKind == Kind::ImageLoadingContent) {
|
||||
MOZ_ASSERT(!mContentURLRequest);
|
||||
MOZ_ASSERT(!mContentURLRequestRegistered);
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
|
@ -398,7 +398,7 @@ void nsImageFrame::DestroyFrom(nsIFrame* aDestructRoot,
|
|||
}
|
||||
|
||||
void nsImageFrame::MaybeRecordContentUrlOnImageTelemetry() {
|
||||
if (mKind != Kind::ImageElement) {
|
||||
if (mKind != Kind::ImageLoadingContent) {
|
||||
return;
|
||||
}
|
||||
const auto& content = *StyleContent();
|
||||
|
@ -465,7 +465,7 @@ static bool SizeIsAvailable(imgIRequest* aRequest) {
|
|||
}
|
||||
|
||||
const StyleImage* nsImageFrame::GetImageFromStyle() const {
|
||||
if (mKind == Kind::ImageElement) {
|
||||
if (mKind == Kind::ImageLoadingContent) {
|
||||
MOZ_ASSERT_UNREACHABLE("Don't call me");
|
||||
return nullptr;
|
||||
}
|
||||
|
@ -520,7 +520,7 @@ void nsImageFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|||
LoadIcons(PresContext());
|
||||
}
|
||||
|
||||
if (mKind == Kind::ImageElement) {
|
||||
if (mKind == Kind::ImageLoadingContent) {
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(aContent);
|
||||
MOZ_ASSERT(imageLoader);
|
||||
imageLoader->AddNativeObserver(mListener);
|
||||
|
@ -563,7 +563,7 @@ void nsImageFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
|
|||
}
|
||||
|
||||
void nsImageFrame::SetupForContentURLRequest() {
|
||||
MOZ_ASSERT(mKind != Kind::ImageElement);
|
||||
MOZ_ASSERT(mKind != Kind::ImageLoadingContent);
|
||||
if (!mContentURLRequest) {
|
||||
return;
|
||||
}
|
||||
|
@ -655,7 +655,7 @@ static IntrinsicSize ComputeIntrinsicSize(imgIContainer* aImage,
|
|||
}
|
||||
}
|
||||
}
|
||||
if (aKind == nsImageFrame::Kind::ImageElement) {
|
||||
if (aKind == nsImageFrame::Kind::ImageLoadingContent) {
|
||||
ScaleIntrinsicSizeForDensity(aImage, *aFrame.GetContent(), intrinsicSize);
|
||||
} else {
|
||||
ScaleIntrinsicSizeForDensity(intrinsicSize,
|
||||
|
@ -691,7 +691,7 @@ static IntrinsicSize ComputeIntrinsicSize(imgIContainer* aImage,
|
|||
// But we shouldn't get fooled by <img loading=lazy>. We do want to apply the
|
||||
// ratio then...
|
||||
bool nsImageFrame::ShouldUseMappedAspectRatio() const {
|
||||
if (mKind != Kind::ImageElement) {
|
||||
if (mKind != Kind::ImageLoadingContent) {
|
||||
return true;
|
||||
}
|
||||
nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest();
|
||||
|
@ -780,7 +780,7 @@ bool nsImageFrame::GetSourceToDestTransform(nsTransform2D& aTransform) {
|
|||
// mContent.
|
||||
bool nsImageFrame::IsPendingLoad(imgIRequest* aRequest) const {
|
||||
// Default to pending load in case of errors
|
||||
if (mKind != Kind::ImageElement) {
|
||||
if (mKind != Kind::ImageLoadingContent) {
|
||||
MOZ_ASSERT(aRequest == mContentURLRequest);
|
||||
return false;
|
||||
}
|
||||
|
@ -913,7 +913,7 @@ void nsImageFrame::Notify(imgIRequest* aRequest, int32_t aType,
|
|||
}
|
||||
|
||||
if (aType == imgINotificationObserver::IS_ANIMATED &&
|
||||
mKind != Kind::ImageElement) {
|
||||
mKind != Kind::ImageLoadingContent) {
|
||||
nsLayoutUtils::RegisterImageRequest(PresContext(), mContentURLRequest,
|
||||
&mContentURLRequestRegistered);
|
||||
}
|
||||
|
@ -1078,7 +1078,7 @@ void nsImageFrame::ElementStateChanged(ElementState aStates) {
|
|||
if (!(aStates & ElementState::BROKEN)) {
|
||||
return;
|
||||
}
|
||||
if (mKind != Kind::ImageElement) {
|
||||
if (mKind != Kind::ImageLoadingContent) {
|
||||
return;
|
||||
}
|
||||
if (!ImageOk(mContent->AsElement()->State())) {
|
||||
|
@ -1205,7 +1205,7 @@ nsRect nsImageFrame::PredictedDestRect(const nsRect& aFrameContentBox) {
|
|||
}
|
||||
|
||||
bool nsImageFrame::IsForMarkerPseudo() const {
|
||||
if (mKind == Kind::ImageElement) {
|
||||
if (mKind == Kind::ImageLoadingContent) {
|
||||
return false;
|
||||
}
|
||||
auto* subtreeRoot = GetContent()->GetClosestNativeAnonymousSubtreeRoot();
|
||||
|
@ -1379,8 +1379,8 @@ void nsImageFrame::Reflow(nsPresContext* aPresContext, ReflowOutput& aMetrics,
|
|||
}
|
||||
|
||||
aMetrics.SetOverflowAreasToDesiredBounds();
|
||||
bool imageOK =
|
||||
mKind != Kind::ImageElement || ImageOk(mContent->AsElement()->State());
|
||||
bool imageOK = mKind != Kind::ImageLoadingContent ||
|
||||
ImageOk(mContent->AsElement()->State());
|
||||
|
||||
// Determine if the size is available
|
||||
bool haveSize = false;
|
||||
|
@ -1667,8 +1667,8 @@ ImgDrawResult nsImageFrame::DisplayAltFeedback(gfxContext& aRenderingContext,
|
|||
MOZ_ASSERT(gIconLoad, "How did we succeed in Init then?");
|
||||
|
||||
// Whether we draw the broken or loading icon.
|
||||
bool isLoading =
|
||||
mKind != Kind::ImageElement || ImageOk(mContent->AsElement()->State());
|
||||
bool isLoading = mKind != Kind::ImageLoadingContent ||
|
||||
ImageOk(mContent->AsElement()->State());
|
||||
|
||||
// Calculate the content area.
|
||||
nsRect inner = GetContentRectRelativeToSelf() + aPt;
|
||||
|
@ -1822,8 +1822,8 @@ ImgDrawResult nsImageFrame::DisplayAltFeedbackWithoutLayer(
|
|||
MOZ_ASSERT(gIconLoad, "How did we succeed in Init then?");
|
||||
|
||||
// Whether we draw the broken or loading icon.
|
||||
bool isLoading =
|
||||
mKind != Kind::ImageElement || ImageOk(mContent->AsElement()->State());
|
||||
bool isLoading = mKind != Kind::ImageLoadingContent ||
|
||||
ImageOk(mContent->AsElement()->State());
|
||||
|
||||
// Calculate the content area.
|
||||
nsRect inner = GetContentRectRelativeToSelf() + aPt;
|
||||
|
@ -2072,7 +2072,7 @@ static bool OldImageHasDifferentRatio(const nsImageFrame& aFrame,
|
|||
|
||||
#ifdef DEBUG
|
||||
void nsImageFrame::AssertSyncDecodingHintIsInSync() const {
|
||||
if (!IsForElement()) {
|
||||
if (!IsForImageLoadingContent()) {
|
||||
return;
|
||||
}
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
|
@ -2304,7 +2304,7 @@ ImgDrawResult nsImageFrame::PaintImage(gfxContext& aRenderingContext,
|
|||
}
|
||||
|
||||
already_AddRefed<imgIRequest> nsImageFrame::GetCurrentRequest() const {
|
||||
if (mKind != Kind::ImageElement) {
|
||||
if (mKind != Kind::ImageLoadingContent) {
|
||||
return do_AddRef(mContentURLRequest);
|
||||
}
|
||||
|
||||
|
@ -2341,15 +2341,15 @@ void nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
aBuilder, this, clipFlags);
|
||||
|
||||
if (mComputedSize.width != 0 && mComputedSize.height != 0) {
|
||||
bool imageOK =
|
||||
mKind != Kind::ImageElement || ImageOk(mContent->AsElement()->State());
|
||||
bool imageOK = mKind != Kind::ImageLoadingContent ||
|
||||
ImageOk(mContent->AsElement()->State());
|
||||
|
||||
nsCOMPtr<imgIRequest> currentRequest = GetCurrentRequest();
|
||||
|
||||
// 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
|
||||
// currently some code that violates this invariant.
|
||||
if ((mKind == Kind::ImageElement ||
|
||||
if ((mKind == Kind::ImageLoadingContent ||
|
||||
GetImageFromStyle()->IsImageRequestType()) &&
|
||||
(!imageOK || !mImage || !SizeIsAvailable(currentRequest))) {
|
||||
// No image yet, or image load failed. Draw the alt-text and an icon
|
||||
|
@ -2374,7 +2374,7 @@ void nsImageFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
|
|||
if (mImage) {
|
||||
aLists.Content()->AppendNewToTop<nsDisplayImage>(aBuilder, this, mImage,
|
||||
mPrevImage);
|
||||
} else if (mKind != Kind::ImageElement) {
|
||||
} else if (mKind != Kind::ImageLoadingContent) {
|
||||
aLists.Content()->AppendNewToTop<nsDisplayGradient>(aBuilder, this);
|
||||
}
|
||||
|
||||
|
@ -2464,7 +2464,7 @@ bool nsImageFrame::GetAnchorHREFTargetAndNode(nsIURI** aHref, nsString& aTarget,
|
|||
}
|
||||
|
||||
bool nsImageFrame::IsLeafDynamic() const {
|
||||
if (mKind != Kind::ImageElement) {
|
||||
if (mKind != Kind::ImageLoadingContent) {
|
||||
// Image frames created for "content: url()" could have an author-controlled
|
||||
// shadow root, we want to be a regular leaf for those.
|
||||
return true;
|
||||
|
@ -2616,7 +2616,7 @@ nsresult nsImageFrame::AttributeChanged(int32_t aNameSpaceID,
|
|||
|
||||
void nsImageFrame::OnVisibilityChange(
|
||||
Visibility aNewVisibility, const Maybe<OnNonvisible>& aNonvisibleAction) {
|
||||
if (mKind == Kind::ImageElement) {
|
||||
if (mKind == Kind::ImageLoadingContent) {
|
||||
nsCOMPtr<nsIImageLoadingContent> imageLoader = do_QueryInterface(mContent);
|
||||
imageLoader->OnVisibilityChange(aNewVisibility, aNonvisibleAction);
|
||||
}
|
||||
|
|
|
@ -103,7 +103,9 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
|
|||
void SetupForContentURLRequest();
|
||||
bool ShouldShowBrokenImageIcon() const;
|
||||
|
||||
bool IsForElement() const { return mKind == Kind::ImageElement; }
|
||||
bool IsForImageLoadingContent() const {
|
||||
return mKind == Kind::ImageLoadingContent;
|
||||
}
|
||||
|
||||
const mozilla::StyleImage* GetImageFromStyle() const;
|
||||
|
||||
|
@ -190,7 +192,7 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
|
|||
// The kind of image frame we are.
|
||||
enum class Kind : uint8_t {
|
||||
// For an nsImageLoadingContent.
|
||||
ImageElement,
|
||||
ImageLoadingContent,
|
||||
// For css 'content: url(..)' on non-generated content.
|
||||
ContentProperty,
|
||||
// For a child of a ::before / ::after pseudo-element that had an url() item
|
||||
|
@ -225,7 +227,7 @@ class nsImageFrame : public nsAtomicContainerFrame, public nsIReflowCallback {
|
|||
|
||||
protected:
|
||||
nsImageFrame(ComputedStyle* aStyle, nsPresContext* aPresContext, ClassID aID)
|
||||
: nsImageFrame(aStyle, aPresContext, aID, Kind::ImageElement) {}
|
||||
: nsImageFrame(aStyle, aPresContext, aID, Kind::ImageLoadingContent) {}
|
||||
|
||||
~nsImageFrame() override;
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче