From 875f5e88ace701d28c2b2b2f1f6145af5bff3e1b Mon Sep 17 00:00:00 2001 From: longsonr Date: Sat, 11 Jul 2020 02:20:20 +0000 Subject: [PATCH] Bug 1259861 - Move everything else into the mozilla namespace in layout/svg r=dholbert Also: adjust include paths to be consistent for usages of various SVG headers, and remove unused SVG includes (mostly for "utils" classes), and drop stray "ns" from already-renamed SVG classes in various code comments. Differential Revision: https://phabricator.services.mozilla.com/D83140 --- dom/base/Document.cpp | 1 - dom/base/DocumentOrShadowRoot.cpp | 5 +- dom/base/Element.cpp | 1 - dom/base/FragmentOrElement.cpp | 1 - dom/base/ResizeObserver.cpp | 4 +- dom/base/nsINode.cpp | 1 - dom/html/HTMLScriptElement.cpp | 4 +- dom/smil/SMILTimedElement.cpp | 2 +- dom/smil/SMILTimedElement.h | 2 +- dom/svg/SVGAnimatedLength.cpp | 4 +- dom/svg/SVGAnimatedTransformList.cpp | 2 +- dom/svg/SVGCircleElement.h | 2 +- dom/svg/SVGContentUtils.cpp | 4 +- dom/svg/SVGContentUtils.h | 6 +- dom/svg/SVGElement.h | 4 +- dom/svg/SVGEllipseElement.h | 2 +- dom/svg/SVGFEBlendElement.cpp | 1 - dom/svg/SVGFEColorMatrixElement.cpp | 1 - dom/svg/SVGFEComponentTransferElement.cpp | 1 - dom/svg/SVGFEConvolveMatrixElement.cpp | 1 - dom/svg/SVGFEDiffuseLightingElement.cpp | 1 - dom/svg/SVGFEDisplacementMapElement.cpp | 1 - dom/svg/SVGFEGaussianBlurElement.cpp | 1 - dom/svg/SVGFEImageElement.cpp | 3 +- dom/svg/SVGFESpecularLightingElement.cpp | 1 - dom/svg/SVGFETurbulenceElement.cpp | 1 - dom/svg/SVGFilterElement.cpp | 2 - dom/svg/SVGFilterElement.h | 2 +- dom/svg/SVGFilters.cpp | 1 - dom/svg/SVGGeometryElement.cpp | 1 - dom/svg/SVGImageElement.h | 2 +- dom/svg/SVGMarkerElement.h | 2 +- dom/svg/SVGMaskElement.h | 2 +- dom/svg/SVGPathElement.h | 2 +- dom/svg/SVGPatternElement.h | 2 +- dom/svg/SVGRectElement.h | 2 +- dom/svg/SVGSVGElement.cpp | 6 +- dom/svg/SVGSwitchElement.cpp | 4 +- dom/svg/SVGSwitchElement.h | 4 - dom/svg/SVGTransformableElement.cpp | 35 ++- dom/svg/SVGUseElement.cpp | 4 +- gfx/layers/wr/StackingContextHelper.h | 1 - gfx/layers/wr/WebRenderCommandBuilder.h | 1 + gfx/layers/wr/WebRenderLayerManager.h | 1 + gfx/thebes/gfxSVGGlyphs.cpp | 6 +- image/VectorImage.cpp | 2 +- image/moz.build | 2 +- layout/base/GeometryUtils.cpp | 4 +- layout/base/MotionPathUtils.cpp | 2 +- layout/base/RestyleManager.cpp | 23 +- layout/base/nsCSSFrameConstructor.cpp | 31 +- layout/base/nsCSSFrameConstructor.h | 4 +- layout/base/nsLayoutUtils.cpp | 26 +- layout/build/nsLayoutStatics.cpp | 3 +- layout/generic/ReflowInput.cpp | 7 +- layout/generic/nsBlockFrame.cpp | 11 +- layout/generic/nsFrameStateBits.h | 2 +- layout/generic/nsGfxScrollFrame.cpp | 1 - layout/generic/nsIFrame.cpp | 55 ++-- layout/generic/nsIFrame.h | 6 +- layout/generic/nsInlineFrame.cpp | 9 +- layout/generic/nsLineLayout.cpp | 10 +- layout/generic/nsTextFrame.cpp | 37 +-- layout/painting/FrameLayerBuilder.cpp | 4 +- layout/painting/nsCSSRendering.cpp | 2 - layout/painting/nsDisplayList.cpp | 80 ++--- layout/painting/nsImageRenderer.cpp | 8 +- layout/style/nsFontFaceUtils.cpp | 11 +- layout/style/nsStyleStructInlines.h | 30 +- layout/style/nsStyleTransformMatrix.cpp | 6 +- layout/svg/CSSClipPathInstance.cpp | 6 +- layout/svg/FilterInstance.cpp | 29 +- layout/svg/ISVGDisplayableFrame.h | 2 +- layout/svg/SVGAFrame.cpp | 2 - layout/svg/SVGClipPathFrame.cpp | 36 +-- layout/svg/SVGClipPathFrame.h | 1 - layout/svg/SVGContainerFrame.cpp | 20 +- layout/svg/SVGContainerFrame.h | 3 +- layout/svg/SVGContextPaint.cpp | 7 +- layout/svg/SVGFilterFrame.cpp | 2 - layout/svg/SVGFilterFrame.h | 1 - layout/svg/SVGFilterInstance.cpp | 12 +- layout/svg/SVGForeignObjectFrame.cpp | 25 +- layout/svg/SVGForeignObjectFrame.h | 1 - layout/svg/SVGGFrame.cpp | 4 - layout/svg/SVGGenericContainerFrame.cpp | 1 - layout/svg/SVGGeometryFrame.cpp | 99 +++--- layout/svg/SVGGeometryFrame.h | 2 - layout/svg/SVGGradientFrame.cpp | 13 +- layout/svg/SVGImageFrame.cpp | 32 +- layout/svg/SVGImageFrame.h | 6 +- ...ationUtils.cpp => SVGIntegrationUtils.cpp} | 110 ++++--- ...tegrationUtils.h => SVGIntegrationUtils.h} | 58 ++-- layout/svg/SVGMarkerFrame.cpp | 13 +- layout/svg/SVGMarkerFrame.h | 1 - layout/svg/SVGMaskFrame.cpp | 23 +- layout/svg/SVGMaskFrame.h | 1 - layout/svg/SVGObserverUtils.cpp | 18 +- layout/svg/SVGObserverUtils.h | 3 +- layout/svg/SVGOuterSVGFrame.cpp | 16 +- layout/svg/SVGPaintServerFrame.h | 1 - layout/svg/SVGPatternFrame.cpp | 38 +-- layout/svg/SVGSwitchFrame.cpp | 16 +- layout/svg/SVGTextFrame.cpp | 67 ++--- layout/svg/SVGTextFrame.h | 4 +- layout/svg/SVGUseFrame.cpp | 13 +- layout/svg/{nsSVGUtils.cpp => SVGUtils.cpp} | 283 +++++++++--------- layout/svg/{nsSVGUtils.h => SVGUtils.h} | 75 +++-- layout/svg/SVGViewFrame.cpp | 3 +- layout/svg/SVGViewportFrame.cpp | 21 +- layout/svg/moz.build | 13 +- layout/xul/nsSliderFrame.cpp | 7 +- 112 files changed, 773 insertions(+), 828 deletions(-) rename layout/svg/{nsSVGIntegrationUtils.cpp => SVGIntegrationUtils.cpp} (93%) rename layout/svg/{nsSVGIntegrationUtils.h => SVGIntegrationUtils.h} (91%) rename layout/svg/{nsSVGUtils.cpp => SVGUtils.cpp} (85%) rename layout/svg/{nsSVGUtils.h => SVGUtils.h} (90%) diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index dcb4e31a0563..9d8c67b1189c 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -244,7 +244,6 @@ #include "mozilla/SMILAnimationController.h" #include "imgIContainer.h" -#include "nsSVGUtils.h" #include "nsRefreshDriver.h" diff --git a/dom/base/DocumentOrShadowRoot.cpp b/dom/base/DocumentOrShadowRoot.cpp index ae007789abbe..a0777976da07 100644 --- a/dom/base/DocumentOrShadowRoot.cpp +++ b/dom/base/DocumentOrShadowRoot.cpp @@ -8,6 +8,7 @@ #include "mozilla/AnimationComparator.h" #include "mozilla/EventStateManager.h" #include "mozilla/PresShell.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/AnimatableBinding.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/HTMLInputElement.h" @@ -18,7 +19,6 @@ #include "nsIRadioVisitor.h" #include "nsIFormControl.h" #include "nsLayoutUtils.h" -#include "nsSVGUtils.h" #include "nsWindowSizes.h" namespace mozilla { @@ -411,8 +411,7 @@ static void QueryNodesFromRect(DocumentOrShadowRoot& aRoot, const nsRect& aRect, // SVG 'text' element's SVGTextFrame doesn't respond to hit-testing, so // if 'content' is a child of such an element then we need to manually // defer to the parent here. - if (aMultiple == Multiple::Yes && - !nsSVGUtils::IsInSVGTextSubtree(frame)) { + if (aMultiple == Multiple::Yes && !SVGUtils::IsInSVGTextSubtree(frame)) { continue; } diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 628dd153f4a7..42828ecbcb95 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -98,7 +98,6 @@ #include "nsPIDOMWindow.h" #include "mozilla/dom/DOMRect.h" -#include "nsSVGUtils.h" #include "nsLayoutUtils.h" #include "nsGkAtoms.h" #include "ChildIterator.h" diff --git a/dom/base/FragmentOrElement.cpp b/dom/base/FragmentOrElement.cpp index d66a281e0c1e..01b812afd7d1 100644 --- a/dom/base/FragmentOrElement.cpp +++ b/dom/base/FragmentOrElement.cpp @@ -68,7 +68,6 @@ #include "nsFrameLoader.h" #include "nsPIDOMWindow.h" -#include "nsSVGUtils.h" #include "nsLayoutUtils.h" #include "nsGkAtoms.h" #include "nsContentUtils.h" diff --git a/dom/base/ResizeObserver.cpp b/dom/base/ResizeObserver.cpp index ce548e55ed2f..8da3d27f463f 100644 --- a/dom/base/ResizeObserver.cpp +++ b/dom/base/ResizeObserver.cpp @@ -8,9 +8,9 @@ #include "mozilla/dom/DOMRect.h" #include "mozilla/dom/Document.h" +#include "mozilla/SVGUtils.h" #include "nsIContent.h" #include "nsIContentInlines.h" -#include "nsSVGUtils.h" #include namespace mozilla { @@ -62,7 +62,7 @@ static nsSize GetTargetSize(Element* aTarget, ResizeObserverBoxOptions aBox) { // Per the spec, SVG size is always its bounding box size no matter what // box option you choose, because SVG elements do not use standard CSS box // model. - gfxRect bbox = nsSVGUtils::GetBBox(frame); + gfxRect bbox = SVGUtils::GetBBox(frame); size.width = NSFloatPixelsToAppUnits(bbox.width, AppUnitsPerCSSPixel()); size.height = NSFloatPixelsToAppUnits(bbox.height, AppUnitsPerCSSPixel()); } else { diff --git a/dom/base/nsINode.cpp b/dom/base/nsINode.cpp index 38c7feadc485..89b319f4c628 100644 --- a/dom/base/nsINode.cpp +++ b/dom/base/nsINode.cpp @@ -86,7 +86,6 @@ #include "nsRange.h" #include "nsString.h" #include "nsStyleConsts.h" -#include "nsSVGUtils.h" #include "nsTextNode.h" #include "nsUnicharUtils.h" #include "nsWindowSizes.h" diff --git a/dom/html/HTMLScriptElement.cpp b/dom/html/HTMLScriptElement.cpp index 581221c616cb..71181b9e607a 100644 --- a/dom/html/HTMLScriptElement.cpp +++ b/dom/html/HTMLScriptElement.cpp @@ -137,7 +137,7 @@ void HTMLScriptElement::SetText(const nsAString& aValue, ErrorResult& aRv) { aRv = nsContentUtils::SetNodeTextContent(this, aValue, true); } -// variation of this code in nsSVGScriptElement - check if changes +// variation of this code in SVGScriptElement - check if changes // need to be transfered when modifying bool HTMLScriptElement::GetScriptType(nsAString& aType) { @@ -176,7 +176,7 @@ void HTMLScriptElement::FreezeExecutionAttrs(Document* aOwnerDoc) { mIsModule = aOwnerDoc->ModuleScriptsEnabled() && !type.IsEmpty() && type.LowerCaseEqualsASCII("module"); - // variation of this code in nsSVGScriptElement - check if changes + // variation of this code in SVGScriptElement - check if changes // need to be transfered when modifying. Note that we don't use GetSrc here // because it will return the base URL when the attr value is "". nsAutoString src; diff --git a/dom/smil/SMILTimedElement.cpp b/dom/smil/SMILTimedElement.cpp index 3404d5e82193..e9a81b77b54d 100644 --- a/dom/smil/SMILTimedElement.cpp +++ b/dom/smil/SMILTimedElement.cpp @@ -311,7 +311,7 @@ nsresult SMILTimedElement::EndElementAt(double aOffsetSeconds) { } //---------------------------------------------------------------------- -// nsSVGAnimationElement methods +// SVGAnimationElement methods SMILTimeValue SMILTimedElement::GetStartTime() const { return mElementState == STATE_WAITING || mElementState == STATE_ACTIVE diff --git a/dom/smil/SMILTimedElement.h b/dom/smil/SMILTimedElement.h index 5070172ad584..d178cc59d86f 100644 --- a/dom/smil/SMILTimedElement.h +++ b/dom/smil/SMILTimedElement.h @@ -87,7 +87,7 @@ class SMILTimedElement { nsresult EndElementAt(double aOffsetSeconds); /** - * Methods for supporting the nsSVGAnimationElement interface. + * Methods for supporting the SVGAnimationElement interface. */ /** diff --git a/dom/svg/SVGAnimatedLength.cpp b/dom/svg/SVGAnimatedLength.cpp index ff77ef6ddfab..12f48e4c59f8 100644 --- a/dom/svg/SVGAnimatedLength.cpp +++ b/dom/svg/SVGAnimatedLength.cpp @@ -10,6 +10,7 @@ #include "mozilla/ArrayUtils.h" #include "mozilla/Maybe.h" #include "mozilla/SMILValue.h" +#include "mozilla/SVGIntegrationUtils.h" #include "mozilla/dom/SVGViewportElement.h" #include "DOMSVGAnimatedLength.h" #include "DOMSVGLength.h" @@ -19,7 +20,6 @@ #include "nsTextFormatter.h" #include "SMILFloatType.h" #include "SVGAttrTearoffTable.h" -#include "nsSVGIntegrationUtils.h" using namespace mozilla::dom; @@ -158,7 +158,7 @@ float NonSVGFrameUserSpaceMetrics::GetExLength() const { } gfx::Size NonSVGFrameUserSpaceMetrics::GetSize() const { - return nsSVGIntegrationUtils::GetSVGCoordContextForNonSVGFrame(mFrame); + return SVGIntegrationUtils::GetSVGCoordContextForNonSVGFrame(mFrame); } float UserSpaceMetricsWithSize::GetAxisLength(uint8_t aCtxType) const { diff --git a/dom/svg/SVGAnimatedTransformList.cpp b/dom/svg/SVGAnimatedTransformList.cpp index 707e95c8880a..8da307a23cb1 100644 --- a/dom/svg/SVGAnimatedTransformList.cpp +++ b/dom/svg/SVGAnimatedTransformList.cpp @@ -198,7 +198,7 @@ void SVGAnimatedTransformList::SMILAnimatedTransformList::ParseValue( MOZ_ASSERT(aResult.IsNull(), "Unexpected type for SMIL value"); static_assert(SVGTransformSMILData::NUM_SIMPLE_PARAMS == 3, - "nsSVGSMILTransform constructor should be expecting array " + "SVGSMILTransform constructor should be expecting array " "with 3 params"); float params[3] = {0.f}; diff --git a/dom/svg/SVGCircleElement.h b/dom/svg/SVGCircleElement.h index efd82e5d7f53..36612084a8eb 100644 --- a/dom/svg/SVGCircleElement.h +++ b/dom/svg/SVGCircleElement.h @@ -34,7 +34,7 @@ class SVGCircleElement final : public SVGCircleElementBase { public: NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; // SVGGeometryElement methods: diff --git a/dom/svg/SVGContentUtils.cpp b/dom/svg/SVGContentUtils.cpp index c718161a0178..062a67780948 100644 --- a/dom/svg/SVGContentUtils.cpp +++ b/dom/svg/SVGContentUtils.cpp @@ -17,6 +17,7 @@ #include "mozilla/PresShell.h" #include "mozilla/RefPtr.h" #include "mozilla/SVGContextPaint.h" +#include "mozilla/SVGUtils.h" #include "mozilla/TextUtils.h" #include "nsComputedDOMStyle.h" #include "nsContainerFrame.h" @@ -25,7 +26,6 @@ #include "nsIScriptError.h" #include "nsLayoutUtils.h" #include "nsMathUtils.h" -#include "nsSVGUtils.h" #include "nsWhitespaceTokenizer.h" #include "SVGAnimationElement.h" #include "SVGAnimatedPreserveAspectRatio.h" @@ -481,7 +481,7 @@ static gfx::Matrix GetCTMInternal(SVGElement* aElement, bool aScreenCTM, gfxMatrix ret; if (auto* f = e->GetPrimaryFrame()) { - ret = nsSVGUtils::GetTransformMatrixInUserSpace(f); + ret = SVGUtils::GetTransformMatrixInUserSpace(f); } else { // FIXME: Ideally we should also return the correct matrix // for display:none, but currently transform related code relies diff --git a/dom/svg/SVGContentUtils.h b/dom/svg/SVGContentUtils.h index d3f83e8d65ba..6027a8f7b56a 100644 --- a/dom/svg/SVGContentUtils.h +++ b/dom/svg/SVGContentUtils.h @@ -71,7 +71,7 @@ enum SVGTransformTypes { /** * Functions generally used by SVG Content classes. Functions here - * should not generally depend on layout methods/classes e.g. nsSVGUtils + * should not generally depend on layout methods/classes e.g. SVGUtils */ class SVGContentUtils { public: @@ -88,9 +88,9 @@ class SVGContentUtils { /** * Activates the animation element aContent as a result of navigation to the * fragment identifier that identifies aContent. aContent must be an instance - * of nsSVGAnimationElement. + * of SVGAnimationElement. * - * This is just a shim to allow nsSVGAnimationElement::ActivateByHyperlink to + * This is just a shim to allow SVGAnimationElement::ActivateByHyperlink to * be called from layout/base without adding to that directory's include * paths. */ diff --git a/dom/svg/SVGElement.h b/dom/svg/SVGElement.h index 17ac55269be1..8aa7fd259b14 100644 --- a/dom/svg/SVGElement.h +++ b/dom/svg/SVGElement.h @@ -165,7 +165,7 @@ class SVGElement : public SVGElementBase // nsIContent SVGTransformTypes aWhich = eAllTransforms) const; // Setter for to set the current transformation - // Only visible for nsSVGGraphicElement, so it's a no-op here, and that + // Only visible for SVGGraphicElement, so it's a no-op here, and that // subclass has the useful implementation. virtual void SetAnimateMotionTransform( const mozilla::gfx::Matrix* aMatrix) { /*no-op*/ @@ -281,7 +281,7 @@ class SVGElement : public SVGElementBase // nsIContent SVGAnimatedLengthList* GetAnimatedLengthList(uint8_t aAttrEnum); virtual SVGAnimatedPointList* GetAnimatedPointList() { return nullptr; } virtual SVGAnimatedPathSegList* GetAnimPathSegList() { - // DOM interface 'SVGAnimatedPathData' (*inherited* by nsSVGPathElement) + // DOM interface 'SVGAnimatedPathData' (*inherited* by SVGPathElement) // has a member called 'animatedPathSegList' member, so we have a shorter // name so we don't get hidden by the GetAnimatedPathSegList declared by // NS_DECL_NSIDOMSVGANIMATEDPATHDATA. diff --git a/dom/svg/SVGEllipseElement.h b/dom/svg/SVGEllipseElement.h index 3e91c83c4afd..97812e64a43b 100644 --- a/dom/svg/SVGEllipseElement.h +++ b/dom/svg/SVGEllipseElement.h @@ -34,7 +34,7 @@ class SVGEllipseElement final : public SVGEllipseElementBase { public: NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; // SVGGeometryElement methods: diff --git a/dom/svg/SVGFEBlendElement.cpp b/dom/svg/SVGFEBlendElement.cpp index 6d764eb5e10d..ed239fbd79c8 100644 --- a/dom/svg/SVGFEBlendElement.cpp +++ b/dom/svg/SVGFEBlendElement.cpp @@ -6,7 +6,6 @@ #include "mozilla/dom/SVGFEBlendElement.h" #include "mozilla/dom/SVGFEBlendElementBinding.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FEBlend) diff --git a/dom/svg/SVGFEColorMatrixElement.cpp b/dom/svg/SVGFEColorMatrixElement.cpp index a21d9340c0a6..024e82c33280 100644 --- a/dom/svg/SVGFEColorMatrixElement.cpp +++ b/dom/svg/SVGFEColorMatrixElement.cpp @@ -8,7 +8,6 @@ #include "DOMSVGAnimatedNumberList.h" #include "mozilla/dom/SVGFEColorMatrixElementBinding.h" -#include "nsSVGUtils.h" #define NUM_ENTRIES_IN_4x5_MATRIX 20 diff --git a/dom/svg/SVGFEComponentTransferElement.cpp b/dom/svg/SVGFEComponentTransferElement.cpp index 676fb7cbadc3..2704280d9c26 100644 --- a/dom/svg/SVGFEComponentTransferElement.cpp +++ b/dom/svg/SVGFEComponentTransferElement.cpp @@ -8,7 +8,6 @@ #include "mozilla/dom/SVGComponentTransferFunctionElement.h" #include "mozilla/dom/SVGFEComponentTransferElementBinding.h" -#include "nsSVGUtils.h" #include "mozilla/gfx/2D.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FEComponentTransfer) diff --git a/dom/svg/SVGFEConvolveMatrixElement.cpp b/dom/svg/SVGFEConvolveMatrixElement.cpp index 0808ef30c355..4afc4234dd82 100644 --- a/dom/svg/SVGFEConvolveMatrixElement.cpp +++ b/dom/svg/SVGFEConvolveMatrixElement.cpp @@ -10,7 +10,6 @@ #include "mozilla/UniquePtr.h" #include "mozilla/UniquePtrExtensions.h" #include "DOMSVGAnimatedNumberList.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FEConvolveMatrix) diff --git a/dom/svg/SVGFEDiffuseLightingElement.cpp b/dom/svg/SVGFEDiffuseLightingElement.cpp index e9aa215134ab..00d6acfd82b4 100644 --- a/dom/svg/SVGFEDiffuseLightingElement.cpp +++ b/dom/svg/SVGFEDiffuseLightingElement.cpp @@ -7,7 +7,6 @@ #include "mozilla/dom/SVGFEDiffuseLightingElement.h" #include "mozilla/dom/SVGFEDiffuseLightingElementBinding.h" #include "mozilla/SVGFilterInstance.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FEDiffuseLighting) diff --git a/dom/svg/SVGFEDisplacementMapElement.cpp b/dom/svg/SVGFEDisplacementMapElement.cpp index 2575756d0243..aa9e8dfe0b42 100644 --- a/dom/svg/SVGFEDisplacementMapElement.cpp +++ b/dom/svg/SVGFEDisplacementMapElement.cpp @@ -7,7 +7,6 @@ #include "mozilla/dom/SVGFEDisplacementMapElement.h" #include "mozilla/dom/SVGFEDisplacementMapElementBinding.h" #include "mozilla/SVGFilterInstance.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FEDisplacementMap) diff --git a/dom/svg/SVGFEGaussianBlurElement.cpp b/dom/svg/SVGFEGaussianBlurElement.cpp index ee994af524e8..c818ba3d2938 100644 --- a/dom/svg/SVGFEGaussianBlurElement.cpp +++ b/dom/svg/SVGFEGaussianBlurElement.cpp @@ -7,7 +7,6 @@ #include "mozilla/dom/SVGFEGaussianBlurElement.h" #include "mozilla/dom/SVGFEGaussianBlurElementBinding.h" #include "mozilla/SVGFilterInstance.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FEGaussianBlur) diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp index c78661ef939e..e72dce6c26da 100644 --- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -7,6 +7,7 @@ #include "mozilla/dom/SVGFEImageElement.h" #include "mozilla/EventStates.h" +#include "mozilla/SVGObserverUtils.h" #include "mozilla/dom/SVGFEImageElementBinding.h" #include "mozilla/dom/SVGFilterElement.h" #include "mozilla/dom/UserActivation.h" @@ -14,9 +15,7 @@ #include "mozilla/RefPtr.h" #include "nsContentUtils.h" #include "nsLayoutUtils.h" -#include "nsSVGUtils.h" #include "nsNetUtil.h" -#include "SVGObserverUtils.h" #include "imgIContainer.h" #include "gfx2DGlue.h" diff --git a/dom/svg/SVGFESpecularLightingElement.cpp b/dom/svg/SVGFESpecularLightingElement.cpp index ee04d49f8567..4f97fdb674d9 100644 --- a/dom/svg/SVGFESpecularLightingElement.cpp +++ b/dom/svg/SVGFESpecularLightingElement.cpp @@ -7,7 +7,6 @@ #include "mozilla/dom/SVGFESpecularLightingElement.h" #include "mozilla/dom/SVGFESpecularLightingElementBinding.h" #include "mozilla/SVGFilterInstance.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FESpecularLighting) diff --git a/dom/svg/SVGFETurbulenceElement.cpp b/dom/svg/SVGFETurbulenceElement.cpp index 41db5b2dec8a..b4e809b36b22 100644 --- a/dom/svg/SVGFETurbulenceElement.cpp +++ b/dom/svg/SVGFETurbulenceElement.cpp @@ -7,7 +7,6 @@ #include "mozilla/dom/SVGFETurbulenceElement.h" #include "mozilla/dom/SVGFETurbulenceElementBinding.h" #include "mozilla/SVGFilterInstance.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(FETurbulence) diff --git a/dom/svg/SVGFilterElement.cpp b/dom/svg/SVGFilterElement.cpp index 1edc9c5f85b6..115b7f489b1c 100644 --- a/dom/svg/SVGFilterElement.cpp +++ b/dom/svg/SVGFilterElement.cpp @@ -13,8 +13,6 @@ #include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGUnitTypesBinding.h" #include "nsQueryObject.h" -#include "nsSVGUtils.h" -#include "SVGObserverUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT(Filter) diff --git a/dom/svg/SVGFilterElement.h b/dom/svg/SVGFilterElement.h index e22324088b0a..7dad2dd0974e 100644 --- a/dom/svg/SVGFilterElement.h +++ b/dom/svg/SVGFilterElement.h @@ -42,7 +42,7 @@ class SVGFilterElement : public SVGFilterElementBase { virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; // WebIDL diff --git a/dom/svg/SVGFilters.cpp b/dom/svg/SVGFilters.cpp index ae6ab7cf1a15..adfc70d8d8f0 100644 --- a/dom/svg/SVGFilters.cpp +++ b/dom/svg/SVGFilters.cpp @@ -21,7 +21,6 @@ #include "mozilla/ComputedStyle.h" #include "mozilla/SVGContentUtils.h" #include "mozilla/SVGFilterInstance.h" -#include "nsSVGUtils.h" #include "mozilla/dom/SVGComponentTransferFunctionElement.h" #include "mozilla/dom/SVGElement.h" #include "mozilla/dom/SVGFEDistantLightElement.h" diff --git a/dom/svg/SVGGeometryElement.cpp b/dom/svg/SVGGeometryElement.cpp index 39dad1c894a8..0bf0cecce0a6 100644 --- a/dom/svg/SVGGeometryElement.cpp +++ b/dom/svg/SVGGeometryElement.cpp @@ -9,7 +9,6 @@ #include "DOMSVGPoint.h" #include "gfxPlatform.h" #include "nsCOMPtr.h" -#include "nsSVGUtils.h" #include "SVGAnimatedLength.h" #include "SVGCircleElement.h" #include "SVGEllipseElement.h" diff --git a/dom/svg/SVGImageElement.h b/dom/svg/SVGImageElement.h index 9b8d383ba932..281567dd6ba9 100644 --- a/dom/svg/SVGImageElement.h +++ b/dom/svg/SVGImageElement.h @@ -76,7 +76,7 @@ class SVGImageElement : public SVGImageElementBase, const Matrix* aToNonScalingStrokeSpace = nullptr) override; virtual already_AddRefed BuildPath(PathBuilder* aBuilder) override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; diff --git a/dom/svg/SVGMarkerElement.h b/dom/svg/SVGMarkerElement.h index 74e47fe6a8d2..7595ca2d6c49 100644 --- a/dom/svg/SVGMarkerElement.h +++ b/dom/svg/SVGMarkerElement.h @@ -50,7 +50,7 @@ class SVGMarkerElement : public SVGMarkerElementBase { // nsIContent interface NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; // public helpers diff --git a/dom/svg/SVGMaskElement.h b/dom/svg/SVGMaskElement.h index 8b51646ec421..40ad50b1934a 100644 --- a/dom/svg/SVGMaskElement.h +++ b/dom/svg/SVGMaskElement.h @@ -39,7 +39,7 @@ class SVGMaskElement final : public SVGMaskElementBase { virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; // WebIDL diff --git a/dom/svg/SVGPathElement.h b/dom/svg/SVGPathElement.h index ad7975f2b3c5..d05fd6f68a55 100644 --- a/dom/svg/SVGPathElement.h +++ b/dom/svg/SVGPathElement.h @@ -41,7 +41,7 @@ class SVGPathElement final : public SVGPathElementBase { // nsIContent interface NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* name) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; // SVGGeometryElement methods: diff --git a/dom/svg/SVGPatternElement.h b/dom/svg/SVGPatternElement.h index b97ac1cbba9d..ebb4074f214a 100644 --- a/dom/svg/SVGPatternElement.h +++ b/dom/svg/SVGPatternElement.h @@ -48,7 +48,7 @@ class SVGPatternElement final : public SVGPatternElementBase { virtual nsresult Clone(dom::NodeInfo*, nsINode** aResult) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; virtual mozilla::SVGAnimatedTransformList* GetAnimatedTransformList( diff --git a/dom/svg/SVGRectElement.h b/dom/svg/SVGRectElement.h index ba5843a052d2..62cfbd5533c2 100644 --- a/dom/svg/SVGRectElement.h +++ b/dom/svg/SVGRectElement.h @@ -33,7 +33,7 @@ class SVGRectElement final : public SVGRectElementBase { public: NS_IMETHOD_(bool) IsAttributeMapped(const nsAtom* aAttribute) const override; - // nsSVGSVGElement methods: + // SVGSVGElement methods: virtual bool HasValidDimensions() const override; // SVGGeometryElement methods: diff --git a/dom/svg/SVGSVGElement.cpp b/dom/svg/SVGSVGElement.cpp index 988d29d8d692..0fd8802b004d 100644 --- a/dom/svg/SVGSVGElement.cpp +++ b/dom/svg/SVGSVGElement.cpp @@ -18,6 +18,7 @@ #include "mozilla/PresShell.h" #include "mozilla/SMILAnimationController.h" #include "mozilla/SMILTimeContainer.h" +#include "mozilla/SVGUtils.h" #include "DOMSVGAngle.h" #include "DOMSVGLength.h" @@ -26,7 +27,6 @@ #include "nsFrameSelection.h" #include "nsIFrame.h" #include "ISVGSVGFrame.h" -#include "nsSVGUtils.h" NS_IMPL_NS_NEW_SVG_ELEMENT_CHECK_PARSER(SVG) @@ -464,7 +464,7 @@ int32_t SVGSVGElement::GetIntrinsicWidth() { // know the length isn't a percentage so the context won't be used (and we // need to pass the element to be able to resolve em/ex units). float width = mLengthAttributes[ATTR_WIDTH].GetAnimValue(this); - return nsSVGUtils::ClampToInt(width); + return SVGUtils::ClampToInt(width); } int32_t SVGSVGElement::GetIntrinsicHeight() { @@ -476,7 +476,7 @@ int32_t SVGSVGElement::GetIntrinsicHeight() { // know the length isn't a percentage so the context won't be used (and we // need to pass the element to be able to resolve em/ex units). float height = mLengthAttributes[ATTR_HEIGHT].GetAnimValue(this); - return nsSVGUtils::ClampToInt(height); + return SVGUtils::ClampToInt(height); } void SVGSVGElement::FlushImageTransformInvalidation() { diff --git a/dom/svg/SVGSwitchElement.cpp b/dom/svg/SVGSwitchElement.cpp index 87079f5bff53..d7609bd1eeac 100644 --- a/dom/svg/SVGSwitchElement.cpp +++ b/dom/svg/SVGSwitchElement.cpp @@ -7,8 +7,8 @@ #include "mozilla/dom/SVGSwitchElement.h" #include "nsLayoutUtils.h" -#include "nsSVGUtils.h" #include "mozilla/Preferences.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGSwitchElementBinding.h" class nsIFrame; @@ -57,7 +57,7 @@ void SVGSwitchElement::MaybeInvalidate() { if (frame) { nsLayoutUtils::PostRestyleEvent(this, RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(frame); + SVGUtils::ScheduleReflowSVG(frame); } mActiveChild = newActiveChild; diff --git a/dom/svg/SVGSwitchElement.h b/dom/svg/SVGSwitchElement.h index 0ac0960b4684..5bdeddb4eaff 100644 --- a/dom/svg/SVGSwitchElement.h +++ b/dom/svg/SVGSwitchElement.h @@ -10,8 +10,6 @@ #include "mozilla/dom/SVGGraphicsElement.h" #include "nsCOMPtr.h" -class nsSVGSwitchFrame; - nsresult NS_NewSVGSwitchElement( nsIContent** aResult, already_AddRefed&& aNodeInfo); @@ -21,8 +19,6 @@ namespace dom { typedef SVGGraphicsElement SVGSwitchElementBase; class SVGSwitchElement final : public SVGSwitchElementBase { - friend class ::nsSVGSwitchFrame; - protected: friend nsresult(::NS_NewSVGSwitchElement( nsIContent** aResult, diff --git a/dom/svg/SVGTransformableElement.cpp b/dom/svg/SVGTransformableElement.cpp index 70e96b619870..fc9c0e9c5fd3 100644 --- a/dom/svg/SVGTransformableElement.cpp +++ b/dom/svg/SVGTransformableElement.cpp @@ -16,9 +16,9 @@ #include "mozilla/ISVGDisplayableFrame.h" #include "mozilla/SVGContentUtils.h" #include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "nsContentUtils.h" #include "nsIFrame.h" -#include "nsSVGUtils.h" using namespace mozilla::gfx; @@ -172,19 +172,19 @@ already_AddRefed SVGTransformableElement::GetBBox( ISVGDisplayableFrame* svgframe = do_QueryFrame(frame); if (!svgframe) { - if (!nsSVGUtils::IsInSVGTextSubtree(frame)) { + if (!SVGUtils::IsInSVGTextSubtree(frame)) { return ZeroBBox(*this); } // For , , the frame is an nsInlineFrame or // nsBlockFrame, |svgframe| will be a nullptr. // We implement their getBBox directly here instead of in - // nsSVGUtils::GetBBox, because nsSVGUtils::GetBBox is more + // SVGUtils::GetBBox, because SVGUtils::GetBBox is more // or less used for other purpose elsewhere. e.g. gradient // code assumes GetBBox of returns the bbox of the // outer . - // TODO: cleanup this sort of usecase of nsSVGUtils::GetBBox, - // then move this code nsSVGUtils::GetBBox. + // TODO: cleanup this sort of usecase of SVGUtils::GetBBox, + // then move this code SVGUtils::GetBBox. SVGTextFrame* text = static_cast(nsLayoutUtils::GetClosestFrameOfType( frame->GetParent(), LayoutFrameType::SVGText)); @@ -207,33 +207,32 @@ already_AddRefed SVGTransformableElement::GetBBox( if (!NS_SVGNewGetBBoxEnabled()) { return do_AddRef(new SVGRect( - this, ToRect(nsSVGUtils::GetBBox( - frame, nsSVGUtils::eBBoxIncludeFillGeometry | - nsSVGUtils::eUseUserSpaceOfUseElement)))); + this, ToRect(SVGUtils::GetBBox( + frame, SVGUtils::eBBoxIncludeFillGeometry | + SVGUtils::eUseUserSpaceOfUseElement)))); } uint32_t flags = 0; if (aOptions.mFill) { - flags |= nsSVGUtils::eBBoxIncludeFill; + flags |= SVGUtils::eBBoxIncludeFill; } if (aOptions.mStroke) { - flags |= nsSVGUtils::eBBoxIncludeStroke; + flags |= SVGUtils::eBBoxIncludeStroke; } if (aOptions.mMarkers) { - flags |= nsSVGUtils::eBBoxIncludeMarkers; + flags |= SVGUtils::eBBoxIncludeMarkers; } if (aOptions.mClipped) { - flags |= nsSVGUtils::eBBoxIncludeClipped; + flags |= SVGUtils::eBBoxIncludeClipped; } if (flags == 0) { return do_AddRef(new SVGRect(this, gfx::Rect())); } - if (flags == nsSVGUtils::eBBoxIncludeMarkers || - flags == nsSVGUtils::eBBoxIncludeClipped) { - flags |= nsSVGUtils::eBBoxIncludeFill; + if (flags == SVGUtils::eBBoxIncludeMarkers || + flags == SVGUtils::eBBoxIncludeClipped) { + flags |= SVGUtils::eBBoxIncludeFill; } - flags |= nsSVGUtils::eUseUserSpaceOfUseElement; - return do_AddRef( - new SVGRect(this, ToRect(nsSVGUtils::GetBBox(frame, flags)))); + flags |= SVGUtils::eUseUserSpaceOfUseElement; + return do_AddRef(new SVGRect(this, ToRect(SVGUtils::GetBBox(frame, flags)))); } already_AddRefed SVGTransformableElement::GetCTM() { diff --git a/dom/svg/SVGUseElement.cpp b/dom/svg/SVGUseElement.cpp index dfc06428b5a7..afc0b695e739 100644 --- a/dom/svg/SVGUseElement.cpp +++ b/dom/svg/SVGUseElement.cpp @@ -313,7 +313,7 @@ void SVGUseElement::UpdateShadowTree() { }); // make sure target is valid type for - // QIable nsSVGGraphicsElement would eliminate enumerating all elements + // QIable SVGGraphicsElement would eliminate enumerating all elements if (!targetElement || !targetElement->IsAnyOfSVGElements( nsGkAtoms::svg, nsGkAtoms::symbol, nsGkAtoms::g, nsGkAtoms::path, @@ -529,7 +529,7 @@ SVGElement::StringAttributesInfo SVGUseElement::GetStringInfo() { SVGUseFrame* SVGUseElement::GetFrame() const { nsIFrame* frame = GetPrimaryFrame(); - // We might be a plain nsSVGContainerFrame if we didn't pass the conditional + // We might be a plain SVGContainerFrame if we didn't pass the conditional // processing checks. if (!frame || !frame->IsSVGUseFrame()) { MOZ_ASSERT_IF(frame, frame->Type() == LayoutFrameType::None); diff --git a/gfx/layers/wr/StackingContextHelper.h b/gfx/layers/wr/StackingContextHelper.h index b29046a60c6b..bd9e57619747 100644 --- a/gfx/layers/wr/StackingContextHelper.h +++ b/gfx/layers/wr/StackingContextHelper.h @@ -12,7 +12,6 @@ #include "mozilla/webrender/WebRenderAPI.h" #include "mozilla/webrender/WebRenderTypes.h" #include "Units.h" -#include "nsSVGIntegrationUtils.h" // for WrFiltersHolder class nsDisplayTransform; diff --git a/gfx/layers/wr/WebRenderCommandBuilder.h b/gfx/layers/wr/WebRenderCommandBuilder.h index c9aca03d4b0e..22ebac8d4f31 100644 --- a/gfx/layers/wr/WebRenderCommandBuilder.h +++ b/gfx/layers/wr/WebRenderCommandBuilder.h @@ -12,6 +12,7 @@ #include "mozilla/layers/WebRenderMessages.h" #include "mozilla/layers/WebRenderScrollData.h" #include "mozilla/layers/WebRenderUserData.h" +#include "mozilla/SVGIntegrationUtils.h" // for WrFiltersHolder #include "nsDisplayList.h" #include "nsIFrame.h" #include "DisplayItemCache.h" diff --git a/gfx/layers/wr/WebRenderLayerManager.h b/gfx/layers/wr/WebRenderLayerManager.h index f76c59dcc5e6..f55f4e9bf431 100644 --- a/gfx/layers/wr/WebRenderLayerManager.h +++ b/gfx/layers/wr/WebRenderLayerManager.h @@ -15,6 +15,7 @@ #include "mozilla/Maybe.h" #include "mozilla/MozPromise.h" #include "mozilla/StaticPrefs_apz.h" +#include "mozilla/SVGIntegrationUtils.h" // for WrFiltersHolder #include "mozilla/layers/APZTestData.h" #include "mozilla/layers/FocusTarget.h" #include "mozilla/layers/IpcResourceUpdateQueue.h" diff --git a/gfx/thebes/gfxSVGGlyphs.cpp b/gfx/thebes/gfxSVGGlyphs.cpp index daed1291d258..a2901ab7a686 100644 --- a/gfx/thebes/gfxSVGGlyphs.cpp +++ b/gfx/thebes/gfxSVGGlyphs.cpp @@ -10,6 +10,7 @@ #include "mozilla/PresShell.h" #include "mozilla/SMILAnimationController.h" #include "mozilla/SVGContextPaint.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/FontTableURIProtocolHandler.h" @@ -27,7 +28,6 @@ #include "nsStringStream.h" #include "nsStreamUtils.h" #include "nsIPrincipal.h" -#include "nsSVGUtils.h" #include "nsContentUtils.h" #include "gfxFont.h" #include "gfxContext.h" @@ -205,7 +205,7 @@ void gfxSVGGlyphs::RenderGlyph(gfxContext* aContext, uint32_t aGlyphId, AutoSetRestoreSVGContextPaint autoSetRestore( *aContextPaint, *glyph->OwnerDoc()->AsSVGDocument()); - nsSVGUtils::PaintSVGGlyph(glyph, aContext); + SVGUtils::PaintSVGGlyph(glyph, aContext); } bool gfxSVGGlyphs::GetGlyphExtents(uint32_t aGlyphId, @@ -215,7 +215,7 @@ bool gfxSVGGlyphs::GetGlyphExtents(uint32_t aGlyphId, NS_ASSERTION(glyph, "No glyph element. Should check with HasSVGGlyph() first!"); - return nsSVGUtils::GetSVGGlyphExtents(glyph, aSVGToAppSpace, aResult); + return SVGUtils::GetSVGGlyphExtents(glyph, aSVGToAppSpace, aResult); } Element* gfxSVGGlyphs::GetGlyphElement(uint32_t aGlyphId) { diff --git a/image/VectorImage.cpp b/image/VectorImage.cpp index 0836a9cbb579..3e038218141c 100644 --- a/image/VectorImage.cpp +++ b/image/VectorImage.cpp @@ -254,7 +254,7 @@ class SVGDrawingCallback : public gfxDrawingCallback { uint32_t mImageFlags; }; -// Based loosely on nsSVGIntegrationUtils' PaintFrameCallback::operator() +// Based loosely on SVGIntegrationUtils' PaintFrameCallback::operator() bool SVGDrawingCallback::operator()(gfxContext* aContext, const gfxRect& aFillRect, const SamplingFilter aSamplingFilter, diff --git a/image/moz.build b/image/moz.build index b598eb78d3e1..07d46690fecf 100644 --- a/image/moz.build +++ b/image/moz.build @@ -117,7 +117,7 @@ LOCAL_INCLUDES += [ '/dom/svg', # We need to instantiate the decoders '/image/decoders', - # Because VectorImage.cpp includes nsSVGUtils.h and SVGObserverUtils.h + # Because VectorImage.cpp includes SVGUtils.h and SVGObserverUtils.h '/layout/svg', # For URI-related functionality '/netwerk/base', diff --git a/layout/base/GeometryUtils.cpp b/layout/base/GeometryUtils.cpp index 877822eb9dbb..04688717b3f0 100644 --- a/layout/base/GeometryUtils.cpp +++ b/layout/base/GeometryUtils.cpp @@ -7,6 +7,7 @@ #include "GeometryUtils.h" #include "mozilla/PresShell.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/CharacterData.h" #include "mozilla/dom/DOMPointBinding.h" #include "mozilla/dom/GeometryUtilsBinding.h" @@ -19,7 +20,6 @@ #include "nsIFrame.h" #include "nsCSSFrameConstructor.h" #include "nsLayoutUtils.h" -#include "nsSVGUtils.h" using namespace mozilla; using namespace mozilla::dom; @@ -143,7 +143,7 @@ static nsIFrame* GetFirstNonAnonymousFrameForNode(nsINode* aNode) { */ static nsRect GetBoxRectForFrame(nsIFrame** aFrame, CSSBoxType aType) { nsRect r; - nsIFrame* f = nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(*aFrame, &r); + nsIFrame* f = SVGUtils::GetOuterSVGFrameAndCoveredRegion(*aFrame, &r); if (f && f != *aFrame) { // For non-outer SVG frames, the BoxType is ignored. *aFrame = f; diff --git a/layout/base/MotionPathUtils.cpp b/layout/base/MotionPathUtils.cpp index 80f1bd94951e..b472949094e9 100644 --- a/layout/base/MotionPathUtils.cpp +++ b/layout/base/MotionPathUtils.cpp @@ -28,7 +28,7 @@ RayReferenceData::RayReferenceData(const nsIFrame* aFrame) { // for calculating the path length. We may need to update this. // https://github.com/w3c/fxtf-drafts/issues/369 // FIXME: Bug 1579294: SVG layout may get a |container| with empty mRect - // (e.g. nsSVGOuterSVGAnonChildFrame), which makes the path length zero. + // (e.g. SVGOuterSVGAnonChildFrame), which makes the path length zero. const nsIFrame* container = aFrame->GetContainingBlock(); if (!container) { // If there is no parent frame, it's impossible to calculate the path diff --git a/layout/base/RestyleManager.cpp b/layout/base/RestyleManager.cpp index 995ed6050464..d2a0105a7cf1 100644 --- a/layout/base/RestyleManager.cpp +++ b/layout/base/RestyleManager.cpp @@ -11,6 +11,7 @@ #include "mozilla/ComputedStyle.h" #include "mozilla/ComputedStyleInlines.h" #include "mozilla/DocumentStyleRootIterator.h" +#include "mozilla/EffectSet.h" #include "mozilla/GeckoBindings.h" #include "mozilla/LayerAnimationInfo.h" #include "mozilla/layers/AnimationInfo.h" @@ -20,8 +21,13 @@ #include "mozilla/ServoBindings.h" #include "mozilla/ServoStyleSetInlines.h" #include "mozilla/StaticPrefs_layout.h" +#include "mozilla/SVGIntegrationUtils.h" +#include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/Unused.h" #include "mozilla/ViewportFrame.h" +#include "mozilla/IntegerRange.h" #include "mozilla/dom/ChildIterator.h" #include "mozilla/dom/DocumentInlines.h" #include "mozilla/dom/ElementInlines.h" @@ -45,12 +51,7 @@ #include "nsStyleUtil.h" #include "nsTransitionManager.h" #include "StickyScrollContainer.h" -#include "mozilla/EffectSet.h" -#include "mozilla/IntegerRange.h" -#include "SVGObserverUtils.h" -#include "SVGTextFrame.h" #include "ActiveLayerTracker.h" -#include "nsSVGIntegrationUtils.h" #ifdef ACCESSIBILITY # include "nsAccessibilityService.h" @@ -653,7 +654,7 @@ static nsIFrame* GetFrameForChildrenOnlyTransformHint(nsIFrame* aFrame) { if (aFrame->IsSVGOuterSVGFrame()) { aFrame = aFrame->PrincipalChildList().FirstChild(); MOZ_ASSERT(aFrame->IsSVGOuterSVGAnonChildFrame(), - "Where is the nsSVGOuterSVGFrame's anon child??"); + "Where is the SVGOuterSVGFrame's anon child??"); } MOZ_ASSERT(aFrame->IsFrameOfType(nsIFrame::eSVG | nsIFrame::eSVGContainer), "Children-only transforms only expected on SVG frames"); @@ -928,7 +929,7 @@ static bool ContainingBlockChangeAffectsDescendants( nsIFrame* outOfFlow = nsPlaceholderFrame::GetRealFrameForPlaceholder(f); // If SVG text frames could appear here, they could confuse us since // they ignore their position style ... but they can't. - NS_ASSERTION(!nsSVGUtils::IsInSVGTextSubtree(outOfFlow), + NS_ASSERTION(!SVGUtils::IsInSVGTextSubtree(outOfFlow), "SVG text frames can't be out of flow"); auto* display = outOfFlow->StyleDisplay(); if (display->IsAbsolutelyPositionedStyle()) { @@ -1028,7 +1029,7 @@ static void DoApplyRenderingChangeToTree(nsIFrame* aFrame, aFrame->IsFrameOfType(nsIFrame::eSVG) && !aFrame->IsSVGOuterSVGFrame()) { // Need to update our overflow rects: - nsSVGUtils::ScheduleReflowSVG(aFrame); + SVGUtils::ScheduleReflowSVG(aFrame); } ActiveLayerTracker::NotifyNeedsRepaint(aFrame); @@ -1039,7 +1040,7 @@ static void DoApplyRenderingChangeToTree(nsIFrame* aFrame, needInvalidatingPaint = true; ActiveLayerTracker::NotifyRestyle(aFrame, eCSSProperty_opacity); - if (nsSVGIntegrationUtils::UsingEffectsForFrame(aFrame)) { + if (SVGIntegrationUtils::UsingEffectsForFrame(aFrame)) { // SVG effects paints the opacity without using // nsDisplayOpacity. We need to invalidate manually. aFrame->InvalidateFrameSubtree(); @@ -1543,9 +1544,9 @@ void RestyleManager::ProcessRestyledFrames(nsStyleChangeList& aChangeList) { // opacity layer change hint when we do opacity optimization for SVG. // We can't do it in nsStyleEffects::CalcDifference() just like we do // for the optimization for 0.99 over opacity values since we have no way - // to call nsSVGUtils::CanOptimizeOpacity() there. + // to call SVGUtils::CanOptimizeOpacity() there. if ((hint & nsChangeHint_UpdateOpacityLayer) && - nsSVGUtils::CanOptimizeOpacity(frame)) { + SVGUtils::CanOptimizeOpacity(frame)) { hint &= ~nsChangeHint_UpdateOpacityLayer; hint |= nsChangeHint_RepaintFrame; } diff --git a/layout/base/nsCSSFrameConstructor.cpp b/layout/base/nsCSSFrameConstructor.cpp index 8dd218269ba4..f11f53cb12f2 100644 --- a/layout/base/nsCSSFrameConstructor.cpp +++ b/layout/base/nsCSSFrameConstructor.cpp @@ -119,7 +119,7 @@ #include "nsMathMLParts.h" #include "mozilla/dom/SVGTests.h" -#include "nsSVGUtils.h" +#include "mozilla/SVGUtils.h" #include "nsRefreshDriver.h" #include "nsTextNode.h" @@ -354,7 +354,7 @@ static inline bool IsDisplayContents(const nsIContent* aContent) { */ static bool IsFrameForSVG(const nsIFrame* aFrame) { return aFrame->IsFrameOfType(nsIFrame::eSVG) || - nsSVGUtils::IsInSVGTextSubtree(aFrame); + SVGUtils::IsInSVGTextSubtree(aFrame); } static bool IsLastContinuationForColumnContent(const nsIFrame* aFrame) { @@ -956,7 +956,7 @@ nsContainerFrame* nsFrameConstructorState::GetGeometricParent( // float to "none"? That's OK per CSS 2.1, as far as I can tell. if (aContentParentFrame && - nsSVGUtils::IsInSVGTextSubtree(aContentParentFrame)) { + SVGUtils::IsInSVGTextSubtree(aContentParentFrame)) { return aContentParentFrame; } @@ -2455,7 +2455,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock( ViewportFrame [fixed-cb] nsHTMLScrollFrame nsCanvasFrame [abs-cb] - root element frame (nsBlockFrame, nsSVGOuterSVGFrame, + root element frame (nsBlockFrame, SVGOuterSVGFrame, nsTableWrapperFrame, nsPlaceholderFrame) Galley presentation, XUL @@ -2471,7 +2471,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock( nsPageFrame nsPageContentFrame [fixed-cb] nsCanvasFrame [abs-cb] - root element frame (nsBlockFrame, nsSVGOuterSVGFrame, + root element frame (nsBlockFrame, SVGOuterSVGFrame, nsTableWrapperFrame, nsPlaceholderFrame) Print-preview presentation, non-XUL @@ -2482,7 +2482,7 @@ void nsCSSFrameConstructor::SetUpDocElementContainingBlock( nsPageFrame nsPageContentFrame [fixed-cb] nsCanvasFrame [abs-cb] - root element frame (nsBlockFrame, nsSVGOuterSVGFrame, + root element frame (nsBlockFrame, SVGOuterSVGFrame, nsTableWrapperFrame, nsPlaceholderFrame) Print/print preview of XUL is not supported. @@ -3177,9 +3177,8 @@ const nsCSSFrameConstructor::FrameConstructionData* nsCSSFrameConstructor::FindTextData(const Text& aTextContent, nsIFrame* aParentFrame) { if (aParentFrame && IsFrameForSVG(aParentFrame)) { - nsIFrame* ancestorFrame = - nsSVGUtils::GetFirstNonAAncestorFrame(aParentFrame); - if (!ancestorFrame || !nsSVGUtils::IsInSVGTextSubtree(ancestorFrame)) { + nsIFrame* ancestorFrame = SVGUtils::GetFirstNonAAncestorFrame(aParentFrame); + if (!ancestorFrame || !SVGUtils::IsInSVGTextSubtree(ancestorFrame)) { return nullptr; } @@ -4569,7 +4568,7 @@ nsIFrame* nsCSSFrameConstructor::ConstructNonScrollableBlockWithConstructor( if ((aDisplay->IsAbsolutelyPositionedStyle() || aDisplay->IsFloatingStyle() || aDisplay->DisplayInside() == StyleDisplayInside::FlowRoot || clipPaginatedOverflow) && - !nsSVGUtils::IsInSVGTextSubtree(aParentFrame)) { + !SVGUtils::IsInSVGTextSubtree(aParentFrame)) { flags = NS_BLOCK_FORMATTING_CONTEXT_STATE_BITS; if (clipPaginatedOverflow) { flags |= NS_BLOCK_CLIP_PAGINATED_OVERFLOW; @@ -4902,12 +4901,12 @@ nsCSSFrameConstructor::FindSVGData(const Element& aElement, } if (tag == nsGkAtoms::svg && !parentIsSVG) { - // We need outer elements to have an nsSVGOuterSVGFrame regardless + // We need outer elements to have an SVGOuterSVGFrame regardless // of whether they fail conditional processing attributes, since various // SVG frames assume that one exists. We handle the non-rendering // of failing outer element contents like statements, // and do the PassesConditionalProcessingTests call in - // nsSVGOuterSVGFrame::Init. + // SVGOuterSVGFrame::Init. static const FrameConstructionData sOuterSVGData = FULL_CTOR_FCDATA(0, &nsCSSFrameConstructor::ConstructOuterSVG); return &sOuterSVGData; @@ -4923,7 +4922,7 @@ nsCSSFrameConstructor::FindSVGData(const Element& aElement, if (tests && !tests->PassesConditionalProcessingTests()) { // Elements with failing conditional processing attributes never get // rendered. Note that this is not where we select which frame in a - // to render! That happens in nsSVGSwitchFrame::PaintSVG. + // to render! That happens in SVGSwitchFrame::PaintSVG. if (aIsWithinSVGText) { // SVGTextFrame doesn't handle conditional processing attributes, // so don't create frames for descendants of with failing @@ -4931,7 +4930,7 @@ nsCSSFrameConstructor::FindSVGData(const Element& aElement, // is correct. return &sSuppressData; } - // If we're not inside , create an nsSVGContainerFrame (which is a + // If we're not inside , create an SVGContainerFrame (which is a // frame that doesn't render) so that paint servers can still be referenced, // even if they live inside an element with failing conditional processing // attributes. @@ -5122,7 +5121,7 @@ void nsCSSFrameConstructor::DoAddFrameConstructionItems( ItemFlags aFlags) { auto flags = aFlags + ItemFlag::AllowPageBreak; if (aParentFrame) { - if (nsSVGUtils::IsInSVGTextSubtree(aParentFrame)) { + if (SVGUtils::IsInSVGTextSubtree(aParentFrame)) { flags += ItemFlag::IsWithinSVGText; } if (aParentFrame->IsBlockFrame() && aParentFrame->GetParent() && @@ -9945,7 +9944,7 @@ void nsCSSFrameConstructor::CreateLetterFrame( const nsStyleDisplay* display = sc->StyleDisplay(); nsFirstLetterFrame* letterFrame; if (display->IsFloatingStyle() && - !nsSVGUtils::IsInSVGTextSubtree(aParentFrame)) { + !SVGUtils::IsInSVGTextSubtree(aParentFrame)) { // Make a floating first-letter frame letterFrame = CreateFloatingLetterFrame(state, aTextContent, textFrame, aParentFrame, parentComputedStyle, diff --git a/layout/base/nsCSSFrameConstructor.h b/layout/base/nsCSSFrameConstructor.h index 053674bcaffa..b779a693b2f7 100644 --- a/layout/base/nsCSSFrameConstructor.h +++ b/layout/base/nsCSSFrameConstructor.h @@ -1466,7 +1466,7 @@ class nsCSSFrameConstructor final : public nsFrameManager { mozilla::PseudoStyleType aInnerPseudo, bool aCandidateRootFrame); /** - * Construct an nsSVGOuterSVGFrame. + * Construct an SVGOuterSVGFrame. */ nsIFrame* ConstructOuterSVG(nsFrameConstructorState& aState, FrameConstructionItem& aItem, @@ -1475,7 +1475,7 @@ class nsCSSFrameConstructor final : public nsFrameManager { nsFrameList& aFrameList); /** - * Construct an nsSVGMarkerFrame. + * Construct an SVGMarkerFrame. */ nsIFrame* ConstructMarker(nsFrameConstructorState& aState, FrameConstructionItem& aItem, diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 5498f6ba6217..8afd42210bda 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -33,7 +33,10 @@ #include "mozilla/StaticPrefs_image.h" #include "mozilla/StaticPrefs_layers.h" #include "mozilla/StaticPrefs_layout.h" +#include "mozilla/SVGImageContext.h" +#include "mozilla/SVGIntegrationUtils.h" #include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/Unused.h" #include "mozilla/ViewportFrame.h" #include "mozilla/ViewportUtils.h" @@ -106,9 +109,6 @@ #include "nsTableWrapperFrame.h" #include "nsTextFrame.h" #include "nsFontInflationData.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" -#include "SVGImageContext.h" #include "nsStyleStructInlines.h" #include "nsStyleTransformMatrix.h" #include "nsIFrameInlines.h" @@ -2355,7 +2355,7 @@ nsPoint GetEventCoordinatesRelativeTo(nsIWidget* aWidget, /* If we encountered a transform, we can't do simple arithmetic to figure * out how to convert back to aFrame's coordinates and must use the CTM. */ - if (transformFound || nsSVGUtils::IsInSVGTextSubtree(frame)) { + if (transformFound || SVGUtils::IsInSVGTextSubtree(frame)) { return nsLayoutUtils::TransformRootPointToFrame(ViewportType::Visual, aFrame, widgetToView); } @@ -3111,7 +3111,7 @@ static Rect TransformGfxRectToAncestor( } static SVGTextFrame* GetContainingSVGTextFrame(const nsIFrame* aFrame) { - if (!nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (!SVGUtils::IsInSVGTextSubtree(aFrame)) { return nullptr; } @@ -4520,7 +4520,7 @@ struct BoxToRect : public nsLayoutUtils::BoxCallback { virtual void AddBox(nsIFrame* aFrame) override { nsRect r; - nsIFrame* outer = nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(aFrame, &r); + nsIFrame* outer = SVGUtils::GetOuterSVGFrameAndCoveredRegion(aFrame, &r); if (!outer) { outer = aFrame; switch (mFlags & nsLayoutUtils::RECTS_WHICH_BOX_MASK) { @@ -8595,7 +8595,7 @@ nscoord nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame* aFrame) { } float nsLayoutUtils::FontSizeInflationFor(const nsIFrame* aFrame) { - if (nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (SVGUtils::IsInSVGTextSubtree(aFrame)) { const nsIFrame* container = aFrame; while (!container->IsSVGTextFrame()) { container = container->GetParent(); @@ -10039,8 +10039,8 @@ static nsRect ComputeSVGReferenceRect(nsIFrame* aFrame, // The size of stroke-box is not correct if this graphic element has // specific stroke-linejoin or stroke-linecap. gfxRect bbox = - nsSVGUtils::GetBBox(aFrame, nsSVGUtils::eBBoxIncludeFillGeometry | - nsSVGUtils::eBBoxIncludeStroke); + SVGUtils::GetBBox(aFrame, SVGUtils::eBBoxIncludeFillGeometry | + SVGUtils::eBBoxIncludeStroke); r = nsLayoutUtils::RoundGfxRectToAppRect(bbox, AppUnitsPerCSSPixel()); break; } @@ -10080,14 +10080,14 @@ static nsRect ComputeSVGReferenceRect(nsIFrame* aFrame, case StyleGeometryBox::MarginBox: case StyleGeometryBox::FillBox: { gfxRect bbox = - nsSVGUtils::GetBBox(aFrame, nsSVGUtils::eBBoxIncludeFillGeometry); + SVGUtils::GetBBox(aFrame, SVGUtils::eBBoxIncludeFillGeometry); r = nsLayoutUtils::RoundGfxRectToAppRect(bbox, AppUnitsPerCSSPixel()); break; } default: { MOZ_ASSERT_UNREACHABLE("unknown StyleGeometryBox type"); gfxRect bbox = - nsSVGUtils::GetBBox(aFrame, nsSVGUtils::eBBoxIncludeFillGeometry); + SVGUtils::GetBBox(aFrame, SVGUtils::eBBoxIncludeFillGeometry); r = nsLayoutUtils::RoundGfxRectToAppRect(bbox, AppUnitsPerCSSPixel()); break; } @@ -10188,7 +10188,7 @@ nsPoint nsLayoutUtils::ComputeOffsetToUserSpace(nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) { nsPoint offsetToBoundingBox = aBuilder->ToReferenceFrame(aFrame) - - nsSVGIntegrationUtils::GetOffsetToBoundingBox(aFrame); + SVGIntegrationUtils::GetOffsetToBoundingBox(aFrame); if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) { // Snap the offset if the reference frame is not a SVG frame, since other // frames will be snapped to pixel when rendering. @@ -10212,7 +10212,7 @@ nsPoint nsLayoutUtils::ComputeOffsetToUserSpace(nsDisplayListBuilder* aBuilder, // frame's position so that SVG painting can later add it again and the // frame is painted in the right place. gfxPoint toUserSpaceGfx = - nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame); + SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame); nsPoint toUserSpace = nsPoint(nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.x)), nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.y))); diff --git a/layout/build/nsLayoutStatics.cpp b/layout/build/nsLayoutStatics.cpp index e2530fd9a903..bb8551952744 100644 --- a/layout/build/nsLayoutStatics.cpp +++ b/layout/build/nsLayoutStatics.cpp @@ -51,8 +51,7 @@ #include "nsFocusManager.h" #include "nsListControlFrame.h" #include "mozilla/dom/HTMLInputElement.h" -#include "SVGElementFactory.h" -#include "nsSVGUtils.h" +#include "mozilla/dom/SVGElementFactory.h" #include "nsMathMLAtoms.h" #include "nsMathMLOperators.h" #include "Navigator.h" diff --git a/layout/generic/ReflowInput.cpp b/layout/generic/ReflowInput.cpp index 0367ee2e2f2e..f1497160b1eb 100644 --- a/layout/generic/ReflowInput.cpp +++ b/layout/generic/ReflowInput.cpp @@ -28,6 +28,7 @@ #include "nsIFrameInlines.h" #include "CounterStyleManager.h" #include +#include "mozilla/SVGUtils.h" #include "mozilla/dom/HTMLInputElement.h" #include "nsGridContainerFrame.h" @@ -2502,7 +2503,7 @@ void SizeComputationInput::InitOffsets(WritingMode aWM, nscoord aPercentBasis, ComputedPhysicalPadding() = LayoutDevicePixel::ToAppUnits( widgetPadding, presContext->AppUnitsPerDevPixel()); needPaddingProp = false; - } else if (nsSVGUtils::IsInSVGTextSubtree(mFrame)) { + } else if (SVGUtils::IsInSVGTextSubtree(mFrame)) { ComputedPhysicalPadding().SizeTo(0, 0, 0, 0); needPaddingProp = false; } else if (aPadding) { // padding is an input arg @@ -2551,7 +2552,7 @@ void SizeComputationInput::InitOffsets(WritingMode aWM, nscoord aPercentBasis, presContext->DeviceContext(), mFrame, disp->mAppearance); ComputedPhysicalBorderPadding() = LayoutDevicePixel::ToAppUnits( border, presContext->AppUnitsPerDevPixel()); - } else if (nsSVGUtils::IsInSVGTextSubtree(mFrame)) { + } else if (SVGUtils::IsInSVGTextSubtree(mFrame)) { ComputedPhysicalBorderPadding().SizeTo(0, 0, 0, 0); } else if (aBorder) { // border is an input arg ComputedPhysicalBorderPadding() = *aBorder; @@ -2828,7 +2829,7 @@ nscoord ReflowInput::CalcLineHeight(nsIContent* aContent, bool SizeComputationInput::ComputeMargin(WritingMode aWM, nscoord aPercentBasis) { // SVG text frames have no margin. - if (nsSVGUtils::IsInSVGTextSubtree(mFrame)) { + if (SVGUtils::IsInSVGTextSubtree(mFrame)) { return false; } diff --git a/layout/generic/nsBlockFrame.cpp b/layout/generic/nsBlockFrame.cpp index 1eb73a2cc1d9..79a23b6c0475 100644 --- a/layout/generic/nsBlockFrame.cpp +++ b/layout/generic/nsBlockFrame.cpp @@ -19,6 +19,7 @@ #include "mozilla/PresShell.h" #include "mozilla/StaticPrefs_browser.h" #include "mozilla/StaticPrefs_layout.h" +#include "mozilla/SVGUtils.h" #include "mozilla/ToString.h" #include "mozilla/UniquePtr.h" @@ -533,7 +534,7 @@ nsresult nsBlockFrame::GetFrameName(nsAString& aResult) const { void nsBlockFrame::InvalidateFrame(uint32_t aDisplayItemKey, bool aRebuildDisplayItems) { - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { NS_ASSERTION(GetParent()->IsSVGTextFrame(), "unexpected block frame in SVG text"); GetParent()->InvalidateFrame(); @@ -545,7 +546,7 @@ void nsBlockFrame::InvalidateFrame(uint32_t aDisplayItemKey, void nsBlockFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey, bool aRebuildDisplayItems) { - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { NS_ASSERTION(GetParent()->IsSVGTextFrame(), "unexpected block frame in SVG text"); GetParent()->InvalidateFrame(); @@ -2188,7 +2189,7 @@ void nsBlockFrame::MarkLineDirty(LineIterator aLine, static inline bool IsAlignedLeft(StyleTextAlign aAlignment, StyleDirection aDirection, uint8_t aUnicodeBidi, nsIFrame* aFrame) { - return nsSVGUtils::IsInSVGTextSubtree(aFrame) || + return SVGUtils::IsInSVGTextSubtree(aFrame) || StyleTextAlign::Left == aAlignment || (((StyleTextAlign::Start == aAlignment && StyleDirection::Ltr == aDirection) || @@ -4870,7 +4871,7 @@ bool nsBlockFrame::PlaceLine(BlockReflowInput& aState, * In other words, isLastLine really means isLastLineAndWeCare. */ const bool isLastLine = - !nsSVGUtils::IsInSVGTextSubtree(this) && + !SVGUtils::IsInSVGTextSubtree(this) && styleText->TextAlignForLastLine() != styleText->mTextAlign && (aLineLayout.GetLineEndsInBR() || IsLastLine(aState, aLine)); @@ -5472,7 +5473,7 @@ void nsBlockFrame::AppendFrames(ChildListID aListID, nsFrameList& aFrameList) { printf("\n"); #endif - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { MOZ_ASSERT(GetParent()->IsSVGTextFrame(), "unexpected block frame in SVG text"); // Workaround for bug 1399425 in case this bit has been removed from the diff --git a/layout/generic/nsFrameStateBits.h b/layout/generic/nsFrameStateBits.h index 9981a7f2d2b0..aafe9edcc373 100644 --- a/layout/generic/nsFrameStateBits.h +++ b/layout/generic/nsFrameStateBits.h @@ -233,7 +233,7 @@ FRAME_STATE_BIT(Generic, 42, NS_FRAME_FONT_INFLATION_FLOW_ROOT) // This bit is set on SVG frames that are laid out using SVG's coordinate // system based layout (as opposed to any of the CSS layout models). Note that -// this does not include nsSVGOuterSVGFrame since it takes part is CSS layout. +// this does not include SVGOuterSVGFrame since it takes part in CSS layout. FRAME_STATE_BIT(Generic, 43, NS_FRAME_SVG_LAYOUT) // This bit is set if a frame has a multi-column ancestor (i.e. diff --git a/layout/generic/nsGfxScrollFrame.cpp b/layout/generic/nsGfxScrollFrame.cpp index b8bcecab3ffc..2fc973bebb37 100644 --- a/layout/generic/nsGfxScrollFrame.cpp +++ b/layout/generic/nsGfxScrollFrame.cpp @@ -59,7 +59,6 @@ #include "ScrollbarActivity.h" #include "nsRefreshDriver.h" #include "nsStyleConsts.h" -#include "nsSVGIntegrationUtils.h" #include "nsIScrollPositionListener.h" #include "StickyScrollContainer.h" #include "nsIFrameInlines.h" diff --git a/layout/generic/nsIFrame.cpp b/layout/generic/nsIFrame.cpp index 36605805998a..3f442186bf64 100644 --- a/layout/generic/nsIFrame.cpp +++ b/layout/generic/nsIFrame.cpp @@ -30,6 +30,8 @@ #include "mozilla/SVGMaskFrame.h" #include "mozilla/SVGObserverUtils.h" #include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGIntegrationUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/ToString.h" #include "mozilla/ViewportUtils.h" @@ -88,7 +90,6 @@ #include "nsBoxLayoutState.h" #include "nsBlockFrame.h" #include "nsDisplayList.h" -#include "nsSVGIntegrationUtils.h" #include "nsChangeHint.h" #include "nsDeckFrame.h" #include "nsSubDocumentFrame.h" @@ -567,7 +568,7 @@ static bool IsFontSizeInflationContainer(nsIFrame* aFrame, } static void MaybeScheduleReflowSVGNonDisplayText(nsIFrame* aFrame) { - if (!nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (!SVGUtils::IsInSVGTextSubtree(aFrame)) { return; } @@ -1654,7 +1655,7 @@ const nsIFrame::ChildListID nsIFrame::kNoReflowPrincipalList; nsMargin nsIFrame::GetUsedMargin() const { nsMargin margin(0, 0, 0, 0); if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) || - nsSVGUtils::IsInSVGTextSubtree(this)) + SVGUtils::IsInSVGTextSubtree(this)) return margin; nsMargin* m = GetProperty(UsedMarginProperty()); @@ -1675,7 +1676,7 @@ nsMargin nsIFrame::GetUsedMargin() const { nsMargin nsIFrame::GetUsedBorder() const { nsMargin border(0, 0, 0, 0); if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) || - nsSVGUtils::IsInSVGTextSubtree(this)) + SVGUtils::IsInSVGTextSubtree(this)) return border; // Theme methods don't use const-ness. @@ -1704,7 +1705,7 @@ nsMargin nsIFrame::GetUsedBorder() const { nsMargin nsIFrame::GetUsedPadding() const { nsMargin padding(0, 0, 0, 0); if (((mState & NS_FRAME_FIRST_REFLOW) && !(mState & NS_FRAME_IN_REFLOW)) || - nsSVGUtils::IsInSVGTextSubtree(this)) + SVGUtils::IsInSVGTextSubtree(this)) return padding; // Theme methods don't use const-ness. @@ -1890,7 +1891,7 @@ bool nsIFrame::Extend3DContext(const nsStyleDisplay* aStyleDisplay, return !ShouldApplyOverflowClipping(disp) && !GetClipPropClipRect(disp, effects, GetSize()) && - !nsSVGIntegrationUtils::UsingEffectsForFrame(this); + !SVGIntegrationUtils::UsingEffectsForFrame(this); } bool nsIFrame::Combines3DTransformWithAncestors( @@ -2996,15 +2997,15 @@ static Maybe ComputeClipForMaskItem(nsDisplayListBuilder* aBuilder, nsIFrame* aMaskedFrame) { const nsStyleSVGReset* svgReset = aMaskedFrame->StyleSVGReset(); - nsSVGUtils::MaskUsage maskUsage; - nsSVGUtils::DetermineMaskUsage(aMaskedFrame, false, maskUsage); + SVGUtils::MaskUsage maskUsage; + SVGUtils::DetermineMaskUsage(aMaskedFrame, false, maskUsage); nsPoint offsetToUserSpace = nsLayoutUtils::ComputeOffsetToUserSpace(aBuilder, aMaskedFrame); int32_t devPixelRatio = aMaskedFrame->PresContext()->AppUnitsPerDevPixel(); gfxPoint devPixelOffsetToUserSpace = nsLayoutUtils::PointToGfxPoint(offsetToUserSpace, devPixelRatio); - gfxMatrix cssToDevMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(aMaskedFrame); + gfxMatrix cssToDevMatrix = SVGUtils::GetCSSPxToDevPxMatrix(aMaskedFrame); nsPoint toReferenceFrame; aBuilder->FindReferenceFrameFor(aMaskedFrame, &toReferenceFrame); @@ -3018,11 +3019,11 @@ static Maybe ComputeClipForMaskItem(nsDisplayListBuilder* aBuilder, combinedClip = Some(ThebesRect(*result)); } } else if (maskUsage.shouldApplyClipPath) { - gfxRect result = nsSVGUtils::GetBBox( + gfxRect result = SVGUtils::GetBBox( aMaskedFrame, - nsSVGUtils::eBBoxIncludeClipped | nsSVGUtils::eBBoxIncludeFill | - nsSVGUtils::eBBoxIncludeMarkers | nsSVGUtils::eBBoxIncludeStroke | - nsSVGUtils::eDoNotClipToBBoxOfContentInsideClipPath); + SVGUtils::eBBoxIncludeClipped | SVGUtils::eBBoxIncludeFill | + SVGUtils::eBBoxIncludeMarkers | SVGUtils::eBBoxIncludeStroke | + SVGUtils::eDoNotClipToBBoxOfContentInsideClipPath); combinedClip = Some(cssToDevMatrix.TransformBounds(result)); } else { // The code for this case is adapted from ComputeMaskGeometry(). @@ -3206,7 +3207,7 @@ void nsIFrame::BuildDisplayListForStackingContext( // NeedsActiveLayer was to change, which we don't currently do. const bool useOpacity = HasVisualOpacity(disp, effects, effectSetForOpacity) && - !nsSVGUtils::CanOptimizeOpacity(this); + !SVGUtils::CanOptimizeOpacity(this); const bool isTransformed = IsTransformed(disp); const bool hasPerspective = isTransformed && HasPerspective(disp); @@ -3330,16 +3331,16 @@ void nsIFrame::BuildDisplayListForStackingContext( } bool usingFilter = effects->HasFilters(); - bool usingMask = nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(this); + bool usingMask = SVGIntegrationUtils::UsingMaskOrClipPathForFrame(this); bool usingSVGEffects = usingFilter || usingMask; nsRect visibleRectOutsideSVGEffects = visibleRect; nsDisplayList hoistedScrollInfoItemsStorage; if (usingSVGEffects) { dirtyRect = - nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea(this, dirtyRect); - visibleRect = nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea( - this, visibleRect); + SVGIntegrationUtils::GetRequiredSourceForInvalidArea(this, dirtyRect); + visibleRect = + SVGIntegrationUtils::GetRequiredSourceForInvalidArea(this, visibleRect); aBuilder->EnterSVGEffectsContents(this, &hoistedScrollInfoItemsStorage); } @@ -5518,7 +5519,7 @@ static FrameTarget GetSelectionClosestFrame(nsIFrame* aFrame, kid->FindCloserFrameForSelection(aPoint, &closest); } if (closest.mFrame) { - if (nsSVGUtils::IsInSVGTextSubtree(closest.mFrame)) + if (SVGUtils::IsInSVGTextSubtree(closest.mFrame)) return FrameTarget(closest.mFrame, false, false); return GetSelectionClosestFrameForChild(closest.mFrame, aPoint, aFlags); } @@ -5638,7 +5639,7 @@ nsIFrame::ContentOffsets nsIFrame::GetContentOffsetsFromPoint( nsPoint pt; if (closest.frame != this) { - if (nsSVGUtils::IsInSVGTextSubtree(closest.frame)) { + if (SVGUtils::IsInSVGTextSubtree(closest.frame)) { pt = nsLayoutUtils::TransformAncestorPointToFrame( RelativeTo{closest.frame}, aPoint, RelativeTo{this}); } else { @@ -7287,7 +7288,7 @@ static nsRect ComputeEffectsRect(nsIFrame* aFrame, const nsRect& aOverflowRect, if (aFrame->StyleEffects()->HasFilters()) { SetOrUpdateRectValuedProperty(aFrame, nsIFrame::PreEffectsBBoxProperty(), r); - r = nsSVGUtils::GetPostFilterVisualOverflowRect(aFrame, aOverflowRect); + r = SVGUtils::GetPostFilterVisualOverflowRect(aFrame, aOverflowRect); } return r; } @@ -7323,10 +7324,10 @@ static nsRect ComputeEffectsRect(nsIFrame* aFrame, const nsRect& aOverflowRect, // only one heap-allocated rect per frame and it will be cleaned up when // the frame dies. - if (nsSVGIntegrationUtils::UsingOverflowAffectingEffects(aFrame)) { + if (SVGIntegrationUtils::UsingOverflowAffectingEffects(aFrame)) { SetOrUpdateRectValuedProperty(aFrame, nsIFrame::PreEffectsBBoxProperty(), r); - r = nsSVGIntegrationUtils::ComputePostEffectsVisualOverflowRect(aFrame, r); + r = SVGIntegrationUtils::ComputePostEffectsVisualOverflowRect(aFrame, r); } return r; @@ -9928,7 +9929,7 @@ static StyleVerticalAlignKeyword ConvertSVGDominantBaselineToVerticalAlign( } Maybe nsIFrame::VerticalAlignEnum() const { - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { StyleDominantBaseline dominantBaseline = StyleSVG()->mDominantBaseline; return Some(ConvertSVGDominantBaselineToVerticalAlign(dominantBaseline)); } @@ -10712,7 +10713,7 @@ bool nsIFrame::IsStackingContext(const nsStyleDisplay* aStyleDisplay, // but the spec says it acts like the rest of these ChildrenHavePerspective(aStyleDisplay) || aStyleEffects->mMixBlendMode != StyleBlend::Normal || - nsSVGIntegrationUtils::UsingEffectsForFrame(this) || + SVGIntegrationUtils::UsingEffectsForFrame(this) || aStyleDisplay->IsPositionForcingStackingContext() || ZIndex().isSome() || (aStyleDisplay->mWillChange.bits & @@ -10971,12 +10972,12 @@ CompositorHitTestInfo nsIFrame::GetCompositorHitTestInfo( // Anything that didn't match the above conditions is visible to hit-testing. result = CompositorHitTestFlags::eVisibleToHitTest; - if (nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(this)) { + if (SVGIntegrationUtils::UsingMaskOrClipPathForFrame(this)) { // If WebRender is enabled, simple clip-paths can be converted into WR // clips that WR knows how to hit-test against, so we don't need to mark // it as an irregular area. if (!gfxVars::UseWebRender() || - !nsSVGIntegrationUtils::UsingSimpleClipPathForFrame(this)) { + !SVGIntegrationUtils::UsingSimpleClipPathForFrame(this)) { result += CompositorHitTestFlags::eIrregularArea; } } diff --git a/layout/generic/nsIFrame.h b/layout/generic/nsIFrame.h index f9249c7f115d..daf9ba807984 100644 --- a/layout/generic/nsIFrame.h +++ b/layout/generic/nsIFrame.h @@ -1060,10 +1060,10 @@ class nsIFrame : public nsQueryFrame { * * Frames that are laid out according to SVG's coordinate space based rules * (frames with the NS_FRAME_SVG_LAYOUT bit set, which *excludes* - * nsSVGOuterSVGFrame) are different. Many frames of this type do not set or + * SVGOuterSVGFrame) are different. Many frames of this type do not set or * use mRect, in which case the frame rect is undefined. The exceptions are: * - * - nsSVGInnerSVGFrame + * - SVGInnerSVGFrame * - SVGGeometryFrame (used for , , etc.) * - SVGImageFrame * - SVGForeignObjectFrame @@ -3316,7 +3316,7 @@ class nsIFrame : public nsQueryFrame { bool IsBlockFrameOrSubclass() const; /** - * Returns true if the frame is an instance of nsSVGGeometryFrame or one + * Returns true if the frame is an instance of SVGGeometryFrame or one * of its subclasses. */ inline bool IsSVGGeometryFrameOrSubclass() const; diff --git a/layout/generic/nsInlineFrame.cpp b/layout/generic/nsInlineFrame.cpp index dfb312846a00..6a4bff6b1551 100644 --- a/layout/generic/nsInlineFrame.cpp +++ b/layout/generic/nsInlineFrame.cpp @@ -14,6 +14,8 @@ #include "mozilla/PresShell.h" #include "mozilla/RestyleManager.h" #include "mozilla/ServoStyleSet.h" +#include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "nsLineLayout.h" #include "nsBlockFrame.h" #include "nsPlaceholderFrame.h" @@ -22,7 +24,6 @@ #include "nsPresContextInlines.h" #include "nsCSSAnonBoxes.h" #include "nsDisplayList.h" -#include "SVGTextFrame.h" #include "nsStyleChangeList.h" #ifdef DEBUG @@ -54,7 +55,7 @@ nsresult nsInlineFrame::GetFrameName(nsAString& aResult) const { void nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey, bool aRebuildDisplayItems) { - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType( GetParent(), LayoutFrameType::SVGText); svgTextFrame->InvalidateFrame(); @@ -66,7 +67,7 @@ void nsInlineFrame::InvalidateFrame(uint32_t aDisplayItemKey, void nsInlineFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey, bool aRebuildDisplayItems) { - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType( GetParent(), LayoutFrameType::SVGText); svgTextFrame->InvalidateFrame(); @@ -379,7 +380,7 @@ nsresult nsInlineFrame::AttributeChanged(int32_t aNameSpaceID, return rv; } - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { SVGTextFrame* f = static_cast( nsLayoutUtils::GetClosestFrameOfType(this, LayoutFrameType::SVGText)); f->HandleAttributeChangeInDescendant(mContent->AsElement(), aNameSpaceID, diff --git a/layout/generic/nsLineLayout.cpp b/layout/generic/nsLineLayout.cpp index a639e07c8489..7d0484af77ea 100644 --- a/layout/generic/nsLineLayout.cpp +++ b/layout/generic/nsLineLayout.cpp @@ -9,9 +9,10 @@ #include "nsLineLayout.h" #include "mozilla/ComputedStyle.h" +#include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "LayoutLogging.h" -#include "SVGTextFrame.h" #include "nsBlockFrame.h" #include "nsFontMetrics.h" #include "nsStyleConsts.h" @@ -79,8 +80,7 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext, mDirtyNextLine(false), mLineAtStart(false), mHasRuby(false), - mSuppressLineWrap( - nsSVGUtils::IsInSVGTextSubtree(aOuterReflowInput->mFrame)) + mSuppressLineWrap(SVGUtils::IsInSVGTextSubtree(aOuterReflowInput->mFrame)) #ifdef DEBUG , mSpansAllocated(0), @@ -1715,7 +1715,7 @@ void nsLineLayout::AdjustLeadings(nsIFrame* spanFrame, PerSpanData* psd, static float GetInflationForBlockDirAlignment(nsIFrame* aFrame, nscoord aInflationMinFontSize) { - if (nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (SVGUtils::IsInSVGTextSubtree(aFrame)) { const nsIFrame* container = nsLayoutUtils::GetClosestFrameOfType(aFrame, LayoutFrameType::SVGText); NS_ASSERTION(container, "expected to find an ancestor SVGTextFrame"); @@ -3081,7 +3081,7 @@ void nsLineLayout::TextAlignLine(nsLineBox* aLine, bool aIsLastLine) { StyleTextAlign textAlign = aIsLastLine ? mStyleText->TextAlignForLastLine() : mStyleText->mTextAlign; - bool isSVG = nsSVGUtils::IsInSVGTextSubtree(mBlockReflowInput->mFrame); + bool isSVG = SVGUtils::IsInSVGTextSubtree(mBlockReflowInput->mFrame); bool doTextAlign = remainingISize > 0; int32_t additionalGaps = 0; diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 232e3d54376e..721e0eed52fa 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -22,6 +22,7 @@ #include "mozilla/StaticPrefs_svg.h" #include "mozilla/StaticPresData.h" #include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/TextEditor.h" #include "mozilla/TextEvents.h" #include "mozilla/BinarySearch.h" @@ -331,13 +332,13 @@ class nsTextPaintStyle { // SVG text has its own painting process, so we should never get its stroke // property from here. nscolor GetWebkitTextStrokeColor() { - if (nsSVGUtils::IsInSVGTextSubtree(mFrame)) { + if (SVGUtils::IsInSVGTextSubtree(mFrame)) { return 0; } return mFrame->StyleText()->mWebkitTextStrokeColor.CalcColor(mFrame); } float GetWebkitTextStrokeWidth() { - if (nsSVGUtils::IsInSVGTextSubtree(mFrame)) { + if (SVGUtils::IsInSVGTextSubtree(mFrame)) { return 0.0f; } nscoord coord = mFrame->StyleText()->mWebkitTextStrokeWidth; @@ -656,7 +657,7 @@ static void InvalidateFrameDueToGlyphsChanged(nsIFrame* aFrame) { // to reflow the SVGTextFrame. (This is similar to reflowing the // SVGTextFrame in response to style changes, in // SVGTextFrame::DidSetComputedStyle.) - if (nsSVGUtils::IsInSVGTextSubtree(f) && + if (SVGUtils::IsInSVGTextSubtree(f) && f->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { auto svgTextFrame = static_cast( nsLayoutUtils::GetClosestFrameOfType(f, LayoutFrameType::SVGText)); @@ -1744,7 +1745,7 @@ static gfxFloat GetMinTabAdvanceAppUnits(const gfxTextRun* aTextRun) { } static float GetSVGFontSizeScaleFactor(nsIFrame* aFrame) { - if (!nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (!SVGUtils::IsInSVGTextSubtree(aFrame)) { return 1.0f; } auto container = @@ -1759,7 +1760,7 @@ static nscoord LetterSpacing(nsIFrame* aFrame, aStyleText = aFrame->StyleText(); } - if (nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (SVGUtils::IsInSVGTextSubtree(aFrame)) { if (!StaticPrefs::svg_text_spacing_enabled()) { return 0; } @@ -1782,7 +1783,7 @@ static nscoord WordSpacing(nsIFrame* aFrame, const gfxTextRun* aTextRun, aStyleText = aFrame->StyleText(); } - if (nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (SVGUtils::IsInSVGTextSubtree(aFrame)) { // SVG text can have a scaling factor applied so that very small or very // large font-sizes don't suffer from poor glyph placement due to app unit // rounding. The used word-spacing value must be scaled by the same @@ -1805,7 +1806,7 @@ static nscoord WordSpacing(nsIFrame* aFrame, const gfxTextRun* aTextRun, // letter-spacing or word-spacing is present. static gfx::ShapedTextFlags GetSpacingFlags( nsIFrame* aFrame, const nsStyleText* aStyleText = nullptr) { - if (nsSVGUtils::IsInSVGTextSubtree(aFrame) && + if (SVGUtils::IsInSVGTextSubtree(aFrame) && !StaticPrefs::svg_text_spacing_enabled()) { return gfx::ShapedTextFlags(); } @@ -2189,7 +2190,7 @@ already_AddRefed BuildTextRunsScanner::BuildTextRunForFrames( uint32_t nextBreakIndex = 0; nsTextFrame* nextBreakBeforeFrame = GetNextBreakBeforeFrame(&nextBreakIndex); - bool isSVG = nsSVGUtils::IsInSVGTextSubtree(mLineContainer); + bool isSVG = SVGUtils::IsInSVGTextSubtree(mLineContainer); bool enabledJustification = (mLineContainer->StyleText()->mTextAlign == StyleTextAlign::Justify || mLineContainer->StyleText()->mTextAlignLast == @@ -3827,7 +3828,7 @@ bool nsTextPaintStyle::EnsureSufficientContrast(nscolor* aForeColor, } nscolor nsTextPaintStyle::GetTextColor() { - if (nsSVGUtils::IsInSVGTextSubtree(mFrame)) { + if (SVGUtils::IsInSVGTextSubtree(mFrame)) { if (!mResolveColors) return NS_SAME_AS_FOREGROUND_COLOR; const nsStyleSVG* style = mFrame->StyleSVG(); @@ -4104,7 +4105,7 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() { // the text color remains intact. if (mSelectionTextColor == NS_DONT_CHANGE_COLOR) { nscolor frameColor = - nsSVGUtils::IsInSVGTextSubtree(mFrame) + SVGUtils::IsInSVGTextSubtree(mFrame) ? mFrame->GetVisitedDependentColor(&nsStyleSVG::mFill) : mFrame->GetVisitedDependentColor( &nsStyleText::mWebkitTextFillColor); @@ -4112,7 +4113,7 @@ bool nsTextPaintStyle::InitSelectionColorsAndShadow() { EnsureDifferentColors(frameColor, mSelectionBGColor); } else if (mSelectionTextColor == NS_CHANGE_COLOR_IF_SAME_AS_BG) { nscolor frameColor = - nsSVGUtils::IsInSVGTextSubtree(mFrame) + SVGUtils::IsInSVGTextSubtree(mFrame) ? mFrame->GetVisitedDependentColor(&nsStyleSVG::mFill) : mFrame->GetVisitedDependentColor( &nsStyleText::mWebkitTextFillColor); @@ -4627,7 +4628,7 @@ nsTextFrame* nsTextFrame::LastContinuation() const { void nsTextFrame::InvalidateFrame(uint32_t aDisplayItemKey, bool aRebuildDisplayItems) { - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType( GetParent(), LayoutFrameType::SVGText); svgTextFrame->InvalidateFrame(); @@ -4639,7 +4640,7 @@ void nsTextFrame::InvalidateFrame(uint32_t aDisplayItemKey, void nsTextFrame::InvalidateFrameWithRect(const nsRect& aRect, uint32_t aDisplayItemKey, bool aRebuildDisplayItems) { - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { nsIFrame* svgTextFrame = nsLayoutUtils::GetClosestFrameOfType( GetParent(), LayoutFrameType::SVGText); svgTextFrame->InvalidateFrame(); @@ -4874,7 +4875,7 @@ void nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, Maybe isSelected; if ((HasAnyStateBits(TEXT_NO_RENDERED_GLYPHS) || (isTextTransparent && !StyleText()->HasTextShadow())) && - aBuilder->IsForPainting() && !nsSVGUtils::IsInSVGTextSubtree(this)) { + aBuilder->IsForPainting() && !SVGUtils::IsInSVGTextSubtree(this)) { isSelected.emplace(IsSelected()); if (!isSelected.value()) { TextDecorations textDecs; @@ -5055,7 +5056,7 @@ void nsTextFrame::GetTextDecorations( nscolor color; if (useOverride) { color = overrideColor; - } else if (nsSVGUtils::IsInSVGTextSubtree(this)) { + } else if (SVGUtils::IsInSVGTextSubtree(this)) { // XXX We might want to do something with text-decoration-color when // painting SVG text, but it's not clear what we should do. We // at least need SVG text decorations to paint with 'fill' if @@ -5135,7 +5136,7 @@ void nsTextFrame::GetTextDecorations( static float GetInflationForTextDecorations(nsIFrame* aFrame, nscoord aInflationMinFontSize) { - if (nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (SVGUtils::IsInSVGTextSubtree(aFrame)) { auto container = nsLayoutUtils::GetClosestFrameOfType(aFrame, LayoutFrameType::SVGText); MOZ_ASSERT(container); @@ -6513,7 +6514,7 @@ nscolor nsTextFrame::GetCaretColorAt(int32_t aOffset) { } bool isSolidTextColor = true; - if (nsSVGUtils::IsInSVGTextSubtree(this)) { + if (SVGUtils::IsInSVGTextSubtree(this)) { const nsStyleSVG* style = StyleSVG(); if (!style->mFill.kind.IsNone() && !style->mFill.kind.IsColor()) { isSolidTextColor = false; @@ -9537,7 +9538,7 @@ void nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, lineContainer->StyleText()->mTextAlignLast == StyleTextAlignLast::Justify || shouldSuppressLineBreak) && - !nsSVGUtils::IsInSVGTextSubtree(lineContainer)) { + !SVGUtils::IsInSVGTextSubtree(lineContainer)) { AddStateBits(TEXT_JUSTIFICATION_ENABLED); Range range(uint32_t(offset), uint32_t(offset + charsFit)); aLineLayout.SetJustificationInfo(provider.ComputeJustification(range)); diff --git a/layout/painting/FrameLayerBuilder.cpp b/layout/painting/FrameLayerBuilder.cpp index 0b2af9c758dc..0576d8140aa6 100644 --- a/layout/painting/FrameLayerBuilder.cpp +++ b/layout/painting/FrameLayerBuilder.cpp @@ -40,6 +40,7 @@ #include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_layers.h" #include "mozilla/StaticPrefs_layout.h" +#include "mozilla/SVGIntegrationUtils.h" #include "mozilla/Unused.h" #include "mozilla/dom/EffectsInfo.h" #include "mozilla/dom/ProfileTimelineMarkerBinding.h" @@ -58,7 +59,6 @@ #include "nsLayoutUtils.h" #include "nsPresContext.h" #include "nsPrintfCString.h" -#include "nsSVGIntegrationUtils.h" #include "nsSubDocumentFrame.h" #include "nsTransitionManager.h" @@ -5461,7 +5461,7 @@ void FrameLayerBuilder::AddPaintedDisplayItem(PaintedLayerData* aLayerData, invalid = visible.ToOutsidePixels(paintedData->mAppUnitsPerDevPixel); } if (aItem.mLayerState == LayerState::LAYER_SVG_EFFECTS) { - invalid = nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects( + invalid = SVGIntegrationUtils::AdjustInvalidAreaForSVGEffects( aItem.mItem->Frame(), aItem.mItem->ToReferenceFrame(), invalid); } if (!invalid.IsEmpty()) { diff --git a/layout/painting/nsCSSRendering.cpp b/layout/painting/nsCSSRendering.cpp index a08e8fe77d32..6052e33d738d 100644 --- a/layout/painting/nsCSSRendering.cpp +++ b/layout/painting/nsCSSRendering.cpp @@ -48,8 +48,6 @@ #include "nsCSSFrameConstructor.h" #include "nsCSSProps.h" #include "nsContentUtils.h" -#include "SVGObserverUtils.h" -#include "nsSVGIntegrationUtils.h" #include "gfxDrawable.h" #include "GeckoProfiler.h" #include "nsCSSRenderingBorders.h" diff --git a/layout/painting/nsDisplayList.cpp b/layout/painting/nsDisplayList.cpp index 074618630d5d..ee963203bb51 100644 --- a/layout/painting/nsDisplayList.cpp +++ b/layout/painting/nsDisplayList.cpp @@ -33,6 +33,8 @@ #include "mozilla/StaticPrefs_gfx.h" #include "mozilla/StaticPrefs_layers.h" #include "mozilla/StaticPrefs_layout.h" +#include "mozilla/SVGIntegrationUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/ViewportUtils.h" #include "nsCSSRendering.h" #include "nsCSSRenderingGradients.h" @@ -41,8 +43,6 @@ #include "nsStyleTransformMatrix.h" #include "nsTransitionManager.h" #include "gfxMatrix.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" #include "nsLayoutUtils.h" #include "nsIScrollableFrame.h" #include "nsIFrameInlines.h" @@ -1975,7 +1975,7 @@ bool nsDisplayListBuilder::ShouldBuildScrollInfoItemsForHoisting() const { * ScrollFrameWillBuildScrollInfoLayer() in nsSliderFrame.cpp. */ for (nsIFrame* frame : mSVGEffectsFrames) { - if (nsSVGIntegrationUtils::UsesSVGEffectsNotSupportedInCompositor(frame)) { + if (SVGIntegrationUtils::UsesSVGEffectsNotSupportedInCompositor(frame)) { return true; } } @@ -5913,7 +5913,7 @@ bool nsDisplayOpacity::ShouldFlattenAway(nsDisplayListBuilder* aBuilder) { const bool usingLayers = !aBuilder->IsPaintingForWebRender(); if (ApplyToFilterOrMask(usingLayers)) { - MOZ_ASSERT(nsSVGIntegrationUtils::UsingEffectsForFrame(mFrame)); + MOZ_ASSERT(SVGIntegrationUtils::UsingEffectsForFrame(mFrame)); mChildOpacityState = ChildOpacityState::Applied; return true; } @@ -7562,7 +7562,7 @@ Matrix4x4 nsDisplayTransform::GetResultingTransformMatrixInternal( // Apply any translation due to 'transform-origin' and/or 'transform-box': result.ChangeBasis(aProperties.mToTransformOrigin); - // See the comment for nsSVGContainerFrame::HasChildrenOnlyTransform for + // See the comment for SVGContainerFrame::HasChildrenOnlyTransform for // an explanation of what children-only transforms are. bool parentHasChildrenOnlyTransform = hasSVGTransforms && !parentsChildrenOnlyTransform.IsIdentity(); @@ -9010,18 +9010,18 @@ void nsDisplayEffectsBase::HitTest(nsDisplayListBuilder* aBuilder, const nsRect& aRect, HitTestState* aState, nsTArray* aOutFrames) { nsPoint rectCenter(aRect.x + aRect.width / 2, aRect.y + aRect.height / 2); - if (nsSVGIntegrationUtils::HitTestFrameForEffects( + if (SVGIntegrationUtils::HitTestFrameForEffects( mFrame, rectCenter - ToReferenceFrame())) { mList.HitTest(aBuilder, aRect, aState, aOutFrames); } } gfxRect nsDisplayEffectsBase::BBoxInUserSpace() const { - return nsSVGUtils::GetBBox(mFrame); + return SVGUtils::GetBBox(mFrame); } gfxPoint nsDisplayEffectsBase::UserSpaceOffset() const { - return nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(mFrame); + return SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(mFrame); } void nsDisplayEffectsBase::ComputeInvalidationRegion( @@ -9062,7 +9062,7 @@ bool nsDisplayEffectsBase::ValidateSVGFrame() { return true; } -typedef nsSVGIntegrationUtils::PaintFramesParams PaintFramesParams; +typedef SVGIntegrationUtils::PaintFramesParams PaintFramesParams; static void ComputeMaskGeometry(PaintFramesParams& aParams) { // Properties are added lazily and may have been removed by a restyle, so @@ -9222,12 +9222,12 @@ bool nsDisplayMasksAndClipPaths::PaintMask(nsDisplayListBuilder* aBuilder, imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags()); nsRect borderArea = nsRect(ToReferenceFrame(), mFrame->GetSize()); - nsSVGIntegrationUtils::PaintFramesParams params( - *aMaskContext, mFrame, mBounds, borderArea, aBuilder, nullptr, - mHandleOpacity, imgParams); + SVGIntegrationUtils::PaintFramesParams params(*aMaskContext, mFrame, mBounds, + borderArea, aBuilder, nullptr, + mHandleOpacity, imgParams); ComputeMaskGeometry(params); bool maskIsComplete = false; - bool painted = nsSVGIntegrationUtils::PaintMask(params, maskIsComplete); + bool painted = SVGIntegrationUtils::PaintMask(params, maskIsComplete); if (aMaskPainted) { *aMaskPainted = painted; } @@ -9263,7 +9263,7 @@ bool nsDisplayMasksAndClipPaths::CanPaintOnMaskLayer(LayerManager* aManager) { return false; } - if (!nsSVGIntegrationUtils::IsMaskResourceReady(mFrame)) { + if (!SVGIntegrationUtils::IsMaskResourceReady(mFrame)) { return false; } @@ -9339,13 +9339,13 @@ void nsDisplayMasksAndClipPaths::PaintAsLayer(nsDisplayListBuilder* aBuilder, imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags()); nsRect borderArea = nsRect(ToReferenceFrame(), mFrame->GetSize()); - nsSVGIntegrationUtils::PaintFramesParams params( - *aCtx, mFrame, GetPaintRect(), borderArea, aBuilder, aManager, - mHandleOpacity, imgParams); + SVGIntegrationUtils::PaintFramesParams params(*aCtx, mFrame, GetPaintRect(), + borderArea, aBuilder, aManager, + mHandleOpacity, imgParams); ComputeMaskGeometry(params); - nsSVGIntegrationUtils::PaintMaskAndClipPath(params); + SVGIntegrationUtils::PaintMaskAndClipPath(params); context->PopClip(); @@ -9366,13 +9366,13 @@ void nsDisplayMasksAndClipPaths::PaintWithContentsPaintCallback( imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags()); nsRect borderArea = nsRect(ToReferenceFrame(), mFrame->GetSize()); - nsSVGIntegrationUtils::PaintFramesParams params(*aCtx, mFrame, GetPaintRect(), - borderArea, aBuilder, nullptr, - mHandleOpacity, imgParams); + SVGIntegrationUtils::PaintFramesParams params(*aCtx, mFrame, GetPaintRect(), + borderArea, aBuilder, nullptr, + mHandleOpacity, imgParams); ComputeMaskGeometry(params); - nsSVGIntegrationUtils::PaintMaskAndClipPath(params, aPaintChildren); + SVGIntegrationUtils::PaintMaskAndClipPath(params, aPaintChildren); context->PopClip(); @@ -9385,7 +9385,7 @@ static Maybe CreateSimpleClipRegion( nsIFrame* frame = aDisplayItem.Frame(); auto* style = frame->StyleSVGReset(); MOZ_ASSERT(style->HasClipPath() || style->HasMask()); - if (!nsSVGIntegrationUtils::UsingSimpleClipPathForFrame(frame)) { + if (!SVGIntegrationUtils::UsingSimpleClipPathForFrame(frame)) { return Nothing(); } @@ -9449,7 +9449,7 @@ static Maybe CreateSimpleClipRegion( // without using a mask image. // // And if you _really really_ need to add an exception, add it to - // nsSVGIntegrationUtils::UsingSimpleClipPathForFrame + // SVGIntegrationUtils::UsingSimpleClipPathForFrame MOZ_ASSERT_UNREACHABLE("Unhandled shape id?"); return Nothing(); } @@ -9522,7 +9522,7 @@ bool nsDisplayMasksAndClipPaths::CreateWebRenderCommands( void nsDisplayMasksAndClipPaths::SelectOpacityOptimization( const bool aUsingLayers) { if (aUsingLayers || - !nsSVGIntegrationUtils::UsingSimpleClipPathForFrame(mFrame)) { + !SVGIntegrationUtils::UsingSimpleClipPathForFrame(mFrame)) { // Handle opacity in mask and clip-path drawing code. SetHandleOpacity(); MOZ_ASSERT(!mApplyOpacityWithSimpleClipPath); @@ -9632,7 +9632,7 @@ bool nsDisplayBackdropRootContainer::CreateWebRenderCommands( /* static */ bool nsDisplayBackdropFilters::CanCreateWebRenderCommands( nsDisplayListBuilder* aBuilder, nsIFrame* aFrame) { - return nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(aFrame); + return SVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(aFrame); } bool nsDisplayBackdropFilters::CreateWebRenderCommands( @@ -9644,10 +9644,10 @@ bool nsDisplayBackdropFilters::CreateWebRenderCommands( WrFiltersHolder wrFilters; Maybe filterClip; auto filterChain = mFrame->StyleEffects()->mBackdropFilters.AsSpan(); - if (!nsSVGIntegrationUtils::CreateWebRenderCSSFilters(filterChain, mFrame, - wrFilters) && - !nsSVGIntegrationUtils::BuildWebRenderFilters(mFrame, filterChain, - wrFilters, filterClip)) { + if (!SVGIntegrationUtils::CreateWebRenderCSSFilters(filterChain, mFrame, + wrFilters) && + !SVGIntegrationUtils::BuildWebRenderFilters(mFrame, filterChain, + wrFilters, filterClip)) { return false; } @@ -9728,7 +9728,7 @@ LayerState nsDisplayFilters::GetLayerState( bool nsDisplayFilters::ComputeVisibility(nsDisplayListBuilder* aBuilder, nsRegion* aVisibleRegion) { nsPoint offset = ToReferenceFrame(); - nsRect dirtyRect = nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea( + nsRect dirtyRect = SVGIntegrationUtils::GetRequiredSourceForInvalidArea( mFrame, GetPaintRect() - offset) + offset; @@ -9761,15 +9761,15 @@ void nsDisplayFilters::PaintAsLayer(nsDisplayListBuilder* aBuilder, gfxContext* aCtx, LayerManager* aManager) { imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags()); nsRect borderArea = nsRect(ToReferenceFrame(), mFrame->GetSize()); - nsSVGIntegrationUtils::PaintFramesParams params( - *aCtx, mFrame, GetPaintRect(), borderArea, aBuilder, aManager, - mHandleOpacity, imgParams); - nsSVGIntegrationUtils::PaintFilter(params); + SVGIntegrationUtils::PaintFramesParams params(*aCtx, mFrame, GetPaintRect(), + borderArea, aBuilder, aManager, + mHandleOpacity, imgParams); + SVGIntegrationUtils::PaintFilter(params); nsDisplayFiltersGeometry::UpdateDrawResult(this, imgParams.result); } bool nsDisplayFilters::CanCreateWebRenderCommands() { - return nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(mFrame); + return SVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(mFrame); } bool nsDisplayFilters::CreateWebRenderCommands( @@ -9783,10 +9783,10 @@ bool nsDisplayFilters::CreateWebRenderCommands( WrFiltersHolder wrFilters; Maybe filterClip; auto filterChain = mFrame->StyleEffects()->mFilters.AsSpan(); - if (!nsSVGIntegrationUtils::CreateWebRenderCSSFilters(filterChain, mFrame, - wrFilters) && - !nsSVGIntegrationUtils::BuildWebRenderFilters(mFrame, filterChain, - wrFilters, filterClip)) { + if (!SVGIntegrationUtils::CreateWebRenderCSSFilters(filterChain, mFrame, + wrFilters) && + !SVGIntegrationUtils::BuildWebRenderFilters(mFrame, filterChain, + wrFilters, filterClip)) { return false; } diff --git a/layout/painting/nsImageRenderer.cpp b/layout/painting/nsImageRenderer.cpp index d8bb8170f4e8..d6d66f18edd4 100644 --- a/layout/painting/nsImageRenderer.cpp +++ b/layout/painting/nsImageRenderer.cpp @@ -24,8 +24,8 @@ #include "nsIFrame.h" #include "nsStyleStructInlines.h" #include "mozilla/ISVGDisplayableFrame.h" +#include "mozilla/SVGIntegrationUtils.h" #include "mozilla/SVGObserverUtils.h" -#include "nsSVGIntegrationUtils.h" using namespace mozilla; using namespace mozilla::gfx; @@ -243,7 +243,7 @@ CSSSizeOrRatio nsImageRenderer::ComputeIntrinsicSize() { int32_t appUnitsPerDevPixel = mForFrame->PresContext()->AppUnitsPerDevPixel(); result.SetSize(IntSizeToAppUnits( - nsSVGIntegrationUtils::GetContinuationUnionSize(mPaintServerFrame) + SVGIntegrationUtils::GetContinuationUnionSize(mPaintServerFrame) .ToNearestPixels(appUnitsPerDevPixel), appUnitsPerDevPixel)); } @@ -699,10 +699,10 @@ already_AddRefed nsImageRenderer::DrawableForElement( // Don't allow creating images that are too big if (aContext.GetDrawTarget()->CanCreateSimilarDrawTarget(imageSize, format)) { - drawable = nsSVGIntegrationUtils::DrawableFromPaintServer( + drawable = SVGIntegrationUtils::DrawableFromPaintServer( mPaintServerFrame, mForFrame, mSize, imageSize, aContext.GetDrawTarget(), aContext.CurrentMatrixDouble(), - nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES); + SVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES); } return drawable.forget(); diff --git a/layout/style/nsFontFaceUtils.cpp b/layout/style/nsFontFaceUtils.cpp index a4a6f1317da8..910eaf980784 100644 --- a/layout/style/nsFontFaceUtils.cpp +++ b/layout/style/nsFontFaceUtils.cpp @@ -6,15 +6,16 @@ #include "nsFontFaceUtils.h" +#include "gfxTextRun.h" #include "gfxUserFontSet.h" #include "mozilla/PresShell.h" #include "mozilla/RestyleManager.h" +#include "mozilla/SVGUtils.h" #include "nsFontMetrics.h" #include "nsIFrame.h" #include "nsLayoutUtils.h" #include "nsPlaceholderFrame.h" #include "nsTArray.h" -#include "SVGTextFrame.h" using namespace mozilla; @@ -89,12 +90,12 @@ static FontUsageKind FrameFontUsage(nsIFrame* aFrame, // TODO(emilio): Can we use the restyle-hint machinery instead of this? static void ScheduleReflow(PresShell* aPresShell, nsIFrame* aFrame) { nsIFrame* f = aFrame; - if (f->IsFrameOfType(nsIFrame::eSVG) || nsSVGUtils::IsInSVGTextSubtree(f)) { + if (f->IsFrameOfType(nsIFrame::eSVG) || SVGUtils::IsInSVGTextSubtree(f)) { // SVG frames (and the non-SVG descendants of an SVGTextFrame) need special // reflow handling. We need to search upwards for the first displayed - // nsSVGOuterSVGFrame or non-SVG frame, which is the frame we can call + // SVGOuterSVGFrame or non-SVG frame, which is the frame we can call // FrameNeedsReflow on. (This logic is based on - // nsSVGUtils::ScheduleReflowSVG and + // SVGUtils::ScheduleReflowSVG and // SVGTextFrame::ScheduleReflowSVGNonDisplayText.) if (f->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { while (f) { @@ -106,7 +107,7 @@ static void ScheduleReflow(PresShell* aPresShell, nsIFrame* aFrame) { return; } if (f->IsSVGOuterSVGFrame() || !(f->IsFrameOfType(nsIFrame::eSVG) || - nsSVGUtils::IsInSVGTextSubtree(f))) { + SVGUtils::IsInSVGTextSubtree(f))) { break; } f->AddStateBits(NS_FRAME_HAS_DIRTY_CHILDREN); diff --git a/layout/style/nsStyleStructInlines.h b/layout/style/nsStyleStructInlines.h index 90f5c8c33c59..0b2285476f4f 100644 --- a/layout/style/nsStyleStructInlines.h +++ b/layout/style/nsStyleStructInlines.h @@ -14,9 +14,9 @@ #include "nsIFrame.h" #include "nsStyleStruct.h" -#include "nsIContent.h" // for GetParent() -#include "nsTextFrame.h" // for nsTextFrame::ShouldSuppressLineBreak -#include "nsSVGUtils.h" // for nsSVGUtils::IsInSVGTextSubtree +#include "nsIContent.h" // for GetParent() +#include "nsTextFrame.h" // for nsTextFrame::ShouldSuppressLineBreak +#include "mozilla/SVGUtils.h" // for SVGUtils::IsInSVGTextSubtree bool nsStyleText::NewlineIsSignificant(const nsTextFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame"); @@ -28,19 +28,20 @@ bool nsStyleText::NewlineIsSignificant(const nsTextFrame* aContextFrame) const { bool nsStyleText::WhiteSpaceCanWrap(const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame"); return WhiteSpaceCanWrapStyle() && - !nsSVGUtils::IsInSVGTextSubtree(aContextFrame) && + !mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame) && !aContextFrame->Style()->IsTextCombined(); } bool nsStyleText::WordCanWrap(const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleText() == this, "unexpected aContextFrame"); - return WordCanWrapStyle() && !nsSVGUtils::IsInSVGTextSubtree(aContextFrame); + return WordCanWrapStyle() && + !mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame); } bool nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); - if (nsSVGUtils::IsInSVGTextSubtree(aContextFrame)) { + if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame)) { return aContextFrame->IsBlockFrame(); } return IsBlockOutsideStyle(); @@ -49,7 +50,7 @@ bool nsStyleDisplay::IsBlockOutside(const nsIFrame* aContextFrame) const { bool nsStyleDisplay::IsInlineOutside(const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); - if (nsSVGUtils::IsInSVGTextSubtree(aContextFrame)) { + if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame)) { return !aContextFrame->IsBlockFrame(); } return IsInlineOutsideStyle(); @@ -59,7 +60,7 @@ mozilla::StyleDisplay nsStyleDisplay::GetDisplay( const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); - if (nsSVGUtils::IsInSVGTextSubtree(aContextFrame) && + if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame) && mDisplay != mozilla::StyleDisplay::None) { return aContextFrame->IsBlockFrame() ? mozilla::StyleDisplay::Block : mozilla::StyleDisplay::Inline; @@ -70,7 +71,8 @@ mozilla::StyleDisplay nsStyleDisplay::GetDisplay( bool nsStyleDisplay::IsFloating(const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); - return IsFloatingStyle() && !nsSVGUtils::IsInSVGTextSubtree(aContextFrame); + return IsFloatingStyle() && + !mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame); } // If you change this function, also change the corresponding block in @@ -129,7 +131,7 @@ bool nsStyleDisplay::IsFixedPosContainingBlock( !aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms))) { return false; } - if (nsSVGUtils::IsInSVGTextSubtree(aContextFrame)) { + if (mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame)) { return false; } MOZ_ASSERT(IsAbsPosContainingBlock(aContextFrame), @@ -150,7 +152,7 @@ bool nsStyleDisplay::IsAbsPosContainingBlock( !aContextFrame->IsFrameOfType(nsIFrame::eSupportsCSSTransforms))) { return false; } - return !nsSVGUtils::IsInSVGTextSubtree(aContextFrame); + return !mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame); } bool nsStyleDisplay::IsRelativelyPositioned( @@ -158,14 +160,14 @@ bool nsStyleDisplay::IsRelativelyPositioned( NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); return IsRelativelyPositionedStyle() && - !nsSVGUtils::IsInSVGTextSubtree(aContextFrame); + !mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame); } bool nsStyleDisplay::IsStickyPositioned(const nsIFrame* aContextFrame) const { NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); return IsStickyPositionedStyle() && - !nsSVGUtils::IsInSVGTextSubtree(aContextFrame); + !mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame); } bool nsStyleDisplay::IsAbsolutelyPositioned( @@ -173,7 +175,7 @@ bool nsStyleDisplay::IsAbsolutelyPositioned( NS_ASSERTION(aContextFrame->StyleDisplay() == this, "unexpected aContextFrame"); return IsAbsolutelyPositionedStyle() && - !nsSVGUtils::IsInSVGTextSubtree(aContextFrame); + !mozilla::SVGUtils::IsInSVGTextSubtree(aContextFrame); } mozilla::StylePointerEvents nsStyleUI::GetEffectivePointerEvents( diff --git a/layout/style/nsStyleTransformMatrix.cpp b/layout/style/nsStyleTransformMatrix.cpp index 5e0d90b584ba..9124cdb3876b 100644 --- a/layout/style/nsStyleTransformMatrix.cpp +++ b/layout/style/nsStyleTransformMatrix.cpp @@ -11,11 +11,11 @@ #include "nsStyleTransformMatrix.h" #include "nsLayoutUtils.h" #include "nsPresContext.h" -#include "nsSVGUtils.h" #include "mozilla/MotionPathUtils.h" #include "mozilla/ServoBindings.h" #include "mozilla/StaticPrefs_svg.h" #include "mozilla/StyleAnimationValue.h" +#include "mozilla/SVGUtils.h" #include "gfxMatrix.h" #include "gfxQuaternion.h" @@ -52,7 +52,7 @@ void TransformReferenceBox::EnsureDimensionsAreCached() { if (!StaticPrefs::svg_transform_box_enabled()) { mX = -mFrame->GetPosition().x; mY = -mFrame->GetPosition().y; - Size contextSize = nsSVGUtils::GetContextSize(mFrame); + Size contextSize = SVGUtils::GetContextSize(mFrame); mWidth = nsPresContext::CSSPixelsToAppUnits(contextSize.width); mHeight = nsPresContext::CSSPixelsToAppUnits(contextSize.height); } else if (mFrame->StyleDisplay()->mTransformBox == @@ -81,7 +81,7 @@ void TransformReferenceBox::EnsureDimensionsAreCached() { // transform is relative to {0,0} in current user space. mX = -mFrame->GetPosition().x; mY = -mFrame->GetPosition().y; - Size contextSize = nsSVGUtils::GetContextSize(mFrame); + Size contextSize = SVGUtils::GetContextSize(mFrame); mWidth = nsPresContext::CSSPixelsToAppUnits(contextSize.width); mHeight = nsPresContext::CSSPixelsToAppUnits(contextSize.height); } diff --git a/layout/svg/CSSClipPathInstance.cpp b/layout/svg/CSSClipPathInstance.cpp index d6c06c2c255c..0fdf4252bb77 100644 --- a/layout/svg/CSSClipPathInstance.cpp +++ b/layout/svg/CSSClipPathInstance.cpp @@ -12,7 +12,7 @@ #include "mozilla/gfx/2D.h" #include "mozilla/gfx/PathHelpers.h" #include "mozilla/ShapeUtils.h" -#include "nsSVGUtils.h" +#include "mozilla/SVGUtils.h" #include "gfx2DGlue.h" #include "gfxContext.h" #include "gfxPlatform.h" @@ -61,7 +61,7 @@ bool CSSClipPathInstance::HitTestBasicShapeOrPathClip(nsIFrame* aFrame, RefPtr drawTarget = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget(); RefPtr path = instance.CreateClipPath( - drawTarget, nsSVGUtils::GetCSSPxToDevPxMatrix(aFrame)); + drawTarget, SVGUtils::GetCSSPxToDevPxMatrix(aFrame)); float pixelRatio = float(AppUnitsPerCSSPixel()) / aFrame->PresContext()->AppUnitsPerDevPixel(); return path && path->ContainsPoint(ToPoint(aPoint) * pixelRatio, Matrix()); @@ -78,7 +78,7 @@ Maybe CSSClipPathInstance::GetBoundingRectForBasicShapeOrPathClip( RefPtr drawTarget = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget(); RefPtr path = instance.CreateClipPath( - drawTarget, nsSVGUtils::GetCSSPxToDevPxMatrix(aFrame)); + drawTarget, SVGUtils::GetCSSPxToDevPxMatrix(aFrame)); return path ? Some(path->GetBounds()) : Nothing(); } diff --git a/layout/svg/FilterInstance.cpp b/layout/svg/FilterInstance.cpp index a88169b4eb49..0fb3915a57d2 100644 --- a/layout/svg/FilterInstance.cpp +++ b/layout/svg/FilterInstance.cpp @@ -26,10 +26,9 @@ #include "mozilla/ISVGDisplayableFrame.h" #include "mozilla/StaticPrefs_gfx.h" #include "mozilla/SVGFilterInstance.h" +#include "mozilla/SVGUtils.h" #include "CSSFilterInstance.h" #include "SVGFilterPaintCallback.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" using namespace mozilla::dom; using namespace mozilla::gfx; @@ -87,7 +86,7 @@ void FilterInstance::PaintFilteredFrame(nsIFrame* aFilteredFrame, aCtx->SetMatrixDouble(reverseScaleMatrix * aCtx->CurrentMatrixDouble()); gfxMatrix scaleMatrixInDevUnits = - scaleMatrix * nsSVGUtils::GetCSSPxToDevPxMatrix(aFilteredFrame); + scaleMatrix * SVGUtils::GetCSSPxToDevPxMatrix(aFilteredFrame); // Hardcode InputIsTainted to true because we don't want JS to be able to // read the rendered contents of aFilteredFrame. @@ -134,7 +133,7 @@ bool FilterInstance::BuildWebRenderFilters(nsIFrame* aFilteredFrame, // gfx context for the non-wr path. gfxMatrix scaleMatrix; gfxMatrix scaleMatrixInDevUnits = - scaleMatrix * nsSVGUtils::GetCSSPxToDevPxMatrix(aFilteredFrame); + scaleMatrix * SVGUtils::GetCSSPxToDevPxMatrix(aFilteredFrame); // Hardcode inputIsTainted to true because we don't want JS to be able to // read the rendered contents of aFilteredFrame. @@ -368,7 +367,7 @@ nsRegion FilterInstance::GetPostFilterDirtyArea( return nsRegion(); } - gfxMatrix tm = nsSVGUtils::GetCanvasTM(aFilteredFrame); + gfxMatrix tm = SVGUtils::GetCanvasTM(aFilteredFrame); auto filterChain = aFilteredFrame->StyleEffects()->mFilters.AsSpan(); UniquePtr metrics = UserSpaceMetricsForFrame(aFilteredFrame); @@ -389,7 +388,7 @@ nsRegion FilterInstance::GetPostFilterDirtyArea( nsRegion FilterInstance::GetPreFilterNeededArea( nsIFrame* aFilteredFrame, const nsRegion& aPostFilterDirtyRegion) { - gfxMatrix tm = nsSVGUtils::GetCanvasTM(aFilteredFrame); + gfxMatrix tm = SVGUtils::GetCanvasTM(aFilteredFrame); auto filterChain = aFilteredFrame->StyleEffects()->mFilters.AsSpan(); UniquePtr metrics = UserSpaceMetricsForFrame(aFilteredFrame); @@ -421,7 +420,7 @@ nsRect FilterInstance::GetPostFilterBounds(nsIFrame* aFilteredFrame, preFilterRegionPtr = &preFilterRegion; } - gfxMatrix tm = nsSVGUtils::GetCanvasTM(aFilteredFrame); + gfxMatrix tm = SVGUtils::GetCanvasTM(aFilteredFrame); auto filterChain = aFilteredFrame->StyleEffects()->mFilters.AsSpan(); UniquePtr metrics = UserSpaceMetricsForFrame(aFilteredFrame); @@ -457,9 +456,9 @@ FilterInstance::FilterInstance( } else { MOZ_ASSERT(mTargetFrame, "Need to supply a frame when there's no aOverrideBBox"); - mTargetBBox = nsSVGUtils::GetBBox(mTargetFrame, - nsSVGUtils::eUseFrameBoundsForOuterSVG | - nsSVGUtils::eBBoxIncludeFillGeometry); + mTargetBBox = + SVGUtils::GetBBox(mTargetFrame, SVGUtils::eUseFrameBoundsForOuterSVG | + SVGUtils::eBBoxIncludeFillGeometry); } // Compute user space to filter space transforms. @@ -609,7 +608,7 @@ static void UpdateNeededBounds(const nsIntRegion& aRegion, nsIntRect& aBounds) { bool overflow; IntSize surfaceSize = - nsSVGUtils::ConvertToSurfaceSize(SizeDouble(aBounds.Size()), &overflow); + SVGUtils::ConvertToSurfaceSize(SizeDouble(aBounds.Size()), &overflow); if (overflow) { aBounds.SizeTo(surfaceSize); } @@ -658,9 +657,9 @@ void FilterInstance::BuildSourcePaint(SourceInfo* aSource, gfxMatrix::Translation(-neededRect.TopLeft())); GeneralPattern pattern; if (aSource == &mFillPaint) { - nsSVGUtils::MakeFillPatternFor(mTargetFrame, ctx, &pattern, aImgParams); + SVGUtils::MakeFillPatternFor(mTargetFrame, ctx, &pattern, aImgParams); } else if (aSource == &mStrokePaint) { - nsSVGUtils::MakeStrokePatternFor(mTargetFrame, ctx, &pattern, aImgParams); + SVGUtils::MakeStrokePatternFor(mTargetFrame, ctx, &pattern, aImgParams); } if (pattern.GetPattern()) { @@ -723,7 +722,7 @@ void FilterInstance::BuildSourceImage(DrawTarget* aDest, // subtle bugs, and in practice it probably makes no real difference.) RefPtr ctx = gfxContext::CreateOrNull(offscreenDT); MOZ_ASSERT(ctx); // already checked the draw target above - gfxMatrix devPxToCssPxTM = nsSVGUtils::GetCSSPxToDevPxMatrix(mTargetFrame); + gfxMatrix devPxToCssPxTM = SVGUtils::GetCSSPxToDevPxMatrix(mTargetFrame); DebugOnly invertible = devPxToCssPxTM.Invert(); MOZ_ASSERT(invertible); ctx->SetMatrixDouble(devPxToCssPxTM * mPaintTransform * @@ -902,7 +901,7 @@ gfxMatrix FilterInstance::GetUserSpaceToFrameSpaceInCSSPxTransform() const { return gfxMatrix(); } return gfxMatrix::Translation( - -nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(mTargetFrame)); + -SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(mTargetFrame)); } } // namespace mozilla diff --git a/layout/svg/ISVGDisplayableFrame.h b/layout/svg/ISVGDisplayableFrame.h index 42e8a163291e..9c424c438948 100644 --- a/layout/svg/ISVGDisplayableFrame.h +++ b/layout/svg/ISVGDisplayableFrame.h @@ -16,11 +16,11 @@ class gfxContext; class nsIFrame; -class SVGBBox; namespace mozilla { class SVGAnimatedLengthList; class SVGAnimatedNumberList; +class SVGBBox; class SVGLengthList; class SVGNumberList; class SVGUserUnitList; diff --git a/layout/svg/SVGAFrame.cpp b/layout/svg/SVGAFrame.cpp index 160d20d3c673..119246ed0229 100644 --- a/layout/svg/SVGAFrame.cpp +++ b/layout/svg/SVGAFrame.cpp @@ -10,8 +10,6 @@ #include "mozilla/SVGContainerFrame.h" #include "mozilla/dom/SVGAElement.h" #include "mozilla/dom/MutationEventBinding.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" #include "SVGLengthList.h" nsIFrame* NS_NewSVGAFrame(mozilla::PresShell* aPresShell, diff --git a/layout/svg/SVGClipPathFrame.cpp b/layout/svg/SVGClipPathFrame.cpp index e2866138a202..cf8e6e5263d3 100644 --- a/layout/svg/SVGClipPathFrame.cpp +++ b/layout/svg/SVGClipPathFrame.cpp @@ -14,10 +14,10 @@ #include "mozilla/PresShell.h" #include "mozilla/SVGGeometryFrame.h" #include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGClipPathElement.h" #include "mozilla/dom/SVGGeometryElement.h" #include "nsGkAtoms.h" -#include "nsSVGUtils.h" using namespace mozilla::dom; using namespace mozilla::gfx; @@ -61,7 +61,7 @@ void SVGClipPathFrame::ApplyClipPath(gfxContext& aContext, static_cast(pathFrame->GetContent()); gfxMatrix toChildsUserSpace = - nsSVGUtils::GetTransformMatrixInUserSpace(pathFrame) * + SVGUtils::GetTransformMatrixInUserSpace(pathFrame) * (GetClipPathTransform(aClippedFrame) * aMatrix); gfxMatrix newMatrix = aContext.CurrentMatrixDouble() @@ -70,7 +70,7 @@ void SVGClipPathFrame::ApplyClipPath(gfxContext& aContext, if (!newMatrix.IsSingular()) { aContext.SetMatrixDouble(newMatrix); FillRule clipRule = - nsSVGUtils::ToFillRule(pathFrame->StyleSVG()->mClipRule); + SVGUtils::ToFillRule(pathFrame->StyleSVG()->mClipRule); clipPath = pathElement->GetOrBuildPath(drawTarget, clipRule); } } @@ -126,8 +126,8 @@ void SVGClipPathFrame::PaintClipMask(gfxContext& aMaskContext, SVGClipPathFrame* clipPathThatClipsClipPath; // XXX check return value? SVGObserverUtils::GetAndObserveClipPath(this, &clipPathThatClipsClipPath); - nsSVGUtils::MaskUsage maskUsage; - nsSVGUtils::DetermineMaskUsage(this, true, maskUsage); + SVGUtils::MaskUsage maskUsage; + SVGUtils::DetermineMaskUsage(this, true, maskUsage); if (maskUsage.shouldApplyClipPath) { clipPathThatClipsClipPath->ApplyClipPath(aMaskContext, aClippedFrame, @@ -181,8 +181,8 @@ void SVGClipPathFrame::PaintFrameIntoMask(nsIFrame* aFrame, return; } - nsSVGUtils::MaskUsage maskUsage; - nsSVGUtils::DetermineMaskUsage(aFrame, true, maskUsage); + SVGUtils::MaskUsage maskUsage; + SVGUtils::DetermineMaskUsage(aFrame, true, maskUsage); if (maskUsage.shouldApplyClipPath) { clipPathThatClipsChild->ApplyClipPath(aTarget, aClippedFrame, mMatrixForChildren); @@ -205,7 +205,7 @@ void SVGClipPathFrame::PaintFrameIntoMask(nsIFrame* aFrame, nsIContent* childContent = child->GetContent(); if (childContent->IsSVGElement()) { toChildsUserSpace = - nsSVGUtils::GetTransformMatrixInUserSpace(child) * mMatrixForChildren; + SVGUtils::GetTransformMatrixInUserSpace(child) * mMatrixForChildren; } // clipPath does not result in any image rendering, so we just use a dummy @@ -286,7 +286,7 @@ bool SVGClipPathFrame::PointIsInsideClipPath(nsIFrame* aClippedFrame, if (SVGFrame) { gfxPoint pointForChild = point; - gfxMatrix m = nsSVGUtils::GetTransformMatrixInUserSpace(kid); + gfxMatrix m = SVGUtils::GetTransformMatrixInUserSpace(kid); if (!m.IsIdentity()) { if (!m.Invert()) { return false; @@ -386,7 +386,7 @@ nsresult SVGClipPathFrame::AttributeChanged(int32_t aNameSpaceID, if (aNameSpaceID == kNameSpaceID_None) { if (aAttribute == nsGkAtoms::transform) { SVGObserverUtils::InvalidateDirectRenderingObservers(this); - nsSVGUtils::NotifyChildrenOfSVGChange( + SVGUtils::NotifyChildrenOfSVGChange( this, ISVGDisplayableFrame::TRANSFORM_CHANGED); } if (aAttribute == nsGkAtoms::clipPathUnits) { @@ -413,19 +413,19 @@ gfxMatrix SVGClipPathFrame::GetClipPathTransform(nsIFrame* aClippedFrame) { SVGClipPathElement* content = static_cast(GetContent()); gfxMatrix tm = content->PrependLocalTransformsTo({}, eChildToUserSpace) * - nsSVGUtils::GetTransformMatrixInUserSpace(this); + SVGUtils::GetTransformMatrixInUserSpace(this); SVGAnimatedEnumeration* clipPathUnits = &content->mEnumAttributes[SVGClipPathElement::CLIPPATHUNITS]; - uint32_t flags = nsSVGUtils::eBBoxIncludeFillGeometry | + uint32_t flags = SVGUtils::eBBoxIncludeFillGeometry | (aClippedFrame->StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Clone - ? nsSVGUtils::eIncludeOnlyCurrentFrameForNonSVGElement + ? SVGUtils::eIncludeOnlyCurrentFrameForNonSVGElement : 0); - return nsSVGUtils::AdjustMatrixForUnits(tm, clipPathUnits, aClippedFrame, - flags); + return SVGUtils::AdjustMatrixForUnits(tm, clipPathUnits, aClippedFrame, + flags); } SVGBBox SVGClipPathFrame::GetBBoxForClipPathFrame(const SVGBBox& aBBox, @@ -447,9 +447,9 @@ SVGBBox SVGClipPathFrame::GetBBoxForClipPathFrame(const SVGBBox& aBBox, ISVGDisplayableFrame* svg = do_QueryFrame(frame); if (svg) { gfxMatrix matrix = - nsSVGUtils::GetTransformMatrixInUserSpace(frame) * aMatrix; + SVGUtils::GetTransformMatrixInUserSpace(frame) * aMatrix; tmpBBox = svg->GetBBoxContribution(gfx::ToMatrix(matrix), - nsSVGUtils::eBBoxIncludeFill); + SVGUtils::eBBoxIncludeFill); SVGClipPathFrame* clipPathFrame; if (SVGObserverUtils::GetAndObserveClipPath(frame, &clipPathFrame) != SVGObserverUtils::eHasRefsSomeInvalid && @@ -457,7 +457,7 @@ SVGBBox SVGClipPathFrame::GetBBoxForClipPathFrame(const SVGBBox& aBBox, tmpBBox = clipPathFrame->GetBBoxForClipPathFrame(tmpBBox, aMatrix, aFlags); } - if (!(aFlags & nsSVGUtils::eDoNotClipToBBoxOfContentInsideClipPath)) { + if (!(aFlags & SVGUtils::eDoNotClipToBBoxOfContentInsideClipPath)) { tmpBBox.Intersect(aBBox); } unionBBox.UnionEdges(tmpBBox); diff --git a/layout/svg/SVGClipPathFrame.h b/layout/svg/SVGClipPathFrame.h index 1a4f2b1a9f54..d610099c6504 100644 --- a/layout/svg/SVGClipPathFrame.h +++ b/layout/svg/SVGClipPathFrame.h @@ -10,7 +10,6 @@ #include "gfxMatrix.h" #include "mozilla/Attributes.h" #include "mozilla/SVGContainerFrame.h" -#include "nsSVGUtils.h" class gfxContext; diff --git a/layout/svg/SVGContainerFrame.cpp b/layout/svg/SVGContainerFrame.cpp index 8daee0d4ba1b..ffc259aa4162 100644 --- a/layout/svg/SVGContainerFrame.cpp +++ b/layout/svg/SVGContainerFrame.cpp @@ -13,9 +13,9 @@ #include "mozilla/RestyleManager.h" #include "mozilla/SVGObserverUtils.h" #include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGElement.h" #include "nsCSSFrameConstructor.h" -#include "nsSVGUtils.h" #include "SVGAnimatedTransformList.h" using namespace mozilla::dom; @@ -171,8 +171,8 @@ void SVGDisplayContainerFrame::InsertFrames( kid->RemoveStateBits(NS_FRAME_FIRST_REFLOW | NS_FRAME_IS_DIRTY | NS_FRAME_HAS_DIRTY_CHILDREN); // No need to invalidate the new kid's old bounds, so we just use - // nsSVGUtils::ScheduleBoundsUpdate. - nsSVGUtils::ScheduleReflowSVG(kid); + // SVGUtils::ScheduleBoundsUpdate. + SVGUtils::ScheduleReflowSVG(kid); if (isFirstReflow) { // Add back the NS_FRAME_FIRST_REFLOW bit: kid->AddStateBits(NS_FRAME_FIRST_REFLOW); @@ -263,12 +263,12 @@ void SVGDisplayContainerFrame::PaintSVG(gfxContext& aContext, continue; // nothing to paint for kid } - m = nsSVGUtils::GetTransformMatrixInUserSpace(kid) * m; + m = SVGUtils::GetTransformMatrixInUserSpace(kid) * m; if (m.IsSingular()) { continue; } } - nsSVGUtils::PaintFrameWithEffects(kid, aContext, m, aImgParams, aDirtyRect); + SVGUtils::PaintFrameWithEffects(kid, aContext, m, aImgParams, aDirtyRect); } } @@ -277,11 +277,11 @@ nsIFrame* SVGDisplayContainerFrame::GetFrameForPoint(const gfxPoint& aPoint) { (mState & NS_FRAME_IS_NONDISPLAY), "If display lists are enabled, only hit-testing of a " "clipPath's contents should take this code path"); - return nsSVGUtils::HitTestChildren(this, aPoint); + return SVGUtils::HitTestChildren(this, aPoint); } void SVGDisplayContainerFrame::ReflowSVG() { - NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this), + NS_ASSERTION(SVGUtils::OuterSVGIsCallingReflowSVG(this), "This call is probably a wasteful mistake"); MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_IS_NONDISPLAY), @@ -289,7 +289,7 @@ void SVGDisplayContainerFrame::ReflowSVG() { MOZ_ASSERT(!IsSVGOuterSVGFrame(), "Do not call on outer-"); - if (!nsSVGUtils::NeedsReflowSVG(this)) { + if (!SVGUtils::NeedsReflowSVG(this)) { return; } @@ -374,7 +374,7 @@ void SVGDisplayContainerFrame::NotifySVGChanged(uint32_t aFlags) { mCanvasTM = nullptr; } - nsSVGUtils::NotifyChildrenOfSVGChange(this, aFlags); + SVGUtils::NotifyChildrenOfSVGChange(this, aFlags); } SVGBBox SVGDisplayContainerFrame::GetBBoxContribution( @@ -393,7 +393,7 @@ SVGBBox SVGDisplayContainerFrame::GetBBoxContribution( if (content->IsSVGElement()) { transform = static_cast(content)->PrependLocalTransformsTo( {}, eChildToUserSpace) * - nsSVGUtils::GetTransformMatrixInUserSpace(kid) * transform; + SVGUtils::GetTransformMatrixInUserSpace(kid) * transform; } // We need to include zero width/height vertical/horizontal lines, so we // have to use UnionEdges. diff --git a/layout/svg/SVGContainerFrame.h b/layout/svg/SVGContainerFrame.h index 1a2295a1bed0..0a40f0f4e829 100644 --- a/layout/svg/SVGContainerFrame.h +++ b/layout/svg/SVGContainerFrame.h @@ -14,7 +14,6 @@ #include "nsIFrame.h" #include "nsQueryFrame.h" #include "nsRect.h" -#include "nsSVGUtils.h" class gfxContext; class nsFrameList; @@ -110,7 +109,7 @@ class SVGContainerFrame : public nsContainerFrame { * * This class's methods can *not* assume that mContent points to an instance of * an SVG element class since this class is inherited by - * nsSVGGenericContainerFrame which is used for unrecognized elements in the + * SVGGenericContainerFrame which is used for unrecognized elements in the * SVG namespace. Do *not* blindly cast to SVG element types. */ class SVGDisplayContainerFrame : public SVGContainerFrame, diff --git a/layout/svg/SVGContextPaint.cpp b/layout/svg/SVGContextPaint.cpp index ddbcf85af184..8bf663751644 100644 --- a/layout/svg/SVGContextPaint.cpp +++ b/layout/svg/SVGContextPaint.cpp @@ -13,6 +13,7 @@ #include "mozilla/dom/SVGDocument.h" #include "mozilla/StaticPrefs_svg.h" #include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "SVGPaintServerFrame.h" using namespace mozilla::gfx; @@ -124,7 +125,7 @@ static void SetupInheritablePaint(const DrawTarget* aDrawTarget, } nscolor color = - nsSVGUtils::GetFallbackOrPaintColor(*aFrame->Style(), aFillOrStroke); + SVGUtils::GetFallbackOrPaintColor(*aFrame->Style(), aFillOrStroke); aTargetPaint.SetColor(color); } @@ -142,7 +143,7 @@ DrawMode SVGContextPaintImpl::Init(const DrawTarget* aDrawTarget, SetFillOpacity(0.0f); } else { float opacity = - nsSVGUtils::GetOpacity(style->mFillOpacity, aOuterContextPaint); + SVGUtils::GetOpacity(style->mFillOpacity, aOuterContextPaint); SetupInheritablePaint(aDrawTarget, aContextMatrix, aFrame, opacity, aOuterContextPaint, mFillPaint, &nsStyleSVG::mFill, @@ -158,7 +159,7 @@ DrawMode SVGContextPaintImpl::Init(const DrawTarget* aDrawTarget, SetStrokeOpacity(0.0f); } else { float opacity = - nsSVGUtils::GetOpacity(style->mStrokeOpacity, aOuterContextPaint); + SVGUtils::GetOpacity(style->mStrokeOpacity, aOuterContextPaint); SetupInheritablePaint(aDrawTarget, aContextMatrix, aFrame, opacity, aOuterContextPaint, mStrokePaint, diff --git a/layout/svg/SVGFilterFrame.cpp b/layout/svg/SVGFilterFrame.cpp index 9ccff2779385..d134e16e30f5 100644 --- a/layout/svg/SVGFilterFrame.cpp +++ b/layout/svg/SVGFilterFrame.cpp @@ -16,8 +16,6 @@ #include "SVGObserverUtils.h" #include "SVGElement.h" #include "SVGFilterInstance.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" #include "nsContentUtils.h" using namespace mozilla; diff --git a/layout/svg/SVGFilterFrame.h b/layout/svg/SVGFilterFrame.h index 773253da31e7..d1662405ad65 100644 --- a/layout/svg/SVGFilterFrame.h +++ b/layout/svg/SVGFilterFrame.h @@ -11,7 +11,6 @@ #include "mozilla/SVGContainerFrame.h" #include "nsIFrame.h" #include "nsQueryFrame.h" -#include "nsSVGUtils.h" class nsAtom; class nsIContent; diff --git a/layout/svg/SVGFilterInstance.cpp b/layout/svg/SVGFilterInstance.cpp index 057c9aeda1a3..8786832fcd26 100644 --- a/layout/svg/SVGFilterInstance.cpp +++ b/layout/svg/SVGFilterInstance.cpp @@ -13,13 +13,13 @@ #include "mozilla/ISVGDisplayableFrame.h" #include "mozilla/SVGContentUtils.h" #include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/HTMLCanvasElement.h" #include "mozilla/dom/IDTracker.h" #include "mozilla/dom/SVGLengthBinding.h" #include "mozilla/dom/SVGUnitTypesBinding.h" #include "mozilla/dom/SVGFilterElement.h" #include "SVGFilterFrame.h" -#include "nsSVGUtils.h" #include "FilterSupport.h" #include "gfx2DGlue.h" @@ -87,7 +87,7 @@ bool SVGFilterInstance::ComputeBounds() { uint16_t filterUnits = mFilterFrame->GetEnumValue(SVGFilterElement::FILTERUNITS); gfxRect userSpaceBounds = - nsSVGUtils::GetRelativeRect(filterUnits, XYWH, mTargetBBox, mMetrics); + SVGUtils::GetRelativeRect(filterUnits, XYWH, mTargetBBox, mMetrics); // Transform the user space bounds to filter space, so we // can align them with the pixel boundaries of the offscreen surface. @@ -171,9 +171,9 @@ float SVGFilterInstance::GetPrimitiveNumber(uint8_t aCtxType, float value; if (mPrimitiveUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { - value = nsSVGUtils::ObjectSpace(mTargetBBox, &val); + value = SVGUtils::ObjectSpace(mTargetBBox, &val); } else { - value = nsSVGUtils::UserSpace(mMetrics, &val); + value = SVGUtils::UserSpace(mMetrics, &val); } switch (aCtxType) { @@ -202,7 +202,7 @@ Point3D SVGFilterInstance::ConvertLocation(const Point3D& aPoint) const { SVGLength_Binding::SVG_LENGTHTYPE_NUMBER); gfxRect feArea = - nsSVGUtils::GetRelativeRect(mPrimitiveUnits, val, mTargetBBox, mMetrics); + SVGUtils::GetRelativeRect(mPrimitiveUnits, val, mTargetBBox, mMetrics); gfxRect r = UserSpaceToFilterSpace(feArea); return Point3D(r.x, r.y, GetPrimitiveNumber(SVGContentUtils::XY, aPoint.z)); } @@ -237,7 +237,7 @@ IntRect SVGFilterInstance::ComputeFilterPrimitiveSubregion( defaultFilterSubregion = mFilterSpaceBounds; } - gfxRect feArea = nsSVGUtils::GetRelativeRect( + gfxRect feArea = SVGUtils::GetRelativeRect( mPrimitiveUnits, &fE->mLengthAttributes[SVGFE::ATTR_X], mTargetBBox, mMetrics); Rect region = ToRect(UserSpaceToFilterSpace(feArea)); diff --git a/layout/svg/SVGForeignObjectFrame.cpp b/layout/svg/SVGForeignObjectFrame.cpp index dfe33c499068..916215f45983 100644 --- a/layout/svg/SVGForeignObjectFrame.cpp +++ b/layout/svg/SVGForeignObjectFrame.cpp @@ -15,6 +15,7 @@ #include "mozilla/SVGContainerFrame.h" #include "mozilla/SVGObserverUtils.h" #include "mozilla/SVGOuterSVGFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGForeignObjectElement.h" #include "nsDisplayList.h" #include "nsGkAtoms.h" @@ -22,8 +23,6 @@ #include "nsLayoutUtils.h" #include "nsRegion.h" #include "SVGGeometryProperty.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" using namespace mozilla::dom; using namespace mozilla::image; @@ -67,7 +66,7 @@ void SVGForeignObjectFrame::Init(nsIContent* aContent, AddStateBits(NS_FRAME_FONT_INFLATION_CONTAINER | NS_FRAME_FONT_INFLATION_FLOW_ROOT); if (!(mState & NS_FRAME_IS_NONDISPLAY)) { - nsSVGUtils::GetOuterSVGFrame(this)->RegisterForeignObject(this); + SVGUtils::GetOuterSVGFrame(this)->RegisterForeignObject(this); } } @@ -75,7 +74,7 @@ void SVGForeignObjectFrame::DestroyFrom(nsIFrame* aDestructRoot, PostDestroyData& aPostDestroyData) { // Only unregister if we registered in the first place: if (!(mState & NS_FRAME_IS_NONDISPLAY)) { - nsSVGUtils::GetOuterSVGFrame(this)->UnregisterForeignObject(this); + SVGUtils::GetOuterSVGFrame(this)->UnregisterForeignObject(this); } nsContainerFrame::DestroyFrom(aDestructRoot, aPostDestroyData); } @@ -110,7 +109,7 @@ void SVGForeignObjectFrame::DidSetComputedStyle( StyleSVGReset()->mY != aOldComputedStyle->StyleSVGReset()->mY) { // Invalidate cached transform matrix. mCanvasTM = nullptr; - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } } } @@ -250,8 +249,8 @@ void SVGForeignObjectFrame::PaintSVG(gfxContext& aContext, static_cast(GetContent()), &x, &y, &width, &height); gfxRect clipRect = - nsSVGUtils::GetClipRectForFrame(this, 0.0f, 0.0f, width, height); - nsSVGUtils::SetClipRect(&aContext, aTransform, clipRect); + SVGUtils::GetClipRectForFrame(this, 0.0f, 0.0f, width, height); + SVGUtils::SetClipRect(&aContext, aTransform, clipRect); } // SVG paints in CSS px, but normally frames paint in dev pixels. Here we @@ -302,7 +301,7 @@ nsIFrame* SVGForeignObjectFrame::GetFrameForPoint(const gfxPoint& aPoint) { static_cast(GetContent()), &x, &y, &width, &height); if (!gfxRect(x, y, width, height).Contains(aPoint) || - !nsSVGUtils::HitTestClip(this, aPoint)) { + !SVGUtils::HitTestClip(this, aPoint)) { return nullptr; } @@ -316,13 +315,13 @@ nsIFrame* SVGForeignObjectFrame::GetFrameForPoint(const gfxPoint& aPoint) { } void SVGForeignObjectFrame::ReflowSVG() { - NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this), + NS_ASSERTION(SVGUtils::OuterSVGIsCallingReflowSVG(this), "This call is probably a wasteful mistake"); MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_IS_NONDISPLAY), "ReflowSVG mechanism not designed for this"); - if (!nsSVGUtils::NeedsReflowSVG(this)) { + if (!SVGUtils::NeedsReflowSVG(this)) { return; } @@ -419,7 +418,7 @@ void SVGForeignObjectFrame::NotifySVGChanged(uint32_t aFlags) { // invalidate them. We also don't need to invalidate ourself, since our // changed ancestor will have invalidated its entire area, which includes // our area. - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } // If we're called while the PresShell is handling reflow events then we @@ -547,8 +546,8 @@ nsRect SVGForeignObjectFrame::GetInvalidRegion() { if (kid->HasInvalidFrameInSubtree()) { gfxRect r(mRect.x, mRect.y, mRect.width, mRect.height); r.Scale(1.0 / AppUnitsPerCSSPixel()); - nsRect rect = nsSVGUtils::ToCanvasBounds(r, GetCanvasTM(), PresContext()); - rect = nsSVGUtils::GetPostFilterVisualOverflowRect(this, rect); + nsRect rect = SVGUtils::ToCanvasBounds(r, GetCanvasTM(), PresContext()); + rect = SVGUtils::GetPostFilterVisualOverflowRect(this, rect); return rect; } return nsRect(); diff --git a/layout/svg/SVGForeignObjectFrame.h b/layout/svg/SVGForeignObjectFrame.h index f7c2e0eee76c..d77fbfdac639 100644 --- a/layout/svg/SVGForeignObjectFrame.h +++ b/layout/svg/SVGForeignObjectFrame.h @@ -13,7 +13,6 @@ #include "mozilla/UniquePtr.h" #include "nsContainerFrame.h" #include "nsRegion.h" -#include "nsSVGUtils.h" class gfxContext; diff --git a/layout/svg/SVGGFrame.cpp b/layout/svg/SVGGFrame.cpp index acff6eca0d90..07fa344216e2 100644 --- a/layout/svg/SVGGFrame.cpp +++ b/layout/svg/SVGGFrame.cpp @@ -11,10 +11,6 @@ #include "mozilla/PresShell.h" #include "nsGkAtoms.h" #include "nsIFrame.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" -#include "SVGGraphicsElement.h" -#include "SVGTransformableElement.h" using namespace mozilla::dom; diff --git a/layout/svg/SVGGenericContainerFrame.cpp b/layout/svg/SVGGenericContainerFrame.cpp index 448d45f4a3fd..1d98d0c0793e 100644 --- a/layout/svg/SVGGenericContainerFrame.cpp +++ b/layout/svg/SVGGenericContainerFrame.cpp @@ -6,7 +6,6 @@ // Main header first: #include "SVGGenericContainerFrame.h" -#include "nsSVGIntegrationUtils.h" #include "mozilla/PresShell.h" diff --git a/layout/svg/SVGGeometryFrame.cpp b/layout/svg/SVGGeometryFrame.cpp index 1047efbed665..25e88e363eb0 100644 --- a/layout/svg/SVGGeometryFrame.cpp +++ b/layout/svg/SVGGeometryFrame.cpp @@ -12,25 +12,23 @@ #include "gfxContext.h" #include "gfxPlatform.h" #include "gfxUtils.h" +#include "mozilla/dom/SVGGeometryElement.h" +#include "mozilla/dom/SVGGraphicsElement.h" #include "mozilla/gfx/2D.h" #include "mozilla/gfx/Helpers.h" +#include "mozilla/ArrayUtils.h" #include "mozilla/PresShell.h" #include "mozilla/RefPtr.h" #include "mozilla/SVGContextPaint.h" +#include "mozilla/SVGContentUtils.h" +#include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "nsDisplayList.h" #include "nsGkAtoms.h" #include "nsLayoutUtils.h" -#include "SVGObserverUtils.h" -#include "nsSVGIntegrationUtils.h" -#include "SVGMarkerFrame.h" -#include "SVGGeometryElement.h" -#include "nsSVGUtils.h" -#include "mozilla/ArrayUtils.h" #include "SVGAnimatedTransformList.h" -#include "SVGContentUtils.h" -#include "SVGGraphicsElement.h" +#include "SVGMarkerFrame.h" -using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::gfx; using namespace mozilla::image; @@ -38,11 +36,14 @@ using namespace mozilla::image; //---------------------------------------------------------------------- // Implementation -nsIFrame* NS_NewSVGGeometryFrame(PresShell* aPresShell, ComputedStyle* aStyle) { +nsIFrame* NS_NewSVGGeometryFrame(mozilla::PresShell* aPresShell, + mozilla::ComputedStyle* aStyle) { return new (aPresShell) - SVGGeometryFrame(aStyle, aPresShell->GetPresContext()); + mozilla::SVGGeometryFrame(aStyle, aPresShell->GetPresContext()); } +namespace mozilla { + NS_IMPL_FRAMEARENA_HELPERS(SVGGeometryFrame) //---------------------------------------------------------------------- @@ -81,7 +82,7 @@ void DisplaySVGGeometry::Paint(nsDisplayListBuilder* aBuilder, gfxPoint devPixelOffset = nsLayoutUtils::PointToGfxPoint(offset, appUnitsPerDevPixel); - gfxMatrix tm = nsSVGUtils::GetCSSPxToDevPxMatrix(mFrame) * + gfxMatrix tm = SVGUtils::GetCSSPxToDevPxMatrix(mFrame) * gfxMatrix::Translation(devPixelOffset); imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags()); static_cast(mFrame)->PaintSVG(*aCtx, tm, imgParams); @@ -105,8 +106,6 @@ void DisplaySVGGeometry::ComputeInvalidationRegion( aInvalidRegion); } -namespace mozilla { - //---------------------------------------------------------------------- // nsIFrame methods @@ -129,7 +128,7 @@ nsresult SVGGeometryFrame::AttributeChanged(int32_t aNameSpaceID, ->AttributeDefinesGeometry(aAttribute))) { nsLayoutUtils::PostRestyleEvent(mContent->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } return NS_OK; } @@ -258,7 +257,7 @@ nsIFrame* SVGGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint) { uint16_t hitTestFlags; if (HasAnyStateBits(NS_STATE_SVG_CLIPPATH_CHILD)) { hitTestFlags = SVG_HIT_TEST_FILL; - fillRule = nsSVGUtils::ToFillRule(StyleSVG()->mClipRule); + fillRule = SVGUtils::ToFillRule(StyleSVG()->mClipRule); } else { hitTestFlags = GetHitTestFlags(); if (!hitTestFlags) { @@ -270,7 +269,7 @@ nsIFrame* SVGGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint) { return nullptr; } } - fillRule = nsSVGUtils::ToFillRule(StyleSVG()->mFillRule); + fillRule = SVGUtils::ToFillRule(StyleSVG()->mFillRule); } bool isHit = false; @@ -295,7 +294,7 @@ nsIFrame* SVGGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint) { SVGContentUtils::AutoStrokeOptions stroke; SVGContentUtils::GetStrokeOptions(&stroke, content, Style(), nullptr); gfxMatrix userToOuterSVG; - if (nsSVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { + if (SVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { // We need to transform the path back into the appropriate ancestor // coordinate system in order for non-scaled stroke to be correct. // Naturally we also need to transform the point into the same @@ -308,7 +307,7 @@ nsIFrame* SVGGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint) { isHit = path->StrokeContainsPoint(stroke, point, Matrix()); } - if (isHit && nsSVGUtils::HitTestClip(this, aPoint)) { + if (isHit && SVGUtils::HitTestClip(this, aPoint)) { return this; } @@ -316,19 +315,18 @@ nsIFrame* SVGGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint) { } void SVGGeometryFrame::ReflowSVG() { - NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this), + NS_ASSERTION(SVGUtils::OuterSVGIsCallingReflowSVG(this), "This call is probably a wasteful mistake"); MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_IS_NONDISPLAY), "ReflowSVG mechanism not designed for this"); - if (!nsSVGUtils::NeedsReflowSVG(this)) { + if (!SVGUtils::NeedsReflowSVG(this)) { return; } - uint32_t flags = nsSVGUtils::eBBoxIncludeFill | - nsSVGUtils::eBBoxIncludeStroke | - nsSVGUtils::eBBoxIncludeMarkers; + uint32_t flags = SVGUtils::eBBoxIncludeFill | SVGUtils::eBBoxIncludeStroke | + SVGUtils::eBBoxIncludeMarkers; // Our "visual" overflow rect needs to be valid for building display lists // for hit testing, which means that for certain values of 'pointer-events' // it needs to include the geometry of the fill or stroke even when the fill/ @@ -336,10 +334,10 @@ void SVGGeometryFrame::ReflowSVG() { // stroke-opacity="0"). GetHitTestFlags() accounts for 'pointer-events'. uint16_t hitTestFlags = GetHitTestFlags(); if ((hitTestFlags & SVG_HIT_TEST_FILL)) { - flags |= nsSVGUtils::eBBoxIncludeFillGeometry; + flags |= SVGUtils::eBBoxIncludeFillGeometry; } if ((hitTestFlags & SVG_HIT_TEST_STROKE)) { - flags |= nsSVGUtils::eBBoxIncludeStrokeGeometry; + flags |= SVGUtils::eBBoxIncludeStrokeGeometry; } gfxRect extent = GetBBoxContribution(Matrix(), flags).ToThebesRect(); @@ -395,14 +393,14 @@ void SVGGeometryFrame::NotifySVGChanged(uint32_t aFlags) { (strokeWidth.IsLengthPercentage() && strokeWidth.AsLengthPercentage().HasPercent())) { geom->ClearAnyCachedPath(); - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } } if ((aFlags & TRANSFORM_CHANGED) && StyleSVGReset()->HasNonScalingStroke()) { // Stroke currently contributes to our mRect, and our stroke depends on // the transform to our outer- if |vector-effect:non-scaling-stroke|. - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } } @@ -415,7 +413,7 @@ SVGBBox SVGGeometryFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, return bbox; } - if ((aFlags & nsSVGUtils::eForGetClientRects) && + if ((aFlags & SVGUtils::eForGetClientRects) && aToBBoxUserspace.PreservesAxisAlignedRectangles()) { Rect rect = NSRectToRect(mRect, AppUnitsPerCSSPixel()); bbox = aToBBoxUserspace.TransformBounds(rect); @@ -424,13 +422,13 @@ SVGBBox SVGGeometryFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, SVGGeometryElement* element = static_cast(GetContent()); - bool getFill = (aFlags & nsSVGUtils::eBBoxIncludeFillGeometry) || - ((aFlags & nsSVGUtils::eBBoxIncludeFill) && + bool getFill = (aFlags & SVGUtils::eBBoxIncludeFillGeometry) || + ((aFlags & SVGUtils::eBBoxIncludeFill) && !StyleSVG()->mFill.kind.IsNone()); - bool getStroke = (aFlags & nsSVGUtils::eBBoxIncludeStrokeGeometry) || - ((aFlags & nsSVGUtils::eBBoxIncludeStroke) && - nsSVGUtils::HasStroke(this)); + bool getStroke = + (aFlags & SVGUtils::eBBoxIncludeStrokeGeometry) || + ((aFlags & SVGUtils::eBBoxIncludeStroke) && SVGUtils::HasStroke(this)); SVGContentUtils::AutoStrokeOptions strokeOptions; if (getStroke) { @@ -446,7 +444,7 @@ SVGBBox SVGGeometryFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, bool gotSimpleBounds = false; gfxMatrix userToOuterSVG; if (getStroke && - nsSVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { + SVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { Matrix moz2dUserToOuterSVG = ToMatrix(userToOuterSVG); if (moz2dUserToOuterSVG.IsSingular()) { return bbox; @@ -476,7 +474,7 @@ SVGBBox SVGGeometryFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, tmpDT = gfxPlatform::GetPlatform()->ScreenReferenceDrawTarget(); #endif - FillRule fillRule = nsSVGUtils::ToFillRule( + FillRule fillRule = SVGUtils::ToFillRule( HasAnyStateBits(NS_STATE_SVG_CLIPPATH_CHILD) ? StyleSVG()->mClipRule : StyleSVG()->mFillRule); RefPtr pathInUserSpace = element->GetOrBuildPath(tmpDT, fillRule); @@ -543,7 +541,7 @@ SVGBBox SVGGeometryFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, SVGContentUtils::eIgnoreStrokeDashing); Rect strokeBBoxExtents; gfxMatrix userToOuterSVG; - if (nsSVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { + if (SVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { Matrix outerSVGToUser = ToMatrix(userToOuterSVG); outerSVGToUser.Invert(); Matrix outerSVGToBBox = aToBBoxUserspace * outerSVGToUser; @@ -559,8 +557,8 @@ SVGBBox SVGGeometryFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, MOZ_ASSERT(strokeBBoxExtents.IsFinite(), "bbox is about to go bad"); bbox.UnionEdges(strokeBBoxExtents); #else - // For now we just use nsSVGUtils::PathExtentsToMaxStrokeExtents: - gfxRect strokeBBoxExtents = nsSVGUtils::PathExtentsToMaxStrokeExtents( + // For now we just use SVGUtils::PathExtentsToMaxStrokeExtents: + gfxRect strokeBBoxExtents = SVGUtils::PathExtentsToMaxStrokeExtents( ThebesRect(pathBBoxExtents), this, ThebesMatrix(aToBBoxUserspace)); MOZ_ASSERT(ToRect(strokeBBoxExtents).IsFinite(), "bbox is about to go bad"); @@ -570,14 +568,13 @@ SVGBBox SVGGeometryFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, } // Account for markers: - if ((aFlags & nsSVGUtils::eBBoxIncludeMarkers) != 0 && - element->IsMarkable()) { + if ((aFlags & SVGUtils::eBBoxIncludeMarkers) != 0 && element->IsMarkable()) { SVGMarkerFrame* markerFrames[SVGMark::eTypeCount]; if (SVGObserverUtils::GetAndObserveMarkers(this, &markerFrames)) { nsTArray marks; element->GetMarkPoints(&marks); if (uint32_t num = marks.Length()) { - float strokeWidth = nsSVGUtils::GetStrokeWidth(this); + float strokeWidth = SVGUtils::GetStrokeWidth(this); for (uint32_t i = 0; i < num; i++) { const SVGMark& mark = marks[i]; SVGMarkerFrame* frame = markerFrames[mark.type]; @@ -619,7 +616,7 @@ void SVGGeometryFrame::Render(gfxContext* aContext, uint32_t aRenderComponents, return; } - FillRule fillRule = nsSVGUtils::ToFillRule( + FillRule fillRule = SVGUtils::ToFillRule( HasAnyStateBits(NS_STATE_SVG_CLIPPATH_CHILD) ? StyleSVG()->mClipRule : StyleSVG()->mFillRule); @@ -665,8 +662,8 @@ void SVGGeometryFrame::Render(gfxContext* aContext, uint32_t aRenderComponents, if (aRenderComponents & eRenderFill) { GeneralPattern fillPattern; - nsSVGUtils::MakeFillPatternFor(this, aContext, &fillPattern, aImgParams, - contextPaint); + SVGUtils::MakeFillPatternFor(this, aContext, &fillPattern, aImgParams, + contextPaint); if (fillPattern.GetPattern()) { DrawOptions drawOptions(1.0f, CompositionOp::OP_OVER, aaMode); @@ -679,10 +676,10 @@ void SVGGeometryFrame::Render(gfxContext* aContext, uint32_t aRenderComponents, } if ((aRenderComponents & eRenderStroke) && - nsSVGUtils::HasStroke(this, contextPaint)) { + SVGUtils::HasStroke(this, contextPaint)) { // Account for vector-effect:non-scaling-stroke: gfxMatrix userToOuterSVG; - if (nsSVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { + if (SVGUtils::GetNonScalingStrokeTransform(this, &userToOuterSVG)) { // A simple Rect can't be transformed with rotate/skew, so let's switch // to using a real path: if (!path) { @@ -703,8 +700,8 @@ void SVGGeometryFrame::Render(gfxContext* aContext, uint32_t aRenderComponents, path = builder->Finish(); } GeneralPattern strokePattern; - nsSVGUtils::MakeStrokePatternFor(this, aContext, &strokePattern, aImgParams, - contextPaint); + SVGUtils::MakeStrokePatternFor(this, aContext, &strokePattern, aImgParams, + contextPaint); if (strokePattern.GetPattern()) { SVGContentUtils::AutoStrokeOptions strokeOptions; @@ -742,7 +739,7 @@ void SVGGeometryFrame::PaintMarkers(gfxContext& aContext, if (uint32_t num = marks.Length()) { SVGContextPaint* contextPaint = SVGContextPaint::GetContextPaint(GetContent()); - float strokeWidth = nsSVGUtils::GetStrokeWidth(this, contextPaint); + float strokeWidth = SVGUtils::GetStrokeWidth(this, contextPaint); for (uint32_t i = 0; i < num; i++) { const SVGMark& mark = marks[i]; SVGMarkerFrame* frame = markerFrames[mark.type]; @@ -757,6 +754,6 @@ void SVGGeometryFrame::PaintMarkers(gfxContext& aContext, } uint16_t SVGGeometryFrame::GetHitTestFlags() { - return nsSVGUtils::GetGeometryHitTestFlags(this); + return SVGUtils::GetGeometryHitTestFlags(this); } } // namespace mozilla diff --git a/layout/svg/SVGGeometryFrame.h b/layout/svg/SVGGeometryFrame.h index 1859fc3625aa..982316958c1b 100644 --- a/layout/svg/SVGGeometryFrame.h +++ b/layout/svg/SVGGeometryFrame.h @@ -15,7 +15,6 @@ #include "nsIFrame.h" #include "nsLiteralString.h" #include "nsQueryFrame.h" -#include "nsSVGUtils.h" namespace mozilla { @@ -37,7 +36,6 @@ struct imgDrawingParams; class gfxContext; class nsAtom; class nsIFrame; -class nsSVGMarkerFrame; struct nsRect; diff --git a/layout/svg/SVGGradientFrame.cpp b/layout/svg/SVGGradientFrame.cpp index a57800d0b09e..3c292e2c6459 100644 --- a/layout/svg/SVGGradientFrame.cpp +++ b/layout/svg/SVGGradientFrame.cpp @@ -13,6 +13,7 @@ #include "gfxPattern.h" #include "mozilla/PresShell.h" #include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGGradientElement.h" #include "mozilla/dom/SVGGradientElementBinding.h" #include "mozilla/dom/SVGStopElement.h" @@ -143,9 +144,9 @@ gfxMatrix SVGGradientFrame::GetGradientTransform( gfxRect bbox = aOverrideBounds ? *aOverrideBounds - : nsSVGUtils::GetBBox( - aSource, nsSVGUtils::eUseFrameBoundsForOuterSVG | - nsSVGUtils::eBBoxIncludeFillGeometry); + : SVGUtils::GetBBox( + aSource, SVGUtils::eUseFrameBoundsForOuterSVG | + SVGUtils::eBBoxIncludeFillGeometry); bboxMatrix = gfxMatrix(bbox.Width(), 0, 0, bbox.Height(), bbox.X(), bbox.Y()); } @@ -271,7 +272,7 @@ already_AddRefed SVGGradientFrame::GetPaintServerPattern( // revert any vector effect transform so that the gradient appears unchanged if (aFillOrStroke == &nsStyleSVG::mStroke) { gfxMatrix userToOuterSVG; - if (nsSVGUtils::GetNonScalingStrokeTransform(aSource, &userToOuterSVG)) { + if (SVGUtils::GetNonScalingStrokeTransform(aSource, &userToOuterSVG)) { patternMatrix *= userToOuterSVG; } } @@ -427,7 +428,7 @@ float SVGLinearGradientFrame::GetLengthValue(uint32_t aIndex) { uint16_t gradientUnits = GetGradientUnits(); if (gradientUnits == SVG_UNIT_TYPE_USERSPACEONUSE) { - return nsSVGUtils::UserSpace(mSource, &length); + return SVGUtils::UserSpace(mSource, &length); } NS_ASSERTION(gradientUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, @@ -528,7 +529,7 @@ float SVGRadialGradientFrame::GetLengthValueFromElement( uint16_t gradientUnits = GetGradientUnits(); if (gradientUnits == SVG_UNIT_TYPE_USERSPACEONUSE) { - return nsSVGUtils::UserSpace(mSource, &length); + return SVGUtils::UserSpace(mSource, &length); } NS_ASSERTION(gradientUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX, diff --git a/layout/svg/SVGImageFrame.cpp b/layout/svg/SVGImageFrame.cpp index 99cdc5399efe..f0a91e0f5f6d 100644 --- a/layout/svg/SVGImageFrame.cpp +++ b/layout/svg/SVGImageFrame.cpp @@ -18,12 +18,12 @@ #include "nsLayoutUtils.h" #include "imgINotificationObserver.h" #include "SVGGeometryProperty.h" -#include "SVGObserverUtils.h" -#include "nsSVGUtils.h" -#include "SVGContentUtils.h" #include "SVGGeometryFrame.h" -#include "SVGImageContext.h" #include "mozilla/PresShell.h" +#include "mozilla/SVGContentUtils.h" +#include "mozilla/SVGImageContext.h" +#include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/MutationEventBinding.h" #include "mozilla/dom/SVGImageElement.h" #include "nsIReflowCallback.h" @@ -324,8 +324,8 @@ void SVGImageFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, if (StyleDisplay()->IsScrollableOverflow()) { gfxRect clipRect = - nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); - nsSVGUtils::SetClipRect(&aContext, aTransform, clipRect); + SVGUtils::GetClipRectForFrame(this, x, y, width, height); + SVGUtils::SetClipRect(&aContext, aTransform, clipRect); } if (!TransformContextForPainting(&aContext, aTransform)) { @@ -336,7 +336,7 @@ void SVGImageFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, // optimize group opacity, the opacity used for compositing the // image into the current canvas is just the group opacity. float opacity = 1.0f; - if (nsSVGUtils::CanOptimizeOpacity(this)) { + if (SVGUtils::CanOptimizeOpacity(this)) { opacity = StyleEffects()->mOpacity; } @@ -435,7 +435,7 @@ bool SVGImageFrame::CreateWebRenderCommands( } float opacity = 1.0f; - if (nsSVGUtils::CanOptimizeOpacity(this)) { + if (SVGUtils::CanOptimizeOpacity(this)) { opacity = StyleEffects()->mOpacity; } @@ -496,7 +496,7 @@ bool SVGImageFrame::CreateWebRenderCommands( if (StyleDisplay()->IsScrollableOverflow()) { // Apply potential non-trivial clip - auto cssClip = nsSVGUtils::GetClipRectForFrame(this, 0, 0, width, height); + auto cssClip = SVGUtils::GetClipRectForFrame(this, 0, 0, width, height); auto appClip = nsLayoutUtils::RoundGfxRectToAppRect(cssClip, appUnitsPerCSSPixel); appClip += toReferenceFrame; @@ -683,8 +683,8 @@ nsIFrame* SVGImageFrame::GetFrameForPoint(const gfxPoint& aPoint) { Matrix viewBoxTM = SVGContentUtils::GetViewBoxTransform( rect.width, rect.height, 0, 0, nativeWidth, nativeHeight, element->mPreserveAspectRatio); - if (!nsSVGUtils::HitTestRect(viewBoxTM, 0, 0, nativeWidth, nativeHeight, - aPoint.x - rect.x, aPoint.y - rect.y)) { + if (!SVGUtils::HitTestRect(viewBoxTM, 0, 0, nativeWidth, nativeHeight, + aPoint.x - rect.x, aPoint.y - rect.y)) { return nullptr; } } @@ -700,13 +700,13 @@ nsIFrame* SVGImageFrame::GetFrameForPoint(const gfxPoint& aPoint) { // properly void SVGImageFrame::ReflowSVG() { - NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this), + NS_ASSERTION(SVGUtils::OuterSVGIsCallingReflowSVG(this), "This call is probably a wasteful mistake"); MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_IS_NONDISPLAY), "ReflowSVG mechanism not designed for this"); - if (!nsSVGUtils::NeedsReflowSVG(this)) { + if (!SVGUtils::NeedsReflowSVG(this)) { return; } @@ -823,12 +823,12 @@ void SVGImageListener::Notify(imgIRequest* aRequest, int32_t aType, nsLayoutUtils::PostRestyleEvent(mFrame->GetContent()->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(mFrame); + SVGUtils::ScheduleReflowSVG(mFrame); } if (aType == imgINotificationObserver::FRAME_UPDATE) { // No new dimensions, so we don't need to call - // nsSVGUtils::InvalidateAndScheduleBoundsUpdate. + // SVGUtils::InvalidateAndScheduleBoundsUpdate. nsLayoutUtils::PostRestyleEvent(mFrame->GetContent()->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); @@ -849,7 +849,7 @@ void SVGImageListener::Notify(imgIRequest* aRequest, int32_t aType, nsLayoutUtils::PostRestyleEvent(mFrame->GetContent()->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(mFrame); + SVGUtils::ScheduleReflowSVG(mFrame); } } diff --git a/layout/svg/SVGImageFrame.h b/layout/svg/SVGImageFrame.h index 3b75bdd9c36d..10de8390306e 100644 --- a/layout/svg/SVGImageFrame.h +++ b/layout/svg/SVGImageFrame.h @@ -15,11 +15,7 @@ #include "nsContainerFrame.h" #include "nsLayoutUtils.h" #include "imgINotificationObserver.h" -#include "SVGObserverUtils.h" -#include "nsSVGUtils.h" -#include "SVGContentUtils.h" -#include "SVGGeometryFrame.h" -#include "SVGImageContext.h" +#include "mozilla/SVGGeometryFrame.h" #include "mozilla/dom/SVGImageElement.h" #include "nsIReflowCallback.h" #include "mozilla/Unused.h" diff --git a/layout/svg/nsSVGIntegrationUtils.cpp b/layout/svg/SVGIntegrationUtils.cpp similarity index 93% rename from layout/svg/nsSVGIntegrationUtils.cpp rename to layout/svg/SVGIntegrationUtils.cpp index b70398ee2b47..4117c84eb8b3 100644 --- a/layout/svg/nsSVGIntegrationUtils.cpp +++ b/layout/svg/SVGIntegrationUtils.cpp @@ -5,7 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ // Main header first: -#include "nsSVGIntegrationUtils.h" +#include "SVGIntegrationUtils.h" // Keep others in (case-insensitive) order: #include "gfxDrawable.h" @@ -17,7 +17,6 @@ #include "gfxContext.h" #include "SVGFilterPaintCallback.h" #include "SVGPaintServerFrame.h" -#include "nsSVGUtils.h" #include "FrameLayerBuilder.h" #include "BasicLayers.h" #include "mozilla/gfx/Point.h" @@ -28,16 +27,16 @@ #include "mozilla/SVGClipPathFrame.h" #include "mozilla/SVGObserverUtils.h" #include "mozilla/SVGMaskFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/Unused.h" #include "mozilla/dom/SVGElement.h" -using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::layers; using namespace mozilla::gfx; using namespace mozilla::image; -// ---------------------------------------------------------------------- +namespace mozilla { /** * This class is used to get the pre-effects visual overflow rect of a frame, @@ -95,7 +94,7 @@ class PreEffectsVisualOverflowCollector : public nsLayoutUtils::BoxCallback { // This function may be called during reflow or painting. We should only // do this check in painting process since the PreEffectsBBoxProperty of // continuations are not set correctly while reflowing. - if (nsSVGIntegrationUtils::UsingOverflowAffectingEffects(aFrame) && + if (SVGIntegrationUtils::UsingOverflowAffectingEffects(aFrame) && !aInReflow) { nsOverflowAreas* preTransformOverflows = aFrame->GetProperty(nsIFrame::PreTransformOverflowAreasProperty()); @@ -149,14 +148,14 @@ static nsRect GetPreEffectsVisualOverflow( return collector.GetResult() + aFirstContinuationToUserSpace; } -bool nsSVGIntegrationUtils::UsingOverflowAffectingEffects( +bool SVGIntegrationUtils::UsingOverflowAffectingEffects( const nsIFrame* aFrame) { // Currently overflow don't take account of SVG or other non-absolute // positioned clipping, or masking. return aFrame->StyleEffects()->HasFilters(); } -bool nsSVGIntegrationUtils::UsingEffectsForFrame(const nsIFrame* aFrame) { +bool SVGIntegrationUtils::UsingEffectsForFrame(const nsIFrame* aFrame) { // Even when SVG display lists are disabled, returning true for SVG frames // does not adversely affect any of our callers. Therefore we don't bother // checking the SDL prefs here, since we don't know if we're being called for @@ -169,14 +168,12 @@ bool nsSVGIntegrationUtils::UsingEffectsForFrame(const nsIFrame* aFrame) { style->HasClipPath() || style->HasMask(); } -bool nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame( - const nsIFrame* aFrame) { +bool SVGIntegrationUtils::UsingMaskOrClipPathForFrame(const nsIFrame* aFrame) { const nsStyleSVGReset* style = aFrame->StyleSVGReset(); return style->HasClipPath() || style->HasMask(); } -bool nsSVGIntegrationUtils::UsingSimpleClipPathForFrame( - const nsIFrame* aFrame) { +bool SVGIntegrationUtils::UsingSimpleClipPathForFrame(const nsIFrame* aFrame) { const nsStyleSVGReset* style = aFrame->StyleSVGReset(); if (!style->HasClipPath() || style->HasMask()) { return false; @@ -190,7 +187,7 @@ bool nsSVGIntegrationUtils::UsingSimpleClipPathForFrame( return !clipPath.AsShape()._0->IsPolygon(); } -nsPoint nsSVGIntegrationUtils::GetOffsetToBoundingBox(nsIFrame* aFrame) { +nsPoint SVGIntegrationUtils::GetOffsetToBoundingBox(nsIFrame* aFrame) { if (aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { // Do NOT call GetAllInFlowRectsUnion for SVG - it will get the // covered region relative to the SVGOuterSVGFrame, which is absolutely @@ -206,7 +203,7 @@ nsPoint nsSVGIntegrationUtils::GetOffsetToBoundingBox(nsIFrame* aFrame) { } /* static */ -nsSize nsSVGIntegrationUtils::GetContinuationUnionSize(nsIFrame* aNonSVGFrame) { +nsSize SVGIntegrationUtils::GetContinuationUnionSize(nsIFrame* aNonSVGFrame) { NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG), "SVG frames should not get here"); nsIFrame* firstFrame = @@ -214,7 +211,7 @@ nsSize nsSVGIntegrationUtils::GetContinuationUnionSize(nsIFrame* aNonSVGFrame) { return nsLayoutUtils::GetAllInFlowRectsUnion(firstFrame, firstFrame).Size(); } -/* static */ gfx::Size nsSVGIntegrationUtils::GetSVGCoordContextForNonSVGFrame( +/* static */ gfx::Size SVGIntegrationUtils::GetSVGCoordContextForNonSVGFrame( nsIFrame* aNonSVGFrame) { NS_ASSERTION(!aNonSVGFrame->IsFrameOfType(nsIFrame::eSVG), "SVG frames should not get here"); @@ -225,7 +222,7 @@ nsSize nsSVGIntegrationUtils::GetContinuationUnionSize(nsIFrame* aNonSVGFrame) { nsPresContext::AppUnitsToFloatCSSPixels(r.height)); } -gfxRect nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame( +gfxRect SVGIntegrationUtils::GetSVGBBoxForNonSVGFrame( nsIFrame* aNonSVGFrame, bool aUnionContinuations) { // Except for SVGOuterSVGFrame, we shouldn't be getting here with SVG // frames at all. This function is for elements that are laid out using the @@ -281,7 +278,7 @@ gfxRect nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame( // pre-effects overflow rect will actually overestimate that area which, while // being a bit wasteful, isn't otherwise a problem. // -nsRect nsSVGIntegrationUtils::ComputePostEffectsVisualOverflowRect( +nsRect SVGIntegrationUtils::ComputePostEffectsVisualOverflowRect( nsIFrame* aFrame, const nsRect& aPreEffectsOverflowRect) { MOZ_ASSERT(!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT), "Don't call this on SVG child frames"); @@ -324,7 +321,7 @@ nsRect nsSVGIntegrationUtils::ComputePostEffectsVisualOverflowRect( (aFrame->GetOffsetTo(firstFrame) + firstFrameToBoundingBox); } -nsIntRegion nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects( +nsIntRegion SVGIntegrationUtils::AdjustInvalidAreaForSVGEffects( nsIFrame* aFrame, const nsPoint& aToReferenceFrame, const nsIntRegion& aInvalidRegion) { if (aInvalidRegion.IsEmpty()) { @@ -364,7 +361,7 @@ nsIntRegion nsSVGIntegrationUtils::AdjustInvalidAreaForSVGEffects( return result.ToOutsidePixels(appUnitsPerDevPixel); } -nsRect nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea( +nsRect SVGIntegrationUtils::GetRequiredSourceForInvalidArea( nsIFrame* aFrame, const nsRect& aDirtyRect) { nsIFrame* firstFrame = nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame); @@ -390,8 +387,8 @@ nsRect nsSVGIntegrationUtils::GetRequiredSourceForInvalidArea( toUserSpace; } -bool nsSVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame, - const nsPoint& aPt) { +bool SVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame, + const nsPoint& aPt) { nsIFrame* firstFrame = nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame); // Convert aPt to user space: @@ -405,7 +402,7 @@ bool nsSVGIntegrationUtils::HitTestFrameForEffects(nsIFrame* aFrame, } nsPoint pt = aPt + toUserSpace; gfxPoint userSpacePt = gfxPoint(pt.x, pt.y) / AppUnitsPerCSSPixel(); - return nsSVGUtils::HitTestClip(firstFrame, userSpacePt); + return SVGUtils::HitTestClip(firstFrame, userSpacePt); } class RegularFramePaintCallback : public SVGFilterPaintCallback { @@ -439,7 +436,7 @@ class RegularFramePaintCallback : public SVGFilterPaintCallback { gfxPoint mUserSpaceToFrameSpaceOffset; }; -typedef nsSVGIntegrationUtils::PaintFramesParams PaintFramesParams; +typedef SVGIntegrationUtils::PaintFramesParams PaintFramesParams; /** * Paint css-positioned-mask onto a given target(aMaskDT). @@ -456,8 +453,7 @@ static bool PaintMaskSurface(const PaintFramesParams& aParams, MOZ_ASSERT(aOpacity == 1.0 || aMaskFrames.Length() == 1); const nsStyleSVGReset* svgReset = aSC->StyleSVGReset(); - gfxMatrix cssPxToDevPxMatrix = - nsSVGUtils::GetCSSPxToDevPxMatrix(aParams.frame); + gfxMatrix cssPxToDevPxMatrix = SVGUtils::GetCSSPxToDevPxMatrix(aParams.frame); nsPresContext* presContext = aParams.frame->PresContext(); gfxPoint devPixelOffsetToUserSpace = nsLayoutUtils::PointToGfxPoint( @@ -538,7 +534,7 @@ static MaskPaintResult CreateAndPaintMaskSurface( // Optimization for single SVG mask. if (((aMaskFrames.Length() == 1) && aMaskFrames[0])) { gfxMatrix cssPxToDevPxMatrix = - nsSVGUtils::GetCSSPxToDevPxMatrix(aParams.frame); + SVGUtils::GetCSSPxToDevPxMatrix(aParams.frame); paintResult.opacityApplied = true; SVGMaskFrame::MaskParams params( &ctx, aParams.frame, cssPxToDevPxMatrix, aOpacity, @@ -619,7 +615,7 @@ static bool ValidateSVGFrame(nsIFrame* aFrame) { NS_ASSERTION(!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT) || (NS_SVGDisplayListPaintingEnabled() && !aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)), - "Should not use nsSVGIntegrationUtils on this SVG frame"); + "Should not use SVGIntegrationUtils on this SVG frame"); #endif bool hasSVGLayout = aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT); @@ -658,7 +654,7 @@ static EffectOffsets ComputeEffectOffset(nsIFrame* aFrame, result.offsetToBoundingBox = aParams.builder->ToReferenceFrame(aFrame) - - nsSVGIntegrationUtils::GetOffsetToBoundingBox(aFrame); + SVGIntegrationUtils::GetOffsetToBoundingBox(aFrame); if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) { /* Snap the offset if the reference frame is not a SVG frame, * since other frames will be snapped to pixel when rendering. */ @@ -681,7 +677,7 @@ static EffectOffsets ComputeEffectOffset(nsIFrame* aFrame, // frame's position so that SVG painting can later add it again and the // frame is painted in the right place. gfxPoint toUserSpaceGfx = - nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame); + SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(aFrame); nsPoint toUserSpace = nsPoint(nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.x)), nsPresContext::CSSPixelsToAppUnits(float(toUserSpaceGfx.y))); @@ -715,7 +711,7 @@ static EffectOffsets MoveContextOriginToUserSpace( return offset; } -bool nsSVGIntegrationUtils::IsMaskResourceReady(nsIFrame* aFrame) { +bool SVGIntegrationUtils::IsMaskResourceReady(nsIFrame* aFrame) { nsIFrame* firstFrame = nsLayoutUtils::FirstContinuationOrIBSplitSibling(aFrame); nsTArray maskFrames; @@ -756,13 +752,12 @@ class AutoPopGroup { gfxContext* mContext; }; -bool nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams, - bool& aOutIsMaskComplete) { +bool SVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams, + bool& aOutIsMaskComplete) { aOutIsMaskComplete = true; - nsSVGUtils::MaskUsage maskUsage; - nsSVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity, - maskUsage); + SVGUtils::MaskUsage maskUsage; + SVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity, maskUsage); if (!maskUsage.shouldDoSomething()) { return false; } @@ -817,7 +812,7 @@ bool nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams, basicShapeSR.SetContext(&ctx); CSSClipPathInstance::ApplyBasicShapeOrPathClip( - ctx, frame, nsSVGUtils::GetCSSPxToDevPxMatrix(frame)); + ctx, frame, SVGUtils::GetCSSPxToDevPxMatrix(frame)); if (!maskUsage.shouldGenerateMaskLayer) { // Only have basic-shape clip-path effect. Fill clipped region by // opaque white. @@ -847,7 +842,7 @@ bool nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams, MoveContextOriginToUserSpace(firstFrame, aParams); Matrix clipMaskTransform; - gfxMatrix cssPxToDevPxMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(frame); + gfxMatrix cssPxToDevPxMatrix = SVGUtils::GetCSSPxToDevPxMatrix(frame); SVGClipPathFrame* clipPathFrame; // XXX check return value? @@ -864,7 +859,7 @@ bool nsSVGIntegrationUtils::PaintMask(const PaintFramesParams& aParams, template void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, const T& aPaintChild) { - MOZ_ASSERT(nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(aParams.frame), + MOZ_ASSERT(SVGIntegrationUtils::UsingMaskOrClipPathForFrame(aParams.frame), "Should not use this method when no mask or clipPath effect" "on this frame"); @@ -886,9 +881,8 @@ void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, return; } - nsSVGUtils::MaskUsage maskUsage; - nsSVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity, - maskUsage); + SVGUtils::MaskUsage maskUsage; + SVGUtils::DetermineMaskUsage(aParams.frame, aParams.handleOpacity, maskUsage); if (maskUsage.opacity == 0.0f) { return; @@ -908,7 +902,7 @@ void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, // XXX check return value? SVGObserverUtils::GetAndObserveMasks(firstFrame, &maskFrames); - gfxMatrix cssPxToDevPxMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(frame); + gfxMatrix cssPxToDevPxMatrix = SVGUtils::GetCSSPxToDevPxMatrix(frame); bool shouldGenerateMask = (maskUsage.opacity != 1.0f || maskUsage.shouldGenerateClipMaskLayer || @@ -1055,7 +1049,7 @@ void PaintMaskAndClipPathInternal(const PaintFramesParams& aParams, } } -void nsSVGIntegrationUtils::PaintMaskAndClipPath( +void SVGIntegrationUtils::PaintMaskAndClipPath( const PaintFramesParams& aParams) { PaintMaskAndClipPathInternal(aParams, [&] { gfxContext& context = aParams.ctx; @@ -1068,13 +1062,13 @@ void nsSVGIntegrationUtils::PaintMaskAndClipPath( }); } -void nsSVGIntegrationUtils::PaintMaskAndClipPath( +void SVGIntegrationUtils::PaintMaskAndClipPath( const PaintFramesParams& aParams, const std::function& aPaintChild) { PaintMaskAndClipPathInternal(aParams, aPaintChild); } -void nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) { +void SVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) { MOZ_ASSERT(!aParams.builder->IsForGenerateGlyphMask(), "Filter effect is discarded while generating glyph mask."); MOZ_ASSERT(aParams.frame->StyleEffects()->HasFilters(), @@ -1085,7 +1079,7 @@ void nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) { return; } - float opacity = nsSVGUtils::ComputeOpacity(frame, aParams.handleOpacity); + float opacity = SVGUtils::ComputeOpacity(frame, aParams.handleOpacity); if (opacity == 0.0f) { return; } @@ -1121,7 +1115,7 @@ void nsSVGIntegrationUtils::PaintFilter(const PaintFramesParams& aParams) { aParams.imgParams, opacity); } -bool nsSVGIntegrationUtils::CreateWebRenderCSSFilters( +bool SVGIntegrationUtils::CreateWebRenderCSSFilters( Span aFilters, nsIFrame* aFrame, WrFiltersHolder& aWrFilters) { // All CSS filters are supported by WebRender. SVG filters are not fully @@ -1171,9 +1165,8 @@ bool nsSVGIntegrationUtils::CreateWebRenderCSSFilters( // TODO(emilio): we should go directly from css pixels -> device pixels. float appUnitsPerDevPixel = aFrame->PresContext()->AppUnitsPerDevPixel(); - wrFilters.AppendElement( - mozilla::wr::FilterOp::Blur(NSAppUnitsToFloatPixels( - filter.AsBlur().ToAppUnits(), appUnitsPerDevPixel))); + wrFilters.AppendElement(wr::FilterOp::Blur(NSAppUnitsToFloatPixels( + filter.AsBlur().ToAppUnits(), appUnitsPerDevPixel))); break; } case StyleFilter::Tag::DropShadow: { @@ -1203,15 +1196,14 @@ bool nsSVGIntegrationUtils::CreateWebRenderCSSFilters( return true; } -bool nsSVGIntegrationUtils::BuildWebRenderFilters( +bool SVGIntegrationUtils::BuildWebRenderFilters( nsIFrame* aFilteredFrame, Span aFilters, WrFiltersHolder& aWrFilters, Maybe& aPostFilterClip) { return FilterInstance::BuildWebRenderFilters(aFilteredFrame, aFilters, aWrFilters, aPostFilterClip); } -bool nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame( - nsIFrame* aFrame) { +bool SVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(nsIFrame* aFrame) { WrFiltersHolder wrFilters; Maybe filterClip; auto filterChain = aFrame->StyleEffects()->mFilters.AsSpan(); @@ -1219,15 +1211,15 @@ bool nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame( BuildWebRenderFilters(aFrame, filterChain, wrFilters, filterClip); } -bool nsSVGIntegrationUtils::UsesSVGEffectsNotSupportedInCompositor( +bool SVGIntegrationUtils::UsesSVGEffectsNotSupportedInCompositor( nsIFrame* aFrame) { // WebRender supports masks / clip-paths and some filters in the compositor. // Non-WebRender doesn't support any SVG effects in the compositor. if (aFrame->StyleEffects()->HasFilters()) { return !gfx::gfxVars::UseWebRender() || - !nsSVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(aFrame); + !SVGIntegrationUtils::CanCreateWebRenderFiltersForFrame(aFrame); } - if (nsSVGIntegrationUtils::UsingMaskOrClipPathForFrame(aFrame)) { + if (SVGIntegrationUtils::UsingMaskOrClipPathForFrame(aFrame)) { return !gfx::gfxVars::UseWebRender(); } return false; @@ -1279,7 +1271,7 @@ bool PaintFrameCallback::operator()(gfxContext* aContext, // to have it anchored at the top left corner of the bounding box of all of // mFrame's continuations. So we add a translation transform. int32_t appUnitsPerDevPixel = mFrame->PresContext()->AppUnitsPerDevPixel(); - nsPoint offset = nsSVGIntegrationUtils::GetOffsetToBoundingBox(mFrame); + nsPoint offset = SVGIntegrationUtils::GetOffsetToBoundingBox(mFrame); gfxPoint devPxOffset = gfxPoint(offset.x, offset.y) / appUnitsPerDevPixel; aContext->Multiply(gfxMatrix::Translation(devPxOffset)); @@ -1299,7 +1291,7 @@ bool PaintFrameCallback::operator()(gfxContext* aContext, using PaintFrameFlags = nsLayoutUtils::PaintFrameFlags; PaintFrameFlags flags = PaintFrameFlags::InTransform; - if (mFlags & nsSVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES) { + if (mFlags & SVGIntegrationUtils::FLAG_SYNC_DECODE_IMAGES) { flags |= PaintFrameFlags::SyncDecodeImages; } nsLayoutUtils::PaintFrame(aContext, mFrame, dirty, NS_RGBA(0, 0, 0, 0), @@ -1328,7 +1320,7 @@ bool PaintFrameCallback::operator()(gfxContext* aContext, } /* static */ -already_AddRefed nsSVGIntegrationUtils::DrawableFromPaintServer( +already_AddRefed SVGIntegrationUtils::DrawableFromPaintServer( nsIFrame* aFrame, nsIFrame* aTarget, const nsSize& aPaintServerSize, const IntSize& aRenderSize, const DrawTarget* aDrawTarget, const gfxMatrix& aContextMatrix, uint32_t aFlags) { @@ -1384,3 +1376,5 @@ already_AddRefed nsSVGIntegrationUtils::DrawableFromPaintServer( RefPtr drawable = new gfxCallbackDrawable(cb, aRenderSize); return drawable.forget(); } + +} // namespace mozilla diff --git a/layout/svg/nsSVGIntegrationUtils.h b/layout/svg/SVGIntegrationUtils.h similarity index 91% rename from layout/svg/nsSVGIntegrationUtils.h rename to layout/svg/SVGIntegrationUtils.h index 74fb1b466152..9ca0546ba0a9 100644 --- a/layout/svg/nsSVGIntegrationUtils.h +++ b/layout/svg/SVGIntegrationUtils.h @@ -20,19 +20,8 @@ class gfxDrawable; class nsDisplayList; class nsDisplayListBuilder; class nsIFrame; - -struct nsRect; - -namespace mozilla { -namespace gfx { -class DrawTarget; -} // namespace gfx -namespace layers { -class LayerManager; -} // namespace layers -} // namespace mozilla - struct nsPoint; +struct nsRect; struct nsSize; struct WrFiltersHolder { @@ -43,14 +32,24 @@ struct WrFiltersHolder { nsTArray> values; }; +namespace mozilla { + +namespace gfx { +class DrawTarget; +} // namespace gfx + +namespace layers { +class LayerManager; +} // namespace layers + /** * Integration of SVG effects (clipPath clipping, masking and filters) into * regular display list based painting and hit-testing. */ -class nsSVGIntegrationUtils final { - typedef mozilla::gfx::DrawTarget DrawTarget; - typedef mozilla::gfx::IntRect IntRect; - typedef mozilla::image::imgDrawingParams imgDrawingParams; +class SVGIntegrationUtils final { + typedef gfx::DrawTarget DrawTarget; + typedef gfx::IntRect IntRect; + typedef image::imgDrawingParams imgDrawingParams; public: /** @@ -89,8 +88,7 @@ class nsSVGIntegrationUtils final { * frame's continuations' border boxes, converted to SVG user units (equal to * CSS px units), as required by the SVG code. */ - static mozilla::gfx::Size GetSVGCoordContextForNonSVGFrame( - nsIFrame* aNonSVGFrame); + static gfx::Size GetSVGCoordContextForNonSVGFrame(nsIFrame* aNonSVGFrame); /** * SVG effects such as SVG filters, masking and clipPath may require an SVG @@ -156,17 +154,17 @@ class nsSVGIntegrationUtils final { const nsRect& dirtyRect; const nsRect& borderArea; nsDisplayListBuilder* builder; - mozilla::layers::LayerManager* layerManager; + layers::LayerManager* layerManager; bool handleOpacity; // If true, PaintMaskAndClipPath/ PaintFilter should // apply css opacity. - mozilla::Maybe maskRect; + Maybe maskRect; imgDrawingParams& imgParams; explicit PaintFramesParams(gfxContext& aCtx, nsIFrame* aFrame, const nsRect& aDirtyRect, const nsRect& aBorderArea, nsDisplayListBuilder* aBuilder, - mozilla::layers::LayerManager* aLayerManager, + layers::LayerManager* aLayerManager, bool aHandleOpacity, imgDrawingParams& aImgParams) : ctx(aCtx), @@ -213,18 +211,18 @@ class nsSVGIntegrationUtils final { /** * Build WebRender filters for a frame with CSS filters applied to it. */ - static bool CreateWebRenderCSSFilters( - mozilla::Span aFilters, nsIFrame* aFrame, - WrFiltersHolder& aWrFilters); + static bool CreateWebRenderCSSFilters(Span aFilters, + nsIFrame* aFrame, + WrFiltersHolder& aWrFilters); /** * Try to build WebRender filters for a frame with SVG filters applied to it * if the filters are supported. */ - static bool BuildWebRenderFilters( - nsIFrame* aFilteredFrame, - mozilla::Span aFilters, - WrFiltersHolder& aWrFilters, mozilla::Maybe& aPostFilterClip); + static bool BuildWebRenderFilters(nsIFrame* aFilteredFrame, + Span aFilters, + WrFiltersHolder& aWrFilters, + Maybe& aPostFilterClip); /** * Check if the filters present on |aFrame| are supported by WebRender. @@ -262,7 +260,7 @@ class nsSVGIntegrationUtils final { static already_AddRefed DrawableFromPaintServer( nsIFrame* aFrame, nsIFrame* aTarget, const nsSize& aPaintServerSize, - const mozilla::gfx::IntSize& aRenderSize, const DrawTarget* aDrawTarget, + const gfx::IntSize& aRenderSize, const DrawTarget* aDrawTarget, const gfxMatrix& aContextMatrix, uint32_t aFlags); /** @@ -272,4 +270,6 @@ class nsSVGIntegrationUtils final { static nsPoint GetOffsetToBoundingBox(nsIFrame* aFrame); }; +} // namespace mozilla + #endif /*NSSVGINTEGRATIONUTILS_H_*/ diff --git a/layout/svg/SVGMarkerFrame.cpp b/layout/svg/SVGMarkerFrame.cpp index fb4454ed18e5..2c70a8f00c47 100644 --- a/layout/svg/SVGMarkerFrame.cpp +++ b/layout/svg/SVGMarkerFrame.cpp @@ -10,10 +10,11 @@ // Keep others in (case-insensitive) order: #include "gfxContext.h" #include "mozilla/PresShell.h" +#include "mozilla/SVGGeometryFrame.h" +#include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" +#include "mozilla/dom/SVGGeometryElement.h" #include "mozilla/dom/SVGMarkerElement.h" -#include "SVGGeometryElement.h" -#include "SVGGeometryFrame.h" -#include "SVGObserverUtils.h" using namespace mozilla::dom; using namespace mozilla::gfx; @@ -123,16 +124,16 @@ void SVGMarkerFrame::PaintMark(gfxContext& aContext, if (StyleDisplay()->IsScrollableOverflow()) { aContext.Save(); - gfxRect clipRect = nsSVGUtils::GetClipRectForFrame( + gfxRect clipRect = SVGUtils::GetClipRectForFrame( this, viewBox.x, viewBox.y, viewBox.width, viewBox.height); - nsSVGUtils::SetClipRect(&aContext, markTM, clipRect); + SVGUtils::SetClipRect(&aContext, markTM, clipRect); } nsIFrame* kid = GetAnonymousChildFrame(this); ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); // The CTM of each frame referencing us may be different. SVGFrame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED); - nsSVGUtils::PaintFrameWithEffects(kid, aContext, markTM, aImgParams); + SVGUtils::PaintFrameWithEffects(kid, aContext, markTM, aImgParams); if (StyleDisplay()->IsScrollableOverflow()) aContext.Restore(); } diff --git a/layout/svg/SVGMarkerFrame.h b/layout/svg/SVGMarkerFrame.h index 7fe9b20cd0dd..f79b7d0ba353 100644 --- a/layout/svg/SVGMarkerFrame.h +++ b/layout/svg/SVGMarkerFrame.h @@ -14,7 +14,6 @@ #include "nsIFrame.h" #include "nsLiteralString.h" #include "nsQueryFrame.h" -#include "nsSVGUtils.h" class gfxContext; diff --git a/layout/svg/SVGMaskFrame.cpp b/layout/svg/SVGMaskFrame.cpp index a4b29c1284d3..90348ac4d9f8 100644 --- a/layout/svg/SVGMaskFrame.cpp +++ b/layout/svg/SVGMaskFrame.cpp @@ -13,10 +13,11 @@ #include "gfxContext.h" #include "mozilla/PresShell.h" #include "mozilla/RefPtr.h" +#include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGMaskElement.h" #include "mozilla/dom/SVGUnitTypesBinding.h" #include "mozilla/gfx/2D.h" -#include "SVGObserverUtils.h" using namespace mozilla::dom; using namespace mozilla::dom::SVGUnitTypes_Binding; @@ -92,10 +93,10 @@ already_AddRefed SVGMaskFrame::GetMaskForMaskedFrame( ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED); - m = nsSVGUtils::GetTransformMatrixInUserSpace(kid) * m; + m = SVGUtils::GetTransformMatrixInUserSpace(kid) * m; } - nsSVGUtils::PaintFrameWithEffects(kid, *tmpCtx, m, aParams.imgParams); + SVGUtils::PaintFrameWithEffects(kid, *tmpCtx, m, aParams.imgParams); } RefPtr surface; @@ -132,13 +133,13 @@ gfxRect SVGMaskFrame::GetMaskArea(nsIFrame* aMaskedFrame) { maskElem->mEnumAttributes[SVGMaskElement::MASKUNITS].GetAnimValue(); gfxRect bbox; if (units == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { - bbox = nsSVGUtils::GetBBox(aMaskedFrame, - nsSVGUtils::eUseFrameBoundsForOuterSVG | - nsSVGUtils::eBBoxIncludeFillGeometry); + bbox = + SVGUtils::GetBBox(aMaskedFrame, SVGUtils::eUseFrameBoundsForOuterSVG | + SVGUtils::eBBoxIncludeFillGeometry); } // Bounds in the user space of aMaskedFrame - gfxRect maskArea = nsSVGUtils::GetRelativeRect( + gfxRect maskArea = SVGUtils::GetRelativeRect( units, &maskElem->mLengthAttributes[SVGMaskElement::ATTR_X], bbox, aMaskedFrame); @@ -177,14 +178,14 @@ gfxMatrix SVGMaskFrame::GetMaskTransform(nsIFrame* aMaskedFrame) { SVGAnimatedEnumeration* maskContentUnits = &content->mEnumAttributes[SVGMaskElement::MASKCONTENTUNITS]; - uint32_t flags = nsSVGUtils::eBBoxIncludeFillGeometry | + uint32_t flags = SVGUtils::eBBoxIncludeFillGeometry | (aMaskedFrame->StyleBorder()->mBoxDecorationBreak == StyleBoxDecorationBreak::Clone - ? nsSVGUtils::eIncludeOnlyCurrentFrameForNonSVGElement + ? SVGUtils::eIncludeOnlyCurrentFrameForNonSVGElement : 0); - return nsSVGUtils::AdjustMatrixForUnits(gfxMatrix(), maskContentUnits, - aMaskedFrame, flags); + return SVGUtils::AdjustMatrixForUnits(gfxMatrix(), maskContentUnits, + aMaskedFrame, flags); } } // namespace mozilla diff --git a/layout/svg/SVGMaskFrame.h b/layout/svg/SVGMaskFrame.h index 7a85048b35f2..f09c43c75ced 100644 --- a/layout/svg/SVGMaskFrame.h +++ b/layout/svg/SVGMaskFrame.h @@ -13,7 +13,6 @@ #include "mozilla/gfx/2D.h" #include "gfxPattern.h" #include "gfxMatrix.h" -#include "nsSVGUtils.h" class gfxContext; diff --git a/layout/svg/SVGObserverUtils.cpp b/layout/svg/SVGObserverUtils.cpp index ea3f7229cb08..abd79077a99c 100644 --- a/layout/svg/SVGObserverUtils.cpp +++ b/layout/svg/SVGObserverUtils.cpp @@ -18,6 +18,7 @@ #include "mozilla/SVGClipPathFrame.h" #include "mozilla/SVGMaskFrame.h" #include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "nsCSSFrameConstructor.h" #include "nsCycleCollectionParticipant.h" #include "nsHashKeys.h" @@ -32,9 +33,10 @@ #include "SVGMarkerFrame.h" #include "SVGPaintServerFrame.h" -using namespace mozilla; using namespace mozilla::dom; +namespace mozilla { + bool URLAndReferrerInfo::operator==(const URLAndReferrerInfo& aRHS) const { bool uriEqual = false, referrerEqual = false; this->mURI->Equals(aRHS.mURI, &uriEqual); @@ -148,8 +150,6 @@ static already_AddRefed ResolveURLUsingLocalRef( return info.forget(); } -namespace mozilla { - class SVGFilterObserverList; /** @@ -475,7 +475,7 @@ void SVGTextPathObserver::OnRenderingChange() { } MOZ_ASSERT(frame->IsFrameOfType(nsIFrame::eSVG) || - nsSVGUtils::IsInSVGTextSubtree(frame), + SVGUtils::IsInSVGTextSubtree(frame), "SVG frame expected"); MOZ_ASSERT(frame->GetContent()->IsSVGElement(nsGkAtoms::textPath), @@ -520,7 +520,7 @@ void SVGMarkerObserver::OnRenderingChange() { // XXXjwatt: We need to unify SVG into standard reflow so we can just use // nsChangeHint_NeedReflow | nsChangeHint_NeedDirtyReflow here. // XXXSDL KILL THIS!!! - nsSVGUtils::ScheduleReflowSVG(frame); + SVGUtils::ScheduleReflowSVG(frame); } frame->PresContext()->RestyleManager()->PostRestyleEvent( frame->GetContent()->AsElement(), RestyleHint{0}, @@ -1269,14 +1269,14 @@ SVGObserverUtils::ReferenceState SVGObserverUtils::GetAndObserveFilters( nsIFrame* aFilteredFrame, nsTArray* aFilterFrames) { SVGFilterObserverListForCSSProp* observerList = GetOrCreateFilterObserverListForCSS(aFilteredFrame); - return ::GetAndObserveFilters(observerList, aFilterFrames); + return mozilla::GetAndObserveFilters(observerList, aFilterFrames); } SVGObserverUtils::ReferenceState SVGObserverUtils::GetFiltersIfObserving( nsIFrame* aFilteredFrame, nsTArray* aFilterFrames) { SVGFilterObserverListForCSSProp* observerList = aFilteredFrame->GetProperty(FilterProperty()); - return ::GetAndObserveFilters(observerList, aFilterFrames); + return mozilla::GetAndObserveFilters(observerList, aFilterFrames); } already_AddRefed SVGObserverUtils::ObserveFiltersForCanvasContext( @@ -1644,7 +1644,7 @@ void SVGObserverUtils::InvalidateRenderingObservers(nsIFrame* aFrame) { } // If the rendering has changed, the bounds may well have changed too: - aFrame->RemoveProperty(nsSVGUtils::ObjectBoundingBoxProperty()); + aFrame->RemoveProperty(SVGUtils::ObjectBoundingBoxProperty()); SVGRenderingObserverSet* observers = GetObserverSet(content->AsElement()); if (observers) { @@ -1670,7 +1670,7 @@ void SVGObserverUtils::InvalidateDirectRenderingObservers( Element* aElement, uint32_t aFlags /* = 0 */) { if (nsIFrame* frame = aElement->GetPrimaryFrame()) { // If the rendering has changed, the bounds may well have changed too: - frame->RemoveProperty(nsSVGUtils::ObjectBoundingBoxProperty()); + frame->RemoveProperty(SVGUtils::ObjectBoundingBoxProperty()); } if (aElement->HasRenderingObservers()) { diff --git a/layout/svg/SVGObserverUtils.h b/layout/svg/SVGObserverUtils.h index 5e6d475c2e0c..544b00f793dd 100644 --- a/layout/svg/SVGObserverUtils.h +++ b/layout/svg/SVGObserverUtils.h @@ -19,7 +19,6 @@ #include "nsIReferrerInfo.h" #include "nsStringFwd.h" #include "nsStubMutationObserver.h" -#include "nsSVGUtils.h" #include "nsCycleCollectionParticipant.h" class nsAtom; @@ -265,7 +264,7 @@ class SVGObserverUtils { * to be applied, only that there are no references to SVG filter elements. * * XXX Callers other than ComputePostEffectsVisualOverflowRect and - * nsSVGUtils::GetPostFilterVisualOverflowRect should not need to initiate + * SVGUtils::GetPostFilterVisualOverflowRect should not need to initiate * observing. If we have a bug that causes invalidation (which would remove * observers) between reflow and painting, then we don't really want to * re-add abservers during painting. That has the potential to hide logic diff --git a/layout/svg/SVGOuterSVGFrame.cpp b/layout/svg/SVGOuterSVGFrame.cpp index b7e506b54d51..6518161dbfdc 100644 --- a/layout/svg/SVGOuterSVGFrame.cpp +++ b/layout/svg/SVGOuterSVGFrame.cpp @@ -13,9 +13,9 @@ #include "nsIInterfaceRequestorUtils.h" #include "nsIObjectLoadingContent.h" #include "nsSubDocumentFrame.h" -#include "nsSVGIntegrationUtils.h" #include "mozilla/PresShell.h" #include "mozilla/SVGForeignObjectFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/Document.h" #include "mozilla/dom/Element.h" #include "mozilla/dom/SVGSVGElement.h" @@ -601,7 +601,7 @@ void nsDisplayOuterSVG::HitTest(nsDisplayListBuilder* aBuilder, outerSVGFrame->PrincipalChildList().FirstChild()); nsIFrame* frame = - nsSVGUtils::HitTestChildren(anonKid, svgViewportRelativePoint); + SVGUtils::HitTestChildren(anonKid, svgViewportRelativePoint); if (frame) { aOutFrames->AppendElement(frame); } @@ -637,10 +637,10 @@ void nsDisplayOuterSVG::Paint(nsDisplayListBuilder* aBuilder, imgDrawingParams imgParams(aBuilder->GetImageDecodeFlags()); // We include the offset of our frame and a scale from device pixels to user // units (i.e. CSS px) in the matrix that we pass to our children): - gfxMatrix tm = nsSVGUtils::GetCSSPxToDevPxMatrix(mFrame) * + gfxMatrix tm = SVGUtils::GetCSSPxToDevPxMatrix(mFrame) * gfxMatrix::Translation(devPixelOffset); - nsSVGUtils::PaintFrameWithEffects(mFrame, *aContext, tm, imgParams, - &contentAreaDirtyRect); + SVGUtils::PaintFrameWithEffects(mFrame, *aContext, tm, imgParams, + &contentAreaDirtyRect); nsDisplayItemGenericImageGeometry::UpdateDrawResult(this, imgParams.result); aContext->Restore(); @@ -695,7 +695,7 @@ nsresult SVGOuterSVGFrame::AttributeChanged(int32_t aNameSpaceID, // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nullptr; - nsSVGUtils::NotifyChildrenOfSVGChange( + SVGUtils::NotifyChildrenOfSVGChange( PrincipalChildList().FirstChild(), aAttribute == nsGkAtoms::viewBox ? TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED @@ -852,8 +852,8 @@ void SVGOuterSVGFrame::NotifyViewportOrTransformChanged(uint32_t aFlags) { } } - nsSVGUtils::NotifyChildrenOfSVGChange(PrincipalChildList().FirstChild(), - aFlags); + SVGUtils::NotifyChildrenOfSVGChange(PrincipalChildList().FirstChild(), + aFlags); } //---------------------------------------------------------------------- diff --git a/layout/svg/SVGPaintServerFrame.h b/layout/svg/SVGPaintServerFrame.h index 5bf94c727c9c..aef594888856 100644 --- a/layout/svg/SVGPaintServerFrame.h +++ b/layout/svg/SVGPaintServerFrame.h @@ -14,7 +14,6 @@ #include "nsIFrame.h" #include "nsIFrame.h" #include "nsQueryFrame.h" -#include "nsSVGUtils.h" class gfxContext; class gfxPattern; diff --git a/layout/svg/SVGPatternFrame.cpp b/layout/svg/SVGPatternFrame.cpp index 922616007aa8..c7ba1538b763 100644 --- a/layout/svg/SVGPatternFrame.cpp +++ b/layout/svg/SVGPatternFrame.cpp @@ -20,12 +20,12 @@ #include "mozilla/SVGContentUtils.h" #include "mozilla/SVGGeometryFrame.h" #include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGPatternElement.h" #include "mozilla/dom/SVGUnitTypesBinding.h" #include "mozilla/gfx/2D.h" #include "nsGkAtoms.h" #include "nsIFrameInlines.h" -#include "nsSVGUtils.h" #include "SVGAnimatedTransformList.h" using namespace mozilla::dom; @@ -172,11 +172,11 @@ static nsresult GetTargetGeometry(gfxRect* aBBox, uint16_t aPatternUnits, nsIFrame* aTarget, const Matrix& aContextMatrix, const gfxRect* aOverrideBounds) { - *aBBox = aOverrideBounds - ? *aOverrideBounds - : nsSVGUtils::GetBBox(aTarget, - nsSVGUtils::eUseFrameBoundsForOuterSVG | - nsSVGUtils::eBBoxIncludeFillGeometry); + *aBBox = + aOverrideBounds + ? *aOverrideBounds + : SVGUtils::GetBBox(aTarget, SVGUtils::eUseFrameBoundsForOuterSVG | + SVGUtils::eBBoxIncludeFillGeometry); // Sanity check if (IncludeBBoxScale(aViewBox, aPatternContentUnits, aPatternUnits) && @@ -281,7 +281,7 @@ already_AddRefed SVGPatternFrame::PaintPattern( // revert the vector effect transform so that the pattern appears unchanged if (aFillOrStroke == &nsStyleSVG::mStroke) { gfxMatrix userToOuterSVG; - if (nsSVGUtils::GetNonScalingStrokeTransform(aSource, &userToOuterSVG)) { + if (SVGUtils::GetNonScalingStrokeTransform(aSource, &userToOuterSVG)) { patternTransform *= ToMatrix(userToOuterSVG); if (patternTransform.IsSingular()) { NS_WARNING("Singular matrix painting non-scaling-stroke"); @@ -304,8 +304,8 @@ already_AddRefed SVGPatternFrame::PaintPattern( ThebesRect(patternTransform.TransformBounds(ToRect(bbox))); bool resultOverflows; - IntSize surfaceSize = nsSVGUtils::ConvertToSurfaceSize(transformedBBox.Size(), - &resultOverflows); + IntSize surfaceSize = + SVGUtils::ConvertToSurfaceSize(transformedBBox.Size(), &resultOverflows); // 0 disables rendering, < 0 is an error if (surfaceSize.width <= 0 || surfaceSize.height <= 0) { @@ -362,10 +362,10 @@ already_AddRefed SVGPatternFrame::PaintPattern( ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->NotifySVGChanged(ISVGDisplayableFrame::TRANSFORM_CHANGED); - tm = nsSVGUtils::GetTransformMatrixInUserSpace(kid) * tm; + tm = SVGUtils::GetTransformMatrixInUserSpace(kid) * tm; } - nsSVGUtils::PaintFrameWithEffects(kid, *ctx, tm, aImgParams); + SVGUtils::PaintFrameWithEffects(kid, *ctx, tm, aImgParams); } } @@ -593,16 +593,16 @@ gfxRect SVGPatternFrame::GetPatternRect(uint16_t aPatternUnits, tmpWidth = GetLengthValue(SVGPatternElement::ATTR_WIDTH); if (aPatternUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { - x = nsSVGUtils::ObjectSpace(aTargetBBox, tmpX); - y = nsSVGUtils::ObjectSpace(aTargetBBox, tmpY); - width = nsSVGUtils::ObjectSpace(aTargetBBox, tmpWidth); - height = nsSVGUtils::ObjectSpace(aTargetBBox, tmpHeight); + x = SVGUtils::ObjectSpace(aTargetBBox, tmpX); + y = SVGUtils::ObjectSpace(aTargetBBox, tmpY); + width = SVGUtils::ObjectSpace(aTargetBBox, tmpWidth); + height = SVGUtils::ObjectSpace(aTargetBBox, tmpHeight); } else { float scale = MaxExpansion(aTargetCTM); - x = nsSVGUtils::UserSpace(aTarget, tmpX) * scale; - y = nsSVGUtils::UserSpace(aTarget, tmpY) * scale; - width = nsSVGUtils::UserSpace(aTarget, tmpWidth) * scale; - height = nsSVGUtils::UserSpace(aTarget, tmpHeight) * scale; + x = SVGUtils::UserSpace(aTarget, tmpX) * scale; + y = SVGUtils::UserSpace(aTarget, tmpY) * scale; + width = SVGUtils::UserSpace(aTarget, tmpWidth) * scale; + height = SVGUtils::UserSpace(aTarget, tmpHeight) * scale; } return gfxRect(x, y, width, height); diff --git a/layout/svg/SVGSwitchFrame.cpp b/layout/svg/SVGSwitchFrame.cpp index 7c7fe8f313a5..5afaddd1d461 100644 --- a/layout/svg/SVGSwitchFrame.cpp +++ b/layout/svg/SVGSwitchFrame.cpp @@ -11,8 +11,8 @@ #include "mozilla/SVGContainerFrame.h" #include "mozilla/SVGObserverUtils.h" #include "mozilla/SVGTextFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGSwitchElement.h" -#include "nsSVGUtils.h" using namespace mozilla::dom; using namespace mozilla::gfx; @@ -68,7 +68,8 @@ class SVGSwitchFrame final : public SVGGFrame { //---------------------------------------------------------------------- // Implementation -nsIFrame* NS_NewSVGSwitchFrame(PresShell* aPresShell, ComputedStyle* aStyle) { +nsIFrame* NS_NewSVGSwitchFrame(mozilla::PresShell* aPresShell, + mozilla::ComputedStyle* aStyle) { return new (aPresShell) mozilla::SVGSwitchFrame(aStyle, aPresShell->GetPresContext()); } @@ -111,10 +112,9 @@ void SVGSwitchFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, if (kid) { gfxMatrix tm = aTransform; if (kid->GetContent()->IsSVGElement()) { - tm = nsSVGUtils::GetTransformMatrixInUserSpace(kid) * tm; + tm = SVGUtils::GetTransformMatrixInUserSpace(kid) * tm; } - nsSVGUtils::PaintFrameWithEffects(kid, aContext, tm, aImgParams, - aDirtyRect); + SVGUtils::PaintFrameWithEffects(kid, aContext, tm, aImgParams, aDirtyRect); } } @@ -191,13 +191,13 @@ void SVGSwitchFrame::ReflowAllSVGTextFramesInsideNonActiveChildren( } void SVGSwitchFrame::ReflowSVG() { - NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this), + NS_ASSERTION(SVGUtils::OuterSVGIsCallingReflowSVG(this), "This call is probably a wasteful mistake"); MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_IS_NONDISPLAY), "ReflowSVG mechanism not designed for this"); - if (!nsSVGUtils::NeedsReflowSVG(this)) { + if (!SVGUtils::NeedsReflowSVG(this)) { return; } @@ -263,7 +263,7 @@ SVGBBox SVGSwitchFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, if (content->IsSVGElement()) { transform = static_cast(content)->PrependLocalTransformsTo( {}, eChildToUserSpace) * - nsSVGUtils::GetTransformMatrixInUserSpace(kid) * transform; + SVGUtils::GetTransformMatrixInUserSpace(kid) * transform; } return svgKid->GetBBoxContribution(ToMatrix(transform), aFlags); } diff --git a/layout/svg/SVGTextFrame.cpp b/layout/svg/SVGTextFrame.cpp index 5be6ee38a9fb..12b133c9ffa8 100644 --- a/layout/svg/SVGTextFrame.cpp +++ b/layout/svg/SVGTextFrame.cpp @@ -24,8 +24,6 @@ #include "nsGkAtoms.h" #include "nsQuickSort.h" #include "SVGPaintServerFrame.h" -#include "nsSVGIntegrationUtils.h" -#include "nsSVGUtils.h" #include "nsTArray.h" #include "nsTextFrame.h" #include "SVGAnimatedNumberList.h" @@ -40,6 +38,7 @@ #include "mozilla/PresShell.h" #include "mozilla/SVGObserverUtils.h" #include "mozilla/SVGOuterSVGFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/DOMPointBinding.h" #include "mozilla/dom/Selection.h" #include "mozilla/dom/SVGGeometryElement.h" @@ -885,9 +884,9 @@ SVGBBox TextRenderedRun::GetRunUserSpaceRect(nsPresContext* aContext, // Include the stroke if requested. if ((aFlags & eIncludeStroke) && !fill.IsEmpty() && - nsSVGUtils::GetStrokeWidth(mFrame) > 0) { + SVGUtils::GetStrokeWidth(mFrame) > 0) { r.UnionEdges( - nsSVGUtils::PathExtentsToMaxStrokeExtents(fill, mFrame, gfxMatrix())); + SVGUtils::PathExtentsToMaxStrokeExtents(fill, mFrame, gfxMatrix())); } return r; @@ -2512,7 +2511,7 @@ void SVGTextDrawPathCallbacks::NotifyAfterText() { mContext.Restore(); } void SVGTextDrawPathCallbacks::PaintDecorationLine(Rect aPath, nscolor aColor) { mColor = aColor; AntialiasMode aaMode = - nsSVGUtils::ToAntialiasMode(mFrame->StyleText()->mTextRendering); + SVGUtils::ToAntialiasMode(mFrame->StyleText()->mTextRendering); mContext.Save(); mContext.NewPath(); @@ -2573,7 +2572,7 @@ void SVGTextDrawPathCallbacks::HandleTextGeometry() { void SVGTextDrawPathCallbacks::MakeFillPattern(GeneralPattern* aOutPattern) { if (mColor == NS_SAME_AS_FOREGROUND_COLOR || mColor == NS_40PERCENT_FOREGROUND_COLOR) { - nsSVGUtils::MakeFillPatternFor(mFrame, &mContext, aOutPattern, mImgParams); + SVGUtils::MakeFillPatternFor(mFrame, &mContext, aOutPattern, mImgParams); return; } @@ -2625,9 +2624,9 @@ void SVGTextDrawPathCallbacks::FillGeometry() { MakeFillPattern(&fillPattern); if (fillPattern.GetPattern()) { RefPtr path = mContext.GetPath(); - FillRule fillRule = nsSVGUtils::ToFillRule( - IsClipPathChild() ? mFrame->StyleSVG()->mClipRule - : mFrame->StyleSVG()->mFillRule); + FillRule fillRule = + SVGUtils::ToFillRule(IsClipPathChild() ? mFrame->StyleSVG()->mClipRule + : mFrame->StyleSVG()->mFillRule); if (fillRule != path->GetFillRule()) { RefPtr builder = path->CopyToBuilder(fillRule); path = builder->Finish(); @@ -2640,10 +2639,10 @@ void SVGTextDrawPathCallbacks::StrokeGeometry() { // We don't paint the stroke when we are filling with a selection color. if (mColor == NS_SAME_AS_FOREGROUND_COLOR || mColor == NS_40PERCENT_FOREGROUND_COLOR) { - if (nsSVGUtils::HasStroke(mFrame, /*aContextPaint*/ nullptr)) { + if (SVGUtils::HasStroke(mFrame, /*aContextPaint*/ nullptr)) { GeneralPattern strokePattern; - nsSVGUtils::MakeStrokePatternFor(mFrame, &mContext, &strokePattern, - mImgParams, /*aContextPaint*/ nullptr); + SVGUtils::MakeStrokePatternFor(mFrame, &mContext, &strokePattern, + mImgParams, /*aContextPaint*/ nullptr); if (strokePattern.GetPattern()) { if (!mFrame->GetParent()->GetContent()->IsSVGElement()) { // The cast that follows would be unsafe @@ -2655,7 +2654,7 @@ void SVGTextDrawPathCallbacks::StrokeGeometry() { // Apply any stroke-specific transform gfxMatrix outerSVGToUser; - if (nsSVGUtils::GetNonScalingStrokeTransform(mFrame, &outerSVGToUser) && + if (SVGUtils::GetNonScalingStrokeTransform(mFrame, &outerSVGToUser) && outerSVGToUser.Invert()) { mContext.Multiply(outerSVGToUser); } @@ -2667,7 +2666,7 @@ void SVGTextDrawPathCallbacks::StrokeGeometry() { /*aContextPaint*/ nullptr); DrawOptions drawOptions; drawOptions.mAntialiasMode = - nsSVGUtils::ToAntialiasMode(mFrame->StyleText()->mTextRendering); + SVGUtils::ToAntialiasMode(mFrame->StyleText()->mTextRendering); mContext.GetDrawTarget()->Stroke(path, strokePattern, strokeOptions); } } @@ -2742,7 +2741,7 @@ void DisplaySVGText::Paint(nsDisplayListBuilder* aBuilder, gfxContext* aCtx) { gfxPoint devPixelOffset = nsLayoutUtils::PointToGfxPoint(offset, appUnitsPerDevPixel); - gfxMatrix tm = nsSVGUtils::GetCSSPxToDevPxMatrix(mFrame) * + gfxMatrix tm = SVGUtils::GetCSSPxToDevPxMatrix(mFrame) * gfxMatrix::Translation(devPixelOffset); gfxContext* ctx = aCtx; @@ -2837,7 +2836,7 @@ nsresult SVGTextFrame::AttributeChanged(int32_t aNameSpaceID, } void SVGTextFrame::ReflowSVGNonDisplayText() { - MOZ_ASSERT(nsSVGUtils::AnyOuterSVGIsCallingReflowSVG(this), + MOZ_ASSERT(SVGUtils::AnyOuterSVGIsCallingReflowSVG(this), "only call ReflowSVGNonDisplayText when an outer SVG frame is " "under ReflowSVG"); MOZ_ASSERT(mState & NS_FRAME_IS_NONDISPLAY, @@ -2862,7 +2861,7 @@ void SVGTextFrame::ReflowSVGNonDisplayText() { } void SVGTextFrame::ScheduleReflowSVGNonDisplayText(IntrinsicDirty aReason) { - MOZ_ASSERT(!nsSVGUtils::OuterSVGIsCallingReflowSVG(this), + MOZ_ASSERT(!SVGUtils::OuterSVGIsCallingReflowSVG(this), "do not call ScheduleReflowSVGNonDisplayText when the outer SVG " "frame is under ReflowSVG"); MOZ_ASSERT(!(mState & NS_STATE_SVG_TEXT_IN_REFLOW), @@ -2989,7 +2988,7 @@ void SVGTextFrame::FindCloserFrameForSelection( m = GetCanvasTM(); } nsRect rect = - nsSVGUtils::ToCanvasBounds(userRect.ToThebesRect(), m, presContext); + SVGUtils::ToCanvasBounds(userRect.ToThebesRect(), m, presContext); if (nsLayoutUtils::PointIsCloserToRect(aPoint, rect, aCurrentBestFrame->mXDistance, @@ -3194,7 +3193,7 @@ void SVGTextFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform, ctxSR.EnsureSaved(&aContext); // This may change the gfxContext's transform (for non-scaling stroke), // in which case this needs to happen before we call SetMatrix() below. - nsSVGUtils::SetupStrokeGeometry(frame, &aContext, outerContextPaint); + SVGUtils::SetupStrokeGeometry(frame, &aContext, outerContextPaint); } nscoord startEdge, endEdge; @@ -3255,7 +3254,7 @@ nsIFrame* SVGTextFrame::GetFrameForPoint(const gfxPoint& aPoint) { // Hit-testing any clip-path will typically be a lot quicker than the // hit-testing of our text frames in the loop below, so we do the former up // front to avoid unnecessarily wasting cycles on the latter. - if (!nsSVGUtils::HitTestClip(this, aPoint)) { + if (!SVGUtils::HitTestClip(this, aPoint)) { return nullptr; } @@ -3269,7 +3268,7 @@ nsIFrame* SVGTextFrame::GetFrameForPoint(const gfxPoint& aPoint) { TextRenderedRunIterator it(this); nsIFrame* hit = nullptr; for (TextRenderedRun run = it.Current(); run.mFrame; run = it.Next()) { - uint16_t hitTestFlags = nsSVGUtils::GetGeometryHitTestFlags(run.mFrame); + uint16_t hitTestFlags = SVGUtils::GetGeometryHitTestFlags(run.mFrame); if (!(hitTestFlags & (SVG_HIT_TEST_FILL | SVG_HIT_TEST_STROKE))) { continue; } @@ -3293,13 +3292,13 @@ nsIFrame* SVGTextFrame::GetFrameForPoint(const gfxPoint& aPoint) { } void SVGTextFrame::ReflowSVG() { - NS_ASSERTION(nsSVGUtils::OuterSVGIsCallingReflowSVG(this), + NS_ASSERTION(SVGUtils::OuterSVGIsCallingReflowSVG(this), "This call is probaby a wasteful mistake"); MOZ_ASSERT(!HasAnyStateBits(NS_FRAME_IS_NONDISPLAY), "ReflowSVG mechanism not designed for this"); - if (!nsSVGUtils::NeedsReflowSVG(this)) { + if (!SVGUtils::NeedsReflowSVG(this)) { MOZ_ASSERT(!HasAnyStateBits(NS_STATE_SVG_TEXT_CORRESPONDENCE_DIRTY | NS_STATE_SVG_POSITIONING_DIRTY), "How did this happen?"); @@ -3319,7 +3318,7 @@ void SVGTextFrame::ReflowSVG() { runFlags |= TextRenderedRun::eIncludeFill | TextRenderedRun::eIncludeTextShadow; } - if (nsSVGUtils::HasStroke(run.mFrame)) { + if (SVGUtils::HasStroke(run.mFrame)) { runFlags |= TextRenderedRun::eIncludeStroke | TextRenderedRun::eIncludeTextShadow; } @@ -3329,7 +3328,7 @@ void SVGTextFrame::ReflowSVG() { // fill/ stroke don't actually render (e.g. when stroke="none" or // stroke-opacity="0"). GetGeometryHitTestFlags accounts for // 'pointer-events'. The text-shadow is not part of the hit-test area. - uint16_t hitTestFlags = nsSVGUtils::GetGeometryHitTestFlags(run.mFrame); + uint16_t hitTestFlags = SVGUtils::GetGeometryHitTestFlags(run.mFrame); if (hitTestFlags & SVG_HIT_TEST_FILL) { runFlags |= TextRenderedRun::eIncludeFill; } @@ -3378,20 +3377,20 @@ void SVGTextFrame::ReflowSVG() { } /** - * Converts nsSVGUtils::eBBox* flags into TextRenderedRun flags appropriate + * Converts SVGUtils::eBBox* flags into TextRenderedRun flags appropriate * for the specified rendered run. */ static uint32_t TextRenderedRunFlagsForBBoxContribution( const TextRenderedRun& aRun, uint32_t aBBoxFlags) { uint32_t flags = 0; - if ((aBBoxFlags & nsSVGUtils::eBBoxIncludeFillGeometry) || - ((aBBoxFlags & nsSVGUtils::eBBoxIncludeFill) && + if ((aBBoxFlags & SVGUtils::eBBoxIncludeFillGeometry) || + ((aBBoxFlags & SVGUtils::eBBoxIncludeFill) && !aRun.mFrame->StyleSVG()->mFill.kind.IsNone())) { flags |= TextRenderedRun::eIncludeFill; } - if ((aBBoxFlags & nsSVGUtils::eBBoxIncludeStrokeGeometry) || - ((aBBoxFlags & nsSVGUtils::eBBoxIncludeStroke) && - nsSVGUtils::HasStroke(aRun.mFrame))) { + if ((aBBoxFlags & SVGUtils::eBBoxIncludeStrokeGeometry) || + ((aBBoxFlags & SVGUtils::eBBoxIncludeStroke) && + SVGUtils::HasStroke(aRun.mFrame))) { flags |= TextRenderedRun::eIncludeStroke; } return flags; @@ -3402,7 +3401,7 @@ SVGBBox SVGTextFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, NS_ASSERTION(PrincipalChildList().FirstChild(), "must have a child frame"); SVGBBox bbox; - if (aFlags & nsSVGUtils::eForGetClientRects) { + if (aFlags & SVGUtils::eForGetClientRects) { Rect rect = NSRectToRect(mRect, AppUnitsPerCSSPixel()); if (!rect.IsEmpty()) { bbox = aToBBoxUserspace.TransformBounds(rect); @@ -5001,7 +5000,7 @@ void SVGTextFrame::ScheduleReflowSVG() { if (mState & NS_FRAME_IS_NONDISPLAY) { ScheduleReflowSVGNonDisplayText(IntrinsicDirty::StyleChange); } else { - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } } @@ -5065,7 +5064,7 @@ void SVGTextFrame::MaybeReflowAnonymousBlockChild() { TextNodeCorrespondenceRecorder::RecordCorrespondence(this); - MOZ_ASSERT(nsSVGUtils::AnyOuterSVGIsCallingReflowSVG(this), + MOZ_ASSERT(SVGUtils::AnyOuterSVGIsCallingReflowSVG(this), "should be under ReflowSVG"); nsPresContext::InterruptPreventer noInterrupts(PresContext()); DoReflow(); diff --git a/layout/svg/SVGTextFrame.h b/layout/svg/SVGTextFrame.h index 006a022babb1..33c527d90f6e 100644 --- a/layout/svg/SVGTextFrame.h +++ b/layout/svg/SVGTextFrame.h @@ -273,7 +273,7 @@ class SVGTextFrame final : public SVGDisplayContainerFrame { /** * Calls ScheduleReflowSVGNonDisplayText if this is a non-display frame, - * and nsSVGUtils::ScheduleReflowSVG otherwise. + * and SVGUtils::ScheduleReflowSVG otherwise. */ void ScheduleReflowSVG(); @@ -291,7 +291,7 @@ class SVGTextFrame final : public SVGDisplayContainerFrame { void ReflowSVGNonDisplayText(); /** - * This is a function that behaves similarly to nsSVGUtils::ScheduleReflowSVG, + * This is a function that behaves similarly to SVGUtils::ScheduleReflowSVG, * but which will skip over any ancestor non-display container frames on the * way to the SVGOuterSVGFrame. It exists for the situation where a * non-display element has changed and needs to ensure ReflowSVG will diff --git a/layout/svg/SVGUseFrame.cpp b/layout/svg/SVGUseFrame.cpp index 1a29263543dc..eca9e2b63509 100644 --- a/layout/svg/SVGUseFrame.cpp +++ b/layout/svg/SVGUseFrame.cpp @@ -8,6 +8,7 @@ #include "mozilla/PresShell.h" #include "mozilla/SVGObserverUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/MutationEvent.h" #include "mozilla/dom/SVGUseElement.h" @@ -58,8 +59,8 @@ void SVGUseFrame::PositionAttributeChanged() { mCanvasTM = nullptr; nsLayoutUtils::PostRestyleEvent(GetContent()->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(this); - nsSVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED); + SVGUtils::ScheduleReflowSVG(this); + SVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED); } void SVGUseFrame::DimensionAttributeChanged(bool aHadValidDimensions, @@ -73,14 +74,14 @@ void SVGUseFrame::DimensionAttributeChanged(bool aHadValidDimensions, if (invalidate) { nsLayoutUtils::PostRestyleEvent(GetContent()->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } } void SVGUseFrame::HrefChanged() { nsLayoutUtils::PostRestyleEvent(GetContent()->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } //---------------------------------------------------------------------- @@ -120,13 +121,13 @@ void SVGUseFrame::NotifySVGChanged(uint32_t aFlags) { // changed ancestor will have invalidated its entire area, which includes // our area. // For perf reasons we call this before calling NotifySVGChanged() below. - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } } // We don't remove the TRANSFORM_CHANGED flag here if we have a viewBox or // non-percentage width/height, since if they're set then they are cloned to - // an anonymous child , and its nsSVGInnerSVGFrame will do that. + // an anonymous child , and its SVGInnerSVGFrame will do that. SVGGFrame::NotifySVGChanged(aFlags); } diff --git a/layout/svg/nsSVGUtils.cpp b/layout/svg/SVGUtils.cpp similarity index 85% rename from layout/svg/nsSVGUtils.cpp rename to layout/svg/SVGUtils.cpp index 29e8677f5dfc..d2720644a1bc 100644 --- a/layout/svg/nsSVGUtils.cpp +++ b/layout/svg/SVGUtils.cpp @@ -6,7 +6,7 @@ // Main header first: // This is also necessary to ensure our definition of M_SQRT1_2 is picked up -#include "nsSVGUtils.h" +#include "SVGUtils.h" #include // Keep others in (case-insensitive) order: @@ -28,13 +28,12 @@ #include "nsStyleStruct.h" #include "nsStyleTransformMatrix.h" #include "SVGAnimatedLength.h" -#include "ISVGDisplayableFrame.h" #include "SVGFilterPaintCallback.h" -#include "nsSVGIntegrationUtils.h" #include "SVGPaintServerFrame.h" #include "nsTextFrame.h" #include "mozilla/CSSClipPathInstance.h" #include "mozilla/FilterInstance.h" +#include "mozilla/ISVGDisplayableFrame.h" #include "mozilla/Preferences.h" #include "mozilla/StaticPrefs_svg.h" #include "mozilla/SVGClipPathFrame.h" @@ -42,6 +41,7 @@ #include "mozilla/SVGContentUtils.h" #include "mozilla/SVGContextPaint.h" #include "mozilla/SVGForeignObjectFrame.h" +#include "mozilla/SVGIntegrationUtils.h" #include "mozilla/SVGGeometryFrame.h" #include "mozilla/SVGMaskFrame.h" #include "mozilla/SVGObserverUtils.h" @@ -57,26 +57,27 @@ #include "mozilla/dom/SVGUnitTypesBinding.h" #include "mozilla/dom/SVGViewportElement.h" -using namespace mozilla; using namespace mozilla::dom; using namespace mozilla::dom::SVGUnitTypes_Binding; using namespace mozilla::gfx; using namespace mozilla::image; bool NS_SVGDisplayListHitTestingEnabled() { - return StaticPrefs::svg_display_lists_hit_testing_enabled(); + return mozilla::StaticPrefs::svg_display_lists_hit_testing_enabled(); } bool NS_SVGDisplayListPaintingEnabled() { - return StaticPrefs::svg_display_lists_painting_enabled(); + return mozilla::StaticPrefs::svg_display_lists_painting_enabled(); } bool NS_SVGNewGetBBoxEnabled() { - return StaticPrefs::svg_new_getBBox_enabled(); + return mozilla::StaticPrefs::svg_new_getBBox_enabled(); } +namespace mozilla { + // we only take the address of this: -static mozilla::gfx::UserDataKey sSVGAutoRenderStateKey; +static gfx::UserDataKey sSVGAutoRenderStateKey; SVGAutoRenderState::SVGAutoRenderState( DrawTarget* aDrawTarget MOZ_GUARD_OBJECT_NOTIFIER_PARAM_IN_IMPL) @@ -111,8 +112,8 @@ bool SVGAutoRenderState::IsPaintingToWindow(DrawTarget* aDrawTarget) { return false; } -nsRect nsSVGUtils::GetPostFilterVisualOverflowRect( - nsIFrame* aFrame, const nsRect& aPreFilterRect) { +nsRect SVGUtils::GetPostFilterVisualOverflowRect(nsIFrame* aFrame, + const nsRect& aPreFilterRect) { MOZ_ASSERT(aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT), "Called on invalid frame type"); @@ -132,11 +133,11 @@ nsRect nsSVGUtils::GetPostFilterVisualOverflowRect( return FilterInstance::GetPostFilterBounds(aFrame, nullptr, &aPreFilterRect); } -bool nsSVGUtils::OuterSVGIsCallingReflowSVG(nsIFrame* aFrame) { +bool SVGUtils::OuterSVGIsCallingReflowSVG(nsIFrame* aFrame) { return GetOuterSVGFrame(aFrame)->IsCallingReflowSVG(); } -bool nsSVGUtils::AnyOuterSVGIsCallingReflowSVG(nsIFrame* aFrame) { +bool SVGUtils::AnyOuterSVGIsCallingReflowSVG(nsIFrame* aFrame) { SVGOuterSVGFrame* outer = GetOuterSVGFrame(aFrame); do { if (outer->IsCallingReflowSVG()) { @@ -147,7 +148,7 @@ bool nsSVGUtils::AnyOuterSVGIsCallingReflowSVG(nsIFrame* aFrame) { return false; } -void nsSVGUtils::ScheduleReflowSVG(nsIFrame* aFrame) { +void SVGUtils::ScheduleReflowSVG(nsIFrame* aFrame) { MOZ_ASSERT(aFrame->IsFrameOfType(nsIFrame::eSVG), "Passed bad frame!"); // If this is triggered, the callers should be fixed to call us before @@ -212,7 +213,7 @@ void nsSVGUtils::ScheduleReflowSVG(nsIFrame* aFrame) { dirtyBit); } -bool nsSVGUtils::NeedsReflowSVG(nsIFrame* aFrame) { +bool SVGUtils::NeedsReflowSVG(nsIFrame* aFrame) { MOZ_ASSERT(aFrame->IsFrameOfType(nsIFrame::eSVG), "SVG uses bits differently!"); @@ -221,7 +222,7 @@ bool nsSVGUtils::NeedsReflowSVG(nsIFrame* aFrame) { return aFrame->IsSubtreeDirty(); } -Size nsSVGUtils::GetContextSize(const nsIFrame* aFrame) { +Size SVGUtils::GetContextSize(const nsIFrame* aFrame) { Size size; MOZ_ASSERT(aFrame->GetContent()->IsSVGElement(), "bad cast"); @@ -235,8 +236,8 @@ Size nsSVGUtils::GetContextSize(const nsIFrame* aFrame) { return size; } -float nsSVGUtils::ObjectSpace(const gfxRect& aRect, - const SVGAnimatedLength* aLength) { +float SVGUtils::ObjectSpace(const gfxRect& aRect, + const SVGAnimatedLength* aLength) { float axis; switch (aLength->GetCtxType()) { @@ -263,22 +264,22 @@ float nsSVGUtils::ObjectSpace(const gfxRect& aRect, axis; } -float nsSVGUtils::UserSpace(SVGElement* aSVGElement, - const SVGAnimatedLength* aLength) { +float SVGUtils::UserSpace(SVGElement* aSVGElement, + const SVGAnimatedLength* aLength) { return aLength->GetAnimValue(aSVGElement); } -float nsSVGUtils::UserSpace(nsIFrame* aNonSVGContext, - const SVGAnimatedLength* aLength) { +float SVGUtils::UserSpace(nsIFrame* aNonSVGContext, + const SVGAnimatedLength* aLength) { return aLength->GetAnimValue(aNonSVGContext); } -float nsSVGUtils::UserSpace(const UserSpaceMetrics& aMetrics, - const SVGAnimatedLength* aLength) { +float SVGUtils::UserSpace(const UserSpaceMetrics& aMetrics, + const SVGAnimatedLength* aLength) { return aLength->GetAnimValue(aMetrics); } -SVGOuterSVGFrame* nsSVGUtils::GetOuterSVGFrame(nsIFrame* aFrame) { +SVGOuterSVGFrame* SVGUtils::GetOuterSVGFrame(nsIFrame* aFrame) { while (aFrame) { if (aFrame->IsSVGOuterSVGFrame()) { return static_cast(aFrame); @@ -289,8 +290,8 @@ SVGOuterSVGFrame* nsSVGUtils::GetOuterSVGFrame(nsIFrame* aFrame) { return nullptr; } -nsIFrame* nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, - nsRect* aRect) { +nsIFrame* SVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, + nsRect* aRect) { ISVGDisplayableFrame* svg = do_QueryFrame(aFrame); if (!svg) { return nullptr; @@ -303,9 +304,9 @@ nsIFrame* nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, if (aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY)) { *aRect = nsRect(0, 0, 0, 0); } else { - uint32_t flags = - nsSVGUtils::eForGetClientRects | nsSVGUtils::eBBoxIncludeFill | - nsSVGUtils::eBBoxIncludeStroke | nsSVGUtils::eBBoxIncludeMarkers; + uint32_t flags = SVGUtils::eForGetClientRects | SVGUtils::eBBoxIncludeFill | + SVGUtils::eBBoxIncludeStroke | + SVGUtils::eBBoxIncludeMarkers; auto ctm = nsLayoutUtils::GetTransformToAncestor(RelativeTo{aFrame}, RelativeTo{outer}); @@ -328,19 +329,19 @@ nsIFrame* nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame, // i.e. with CSS pixel unit. m = m.PreScale(devPixelPerCSSPixel, devPixelPerCSSPixel); - // Both nsSVGUtils::GetBBox and nsLayoutUtils::GetTransformToAncestor + // Both SVGUtils::GetBBox and nsLayoutUtils::GetTransformToAncestor // will count this displacement, we should remove it here to avoid // double-counting. m = m.PreTranslate(-initPositionX, -initPositionY); - gfxRect bbox = nsSVGUtils::GetBBox(aFrame, flags, &m); + gfxRect bbox = SVGUtils::GetBBox(aFrame, flags, &m); *aRect = nsLayoutUtils::RoundGfxRectToAppRect(bbox, appUnitsPerDevPixel); } return outer; } -gfxMatrix nsSVGUtils::GetCanvasTM(nsIFrame* aFrame) { +gfxMatrix SVGUtils::GetCanvasTM(nsIFrame* aFrame) { // XXX yuck, we really need a common interface for GetCanvasTM if (!aFrame->IsFrameOfType(nsIFrame::eSVG)) { @@ -363,14 +364,14 @@ gfxMatrix nsSVGUtils::GetCanvasTM(nsIFrame* aFrame) { return static_cast(aFrame)->GetCanvasTM(); } -void nsSVGUtils::NotifyChildrenOfSVGChange(nsIFrame* aFrame, uint32_t aFlags) { +void SVGUtils::NotifyChildrenOfSVGChange(nsIFrame* aFrame, uint32_t aFlags) { for (nsIFrame* kid : aFrame->PrincipalChildList()) { ISVGDisplayableFrame* SVGFrame = do_QueryFrame(kid); if (SVGFrame) { SVGFrame->NotifySVGChanged(aFlags); } else { NS_ASSERTION(kid->IsFrameOfType(nsIFrame::eSVG) || - nsSVGUtils::IsInSVGTextSubtree(kid), + SVGUtils::IsInSVGTextSubtree(kid), "SVG frame expected"); // recurse into the children of container frames e.g. , // in case they have child frames with transformation matrices @@ -409,24 +410,24 @@ class SVGPaintCallback : public SVGFilterPaintCallback { } } - svgFrame->PaintSVG(aContext, nsSVGUtils::GetCSSPxToDevPxMatrix(aTarget), + svgFrame->PaintSVG(aContext, SVGUtils::GetCSSPxToDevPxMatrix(aTarget), aImgParams, dirtyRect); } }; -float nsSVGUtils::ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity) { +float SVGUtils::ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity) { float opacity = aFrame->StyleEffects()->mOpacity; if (opacity != 1.0f && - (nsSVGUtils::CanOptimizeOpacity(aFrame) || !aHandleOpacity)) { + (SVGUtils::CanOptimizeOpacity(aFrame) || !aHandleOpacity)) { return 1.0f; } return opacity; } -void nsSVGUtils::DetermineMaskUsage(nsIFrame* aFrame, bool aHandleOpacity, - MaskUsage& aUsage) { +void SVGUtils::DetermineMaskUsage(nsIFrame* aFrame, bool aHandleOpacity, + MaskUsage& aUsage) { using ClipPathType = StyleClipPath::Tag; aUsage.opacity = ComputeOpacity(aFrame, aHandleOpacity); @@ -544,7 +545,7 @@ class MixModeBlender { mSourceCtx->Multiply(aTransform); nsRect overflowRect = mFrame->GetVisualOverflowRectRelativeToSelf(); if (mFrame->IsSVGGeometryFrameOrSubclass() || - nsSVGUtils::IsInSVGTextSubtree(mFrame)) { + SVGUtils::IsInSVGTextSubtree(mFrame)) { // Unlike containers, leaf frames do not include GetPosition() in // GetCanvasTM(). overflowRect = overflowRect + mFrame->GetPosition(); @@ -571,10 +572,10 @@ class MixModeBlender { IntPoint mTargetOffset; }; -void nsSVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext, - const gfxMatrix& aTransform, - imgDrawingParams& aImgParams, - const nsIntRect* aDirtyRect) { +void SVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext, + const gfxMatrix& aTransform, + imgDrawingParams& aImgParams, + const nsIntRect* aDirtyRect) { NS_ASSERTION(!NS_SVGDisplayListPaintingEnabled() || aFrame->HasAnyStateBits(NS_FRAME_IS_NONDISPLAY) || aFrame->PresContext()->Document()->IsSVGGlyphsDocument(), @@ -605,7 +606,7 @@ void nsSVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext, // SVG doesn't maintain bounds/overflow rects. nsRect overflowRect = aFrame->GetVisualOverflowRectRelativeToSelf(); if (aFrame->IsSVGGeometryFrameOrSubclass() || - nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + SVGUtils::IsInSVGTextSubtree(aFrame)) { // Unlike containers, leaf frames do not include GetPosition() in // GetCanvasTM(). overflowRect = overflowRect + aFrame->GetPosition(); @@ -690,7 +691,7 @@ void nsSVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext, // true. That happens when a user gives an unresolvable mask-id, such as // mask:url() // mask:url(#id-which-does-not-exist) - // Since we only uses nsSVGUtils with SVG elements, not like mask on an + // Since we only uses SVGUtils with SVG elements, not like mask on an // HTML element, we should treat an unresolvable mask as no-mask here. if (maskUsage.shouldGenerateMaskLayer && maskFrame) { StyleMaskMode maskMode = @@ -786,7 +787,7 @@ void nsSVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext, // pixels (SVG user space units). But PaintFilteredFrame expects it to be // scaled in such a way that its user space units are device pixels. So we // have to adjust the scale. - gfxMatrix reverseScaleMatrix = nsSVGUtils::GetCSSPxToDevPxMatrix(aFrame); + gfxMatrix reverseScaleMatrix = SVGUtils::GetCSSPxToDevPxMatrix(aFrame); DebugOnly invertible = reverseScaleMatrix.Invert(); target->SetMatrixDouble(reverseScaleMatrix * aTransform * target->CurrentMatrixDouble()); @@ -812,7 +813,7 @@ void nsSVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext, } } -bool nsSVGUtils::HitTestClip(nsIFrame* aFrame, const gfxPoint& aPoint) { +bool SVGUtils::HitTestClip(nsIFrame* aFrame, const gfxPoint& aPoint) { // If the clip-path property references non-existent or invalid clipPath // element(s) we ignore it. SVGClipPathFrame* clipPathFrame; @@ -826,8 +827,8 @@ bool nsSVGUtils::HitTestClip(nsIFrame* aFrame, const gfxPoint& aPoint) { return true; } -nsIFrame* nsSVGUtils::HitTestChildren(SVGDisplayContainerFrame* aFrame, - const gfxPoint& aPoint) { +nsIFrame* SVGUtils::HitTestChildren(SVGDisplayContainerFrame* aFrame, + const gfxPoint& aPoint) { // First we transform aPoint into the coordinate space established by aFrame // for its children (e.g. take account of any 'viewBox' attribute): gfxPoint point = aPoint; @@ -879,17 +880,17 @@ nsIFrame* nsSVGUtils::HitTestChildren(SVGDisplayContainerFrame* aFrame, return result; } -nsRect nsSVGUtils::TransformFrameRectToOuterSVG(const nsRect& aRect, - const gfxMatrix& aMatrix, - nsPresContext* aPresContext) { +nsRect SVGUtils::TransformFrameRectToOuterSVG(const nsRect& aRect, + const gfxMatrix& aMatrix, + nsPresContext* aPresContext) { gfxRect r(aRect.x, aRect.y, aRect.width, aRect.height); r.Scale(1.0 / AppUnitsPerCSSPixel()); return nsLayoutUtils::RoundGfxRectToAppRect( aMatrix.TransformBounds(r), aPresContext->AppUnitsPerDevPixel()); } -IntSize nsSVGUtils::ConvertToSurfaceSize(const gfxSize& aSize, - bool* aResultOverflows) { +IntSize SVGUtils::ConvertToSurfaceSize(const gfxSize& aSize, + bool* aResultOverflows) { IntSize surfaceSize(ClampToInt(ceil(aSize.width)), ClampToInt(ceil(aSize.height))); @@ -907,9 +908,8 @@ IntSize nsSVGUtils::ConvertToSurfaceSize(const gfxSize& aSize, return surfaceSize; } -bool nsSVGUtils::HitTestRect(const gfx::Matrix& aMatrix, float aRX, float aRY, - float aRWidth, float aRHeight, float aX, - float aY) { +bool SVGUtils::HitTestRect(const gfx::Matrix& aMatrix, float aRX, float aRY, + float aRWidth, float aRHeight, float aX, float aY) { gfx::Rect rect(aRX, aRY, aRWidth, aRHeight); if (rect.IsEmpty() || aMatrix.IsSingular()) { return false; @@ -921,8 +921,8 @@ bool nsSVGUtils::HitTestRect(const gfx::Matrix& aMatrix, float aRX, float aRY, p.y <= rect.YMost(); } -gfxRect nsSVGUtils::GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY, - float aWidth, float aHeight) { +gfxRect SVGUtils::GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY, + float aWidth, float aHeight) { const nsStyleDisplay* disp = aFrame->StyleDisplay(); const nsStyleEffects* effects = aFrame->StyleEffects(); @@ -956,8 +956,8 @@ gfxRect nsSVGUtils::GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY, return clipRect; } -void nsSVGUtils::SetClipRect(gfxContext* aContext, const gfxMatrix& aCTM, - const gfxRect& aRect) { +void SVGUtils::SetClipRect(gfxContext* aContext, const gfxMatrix& aCTM, + const gfxRect& aRect) { if (aCTM.IsSingular()) { return; } @@ -967,19 +967,19 @@ void nsSVGUtils::SetClipRect(gfxContext* aContext, const gfxMatrix& aCTM, aContext->Clip(aRect); } -gfxRect nsSVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, - const gfxMatrix* aToBoundsSpace) { +gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, + const gfxMatrix* aToBoundsSpace) { if (aFrame->GetContent()->IsText()) { aFrame = aFrame->GetParent(); } - if (nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + if (SVGUtils::IsInSVGTextSubtree(aFrame)) { // It is possible to apply a gradient, pattern, clipping path, mask or // filter to text. When one of these facilities is applied to text // the bounding box is the entire text element in all // cases. nsIFrame* ancestor = GetFirstNonAAncestorFrame(aFrame); - if (ancestor && nsSVGUtils::IsInSVGTextSubtree(ancestor)) { + if (ancestor && SVGUtils::IsInSVGTextSubtree(ancestor)) { while (!ancestor->IsSVGTextFrame()) { ancestor = ancestor->GetParent(); } @@ -1001,7 +1001,7 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, // An HTML element or an SVG outer frame. MOZ_ASSERT(!hasSVGLayout); bool onlyCurrentFrame = aFlags & eIncludeOnlyCurrentFrameForNonSVGElement; - return nsSVGIntegrationUtils::GetSVGBBoxForNonSVGFrame( + return SVGIntegrationUtils::GetSVGBBoxForNonSVGFrame( aFrame, /* aUnionContinuations = */ !onlyCurrentFrame); } @@ -1037,12 +1037,12 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, } if (aFrame->IsSVGForeignObjectFrame() || - aFlags & nsSVGUtils::eUseUserSpaceOfUseElement) { + aFlags & SVGUtils::eUseUserSpaceOfUseElement) { // The spec says getBBox "Returns the tight bounding box in *current user // space*". So we should really be doing this for all elements, but that // needs investigation to check that we won't break too much content. // NOTE: When changing this to apply to other frame types, make sure to - // also update nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset. + // also update SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset. MOZ_ASSERT(content->IsSVGElement(), "bad cast"); SVGElement* element = static_cast(content); matrix = element->PrependLocalTransformsTo(matrix, eChildToUserSpace); @@ -1050,12 +1050,12 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, gfxRect bbox = svg->GetBBoxContribution(ToMatrix(matrix), aFlags).ToThebesRect(); // Account for 'clipped'. - if (aFlags & nsSVGUtils::eBBoxIncludeClipped) { + if (aFlags & SVGUtils::eBBoxIncludeClipped) { gfxRect clipRect(0, 0, 0, 0); float x, y, width, height; gfxMatrix tm; gfxRect fillBBox = - svg->GetBBoxContribution(ToMatrix(tm), nsSVGUtils::eBBoxIncludeFill) + svg->GetBBoxContribution(ToMatrix(tm), SVGUtils::eBBoxIncludeFill) .ToThebesRect(); x = fillBBox.x; y = fillBBox.y; @@ -1063,7 +1063,7 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, height = fillBBox.height; bool hasClip = aFrame->StyleDisplay()->IsScrollableOverflow(); if (hasClip) { - clipRect = nsSVGUtils::GetClipRectForFrame(aFrame, x, y, width, height); + clipRect = SVGUtils::GetClipRectForFrame(aFrame, x, y, width, height); if (aFrame->IsSVGForeignObjectFrame() || aFrame->IsSVGUseFrame()) { clipRect = matrix.TransformBounds(clipRect); } @@ -1084,7 +1084,7 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, } matrix = - nsSVGUtils::GetTransformMatrixInUserSpace(clipPathFrame) * matrix; + SVGUtils::GetTransformMatrixInUserSpace(clipPathFrame) * matrix; bbox = clipPathFrame->GetBBoxForClipPathFrame(bbox, matrix, aFlags) .ToThebesRect(); @@ -1111,7 +1111,7 @@ gfxRect nsSVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags, return bbox; } -gfxPoint nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame* aFrame) { +gfxPoint SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame* aFrame) { if (!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { // The user space for non-SVG frames is defined as the bounding box of the // frame's border-box rects over all continuations. @@ -1120,13 +1120,13 @@ gfxPoint nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame* aFrame) { // Leaf frames apply their own offset inside their user space. if (aFrame->IsSVGGeometryFrameOrSubclass() || - nsSVGUtils::IsInSVGTextSubtree(aFrame)) { + SVGUtils::IsInSVGTextSubtree(aFrame)) { return nsLayoutUtils::RectToGfxRect(aFrame->GetRect(), AppUnitsPerCSSPixel()) .TopLeft(); } - // For foreignObject frames, nsSVGUtils::GetBBox applies their local + // For foreignObject frames, SVGUtils::GetBBox applies their local // transform, so we need to do the same here. if (aFrame->IsSVGForeignObjectFrame()) { gfxMatrix transform = @@ -1142,16 +1142,16 @@ gfxPoint nsSVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame* aFrame) { static gfxRect GetBoundingBoxRelativeRect(const SVGAnimatedLength* aXYWH, const gfxRect& aBBox) { - return gfxRect(aBBox.x + nsSVGUtils::ObjectSpace(aBBox, &aXYWH[0]), - aBBox.y + nsSVGUtils::ObjectSpace(aBBox, &aXYWH[1]), - nsSVGUtils::ObjectSpace(aBBox, &aXYWH[2]), - nsSVGUtils::ObjectSpace(aBBox, &aXYWH[3])); + return gfxRect(aBBox.x + SVGUtils::ObjectSpace(aBBox, &aXYWH[0]), + aBBox.y + SVGUtils::ObjectSpace(aBBox, &aXYWH[1]), + SVGUtils::ObjectSpace(aBBox, &aXYWH[2]), + SVGUtils::ObjectSpace(aBBox, &aXYWH[3])); } -gfxRect nsSVGUtils::GetRelativeRect(uint16_t aUnits, - const SVGAnimatedLength* aXYWH, - const gfxRect& aBBox, - const UserSpaceMetrics& aMetrics) { +gfxRect SVGUtils::GetRelativeRect(uint16_t aUnits, + const SVGAnimatedLength* aXYWH, + const gfxRect& aBBox, + const UserSpaceMetrics& aMetrics) { if (aUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { return GetBoundingBoxRelativeRect(aXYWH, aBBox); } @@ -1160,9 +1160,9 @@ gfxRect nsSVGUtils::GetRelativeRect(uint16_t aUnits, UserSpace(aMetrics, &aXYWH[3])); } -gfxRect nsSVGUtils::GetRelativeRect(uint16_t aUnits, - const SVGAnimatedLength* aXYWH, - const gfxRect& aBBox, nsIFrame* aFrame) { +gfxRect SVGUtils::GetRelativeRect(uint16_t aUnits, + const SVGAnimatedLength* aXYWH, + const gfxRect& aBBox, nsIFrame* aFrame) { if (aUnits == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { return GetBoundingBoxRelativeRect(aXYWH, aBBox); } @@ -1175,7 +1175,7 @@ gfxRect nsSVGUtils::GetRelativeRect(uint16_t aUnits, NonSVGFrameUserSpaceMetrics(aFrame)); } -bool nsSVGUtils::CanOptimizeOpacity(nsIFrame* aFrame) { +bool SVGUtils::CanOptimizeOpacity(nsIFrame* aFrame) { if (!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) { return false; } @@ -1204,9 +1204,9 @@ bool nsSVGUtils::CanOptimizeOpacity(nsIFrame* aFrame) { return !style->HasFill() || !HasStroke(aFrame); } -gfxMatrix nsSVGUtils::AdjustMatrixForUnits(const gfxMatrix& aMatrix, - SVGAnimatedEnumeration* aUnits, - nsIFrame* aFrame, uint32_t aFlags) { +gfxMatrix SVGUtils::AdjustMatrixForUnits(const gfxMatrix& aMatrix, + SVGAnimatedEnumeration* aUnits, + nsIFrame* aFrame, uint32_t aFlags) { if (aFrame && aUnits->GetAnimValue() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) { gfxRect bbox = GetBBox(aFrame, aFlags); gfxMatrix tm = aMatrix; @@ -1217,7 +1217,7 @@ gfxMatrix nsSVGUtils::AdjustMatrixForUnits(const gfxMatrix& aMatrix, return aMatrix; } -nsIFrame* nsSVGUtils::GetFirstNonAAncestorFrame(nsIFrame* aStartFrame) { +nsIFrame* SVGUtils::GetFirstNonAAncestorFrame(nsIFrame* aStartFrame) { for (nsIFrame* ancestorFrame = aStartFrame; ancestorFrame; ancestorFrame = ancestorFrame->GetParent()) { if (!ancestorFrame->IsSVGAFrame()) { @@ -1227,8 +1227,8 @@ nsIFrame* nsSVGUtils::GetFirstNonAAncestorFrame(nsIFrame* aStartFrame) { return nullptr; } -bool nsSVGUtils::GetNonScalingStrokeTransform(nsIFrame* aFrame, - gfxMatrix* aUserToOuterSVG) { +bool SVGUtils::GetNonScalingStrokeTransform(nsIFrame* aFrame, + gfxMatrix* aUserToOuterSVG) { if (aFrame->GetContent()->IsText()) { aFrame = aFrame->GetParent(); } @@ -1251,12 +1251,12 @@ static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, double aStyleExpansionFactor, const gfxMatrix& aMatrix) { double style_expansion = - aStyleExpansionFactor * nsSVGUtils::GetStrokeWidth(aFrame); + aStyleExpansionFactor * SVGUtils::GetStrokeWidth(aFrame); gfxMatrix matrix = aMatrix; gfxMatrix outerSVGToUser; - if (nsSVGUtils::GetNonScalingStrokeTransform(aFrame, &outerSVGToUser)) { + if (SVGUtils::GetNonScalingStrokeTransform(aFrame, &outerSVGToUser)) { outerSVGToUser.Invert(); matrix.PreMultiply(outerSVGToUser); } @@ -1270,18 +1270,19 @@ static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, } /*static*/ -gfxRect nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, - nsTextFrame* aFrame, - const gfxMatrix& aMatrix) { - NS_ASSERTION(nsSVGUtils::IsInSVGTextSubtree(aFrame), +gfxRect SVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, + nsTextFrame* aFrame, + const gfxMatrix& aMatrix) { + NS_ASSERTION(SVGUtils::IsInSVGTextSubtree(aFrame), "expected an nsTextFrame for SVG text"); - return ::PathExtentsToMaxStrokeExtents(aPathExtents, aFrame, 0.5, aMatrix); + return mozilla::PathExtentsToMaxStrokeExtents(aPathExtents, aFrame, 0.5, + aMatrix); } /*static*/ -gfxRect nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, - SVGGeometryFrame* aFrame, - const gfxMatrix& aMatrix) { +gfxRect SVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, + SVGGeometryFrame* aFrame, + const gfxMatrix& aMatrix) { bool strokeMayHaveCorners = !SVGContentUtils::ShapeTypeHasNoCorners(aFrame->GetContent()); @@ -1306,14 +1307,14 @@ gfxRect nsSVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents, } } - return ::PathExtentsToMaxStrokeExtents(aPathExtents, aFrame, - styleExpansionFactor, aMatrix); + return mozilla::PathExtentsToMaxStrokeExtents(aPathExtents, aFrame, + styleExpansionFactor, aMatrix); } // ---------------------------------------------------------------------- /* static */ -nscolor nsSVGUtils::GetFallbackOrPaintColor( +nscolor SVGUtils::GetFallbackOrPaintColor( const ComputedStyle& aStyle, StyleSVGPaint nsStyleSVG::*aFillOrStroke) { const auto& paint = aStyle.StyleSVG()->*aFillOrStroke; nscolor color; @@ -1353,10 +1354,10 @@ nscolor nsSVGUtils::GetFallbackOrPaintColor( } /* static */ -void nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame, gfxContext* aContext, - GeneralPattern* aOutPattern, - imgDrawingParams& aImgParams, - SVGContextPaint* aContextPaint) { +void SVGUtils::MakeFillPatternFor(nsIFrame* aFrame, gfxContext* aContext, + GeneralPattern* aOutPattern, + imgDrawingParams& aImgParams, + SVGContextPaint* aContextPaint) { const nsStyleSVG* style = aFrame->StyleSVG(); if (style->mFill.kind.IsNone()) { return; @@ -1365,7 +1366,7 @@ void nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame, gfxContext* aContext, const float opacity = aFrame->StyleEffects()->mOpacity; float fillOpacity = GetOpacity(style->mFillOpacity, aContextPaint); - if (opacity < 1.0f && nsSVGUtils::CanOptimizeOpacity(aFrame)) { + if (opacity < 1.0f && SVGUtils::CanOptimizeOpacity(aFrame)) { // Combine the group opacity into the fill opacity (we will have skipped // creating an offscreen surface to apply the group opacity). fillOpacity *= opacity; @@ -1420,10 +1421,10 @@ void nsSVGUtils::MakeFillPatternFor(nsIFrame* aFrame, gfxContext* aContext, } /* static */ -void nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame, gfxContext* aContext, - GeneralPattern* aOutPattern, - imgDrawingParams& aImgParams, - SVGContextPaint* aContextPaint) { +void SVGUtils::MakeStrokePatternFor(nsIFrame* aFrame, gfxContext* aContext, + GeneralPattern* aOutPattern, + imgDrawingParams& aImgParams, + SVGContextPaint* aContextPaint) { const nsStyleSVG* style = aFrame->StyleSVG(); if (style->mStroke.kind.IsNone()) { return; @@ -1432,7 +1433,7 @@ void nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame, gfxContext* aContext, const float opacity = aFrame->StyleEffects()->mOpacity; float strokeOpacity = GetOpacity(style->mStrokeOpacity, aContextPaint); - if (opacity < 1.0f && nsSVGUtils::CanOptimizeOpacity(aFrame)) { + if (opacity < 1.0f && SVGUtils::CanOptimizeOpacity(aFrame)) { // Combine the group opacity into the stroke opacity (we will have skipped // creating an offscreen surface to apply the group opacity). strokeOpacity *= opacity; @@ -1487,8 +1488,8 @@ void nsSVGUtils::MakeStrokePatternFor(nsIFrame* aFrame, gfxContext* aContext, } /* static */ -float nsSVGUtils::GetOpacity(const StyleSVGOpacity& aOpacity, - SVGContextPaint* aContextPaint) { +float SVGUtils::GetOpacity(const StyleSVGOpacity& aOpacity, + SVGContextPaint* aContextPaint) { float opacity = 1.0f; switch (aOpacity.tag) { case StyleSVGOpacity::Tag::Opacity: @@ -1507,13 +1508,13 @@ float nsSVGUtils::GetOpacity(const StyleSVGOpacity& aOpacity, return opacity; } -bool nsSVGUtils::HasStroke(nsIFrame* aFrame, SVGContextPaint* aContextPaint) { +bool SVGUtils::HasStroke(nsIFrame* aFrame, SVGContextPaint* aContextPaint) { const nsStyleSVG* style = aFrame->StyleSVG(); return style->HasStroke() && GetStrokeWidth(aFrame, aContextPaint) > 0; } -float nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, - SVGContextPaint* aContextPaint) { +float SVGUtils::GetStrokeWidth(nsIFrame* aFrame, + SVGContextPaint* aContextPaint) { const nsStyleSVG* style = aFrame->StyleSVG(); if (style->mStrokeWidth.IsContextValue()) { return aContextPaint ? aContextPaint->GetStrokeWidth() : 1.0f; @@ -1529,8 +1530,8 @@ float nsSVGUtils::GetStrokeWidth(nsIFrame* aFrame, ctx, style->mStrokeWidth.AsLengthPercentage()); } -void nsSVGUtils::SetupStrokeGeometry(nsIFrame* aFrame, gfxContext* aContext, - SVGContextPaint* aContextPaint) { +void SVGUtils::SetupStrokeGeometry(nsIFrame* aFrame, gfxContext* aContext, + SVGContextPaint* aContextPaint) { SVGContentUtils::AutoStrokeOptions strokeOptions; SVGContentUtils::GetStrokeOptions( &strokeOptions, static_cast(aFrame->GetContent()), @@ -1548,7 +1549,7 @@ void nsSVGUtils::SetupStrokeGeometry(nsIFrame* aFrame, gfxContext* aContext, strokeOptions.mDashOffset); } -uint16_t nsSVGUtils::GetGeometryHitTestFlags(nsIFrame* aFrame) { +uint16_t SVGUtils::GetGeometryHitTestFlags(nsIFrame* aFrame) { uint16_t flags = 0; switch (aFrame->StyleUI()->mPointerEvents) { @@ -1607,7 +1608,7 @@ uint16_t nsSVGUtils::GetGeometryHitTestFlags(nsIFrame* aFrame) { return flags; } -void nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext) { +void SVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext) { nsIFrame* frame = aElement->GetPrimaryFrame(); ISVGDisplayableFrame* svgFrame = do_QueryFrame(frame); if (!svgFrame) { @@ -1617,7 +1618,7 @@ void nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext) { if (frame->GetContent()->IsSVGElement()) { // PaintSVG() expects the passed transform to be the transform to its own // SVG user space, so we need to account for any 'transform' attribute: - m = nsSVGUtils::GetTransformMatrixInUserSpace(frame); + m = SVGUtils::GetTransformMatrixInUserSpace(frame); } // SVG-in-OpenType is not allowed to paint external resources, so we can @@ -1626,9 +1627,9 @@ void nsSVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext) { svgFrame->PaintSVG(*aContext, m, dummy); } -bool nsSVGUtils::GetSVGGlyphExtents(Element* aElement, - const gfxMatrix& aSVGToAppSpace, - gfxRect* aResult) { +bool SVGUtils::GetSVGGlyphExtents(Element* aElement, + const gfxMatrix& aSVGToAppSpace, + gfxRect* aResult) { nsIFrame* frame = aElement->GetPrimaryFrame(); ISVGDisplayableFrame* svgFrame = do_QueryFrame(frame); if (!svgFrame) { @@ -1645,24 +1646,24 @@ bool nsSVGUtils::GetSVGGlyphExtents(Element* aElement, *aResult = svgFrame ->GetBBoxContribution(gfx::ToMatrix(transform), - nsSVGUtils::eBBoxIncludeFill | - nsSVGUtils::eBBoxIncludeFillGeometry | - nsSVGUtils::eBBoxIncludeStroke | - nsSVGUtils::eBBoxIncludeStrokeGeometry | - nsSVGUtils::eBBoxIncludeMarkers) + SVGUtils::eBBoxIncludeFill | + SVGUtils::eBBoxIncludeFillGeometry | + SVGUtils::eBBoxIncludeStroke | + SVGUtils::eBBoxIncludeStrokeGeometry | + SVGUtils::eBBoxIncludeMarkers) .ToThebesRect(); return true; } -nsRect nsSVGUtils::ToCanvasBounds(const gfxRect& aUserspaceRect, - const gfxMatrix& aToCanvas, - const nsPresContext* presContext) { +nsRect SVGUtils::ToCanvasBounds(const gfxRect& aUserspaceRect, + const gfxMatrix& aToCanvas, + const nsPresContext* presContext) { return nsLayoutUtils::RoundGfxRectToAppRect( aToCanvas.TransformBounds(aUserspaceRect), presContext->AppUnitsPerDevPixel()); } -gfxMatrix nsSVGUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame) { +gfxMatrix SVGUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame) { int32_t appUnitsPerDevPixel = aNonSVGFrame->PresContext()->AppUnitsPerDevPixel(); float devPxPerCSSPx = @@ -1671,7 +1672,7 @@ gfxMatrix nsSVGUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame) { return gfxMatrix(devPxPerCSSPx, 0.0, 0.0, devPxPerCSSPx, 0.0, 0.0); } -gfxMatrix nsSVGUtils::GetTransformMatrixInUserSpace(const nsIFrame* aFrame) { +gfxMatrix SVGUtils::GetTransformMatrixInUserSpace(const nsIFrame* aFrame) { // We check element instead of aFrame directly because SVG element // may have non-SVG frame, for example. MOZ_ASSERT(aFrame->GetContent() && aFrame->GetContent()->IsSVGElement(), @@ -1713,3 +1714,5 @@ gfxMatrix nsSVGUtils::GetTransformMatrixInUserSpace(const nsIFrame* aFrame) { return ThebesMatrix(mm); } + +} // namespace mozilla diff --git a/layout/svg/nsSVGUtils.h b/layout/svg/SVGUtils.h similarity index 90% rename from layout/svg/nsSVGUtils.h rename to layout/svg/SVGUtils.h index 810848d2fcb2..de87fcf46453 100644 --- a/layout/svg/nsSVGUtils.h +++ b/layout/svg/SVGUtils.h @@ -72,12 +72,14 @@ bool NS_SVGDisplayListHitTestingEnabled(); bool NS_SVGDisplayListPaintingEnabled(); bool NS_SVGNewGetBBoxEnabled(); +namespace mozilla { + /** * Sometimes we need to distinguish between an empty box and a box * that contains an element that has no size e.g. a point at the origin. */ -class SVGBBox { - typedef mozilla::gfx::Rect Rect; +class SVGBBox final { + typedef gfx::Rect Rect; public: SVGBBox() : mIsEmpty(true) {} @@ -126,8 +128,8 @@ class SVGBBox { // GRRR WINDOWS HATE HATE HATE #undef CLIP_MASK -class MOZ_RAII SVGAutoRenderState { - typedef mozilla::gfx::DrawTarget DrawTarget; +class MOZ_RAII SVGAutoRenderState final { + typedef gfx::DrawTarget DrawTarget; public: explicit SVGAutoRenderState( @@ -150,22 +152,16 @@ class MOZ_RAII SVGAutoRenderState { * If a method is used by content and depends only on other content methods * it should go in SVGContentUtils instead. */ -class nsSVGUtils { +class SVGUtils final { public: - typedef mozilla::dom::Element Element; - typedef mozilla::dom::SVGElement SVGElement; - typedef mozilla::gfx::AntialiasMode AntialiasMode; - typedef mozilla::gfx::DrawTarget DrawTarget; - typedef mozilla::gfx::FillRule FillRule; - typedef mozilla::gfx::GeneralPattern GeneralPattern; - typedef mozilla::gfx::Size Size; - typedef mozilla::SVGAnimatedLength SVGAnimatedLength; - typedef mozilla::SVGContextPaint SVGContextPaint; - typedef mozilla::SVGContextPaintImpl SVGContextPaintImpl; - typedef mozilla::SVGDisplayContainerFrame SVGDisplayContainerFrame; - typedef mozilla::SVGGeometryFrame SVGGeometryFrame; - typedef mozilla::SVGOuterSVGFrame SVGOuterSVGFrame; - typedef mozilla::image::imgDrawingParams imgDrawingParams; + typedef dom::Element Element; + typedef dom::SVGElement SVGElement; + typedef gfx::AntialiasMode AntialiasMode; + typedef gfx::DrawTarget DrawTarget; + typedef gfx::FillRule FillRule; + typedef gfx::GeneralPattern GeneralPattern; + typedef gfx::Size Size; + typedef image::imgDrawingParams imgDrawingParams; NS_DECLARE_FRAME_PROPERTY_DELETABLE(ObjectBoundingBoxProperty, gfxRect) @@ -236,7 +232,7 @@ class nsSVGUtils { const SVGAnimatedLength* aLength); static float UserSpace(nsIFrame* aNonSVGContext, const SVGAnimatedLength* aLength); - static float UserSpace(const mozilla::dom::UserSpaceMetrics& aMetrics, + static float UserSpace(const dom::UserSpaceMetrics& aMetrics, const SVGAnimatedLength* aLength); /* Find the outermost SVG frame of the passed frame */ @@ -295,15 +291,14 @@ class nsSVGUtils { * @param aResultOverflows true if the desired surface size is too big * @return the surface size to use */ - static mozilla::gfx::IntSize ConvertToSurfaceSize(const gfxSize& aSize, - bool* aResultOverflows); + static gfx::IntSize ConvertToSurfaceSize(const gfxSize& aSize, + bool* aResultOverflows); /* * Hit test a given rectangle/matrix. */ - static bool HitTestRect(const mozilla::gfx::Matrix& aMatrix, float aRX, - float aRY, float aRWidth, float aRHeight, float aX, - float aY); + static bool HitTestRect(const gfx::Matrix& aMatrix, float aRX, float aRY, + float aRWidth, float aRHeight, float aX, float aY); /** * Get the clip rect for the given frame, taking into account the CSS 'clip' @@ -336,7 +331,7 @@ class nsSVGUtils { * @param aFlags One or more of the BBoxFlags values defined below. */ static gfxMatrix AdjustMatrixForUnits(const gfxMatrix& aMatrix, - mozilla::SVGAnimatedEnumeration* aUnits, + SVGAnimatedEnumeration* aUnits, nsIFrame* aFrame, uint32_t aFlags); enum BBoxFlags { @@ -394,7 +389,7 @@ class nsSVGUtils { /* * "User space" is the space that the frame's BBox (as calculated by - * nsSVGUtils::GetBBox) is in. "Frame space" is the space that has its origin + * SVGUtils::GetBBox) is in. "Frame space" is the space that has its origin * at the top left of the union of the frame's border-box rects over all * continuations. * This function returns the offset one needs to add to something in frame @@ -418,9 +413,10 @@ class nsSVGUtils { const SVGAnimatedLength* aXYWH, const gfxRect& aBBox, nsIFrame* aFrame); - static gfxRect GetRelativeRect( - uint16_t aUnits, const SVGAnimatedLength* aXYWH, const gfxRect& aBBox, - const mozilla::dom::UserSpaceMetrics& aMetrics); + static gfxRect GetRelativeRect(uint16_t aUnits, + const SVGAnimatedLength* aXYWH, + const gfxRect& aBBox, + const dom::UserSpaceMetrics& aMetrics); /** * Find the first frame, starting with aStartFrame and going up its @@ -474,8 +470,7 @@ class nsSVGUtils { } static nscolor GetFallbackOrPaintColor( - const mozilla::ComputedStyle&, - mozilla::StyleSVGPaint nsStyleSVG::*aFillOrStroke); + const ComputedStyle&, StyleSVGPaint nsStyleSVG::*aFillOrStroke); static void MakeFillPatternFor(nsIFrame* aFrame, gfxContext* aContext, GeneralPattern* aOutPattern, @@ -487,7 +482,7 @@ class nsSVGUtils { imgDrawingParams& aImgParams, SVGContextPaint* aContextPaint = nullptr); - static float GetOpacity(const mozilla::StyleSVGOpacity&, SVGContextPaint*); + static float GetOpacity(const StyleSVGOpacity&, SVGContextPaint*); /* * @return false if there is no stroke @@ -512,15 +507,13 @@ class nsSVGUtils { */ static uint16_t GetGeometryHitTestFlags(nsIFrame* aFrame); - static FillRule ToFillRule(mozilla::StyleFillRule aFillRule) { - return aFillRule == mozilla::StyleFillRule::Evenodd - ? FillRule::FILL_EVEN_ODD - : FillRule::FILL_WINDING; + static FillRule ToFillRule(StyleFillRule aFillRule) { + return aFillRule == StyleFillRule::Evenodd ? FillRule::FILL_EVEN_ODD + : FillRule::FILL_WINDING; } - static AntialiasMode ToAntialiasMode( - mozilla::StyleTextRendering aTextRendering) { - return aTextRendering == mozilla::StyleTextRendering::Optimizespeed + static AntialiasMode ToAntialiasMode(StyleTextRendering aTextRendering) { + return aTextRendering == StyleTextRendering::Optimizespeed ? AntialiasMode::NONE : AntialiasMode::SUBPIXEL; } @@ -603,4 +596,6 @@ class nsSVGUtils { static gfxMatrix GetTransformMatrixInUserSpace(const nsIFrame* aFrame); }; +} // namespace mozilla + #endif diff --git a/layout/svg/SVGViewFrame.cpp b/layout/svg/SVGViewFrame.cpp index a65f97e927af..8639dc0289d7 100644 --- a/layout/svg/SVGViewFrame.cpp +++ b/layout/svg/SVGViewFrame.cpp @@ -7,6 +7,7 @@ // Keep in (case-insensitive) order: #include "mozilla/PresShell.h" #include "mozilla/SVGOuterSVGFrame.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGSVGElement.h" #include "mozilla/dom/SVGViewElement.h" #include "nsIFrame.h" @@ -95,7 +96,7 @@ nsresult SVGViewFrame::AttributeChanged(int32_t aNameSpaceID, if (aNameSpaceID == kNameSpaceID_None && (aAttribute == nsGkAtoms::preserveAspectRatio || aAttribute == nsGkAtoms::viewBox)) { - SVGOuterSVGFrame* outerSVGFrame = nsSVGUtils::GetOuterSVGFrame(this); + SVGOuterSVGFrame* outerSVGFrame = SVGUtils::GetOuterSVGFrame(this); NS_ASSERTION(outerSVGFrame->GetContent()->IsSVGElement(nsGkAtoms::svg), "Expecting an element"); diff --git a/layout/svg/SVGViewportFrame.cpp b/layout/svg/SVGViewportFrame.cpp index a4cfd9c14d85..d86ecf22bb8d 100644 --- a/layout/svg/SVGViewportFrame.cpp +++ b/layout/svg/SVGViewportFrame.cpp @@ -13,7 +13,7 @@ #include "nsIFrame.h" #include "mozilla/ISVGDisplayableFrame.h" #include "mozilla/SVGContainerFrame.h" -#include "nsSVGIntegrationUtils.h" +#include "mozilla/SVGUtils.h" #include "mozilla/dom/SVGViewportElement.h" using namespace mozilla::dom; @@ -46,9 +46,8 @@ void SVGViewportFrame::PaintSVG(gfxContext& aContext, } autoSR.SetContext(&aContext); - gfxRect clipRect = - nsSVGUtils::GetClipRectForFrame(this, x, y, width, height); - nsSVGUtils::SetClipRect(&aContext, aTransform, clipRect); + gfxRect clipRect = SVGUtils::GetClipRectForFrame(this, x, y, width, height); + SVGUtils::SetClipRect(&aContext, aTransform, clipRect); } SVGDisplayContainerFrame::PaintSVG(aContext, aTransform, aImgParams, @@ -94,7 +93,7 @@ void SVGViewportFrame::NotifySVGChanged(uint32_t aFlags) { // changed ancestor will have invalidated its entire area, which includes // our area. // For perf reasons we call this before calling NotifySVGChanged() below. - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } // Coordinate context changes affect mCanvasTM if we have a @@ -130,7 +129,7 @@ SVGBBox SVGViewportFrame::GetBBoxContribution(const Matrix& aToBBoxUserspace, SVGBBox bbox; - if (aFlags & nsSVGUtils::eForGetClientRects) { + if (aFlags & SVGUtils::eForGetClientRects) { // XXXjwatt For consistency with the old code this code includes the // viewport we establish in the result, but only includes the bounds of our // descendants if they are not clipped to that viewport. However, this is @@ -171,20 +170,20 @@ nsresult SVGViewportFrame::AttributeChanged(int32_t aNameSpaceID, nsLayoutUtils::PostRestyleEvent( mContent->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); if (content->HasViewBoxOrSyntheticViewBox()) { // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nullptr; content->ChildrenOnlyTransformChanged(); - nsSVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED); + SVGUtils::NotifyChildrenOfSVGChange(this, TRANSFORM_CHANGED); } else { uint32_t flags = COORD_CONTEXT_CHANGED; if (mCanvasTM && mCanvasTM->IsSingular()) { mCanvasTM = nullptr; flags |= TRANSFORM_CHANGED; } - nsSVGUtils::NotifyChildrenOfSVGChange(this, flags); + SVGUtils::NotifyChildrenOfSVGChange(this, flags); } } else if (aAttribute == nsGkAtoms::transform || @@ -194,7 +193,7 @@ nsresult SVGViewportFrame::AttributeChanged(int32_t aNameSpaceID, // make sure our cached transform matrix gets (lazily) updated mCanvasTM = nullptr; - nsSVGUtils::NotifyChildrenOfSVGChange( + SVGUtils::NotifyChildrenOfSVGChange( this, aAttribute == nsGkAtoms::viewBox ? TRANSFORM_CHANGED | COORD_CONTEXT_CHANGED : TRANSFORM_CHANGED); @@ -208,7 +207,7 @@ nsresult SVGViewportFrame::AttributeChanged(int32_t aNameSpaceID, nsLayoutUtils::PostRestyleEvent( mContent->AsElement(), RestyleHint{0}, nsChangeHint_InvalidateRenderingObservers); - nsSVGUtils::ScheduleReflowSVG(this); + SVGUtils::ScheduleReflowSVG(this); } else if (aAttribute == nsGkAtoms::viewBox || (aAttribute == nsGkAtoms::preserveAspectRatio && content->HasViewBoxOrSyntheticViewBox())) { diff --git a/layout/svg/moz.build b/layout/svg/moz.build index e2cff21af5d8..b30a54ba3d57 100644 --- a/layout/svg/moz.build +++ b/layout/svg/moz.build @@ -15,11 +15,6 @@ if CONFIG['ENABLE_TESTS']: 'tests/chrome.ini', ] -EXPORTS += [ - 'nsSVGIntegrationUtils.h', - 'nsSVGUtils.h', -] - EXPORTS.mozilla += [ 'CSSClipPathInstance.h', 'FilterInstance.h', @@ -32,19 +27,19 @@ EXPORTS.mozilla += [ 'SVGGeometryFrame.h', 'SVGImageContext.h', 'SVGImageFrame.h', + 'SVGIntegrationUtils.h', 'SVGMaskFrame.h', 'SVGObserverUtils.h', 'SVGOuterSVGFrame.h', 'SVGTextFrame.h', - 'SVGUseFrame.h' + 'SVGUseFrame.h', + 'SVGUtils.h' ] UNIFIED_SOURCES += [ 'CSSClipPathInstance.cpp', 'CSSFilterInstance.cpp', 'FilterInstance.cpp', - 'nsSVGIntegrationUtils.cpp', - 'nsSVGUtils.cpp', 'SVGAFrame.cpp', 'SVGClipPathFrame.cpp', 'SVGContainerFrame.cpp', @@ -63,6 +58,7 @@ UNIFIED_SOURCES += [ 'SVGImageContext.cpp', 'SVGImageFrame.cpp', 'SVGInnerSVGFrame.cpp', + 'SVGIntegrationUtils.cpp', 'SVGMarkerFrame.cpp', 'SVGMaskFrame.cpp', 'SVGObserverUtils.cpp', @@ -73,6 +69,7 @@ UNIFIED_SOURCES += [ 'SVGSymbolFrame.cpp', 'SVGTextFrame.cpp', 'SVGUseFrame.cpp', + 'SVGUtils.cpp', 'SVGViewFrame.cpp', 'SVGViewportFrame.cpp', ] diff --git a/layout/xul/nsSliderFrame.cpp b/layout/xul/nsSliderFrame.cpp index bb3c4e2d0b21..438634288a09 100644 --- a/layout/xul/nsSliderFrame.cpp +++ b/layout/xul/nsSliderFrame.cpp @@ -32,13 +32,13 @@ #include "nsContentUtils.h" #include "nsLayoutUtils.h" #include "nsDisplayList.h" -#include "nsRefreshDriver.h" // for nsAPostRefreshObserver -#include "nsSVGIntegrationUtils.h" +#include "nsRefreshDriver.h" // for nsAPostRefreshObserver #include "mozilla/Assertions.h" // for MOZ_ASSERT #include "mozilla/LookAndFeel.h" #include "mozilla/MouseEvents.h" #include "mozilla/Preferences.h" #include "mozilla/PresShell.h" +#include "mozilla/SVGIntegrationUtils.h" #include "mozilla/Telemetry.h" #include "mozilla/dom/Event.h" #include "mozilla/layers/APZCCallbackHelper.h" @@ -931,8 +931,7 @@ static bool ScrollFrameWillBuildScrollInfoLayer(nsIFrame* aScrollFrame) { */ nsIFrame* current = aScrollFrame; while (current) { - if (nsSVGIntegrationUtils::UsesSVGEffectsNotSupportedInCompositor( - current)) { + if (SVGIntegrationUtils::UsesSVGEffectsNotSupportedInCompositor(current)) { return true; } current = nsLayoutUtils::GetParentOrPlaceholderForCrossDoc(current);