Bug 1513387: Add braces & newlines to re-wrap some return statements that clang-format unwrapped, in layout/svg. r=heycam

This patch shouldn't affect behavior; it's just making the existing control
flow clearer and more debuggable.

Differential Revision: https://phabricator.services.mozilla.com/D14216

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Daniel Holbert 2018-12-12 06:32:44 +00:00
Родитель 12adcc1edd
Коммит fa80837513
14 изменённых файлов: 125 добавлений и 42 удалений

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

@ -246,7 +246,9 @@ void SVGGeometryFrame::PaintSVG(gfxContext& aContext,
const gfxMatrix& aTransform,
imgDrawingParams& aImgParams,
const nsIntRect* aDirtyRect) {
if (!StyleVisibility()->IsVisible()) return;
if (!StyleVisibility()->IsVisible()) {
return;
}
// Matrix to the geometry's user space:
gfxMatrix newMatrix =
@ -335,7 +337,9 @@ nsIFrame* SVGGeometryFrame::GetFrameForPoint(const gfxPoint& aPoint) {
isHit = path->StrokeContainsPoint(stroke, point, Matrix());
}
if (isHit && nsSVGUtils::HitTestClip(this, aPoint)) return this;
if (isHit && nsSVGUtils::HitTestClip(this, aPoint)) {
return this;
}
return nullptr;
}

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

@ -136,7 +136,9 @@ nsIFrame* SVGRenderingObserver::GetAndObserveReferencedFrame(
LayoutFrameType aFrameType, bool* aOK) {
nsIFrame* frame = GetAndObserveReferencedFrame();
if (frame) {
if (frame->Type() == aFrameType) return frame;
if (frame->Type() == aFrameType) {
return frame;
}
if (aOK) {
*aOK = false;
}
@ -653,7 +655,9 @@ class SVGFilterObserverListForCSSProp final : public SVGFilterObserverList {
void SVGFilterObserverListForCSSProp::OnRenderingChange() {
nsIFrame* frame = mFrameReference.Get();
if (!frame) return;
if (!frame) {
return;
}
// Repaint asynchronously in case the filter frame is being torn down
nsChangeHint changeHint = nsChangeHint(nsChangeHint_RepaintFrame);
@ -992,10 +996,14 @@ template <class T>
static T* GetEffectProperty(
URLAndReferrerInfo* aURI, nsIFrame* aFrame,
const mozilla::FramePropertyDescriptor<T>* aProperty) {
if (!aURI) return nullptr;
if (!aURI) {
return nullptr;
}
T* prop = aFrame->GetProperty(aProperty);
if (prop) return prop;
if (prop) {
return prop;
}
prop = new T(aURI, aFrame, false);
NS_ADDREF(prop);
aFrame->SetProperty(aProperty, prop);
@ -1353,7 +1361,9 @@ nsSVGPaintServerFrame* SVGObserverUtils::GetAndObservePaintServer(
}
const nsStyleSVG* svgStyle = frame->StyleSVG();
if ((svgStyle->*aPaint).Type() != eStyleSVGPaintType_Server) return nullptr;
if ((svgStyle->*aPaint).Type() != eStyleSVGPaintType_Server) {
return nullptr;
}
RefPtr<URLAndReferrerInfo> paintServerURL =
ResolveURLUsingLocalRef(frame, (svgStyle->*aPaint).GetPaintServer());
@ -1363,15 +1373,20 @@ nsSVGPaintServerFrame* SVGObserverUtils::GetAndObservePaintServer(
(aPaint == &nsStyleSVG::mFill) ? FillProperty() : StrokeProperty();
nsSVGPaintingProperty* property =
GetPaintingProperty(paintServerURL, frame, propDesc);
if (!property) return nullptr;
if (!property) {
return nullptr;
}
nsIFrame* result = property->GetAndObserveReferencedFrame();
if (!result) return nullptr;
if (!result) {
return nullptr;
}
LayoutFrameType type = result->Type();
if (type != LayoutFrameType::SVGLinearGradient &&
type != LayoutFrameType::SVGRadialGradient &&
type != LayoutFrameType::SVGPattern)
type != LayoutFrameType::SVGPattern) {
return nullptr;
}
return static_cast<nsSVGPaintServerFrame*>(result);
}
@ -1449,7 +1464,9 @@ void SVGObserverUtils::InvalidateRenderingObservers(nsIFrame* aFrame) {
"aFrame must be first continuation");
nsIContent* content = aFrame->GetContent();
if (!content || !content->IsElement()) return;
if (!content || !content->IsElement()) {
return;
}
// If the rendering has changed, the bounds may well have changed too:
aFrame->DeleteProperty(nsSVGUtils::ObjectBoundingBoxProperty());

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

@ -2949,7 +2949,9 @@ void SVGTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
nsresult SVGTextFrame::AttributeChanged(int32_t aNameSpaceID,
nsAtom* aAttribute, int32_t aModType) {
if (aNameSpaceID != kNameSpaceID_None) return NS_OK;
if (aNameSpaceID != kNameSpaceID_None) {
return NS_OK;
}
if (aAttribute == nsGkAtoms::transform) {
// We don't invalidate for transform changes (the layers code does that).
@ -4486,7 +4488,9 @@ enum TextAnchorSide { eAnchorLeft, eAnchorMiddle, eAnchorRight };
static TextAnchorSide ConvertLogicalTextAnchorToPhysical(uint8_t aTextAnchor,
bool aIsRightToLeft) {
NS_ASSERTION(aTextAnchor <= 3, "unexpected value for aTextAnchor");
if (!aIsRightToLeft) return TextAnchorSide(aTextAnchor);
if (!aIsRightToLeft) {
return TextAnchorSide(aTextAnchor);
}
return TextAnchorSide(2 - aTextAnchor);
}
@ -5053,7 +5057,9 @@ void SVGTextFrame::MaybeResolveBidiForAnonymousBlockChild() {
void SVGTextFrame::MaybeReflowAnonymousBlockChild() {
nsIFrame* kid = PrincipalChildList().FirstChild();
if (!kid) return;
if (!kid) {
return;
}
NS_ASSERTION(!(kid->GetStateBits() & NS_FRAME_IN_REFLOW),
"should not be in reflow when about to reflow again");
@ -5101,7 +5107,9 @@ void SVGTextFrame::DoReflow() {
nsPresContext* presContext = PresContext();
nsIFrame* kid = PrincipalChildList().FirstChild();
if (!kid) return;
if (!kid) {
return;
}
RefPtr<gfxContext> renderingContext =
presContext->PresShell()->CreateReferenceRenderingContext();

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

@ -723,7 +723,9 @@ nsRect nsFilterInstance::ComputeSourceNeededRect() {
nsIntRect nsFilterInstance::OutputFilterSpaceBounds() const {
uint32_t numPrimitives = mFilterDescription.mPrimitives.Length();
if (numPrimitives <= 0) return nsIntRect();
if (numPrimitives <= 0) {
return nsIntRect();
}
return mFilterDescription.mPrimitives[numPrimitives - 1].PrimitiveSubregion();
}

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

@ -333,7 +333,9 @@ bool nsSVGClipPathFrame::IsTrivial(nsSVGDisplayableFrame** aSingleChild) {
if (svgChild) {
// We consider a non-trivial clipPath to be one containing
// either more than one svg child and/or a svg container
if (foundChild || svgChild->IsDisplayContainer()) return false;
if (foundChild || svgChild->IsDisplayContainer()) {
return false;
}
// or where the child is itself clipped
if (SVGObserverUtils::GetAndObserveClipPath(kid, nullptr) ==

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

@ -33,7 +33,9 @@ uint16_t nsSVGFilterFrame::GetEnumValue(uint32_t aIndex, nsIContent* aDefault) {
nsSVGEnum& thisEnum =
static_cast<SVGFilterElement*>(GetContent())->mEnumAttributes[aIndex];
if (thisEnum.IsExplicitlySet()) return thisEnum.GetAnimValue();
if (thisEnum.IsExplicitlySet()) {
return thisEnum.GetAnimValue();
}
// Before we recurse, make sure we'll break reference loops and over long
// reference chains:
@ -60,7 +62,9 @@ const nsSVGLength2* nsSVGFilterFrame::GetLengthValue(uint32_t aIndex,
const nsSVGLength2* thisLength =
&static_cast<SVGFilterElement*>(GetContent())->mLengthAttributes[aIndex];
if (thisLength->IsExplicitlySet()) return thisLength;
if (thisLength->IsExplicitlySet()) {
return thisLength;
}
// Before we recurse, make sure we'll break reference loops and over long
// reference chains:

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

@ -281,7 +281,9 @@ int32_t nsSVGFilterInstance::GetOrCreateSourceAlphaIndex(
nsTArray<FilterPrimitiveDescription>& aPrimitiveDescrs) {
// If the SourceAlpha index has already been determined or created for this
// SVG filter, just return it.
if (mSourceAlphaAvailable) return mSourceAlphaIndex;
if (mSourceAlphaAvailable) {
return mSourceAlphaIndex;
}
// If this is the first filter in the chain, we can just use the
// kPrimitiveIndexSourceAlpha keyword to refer to the SourceAlpha of the

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

@ -231,7 +231,9 @@ void nsSVGForeignObjectFrame::PaintSVG(gfxContext& aContext,
// not with kidDirtyRect. I.e.
// int32_t appUnitsPerDevPx = PresContext()->AppUnitsPerDevPixel();
// mRect.ToOutsidePixels(appUnitsPerDevPx).Intersects(*aDirtyRect)
if (kidDirtyRect.IsEmpty()) return;
if (kidDirtyRect.IsEmpty()) {
return;
}
}
aContext.Save();
@ -277,10 +279,14 @@ nsIFrame* nsSVGForeignObjectFrame::GetFrameForPoint(const gfxPoint& aPoint) {
"If display lists are enabled, only hit-testing of a "
"clipPath's contents should take this code path");
if (IsDisabled() || (GetStateBits() & NS_FRAME_IS_NONDISPLAY)) return nullptr;
if (IsDisabled() || (GetStateBits() & NS_FRAME_IS_NONDISPLAY)) {
return nullptr;
}
nsIFrame* kid = PrincipalChildList().FirstChild();
if (!kid) return nullptr;
if (!kid) {
return nullptr;
}
float x, y, width, height;
static_cast<nsSVGElement*>(GetContent())
@ -475,7 +481,9 @@ void nsSVGForeignObjectFrame::RequestReflow(
return;
nsIFrame* kid = PrincipalChildList().FirstChild();
if (!kid) return;
if (!kid) {
return;
}
PresShell()->FrameNeedsReflow(kid, aType, NS_FRAME_IS_DIRTY);
}
@ -483,11 +491,15 @@ void nsSVGForeignObjectFrame::RequestReflow(
void nsSVGForeignObjectFrame::DoReflow() {
MarkInReflow();
// Skip reflow if we're zero-sized, unless this is our first reflow.
if (IsDisabled() && !(GetStateBits() & NS_FRAME_FIRST_REFLOW)) return;
if (IsDisabled() && !(GetStateBits() & NS_FRAME_FIRST_REFLOW)) {
return;
}
nsPresContext* presContext = PresContext();
nsIFrame* kid = PrincipalChildList().FirstChild();
if (!kid) return;
if (!kid) {
return;
}
// initiate a synchronous reflow here and now:
RefPtr<gfxContext> renderingContext =

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

@ -69,7 +69,9 @@ uint16_t nsSVGGradientFrame::GetEnumValue(uint32_t aIndex,
static_cast<dom::SVGGradientElement*>(GetContent())
->mEnumAttributes[aIndex];
if (thisEnum.IsExplicitlySet()) return thisEnum.GetAnimValue();
if (thisEnum.IsExplicitlySet()) {
return thisEnum.GetAnimValue();
}
// Before we recurse, make sure we'll break reference loops and over long
// reference chains:
@ -148,7 +150,9 @@ gfxMatrix nsSVGGradientFrame::GetGradientTransform(
const nsSVGAnimatedTransformList* animTransformList =
GetGradientTransformList(GetContent());
if (!animTransformList) return bboxMatrix;
if (!animTransformList) {
return bboxMatrix;
}
gfxMatrix gradientTransform =
animTransformList->GetAnimValue().GetConsolidationMatrix();

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

@ -505,7 +505,9 @@ nsSVGImageListener::nsSVGImageListener(nsSVGImageFrame* aFrame)
NS_IMETHODIMP
nsSVGImageListener::Notify(imgIRequest* aRequest, int32_t aType,
const nsIntRect* aData) {
if (!mFrame) return NS_ERROR_FAILURE;
if (!mFrame) {
return NS_ERROR_FAILURE;
}
if (aType == imgINotificationObserver::LOAD_COMPLETE) {
mFrame->InvalidateFrame();

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

@ -1125,7 +1125,9 @@ bool PaintFrameCallback::operator()(gfxContext* aContext,
const gfxRect& aFillRect,
const SamplingFilter aSamplingFilter,
const gfxMatrix& aTransform) {
if (mFrame->GetStateBits() & NS_FRAME_DRAWING_AS_PAINTSERVER) return false;
if (mFrame->GetStateBits() & NS_FRAME_DRAWING_AS_PAINTSERVER) {
return false;
}
AutoSetRestorePaintServerState paintServer(mFrame);
@ -1219,7 +1221,9 @@ nsSVGIntegrationUtils::DrawableFromPaintServer(
aTarget, aDrawTarget, aContextMatrix, &nsStyleSVG::mFill, 1.0,
imgParams, &overrideBounds);
if (!pattern) return nullptr;
if (!pattern) {
return nullptr;
}
// pattern is now set up to fill aPaintServerSize. But we want it to
// fill aRenderSize, so we need to add a scaling transform.

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

@ -143,7 +143,9 @@ SVGBBox nsSVGMarkerFrame::GetMarkBBoxContribution(
// If the flag is set when we get here, it means this marker frame
// has already been used in calculating the current mark bbox, and
// the document has a marker reference loop.
if (mInUse) return bbox;
if (mInUse) {
return bbox;
}
AutoMarkerReferencer markerRef(this, aMarkedFrame);

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

@ -384,7 +384,9 @@ already_AddRefed<SourceSurface> nsSVGPatternFrame::PaintPattern(
// do we?
nsSVGPatternFrame *nsSVGPatternFrame::GetPatternWithChildren() {
// Do we have any children ourselves?
if (!mFrames.IsEmpty()) return this;
if (!mFrames.IsEmpty()) {
return this;
}
// No, see if we chain to someone who does
@ -399,7 +401,9 @@ nsSVGPatternFrame *nsSVGPatternFrame::GetPatternWithChildren() {
}
nsSVGPatternFrame *next = GetReferencedPattern();
if (!next) return nullptr;
if (!next) {
return nullptr;
}
return next->GetPatternWithChildren();
}
@ -409,7 +413,9 @@ uint16_t nsSVGPatternFrame::GetEnumValue(uint32_t aIndex,
nsSVGEnum &thisEnum =
static_cast<SVGPatternElement *>(GetContent())->mEnumAttributes[aIndex];
if (thisEnum.IsExplicitlySet()) return thisEnum.GetAnimValue();
if (thisEnum.IsExplicitlySet()) {
return thisEnum.GetAnimValue();
}
// Before we recurse, make sure we'll break reference loops and over long
// reference chains:
@ -458,7 +464,9 @@ nsSVGAnimatedTransformList *nsSVGPatternFrame::GetPatternTransformList(
gfxMatrix nsSVGPatternFrame::GetPatternTransform() {
nsSVGAnimatedTransformList *animTransformList =
GetPatternTransformList(GetContent());
if (!animTransformList) return gfxMatrix();
if (!animTransformList) {
return gfxMatrix();
}
return animTransformList->GetAnimValue().GetConsolidationMatrix();
}
@ -467,7 +475,9 @@ const nsSVGViewBox &nsSVGPatternFrame::GetViewBox(nsIContent *aDefault) {
const nsSVGViewBox &thisViewBox =
static_cast<SVGPatternElement *>(GetContent())->mViewBox;
if (thisViewBox.IsExplicitlySet()) return thisViewBox;
if (thisViewBox.IsExplicitlySet()) {
return thisViewBox;
}
// Before we recurse, make sure we'll break reference loops and over long
// reference chains:
@ -489,7 +499,9 @@ const SVGAnimatedPreserveAspectRatio &nsSVGPatternFrame::GetPreserveAspectRatio(
const SVGAnimatedPreserveAspectRatio &thisPar =
static_cast<SVGPatternElement *>(GetContent())->mPreserveAspectRatio;
if (thisPar.IsExplicitlySet()) return thisPar;
if (thisPar.IsExplicitlySet()) {
return thisPar;
}
// Before we recurse, make sure we'll break reference loops and over long
// reference chains:
@ -513,7 +525,9 @@ const nsSVGLength2 *nsSVGPatternFrame::GetLengthValue(uint32_t aIndex,
&static_cast<SVGPatternElement *>(GetContent())
->mLengthAttributes[aIndex];
if (thisLength->IsExplicitlySet()) return thisLength;
if (thisLength->IsExplicitlySet()) {
return thisLength;
}
// Before we recurse, make sure we'll break reference loops and over long
// reference chains:

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

@ -308,7 +308,9 @@ nsSVGOuterSVGFrame* nsSVGUtils::GetOuterSVGFrame(nsIFrame* aFrame) {
nsIFrame* nsSVGUtils::GetOuterSVGFrameAndCoveredRegion(nsIFrame* aFrame,
nsRect* aRect) {
nsSVGDisplayableFrame* svg = do_QueryFrame(aFrame);
if (!svg) return nullptr;
if (!svg) {
return nullptr;
}
nsSVGOuterSVGFrame* outer = GetOuterSVGFrame(aFrame);
if (outer == svg) {
return nullptr;
@ -585,7 +587,9 @@ void nsSVGUtils::PaintFrameWithEffects(nsIFrame* aFrame, gfxContext& aContext,
"SVG should take this code path");
nsSVGDisplayableFrame* svgFrame = do_QueryFrame(aFrame);
if (!svgFrame) return;
if (!svgFrame) {
return;
}
MaskUsage maskUsage;
DetermineMaskUsage(aFrame, true, maskUsage);
@ -956,7 +960,9 @@ gfxRect nsSVGUtils::GetClipRectForFrame(nsIFrame* aFrame, float aX, float aY,
void nsSVGUtils::SetClipRect(gfxContext* aContext, const gfxMatrix& aCTM,
const gfxRect& aRect) {
if (aCTM.IsSingular()) return;
if (aCTM.IsSingular()) {
return;
}
gfxContextMatrixAutoSaveRestore matrixAutoSaveRestore(aContext);
aContext->Multiply(aCTM);