Bug 1542646 Part 10 - simplify boolean logic r=dholbert
authorlongsonr <longsonr@gmail.com>
Sat, 20 Apr 2019 11:29:32 +0100
changeset 470297 8f243d93742049295c734a5bd6e252d5a7d67c99
parent 470296 9bb46f41277cf0beec92dd551c86c500dad5c3cf
child 470298 3dec47dd1b9bd55ef81b52d39f18742ecd2c9c05
push id35894
push userdvarga@mozilla.com
push dateSat, 20 Apr 2019 21:47:58 +0000
treeherdermozilla-central@72be82c6809e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersdholbert
bugs1542646
milestone68.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1542646 Part 10 - simplify boolean logic r=dholbert
dom/svg/SVGAnimatedLength.cpp
dom/svg/SVGAnimatedOrient.cpp
dom/svg/SVGPolyElement.cpp
layout/svg/SVGTextFrame.cpp
layout/svg/nsSVGUtils.cpp
--- a/dom/svg/SVGAnimatedLength.cpp
+++ b/dom/svg/SVGAnimatedLength.cpp
@@ -37,21 +37,18 @@ static const nsStaticAtom* const unitMap
     nsGkAtoms::pc};
 
 static SVGAttrTearoffTable<SVGAnimatedLength, DOMSVGAnimatedLength>
     sSVGAnimatedLengthTearoffTable;
 
 /* Helper functions */
 
 static bool IsValidUnitType(uint16_t unit) {
-  if (unit > SVGLength_Binding::SVG_LENGTHTYPE_UNKNOWN &&
-      unit <= SVGLength_Binding::SVG_LENGTHTYPE_PC)
-    return true;
-
-  return false;
+  return unit > SVGLength_Binding::SVG_LENGTHTYPE_UNKNOWN &&
+         unit <= SVGLength_Binding::SVG_LENGTHTYPE_PC;
 }
 
 static void GetUnitString(nsAString& unit, uint16_t unitType) {
   if (IsValidUnitType(unitType)) {
     if (unitMap[unitType]) {
       unitMap[unitType]->ToString(unit);
     }
     return;
--- a/dom/svg/SVGAnimatedOrient.cpp
+++ b/dom/svg/SVGAnimatedOrient.cpp
@@ -71,19 +71,17 @@ class MOZ_RAII AutoChangeOrientNotifier 
   SVGAnimatedOrient* const mOrient;
   SVGElement* const mSVGElement;
   nsAttrValue mEmptyOrOldValue;
   bool mDoSetAttr;
   MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
 };
 
 static bool IsValidAngleUnitType(uint16_t unit) {
-  if (unit > SVG_ANGLETYPE_UNKNOWN && unit <= SVG_ANGLETYPE_GRAD) return true;
-
-  return false;
+  return unit > SVG_ANGLETYPE_UNKNOWN && unit <= SVG_ANGLETYPE_GRAD;
 }
 
 static void GetAngleUnitString(nsAString& unit, uint16_t unitType) {
   if (IsValidAngleUnitType(unitType)) {
     if (angleUnitMap[unitType]) {
       angleUnitMap[unitType]->ToString(unit);
     }
     return;
--- a/dom/svg/SVGPolyElement.cpp
+++ b/dom/svg/SVGPolyElement.cpp
@@ -53,19 +53,17 @@ SVGPolyElement::IsAttributeMapped(const 
 bool SVGPolyElement::HasValidDimensions() const {
   return !mPoints.GetAnimValue().IsEmpty();
 }
 
 //----------------------------------------------------------------------
 // SVGGeometryElement methods
 
 bool SVGPolyElement::AttributeDefinesGeometry(const nsAtom* aName) {
-  if (aName == nsGkAtoms::points) return true;
-
-  return false;
+  return aName == nsGkAtoms::points;
 }
 
 void SVGPolyElement::GetMarkPoints(nsTArray<SVGMark>* aMarks) {
   const SVGPointList& points = mPoints.GetAnimValue();
 
   if (!points.Length()) return;
 
   float px = points[0].mX, py = points[0].mY, prevAngle = 0.0;
--- a/layout/svg/SVGTextFrame.cpp
+++ b/layout/svg/SVGTextFrame.cpp
@@ -211,21 +211,17 @@ static bool IsTextContentElement(nsICont
     return !parent || !IsTextContentElement(parent);
   }
 
   if (aContent->IsSVGElement(nsGkAtoms::textPath)) {
     nsIContent* parent = GetFirstNonAAncestor(aContent->GetParent());
     return parent && parent->IsSVGElement(nsGkAtoms::text);
   }
 
-  if (aContent->IsAnyOfSVGElements(nsGkAtoms::a, nsGkAtoms::tspan)) {
-    return true;
-  }
-
-  return false;
+  return aContent->IsAnyOfSVGElements(nsGkAtoms::a, nsGkAtoms::tspan);
 }
 
 /**
  * Returns whether the specified frame is an nsTextFrame that has some text
  * content.
  */
 static bool IsNonEmptyTextFrame(nsIFrame* aFrame) {
   nsTextFrame* textFrame = do_QueryFrame(aFrame);
@@ -3236,23 +3232,19 @@ static int32_t GetCaretOffset(nsCaret* a
  */
 static bool ShouldPaintCaret(const TextRenderedRun& aThisRun, nsCaret* aCaret) {
   int32_t caretOffset = GetCaretOffset(aCaret);
 
   if (caretOffset < 0) {
     return false;
   }
 
-  if (uint32_t(caretOffset) >= aThisRun.mTextFrameContentOffset &&
-      uint32_t(caretOffset) <
-          aThisRun.mTextFrameContentOffset + aThisRun.mTextFrameContentLength) {
-    return true;
-  }
-
-  return false;
+  return uint32_t(caretOffset) >= aThisRun.mTextFrameContentOffset &&
+         uint32_t(caretOffset) < aThisRun.mTextFrameContentOffset +
+                                     aThisRun.mTextFrameContentLength;
 }
 
 void SVGTextFrame::PaintSVG(gfxContext& aContext, const gfxMatrix& aTransform,
                             imgDrawingParams& aImgParams,
                             const nsIntRect* aDirtyRect) {
   DrawTarget& aDrawTarget = *aContext.GetDrawTarget();
   nsIFrame* kid = PrincipalChildList().FirstChild();
   if (!kid) {
--- a/layout/svg/nsSVGUtils.cpp
+++ b/layout/svg/nsSVGUtils.cpp
@@ -1204,20 +1204,17 @@ bool nsSVGUtils::CanOptimizeOpacity(nsIF
     return false;
   }
 
   if (nsLayoutUtils::HasAnimationOfPropertySet(
           aFrame, nsCSSPropertyIDSet::OpacityProperties())) {
     return false;
   }
 
-  if (!style->HasFill() || !HasStroke(aFrame)) {
-    return true;
-  }
-  return false;
+  return !style->HasFill() || !HasStroke(aFrame);
 }
 
 gfxMatrix nsSVGUtils::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;