icecat: add release icecat-140.6.0-1gnu1 for aramo

This commit is contained in:
Ark74 2026-01-17 18:56:47 -06:00
parent 92fef42cd6
commit 17ba0259bf
3382 changed files with 457689 additions and 569094 deletions

View file

@ -54,6 +54,7 @@
#include "mozilla/dom/ImageTracker.h"
#include "mozilla/dom/PageLoadEventUtils.h"
#include "mozilla/dom/ReferrerInfo.h"
#include "mozilla/dom/ResponsiveImageSelector.h"
#include "mozilla/dom/ScriptSettings.h"
#include "mozilla/intl/LocaleService.h"
#include "mozilla/intl/Locale.h"
@ -1275,18 +1276,100 @@ already_AddRefed<Promise> nsImageLoadingContent::RecognizeCurrentImageText(
return domPromise.forget();
}
CSSIntSize nsImageLoadingContent::NaturalSize(
DoDensityCorrection aDensityCorrection) {
if (!mCurrentRequest) {
return {};
}
nsCOMPtr<imgIContainer> image;
mCurrentRequest->GetImage(getter_AddRefs(image));
if (!image) {
return {};
}
mozilla::image::ImageIntrinsicSize intrinsicSize;
nsresult rv = image->GetIntrinsicSize(&intrinsicSize);
if (NS_FAILED(rv)) {
return {};
}
CSSIntSize size; // defaults to 0,0
if (!StaticPrefs::image_natural_size_fallback_enabled()) {
size.width = intrinsicSize.mWidth.valueOr(0);
size.height = intrinsicSize.mHeight.valueOr(0);
} else {
// Fallback case, for web-compatibility!
// See https://github.com/whatwg/html/issues/11287 and bug 1935269.
// If we lack an intrinsic size in either axis, then use the fallback size,
// unless we can transfer the size through the aspect ratio.
// (And if we *only* have an intrinsic aspect ratio, use the fallback width
// and transfer that through the aspect ratio to produce a height.)
size.width = intrinsicSize.mWidth.valueOr(kFallbackIntrinsicWidthInPixels);
size.height =
intrinsicSize.mHeight.valueOr(kFallbackIntrinsicHeightInPixels);
AspectRatio ratio = image->GetIntrinsicRatio();
if (ratio) {
if (!intrinsicSize.mHeight) {
// Compute the height from the width & ratio. (Note that the width we
// use here might be kFallbackIntrinsicWidthInPixels, and that's fine.)
size.height = ratio.Inverted().ApplyTo(size.width);
} else if (!intrinsicSize.mWidth) {
// Compute the width from the height & ratio.
size.width = ratio.ApplyTo(size.height);
}
}
}
ImageResolution resolution = image->GetResolution();
if (aDensityCorrection == DoDensityCorrection::Yes) {
// NOTE(emilio): What we implement here matches the image-set() spec, but
// it's unclear whether this is the right thing to do, see
// https://github.com/whatwg/html/pull/5574#issuecomment-826335244.
if (auto* image = HTMLImageElement::FromNode(AsContent())) {
if (auto* sel = image->GetResponsiveImageSelector()) {
float density = sel->GetSelectedImageDensity();
MOZ_ASSERT(density >= 0.0);
resolution.ScaleBy(density);
}
}
}
resolution.ApplyTo(size.width, size.height);
return size;
}
CSSIntSize nsImageLoadingContent::GetWidthHeightForImage() {
Element* element = AsContent()->AsElement();
if (nsIFrame* frame = element->GetPrimaryFrame(FlushType::Layout)) {
return CSSIntSize::FromAppUnitsRounded(frame->GetContentRect().Size());
}
const nsAttrValue* value;
CSSIntSize size;
nsCOMPtr<imgIContainer> image;
if (mCurrentRequest) {
if (StaticPrefs::image_natural_size_fallback_enabled()) {
// Our image is not rendered (we don't have any frame); so we should should
// return the natural size, per:
// https://html.spec.whatwg.org/multipage/embedded-content.html#dom-img-width
//
// Note that the spec says to use the "density-corrected natural width and
// height of the image", but we don't do that -- we specifically request
// the NaturalSize *without* density-correction here. This handles a case
// where browsers deviate from the spec in an interoperable way, which
// hopefully we'll address in the spec soon. See case (2) in this comment
// for more:
// https://github.com/whatwg/html/issues/11287#issuecomment-2923467541
size = NaturalSize(DoDensityCorrection::No);
} else if (mCurrentRequest) {
mCurrentRequest->GetImage(getter_AddRefs(image));
}
CSSIntSize size;
// If we have width or height attrs, we'll let those stomp on whatever
// NaturalSize we may have gotten above. This handles a case where browsers
// deviate from the spec in an interoperable way, which hopefully we'll
// address in the spec soon. See case (1) in this comment for more:
// https://github.com/whatwg/html/issues/11287#issuecomment-2923467541
const nsAttrValue* value;
if ((value = element->GetParsedAttr(nsGkAtoms::width)) &&
value->Type() == nsAttrValue::eInteger) {
size.width = value->GetIntegerValue();