summaryrefslogtreecommitdiffstats
path: root/layout/svg
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-15 03:35:49 +0000
commitd8bbc7858622b6d9c278469aab701ca0b609cddf (patch)
treeeff41dc61d9f714852212739e6b3738b82a2af87 /layout/svg
parentReleasing progress-linux version 125.0.3-1~progress7.99u1. (diff)
downloadfirefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.tar.xz
firefox-d8bbc7858622b6d9c278469aab701ca0b609cddf.zip
Merging upstream version 126.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'layout/svg')
-rw-r--r--layout/svg/CSSClipPathInstance.cpp43
-rw-r--r--layout/svg/CSSClipPathInstance.h3
-rw-r--r--layout/svg/SVGAFrame.cpp14
-rw-r--r--layout/svg/SVGContextPaint.cpp2
-rw-r--r--layout/svg/SVGFEImageFrame.cpp18
-rw-r--r--layout/svg/SVGGradientFrame.cpp9
-rw-r--r--layout/svg/SVGImageFrame.cpp20
-rw-r--r--layout/svg/SVGOuterSVGFrame.cpp9
-rw-r--r--layout/svg/SVGUseFrame.cpp13
-rw-r--r--layout/svg/SVGUseFrame.h2
10 files changed, 45 insertions, 88 deletions
diff --git a/layout/svg/CSSClipPathInstance.cpp b/layout/svg/CSSClipPathInstance.cpp
index 77bde2bb54..a8e0306d3e 100644
--- a/layout/svg/CSSClipPathInstance.cpp
+++ b/layout/svg/CSSClipPathInstance.cpp
@@ -66,7 +66,7 @@ bool CSSClipPathInstance::HitTestBasicShapeOrPathClip(nsIFrame* aFrame,
RefPtr<Path> path = instance.CreateClipPath(
drawTarget, SVGUtils::GetCSSPxToDevPxMatrix(aFrame));
float pixelRatio = float(AppUnitsPerCSSPixel()) /
- aFrame->PresContext()->AppUnitsPerDevPixel();
+ float(aFrame->PresContext()->AppUnitsPerDevPixel());
return path && path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix());
}
@@ -121,8 +121,10 @@ already_AddRefed<Path> CSSClipPathInstance::CreateClipPath(
return CreateClipPathPolygon(aDrawTarget, r);
case StyleBasicShape::Tag::Rect:
return CreateClipPathInset(aDrawTarget, r);
- case StyleBasicShape::Tag::Path:
- return CreateClipPathPath(aDrawTarget, r);
+ case StyleBasicShape::Tag::PathOrShape:
+ return basicShape.AsPathOrShape().IsPath()
+ ? CreateClipPathPath(aDrawTarget, r)
+ : CreateClipPathShape(aDrawTarget, r);
default:
MOZ_MAKE_COMPILER_ASSUME_IS_UNREACHABLE("Unexpected shape type");
}
@@ -175,18 +177,41 @@ already_AddRefed<Path> CSSClipPathInstance::CreateClipPathInset(
already_AddRefed<Path> CSSClipPathInstance::CreateClipPathPath(
DrawTarget* aDrawTarget, const nsRect& aRefBox) {
- const auto& path = mClipPathStyle.AsShape()._0->AsPath();
+ const auto& path = mClipPathStyle.AsShape()._0->AsPathOrShape().AsPath();
RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder(
path.fill == StyleFillRule::Nonzero ? FillRule::FILL_WINDING
: FillRule::FILL_EVEN_ODD);
- nscoord appUnitsPerDevPixel =
+ const nscoord appUnitsPerDevPixel =
mTargetFrame->PresContext()->AppUnitsPerDevPixel();
- float scale = float(AppUnitsPerCSSPixel()) / appUnitsPerDevPixel;
- Point offset = Point(aRefBox.x, aRefBox.y) / appUnitsPerDevPixel;
-
+ const Point offset =
+ LayoutDevicePoint::FromAppUnits(aRefBox.TopLeft(), appUnitsPerDevPixel)
+ .ToUnknownPoint();
+ const float scale = mTargetFrame->Style()->EffectiveZoom().Zoom(
+ float(AppUnitsPerCSSPixel()) / float(appUnitsPerDevPixel));
return SVGPathData::BuildPath(path.path._0.AsSpan(), builder,
- StyleStrokeLinecap::Butt, 0.0, offset, scale);
+ StyleStrokeLinecap::Butt, 0.0, {}, offset,
+ scale);
+}
+
+already_AddRefed<Path> CSSClipPathInstance::CreateClipPathShape(
+ DrawTarget* aDrawTarget, const nsRect& aRefBox) {
+ const auto& shape = mClipPathStyle.AsShape()._0->AsPathOrShape().AsShape();
+
+ RefPtr<PathBuilder> builder = aDrawTarget->CreatePathBuilder(
+ shape.fill == StyleFillRule::Nonzero ? FillRule::FILL_WINDING
+ : FillRule::FILL_EVEN_ODD);
+ const nscoord appUnitsPerDevPixel =
+ mTargetFrame->PresContext()->AppUnitsPerDevPixel();
+ const CSSSize basis = CSSSize::FromAppUnits(aRefBox.Size());
+ const Point offset =
+ LayoutDevicePoint::FromAppUnits(aRefBox.TopLeft(), appUnitsPerDevPixel)
+ .ToUnknownPoint();
+ const float scale = mTargetFrame->Style()->EffectiveZoom().Zoom(
+ float(AppUnitsPerCSSPixel()) / float(appUnitsPerDevPixel));
+ return SVGPathData::BuildPath(shape.commands.AsSpan(), builder,
+ StyleStrokeLinecap::Butt, 0.0, basis, offset,
+ scale);
}
} // namespace mozilla
diff --git a/layout/svg/CSSClipPathInstance.h b/layout/svg/CSSClipPathInstance.h
index 2d1e16c62f..2cec8c125f 100644
--- a/layout/svg/CSSClipPathInstance.h
+++ b/layout/svg/CSSClipPathInstance.h
@@ -58,6 +58,9 @@ class MOZ_STACK_CLASS CSSClipPathInstance {
already_AddRefed<Path> CreateClipPathPath(DrawTarget* aDrawTarget,
const nsRect& aRefBox);
+ already_AddRefed<Path> CreateClipPathShape(DrawTarget* aDrawTarget,
+ const nsRect& aRefBox);
+
/**
* The frame for the element that is currently being clipped.
*/
diff --git a/layout/svg/SVGAFrame.cpp b/layout/svg/SVGAFrame.cpp
index 02ff68d7e7..3d09cdc3f5 100644
--- a/layout/svg/SVGAFrame.cpp
+++ b/layout/svg/SVGAFrame.cpp
@@ -82,20 +82,6 @@ nsresult SVGAFrame::AttributeChanged(int32_t aNameSpaceID, nsAtom* aAttribute,
NotifySVGChanged(TRANSFORM_CHANGED);
}
- // Currently our SMIL implementation does not modify the DOM attributes. Once
- // we implement the SVG 2 SMIL behaviour this can be removed
- // SVGAElement::SetAttr/UnsetAttr's ResetLinkState() call will be sufficient.
- if (aModType == dom::MutationEvent_Binding::SMIL &&
- aAttribute == nsGkAtoms::href &&
- (aNameSpaceID == kNameSpaceID_None ||
- aNameSpaceID == kNameSpaceID_XLink)) {
- auto* content = static_cast<dom::SVGAElement*>(GetContent());
-
- // SMIL may change whether an <a> element is a link, in which case we will
- // need to update the link state.
- content->ResetLinkState(true, content->ElementHasHref());
- }
-
return NS_OK;
}
diff --git a/layout/svg/SVGContextPaint.cpp b/layout/svg/SVGContextPaint.cpp
index 0d7a610df9..e135ea2db3 100644
--- a/layout/svg/SVGContextPaint.cpp
+++ b/layout/svg/SVGContextPaint.cpp
@@ -80,7 +80,7 @@ bool SVGContextPaint::IsAllowedForImageFromURI(nsIURI* aURI) {
// Only allowed for extensions that have the
// internal:svgContextPropertiesAllowed permission (added internally from
// to Mozilla-owned extensions, see `isMozillaExtension` function
- // defined in Extension.jsm for the exact criteria).
+ // defined in Extension.sys.mjs for the exact criteria).
return addonPolicy->HasPermission(
nsGkAtoms::svgContextPropertiesAllowedPermission);
}
diff --git a/layout/svg/SVGFEImageFrame.cpp b/layout/svg/SVGFEImageFrame.cpp
index 50fb42cd68..d89ed566f1 100644
--- a/layout/svg/SVGFEImageFrame.cpp
+++ b/layout/svg/SVGFEImageFrame.cpp
@@ -121,24 +121,6 @@ nsresult SVGFEImageFrame::AttributeChanged(int32_t aNameSpaceID,
SVGObserverUtils::InvalidateRenderingObservers(GetParent());
}
- // Currently our SMIL implementation does not modify the DOM attributes. Once
- // we implement the SVG 2 SMIL behaviour this can be removed
- // SVGFEImageElement::AfterSetAttr's implementation will be sufficient.
- if (aModType == MutationEvent_Binding::SMIL &&
- aAttribute == nsGkAtoms::href &&
- (aNameSpaceID == kNameSpaceID_XLink ||
- aNameSpaceID == kNameSpaceID_None)) {
- bool hrefIsSet =
- element->mStringAttributes[SVGFEImageElement::HREF].IsExplicitlySet() ||
- element->mStringAttributes[SVGFEImageElement::XLINK_HREF]
- .IsExplicitlySet();
- if (hrefIsSet) {
- element->LoadSVGImage(true, true);
- } else {
- element->CancelImageRequests(true);
- }
- }
-
return nsIFrame::AttributeChanged(aNameSpaceID, aAttribute, aModType);
}
diff --git a/layout/svg/SVGGradientFrame.cpp b/layout/svg/SVGGradientFrame.cpp
index 92558cefcd..be6f395cda 100644
--- a/layout/svg/SVGGradientFrame.cpp
+++ b/layout/svg/SVGGradientFrame.cpp
@@ -244,8 +244,10 @@ class MOZ_STACK_CLASS SVGColorStopInterpolator
public:
SVGColorStopInterpolator(
gfxPattern* aGradient, const nsTArray<ColorStop>& aStops,
- const StyleColorInterpolationMethod& aStyleColorInterpolationMethod)
- : ColorStopInterpolator(aStops, aStyleColorInterpolationMethod),
+ const StyleColorInterpolationMethod& aStyleColorInterpolationMethod,
+ bool aExtendLastStop)
+ : ColorStopInterpolator(aStops, aStyleColorInterpolationMethod,
+ aExtendLastStop),
mGradient(aGradient) {}
void CreateStop(float aPosition, DeviceColor aColor) {
@@ -327,7 +329,8 @@ already_AddRefed<gfxPattern> SVGGradientFrame::GetPaintServerPattern(
if (StyleSVG()->mColorInterpolation == StyleColorInterpolation::Linearrgb) {
static constexpr auto interpolationMethod = StyleColorInterpolationMethod{
StyleColorSpace::SrgbLinear, StyleHueInterpolationMethod::Shorter};
- SVGColorStopInterpolator interpolator(gradient, stops, interpolationMethod);
+ SVGColorStopInterpolator interpolator(gradient, stops, interpolationMethod,
+ false);
interpolator.CreateStops();
} else {
// setup standard sRGB stops
diff --git a/layout/svg/SVGImageFrame.cpp b/layout/svg/SVGImageFrame.cpp
index 242ee6e25e..35693e87c0 100644
--- a/layout/svg/SVGImageFrame.cpp
+++ b/layout/svg/SVGImageFrame.cpp
@@ -191,26 +191,6 @@ nsresult SVGImageFrame::AttributeChanged(int32_t aNameSpaceID,
}
}
- // Currently our SMIL implementation does not modify the DOM attributes. Once
- // we implement the SVG 2 SMIL behaviour this can be removed
- // SVGImageElement::AfterSetAttr's implementation will be sufficient.
- if (aModType == MutationEvent_Binding::SMIL &&
- aAttribute == nsGkAtoms::href &&
- (aNameSpaceID == kNameSpaceID_XLink ||
- aNameSpaceID == kNameSpaceID_None)) {
- SVGImageElement* element = static_cast<SVGImageElement*>(GetContent());
-
- bool hrefIsSet =
- element->mStringAttributes[SVGImageElement::HREF].IsExplicitlySet() ||
- element->mStringAttributes[SVGImageElement::XLINK_HREF]
- .IsExplicitlySet();
- if (hrefIsSet) {
- element->LoadSVGImage(true, true);
- } else {
- element->CancelImageRequests(true);
- }
- }
-
return NS_OK;
}
diff --git a/layout/svg/SVGOuterSVGFrame.cpp b/layout/svg/SVGOuterSVGFrame.cpp
index ea0879c0c2..d88327f059 100644
--- a/layout/svg/SVGOuterSVGFrame.cpp
+++ b/layout/svg/SVGOuterSVGFrame.cpp
@@ -126,20 +126,14 @@ NS_QUERYFRAME_TAIL_INHERITING(SVGDisplayContainerFrame)
/* virtual */
nscoord SVGOuterSVGFrame::GetMinISize(gfxContext* aRenderingContext) {
- nscoord result;
- DISPLAY_MIN_INLINE_SIZE(this, result);
-
// If this ever changes to return something other than zero, then
// nsSubDocumentFrame::GetMinISize will also need to change.
- result = nscoord(0);
-
- return result;
+ return 0;
}
/* virtual */
nscoord SVGOuterSVGFrame::GetPrefISize(gfxContext* aRenderingContext) {
nscoord result;
- DISPLAY_PREF_INLINE_SIZE(this, result);
SVGSVGElement* svg = static_cast<SVGSVGElement*>(GetContent());
WritingMode wm = GetWritingMode();
@@ -325,7 +319,6 @@ void SVGOuterSVGFrame::Reflow(nsPresContext* aPresContext,
nsReflowStatus& aStatus) {
MarkInReflow();
DO_GLOBAL_REFLOW_COUNT("SVGOuterSVGFrame");
- DISPLAY_REFLOW(aPresContext, this, aReflowInput, aDesiredSize, aStatus);
MOZ_ASSERT(aStatus.IsEmpty(), "Caller should pass a fresh reflow status!");
NS_FRAME_TRACE(
NS_FRAME_TRACE_CALLS,
diff --git a/layout/svg/SVGUseFrame.cpp b/layout/svg/SVGUseFrame.cpp
index c655f7b24f..e356895208 100644
--- a/layout/svg/SVGUseFrame.cpp
+++ b/layout/svg/SVGUseFrame.cpp
@@ -42,19 +42,6 @@ void SVGUseFrame::Init(nsIContent* aContent, nsContainerFrame* aParent,
SVGGFrame::Init(aContent, aParent, aPrevInFlow);
}
-nsresult SVGUseFrame::AttributeChanged(int32_t aNamespaceID, nsAtom* aAttribute,
- int32_t aModType) {
- // Currently our SMIL implementation does not modify the DOM attributes. Once
- // we implement the SVG 2 SMIL behaviour this can be removed
- // SVGUseElement::AfterSetAttr's implementation will be sufficient.
- if (aModType == MutationEvent_Binding::SMIL) {
- auto* content = SVGUseElement::FromNode(GetContent());
- content->ProcessAttributeChange(aNamespaceID, aAttribute);
- }
-
- return SVGGFrame::AttributeChanged(aNamespaceID, aAttribute, aModType);
-}
-
void SVGUseFrame::DidSetComputedStyle(ComputedStyle* aOldComputedStyle) {
SVGGFrame::DidSetComputedStyle(aOldComputedStyle);
diff --git a/layout/svg/SVGUseFrame.h b/layout/svg/SVGUseFrame.h
index b72d29247a..a528522991 100644
--- a/layout/svg/SVGUseFrame.h
+++ b/layout/svg/SVGUseFrame.h
@@ -41,8 +41,6 @@ class SVGUseFrame final : public SVGGFrame {
void DimensionAttributeChanged(bool aHadValidDimensions,
bool aAttributeIsUsed);
- nsresult AttributeChanged(int32_t aNamespaceID, nsAtom* aAttribute,
- int32_t aModType) override;
void DidSetComputedStyle(ComputedStyle* aOldComputedStyle) override;
#ifdef DEBUG_FRAME_DUMP