Bug 1817413 - add const to various method signatures or allow them to be given const pointers r=emilio

Differential Revision: https://phabricator.services.mozilla.com/D170188
This commit is contained in:
Robert Longson 2023-02-17 12:47:27 +00:00
Родитель 690fadc913
Коммит 824c238c5e
6 изменённых файлов: 67 добавлений и 62 удалений

Просмотреть файл

@ -149,7 +149,7 @@ enum DashState {
static DashState GetStrokeDashData(
SVGContentUtils::AutoStrokeOptions* aStrokeOptions, SVGElement* aElement,
const nsStyleSVG* aStyleSVG, SVGContextPaint* aContextPaint) {
const nsStyleSVG* aStyleSVG, const SVGContextPaint* aContextPaint) {
size_t dashArrayLength;
Float totalLengthOfDashes = 0.0, totalLengthOfGaps = 0.0;
Float pathScale = 1.0;
@ -250,7 +250,7 @@ static DashState GetStrokeDashData(
void SVGContentUtils::GetStrokeOptions(AutoStrokeOptions* aStrokeOptions,
SVGElement* aElement,
const ComputedStyle* aComputedStyle,
SVGContextPaint* aContextPaint,
const SVGContextPaint* aContextPaint,
StrokeOptionFlags aFlags) {
auto doCompute = [&](const ComputedStyle* computedStyle) {
const nsStyleSVG* styleSVG = computedStyle->StyleSVG();
@ -317,9 +317,9 @@ void SVGContentUtils::GetStrokeOptions(AutoStrokeOptions* aStrokeOptions,
}
}
Float SVGContentUtils::GetStrokeWidth(SVGElement* aElement,
Float SVGContentUtils::GetStrokeWidth(const SVGElement* aElement,
const ComputedStyle* aComputedStyle,
SVGContextPaint* aContextPaint) {
const SVGContextPaint* aContextPaint) {
Float res = 0.0;
auto doCompute = [&](const ComputedStyle* computedStyle) {
@ -349,7 +349,7 @@ Float SVGContentUtils::GetStrokeWidth(SVGElement* aElement,
return res;
}
float SVGContentUtils::GetFontSize(Element* aElement) {
float SVGContentUtils::GetFontSize(const Element* aElement) {
if (!aElement) {
return 1.0f;
}
@ -373,7 +373,7 @@ float SVGContentUtils::GetFontSize(Element* aElement) {
return 1.0f;
}
float SVGContentUtils::GetFontSize(nsIFrame* aFrame) {
float SVGContentUtils::GetFontSize(const nsIFrame* aFrame) {
MOZ_ASSERT(aFrame, "NULL frame in GetFontSize");
return GetFontSize(aFrame->Style(), aFrame->PresContext());
}
@ -387,7 +387,7 @@ float SVGContentUtils::GetFontSize(const ComputedStyle* aComputedStyle,
aPresContext->EffectiveTextZoom();
}
float SVGContentUtils::GetFontXHeight(Element* aElement) {
float SVGContentUtils::GetFontXHeight(const Element* aElement) {
if (!aElement) {
return 1.0f;
}
@ -411,7 +411,7 @@ float SVGContentUtils::GetFontXHeight(Element* aElement) {
return 1.0f;
}
float SVGContentUtils::GetFontXHeight(nsIFrame* aFrame) {
float SVGContentUtils::GetFontXHeight(const nsIFrame* aFrame) {
MOZ_ASSERT(aFrame, "NULL frame in GetFontXHeight");
return GetFontXHeight(aFrame->Style(), aFrame->PresContext());
}
@ -434,14 +434,15 @@ float SVGContentUtils::GetFontXHeight(const ComputedStyle* aComputedStyle,
return nsPresContext::AppUnitsToFloatCSSPixels(xHeight) /
aPresContext->EffectiveTextZoom();
}
nsresult SVGContentUtils::ReportToConsole(Document* doc, const char* aWarning,
nsresult SVGContentUtils::ReportToConsole(const Document* doc,
const char* aWarning,
const nsTArray<nsString>& aParams) {
return nsContentUtils::ReportToConsole(nsIScriptError::warningFlag, "SVG"_ns,
doc, nsContentUtils::eSVG_PROPERTIES,
aWarning, aParams);
}
bool SVGContentUtils::EstablishesViewport(nsIContent* aContent) {
bool SVGContentUtils::EstablishesViewport(const nsIContent* aContent) {
// Although SVG 1.1 states that <image> is an element that establishes a
// viewport, this is really only for the document it references, not
// for any child content, which is what this function is used for.
@ -799,7 +800,7 @@ bool SVGContentUtils::ParseInteger(const nsAString& aString, int32_t& aValue) {
return ParseInteger(iter, end, aValue) && iter == end;
}
float SVGContentUtils::CoordToFloat(SVGElement* aContent,
float SVGContentUtils::CoordToFloat(const SVGElement* aContent,
const LengthPercentage& aLength,
uint8_t aCtxType) {
float result = aLength.ResolveToCSSPixelsWith([&] {

Просмотреть файл

@ -142,7 +142,7 @@ class SVGContentUtils {
static void GetStrokeOptions(AutoStrokeOptions* aStrokeOptions,
dom::SVGElement* aElement,
const ComputedStyle* aComputedStyle,
mozilla::SVGContextPaint* aContextPaint,
const SVGContextPaint* aContextPaint,
StrokeOptionFlags aFlags = eAllStrokeOptions);
/**
@ -154,9 +154,9 @@ class SVGContentUtils {
* and 'stroke-opacity' properties to, say, return zero if they are "none" or
* "0", respectively.
*/
static Float GetStrokeWidth(dom::SVGElement* aElement,
static Float GetStrokeWidth(const dom::SVGElement* aElement,
const ComputedStyle* aComputedStyle,
mozilla::SVGContextPaint* aContextPaint);
const SVGContextPaint* aContextPaint);
/*
* Get the number of CSS px (user units) per em (i.e. the em-height in user
@ -165,8 +165,8 @@ class SVGContentUtils {
* XXX document the conditions under which these may fail, and what they
* return in those cases.
*/
static float GetFontSize(mozilla::dom::Element* aElement);
static float GetFontSize(nsIFrame* aFrame);
static float GetFontSize(const mozilla::dom::Element* aElement);
static float GetFontSize(const nsIFrame* aFrame);
static float GetFontSize(const ComputedStyle*, nsPresContext*);
/*
* Get the number of CSS px (user units) per ex (i.e. the x-height in user
@ -175,14 +175,15 @@ class SVGContentUtils {
* XXX document the conditions under which these may fail, and what they
* return in those cases.
*/
static float GetFontXHeight(mozilla::dom::Element* aElement);
static float GetFontXHeight(nsIFrame* aFrame);
static float GetFontXHeight(const mozilla::dom::Element* aElement);
static float GetFontXHeight(const nsIFrame* aFrame);
static float GetFontXHeight(const ComputedStyle*, nsPresContext*);
/*
* Report a localized error message to the error console.
*/
static nsresult ReportToConsole(dom::Document* doc, const char* aWarning,
static nsresult ReportToConsole(const dom::Document* doc,
const char* aWarning,
const nsTArray<nsString>& aParams);
static Matrix GetCTM(dom::SVGElement* aElement, bool aScreenCTM);
@ -205,7 +206,7 @@ class SVGContentUtils {
* Check if this is one of the SVG elements that SVG 1.1 Full says
* establishes a viewport: svg, symbol, image or foreignObject.
*/
static bool EstablishesViewport(nsIContent* aContent);
static bool EstablishesViewport(const nsIContent* aContent);
static mozilla::dom::SVGViewportElement* GetNearestViewportElement(
const nsIContent* aContent);
@ -317,7 +318,7 @@ class SVGContentUtils {
* Converts a LengthPercentage into a userspace value, resolving percentage
* values relative to aContent's SVG viewport.
*/
static float CoordToFloat(dom::SVGElement* aContent,
static float CoordToFloat(const dom::SVGElement* aContent,
const StyleLengthPercentageUnion&,
uint8_t aCtxType = SVGContentUtils::XY);
/**

Просмотреть файл

@ -8365,9 +8365,11 @@ void nsIFrame::DumpFrameTreeLimitedInCSSPixels() const {
#endif
bool nsIFrame::IsVisibleForPainting() { return StyleVisibility()->IsVisible(); }
bool nsIFrame::IsVisibleForPainting() const {
return StyleVisibility()->IsVisible();
}
bool nsIFrame::IsVisibleOrCollapsedForPainting() {
bool nsIFrame::IsVisibleOrCollapsedForPainting() const {
return StyleVisibility()->IsVisibleOrCollapsed();
}

Просмотреть файл

@ -4130,12 +4130,12 @@ class nsIFrame : public nsQueryFrame {
* Determines whether a frame is visible for painting;
* taking into account whether it is painting a selection or printing.
*/
bool IsVisibleForPainting();
bool IsVisibleForPainting() const;
/**
* Determines whether a frame is visible for painting or collapsed;
* taking into account whether it is painting a selection or printing,
*/
bool IsVisibleOrCollapsedForPainting();
bool IsVisibleOrCollapsedForPainting() const;
/**
* Determines if this frame is a stacking context.

Просмотреть файл

@ -211,7 +211,7 @@ void SVGUtils::ScheduleReflowSVG(nsIFrame* aFrame) {
dirtyBit);
}
bool SVGUtils::NeedsReflowSVG(nsIFrame* aFrame) {
bool SVGUtils::NeedsReflowSVG(const nsIFrame* aFrame) {
MOZ_ASSERT(aFrame->IsFrameOfType(nsIFrame::eSVG),
"SVG uses bits differently!");
@ -411,7 +411,7 @@ void SVGUtils::NotifyChildrenOfSVGChange(nsIFrame* aFrame, uint32_t aFlags) {
// ************************************************************
float SVGUtils::ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity) {
float SVGUtils::ComputeOpacity(const nsIFrame* aFrame, bool aHandleOpacity) {
float opacity = aFrame->StyleEffects()->mOpacity;
if (opacity != 1.0f &&
@ -422,7 +422,7 @@ float SVGUtils::ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity) {
return opacity;
}
void SVGUtils::DetermineMaskUsage(nsIFrame* aFrame, bool aHandleOpacity,
void SVGUtils::DetermineMaskUsage(const nsIFrame* aFrame, bool aHandleOpacity,
MaskUsage& aUsage) {
using ClipPathType = StyleClipPath::Tag;
@ -936,8 +936,8 @@ bool SVGUtils::HitTestRect(const gfx::Matrix& aMatrix, float aRX, float aRY,
p.y <= rect.YMost();
}
gfxRect SVGUtils::GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY,
float aWidth, float aHeight) {
gfxRect SVGUtils::GetClipRectForFrame(const nsIFrame* aFrame, float aX,
float aY, float aWidth, float aHeight) {
const nsStyleDisplay* disp = aFrame->StyleDisplay();
const nsStyleEffects* effects = aFrame->StyleEffects();
@ -1126,7 +1126,7 @@ gfxRect SVGUtils::GetBBox(nsIFrame* aFrame, uint32_t aFlags,
return bbox;
}
gfxPoint SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame* aFrame) {
gfxPoint SVGUtils::FrameSpaceInCSSPxToUserSpaceOffset(const 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.
@ -1187,7 +1187,7 @@ gfxRect SVGUtils::GetRelativeRect(uint16_t aUnits,
NonSVGFrameUserSpaceMetrics(aFrame));
}
bool SVGUtils::CanOptimizeOpacity(nsIFrame* aFrame) {
bool SVGUtils::CanOptimizeOpacity(const nsIFrame* aFrame) {
if (!aFrame->HasAnyStateBits(NS_FRAME_SVG_LAYOUT)) {
return false;
}
@ -1217,7 +1217,7 @@ bool SVGUtils::CanOptimizeOpacity(nsIFrame* aFrame) {
}
gfxMatrix SVGUtils::AdjustMatrixForUnits(const gfxMatrix& aMatrix,
SVGAnimatedEnumeration* aUnits,
const SVGAnimatedEnumeration* aUnits,
nsIFrame* aFrame, uint32_t aFlags) {
if (aFrame && aUnits->GetAnimValue() == SVG_UNIT_TYPE_OBJECTBOUNDINGBOX) {
gfxRect bbox = GetBBox(aFrame, aFlags);
@ -1239,7 +1239,7 @@ nsIFrame* SVGUtils::GetFirstNonAAncestorFrame(nsIFrame* aStartFrame) {
return nullptr;
}
bool SVGUtils::GetNonScalingStrokeTransform(nsIFrame* aFrame,
bool SVGUtils::GetNonScalingStrokeTransform(const nsIFrame* aFrame,
gfxMatrix* aUserToOuterSVG) {
if (aFrame->GetContent()->IsText()) {
aFrame = aFrame->GetParent();
@ -1259,7 +1259,7 @@ bool SVGUtils::GetNonScalingStrokeTransform(nsIFrame* aFrame,
// The logic here comes from _cairo_stroke_style_max_distance_from_path
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsIFrame* aFrame,
const nsIFrame* aFrame,
double aStyleExpansionFactor,
const gfxMatrix& aMatrix) {
double style_expansion =
@ -1283,7 +1283,7 @@ static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
/*static*/
gfxRect SVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsTextFrame* aFrame,
const nsTextFrame* aFrame,
const gfxMatrix& aMatrix) {
NS_ASSERTION(SVGUtils::IsInSVGTextSubtree(aFrame),
"expected an nsTextFrame for SVG text");
@ -1293,7 +1293,7 @@ gfxRect SVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
/*static*/
gfxRect SVGUtils::PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
SVGGeometryFrame* aFrame,
const SVGGeometryFrame* aFrame,
const gfxMatrix& aMatrix) {
bool strokeMayHaveCorners =
!SVGContentUtils::ShapeTypeHasNoCorners(aFrame->GetContent());
@ -1502,7 +1502,7 @@ void SVGUtils::MakeStrokePatternFor(nsIFrame* aFrame, gfxContext* aContext,
/* static */
float SVGUtils::GetOpacity(const StyleSVGOpacity& aOpacity,
SVGContextPaint* aContextPaint) {
const SVGContextPaint* aContextPaint) {
float opacity = 1.0f;
switch (aOpacity.tag) {
case StyleSVGOpacity::Tag::Opacity:
@ -1521,13 +1521,14 @@ float SVGUtils::GetOpacity(const StyleSVGOpacity& aOpacity,
return opacity;
}
bool SVGUtils::HasStroke(nsIFrame* aFrame, SVGContextPaint* aContextPaint) {
bool SVGUtils::HasStroke(const nsIFrame* aFrame,
const SVGContextPaint* aContextPaint) {
const nsStyleSVG* style = aFrame->StyleSVG();
return style->HasStroke() && GetStrokeWidth(aFrame, aContextPaint) > 0;
}
float SVGUtils::GetStrokeWidth(nsIFrame* aFrame,
SVGContextPaint* aContextPaint) {
float SVGUtils::GetStrokeWidth(const nsIFrame* aFrame,
const SVGContextPaint* aContextPaint) {
nsIContent* content = aFrame->GetContent();
if (content->IsText()) {
content = content->GetParent();
@ -1561,7 +1562,7 @@ void SVGUtils::SetupStrokeGeometry(nsIFrame* aFrame, gfxContext* aContext,
strokeOptions.mDashOffset, devPxPerCSSPx);
}
uint16_t SVGUtils::GetGeometryHitTestFlags(nsIFrame* aFrame) {
uint16_t SVGUtils::GetGeometryHitTestFlags(const nsIFrame* aFrame) {
uint16_t flags = 0;
switch (aFrame->Style()->PointerEvents()) {
@ -1639,7 +1640,7 @@ void SVGUtils::PaintSVGGlyph(Element* aElement, gfxContext* aContext) {
svgFrame->PaintSVG(*aContext, m, dummy);
}
bool SVGUtils::GetSVGGlyphExtents(Element* aElement,
bool SVGUtils::GetSVGGlyphExtents(const Element* aElement,
const gfxMatrix& aSVGToAppSpace,
gfxRect* aResult) {
nsIFrame* frame = aElement->GetPrimaryFrame();
@ -1673,7 +1674,7 @@ nsRect SVGUtils::ToCanvasBounds(const gfxRect& aUserspaceRect,
presContext->AppUnitsPerDevPixel());
}
gfxMatrix SVGUtils::GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame) {
gfxMatrix SVGUtils::GetCSSPxToDevPxMatrix(const nsIFrame* aNonSVGFrame) {
float devPxPerCSSPx = aNonSVGFrame->PresContext()->CSSToDevPixelScale().scale;
return gfxMatrix(devPxPerCSSPx, 0.0, 0.0, devPxPerCSSPx, 0.0, 0.0);

Просмотреть файл

@ -203,7 +203,7 @@ class SVGUtils final {
* Returns true if the frame or any of its children need ReflowSVG
* to be called on them.
*/
static bool NeedsReflowSVG(nsIFrame* aFrame);
static bool NeedsReflowSVG(const nsIFrame* aFrame);
/**
* Percentage lengths in SVG are resolved against the width/height of the
@ -310,7 +310,7 @@ class SVGUtils final {
* The arguments for aX, aY, aWidth and aHeight should be the dimensions of
* the viewport established by aFrame.
*/
static gfxRect GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY,
static gfxRect GetClipRectForFrame(const nsIFrame* aFrame, float aX, float aY,
float aWidth, float aHeight);
static void SetClipRect(gfxContext* aContext, const gfxMatrix& aCTM,
@ -321,7 +321,7 @@ class SVGUtils final {
* not applying filters and not both stroking and filling, we can
* generate the same result without going through the overhead of a
* push/pop group. */
static bool CanOptimizeOpacity(nsIFrame* aFrame);
static bool CanOptimizeOpacity(const nsIFrame* aFrame);
/**
* Take the CTM to userspace for an element, and adjust it to a CTM to its
@ -334,7 +334,7 @@ class SVGUtils final {
* @param aFlags One or more of the BBoxFlags values defined below.
*/
static gfxMatrix AdjustMatrixForUnits(const gfxMatrix& aMatrix,
SVGAnimatedEnumeration* aUnits,
const SVGAnimatedEnumeration* aUnits,
nsIFrame* aFrame, uint32_t aFlags);
enum BBoxFlags {
@ -398,7 +398,7 @@ class SVGUtils final {
* This function returns the offset one needs to add to something in frame
* space in order to get its coordinates in user space.
*/
static gfxPoint FrameSpaceInCSSPxToUserSpaceOffset(nsIFrame* aFrame);
static gfxPoint FrameSpaceInCSSPxToUserSpaceOffset(const nsIFrame* aFrame);
/**
* Convert a userSpaceOnUse/objectBoundingBoxUnits rectangle that's specified
@ -440,7 +440,7 @@ class SVGUtils final {
* system in which the stroke is fixed). If aUserToOuterSVG is set to a
* non-identity matrix this function returns true, else it returns false.
*/
static bool GetNonScalingStrokeTransform(nsIFrame* aFrame,
static bool GetNonScalingStrokeTransform(const nsIFrame* aFrame,
gfxMatrix* aUserToOuterSVG);
/**
@ -457,10 +457,10 @@ class SVGUtils final {
* This should die once bug 478152 is fixed.
*/
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
nsTextFrame* aFrame,
const nsTextFrame* aFrame,
const gfxMatrix& aMatrix);
static gfxRect PathExtentsToMaxStrokeExtents(const gfxRect& aPathExtents,
SVGGeometryFrame* aFrame,
const SVGGeometryFrame* aFrame,
const gfxMatrix& aMatrix);
/**
@ -495,16 +495,16 @@ class SVGUtils final {
imgDrawingParams& aImgParams,
SVGContextPaint* aContextPaint = nullptr);
static float GetOpacity(const StyleSVGOpacity&, SVGContextPaint*);
static float GetOpacity(const StyleSVGOpacity&, const SVGContextPaint*);
/*
* @return false if there is no stroke
*/
static bool HasStroke(nsIFrame* aFrame,
SVGContextPaint* aContextPaint = nullptr);
static bool HasStroke(const nsIFrame* aFrame,
const SVGContextPaint* aContextPaint = nullptr);
static float GetStrokeWidth(nsIFrame* aFrame,
SVGContextPaint* aContextPaint = nullptr);
static float GetStrokeWidth(const nsIFrame* aFrame,
const SVGContextPaint* aContextPaint = nullptr);
/*
* Set up a context for a stroked path (including any dashing that applies).
@ -518,7 +518,7 @@ class SVGUtils final {
* into account the type of element and the value of the 'pointer-events'
* property on the element.
*/
static uint16_t GetGeometryHitTestFlags(nsIFrame* aFrame);
static uint16_t GetGeometryHitTestFlags(const nsIFrame* aFrame);
static FillRule ToFillRule(StyleFillRule aFillRule) {
return aFillRule == StyleFillRule::Evenodd ? FillRule::FILL_EVEN_ODD
@ -547,7 +547,7 @@ class SVGUtils final {
* @param aResult the result (valid when true is returned)
* @return true if calculating the extents succeeded
*/
static bool GetSVGGlyphExtents(Element* aElement,
static bool GetSVGGlyphExtents(const Element* aElement,
const gfxMatrix& aSVGToAppSpace,
gfxRect* aResult);
@ -581,10 +581,10 @@ class SVGUtils final {
}
};
static void DetermineMaskUsage(nsIFrame* aFrame, bool aHandleOpacity,
static void DetermineMaskUsage(const nsIFrame* aFrame, bool aHandleOpacity,
MaskUsage& aUsage);
static float ComputeOpacity(nsIFrame* aFrame, bool aHandleOpacity);
static float ComputeOpacity(const nsIFrame* aFrame, bool aHandleOpacity);
/**
* SVG frames expect to paint in SVG user units, which are equal to CSS px
@ -592,7 +592,7 @@ class SVGUtils final {
* gfxContext's current transform to convert the context's current units from
* its usual dev pixels to SVG user units/CSS px to keep the SVG code happy.
*/
static gfxMatrix GetCSSPxToDevPxMatrix(nsIFrame* aNonSVGFrame);
static gfxMatrix GetCSSPxToDevPxMatrix(const nsIFrame* aNonSVGFrame);
static bool IsInSVGTextSubtree(const nsIFrame* aFrame) {
// Returns true if the frame is an SVGTextFrame or one of its descendants.