diff --git a/layout/forms/nsButtonFrameRenderer.cpp b/layout/forms/nsButtonFrameRenderer.cpp index ffe8048000f9..84458fd7c382 100644 --- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -409,9 +409,7 @@ nsButtonFrameRenderer::GetButtonInnerFocusMargin() if (mInnerFocusStyle) { const nsStyleMargin* margin = mInnerFocusStyle->StyleMargin(); - if (!margin->GetMargin(innerFocusMargin)) { - NS_NOTYETIMPLEMENTED("percentage margin"); - } + margin->GetMarginNoPercentage(innerFocusMargin); } return innerFocusMargin; diff --git a/layout/generic/nsFrame.cpp b/layout/generic/nsFrame.cpp index 5c3fd4b420bb..9be773bbecd7 100644 --- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -966,8 +966,7 @@ nsIFrame::GetUsedMargin() const if (m) { margin = *m; } else { - DebugOnly hasMargin = StyleMargin()->GetMargin(margin); - NS_ASSERTION(hasMargin, "We should have a margin here! (out of memory?)"); + StyleMargin()->GetMarginNoPercentage(margin); } return margin; } diff --git a/layout/style/nsRuleNode.cpp b/layout/style/nsRuleNode.cpp index 714b68511dad..e7ae77d7591e 100644 --- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -7217,7 +7217,6 @@ nsRuleNode::ComputeMarginData(void* aStartStruct, } } - margin->RecalcData(); COMPUTE_END_RESET(Margin, margin) } diff --git a/layout/style/nsStyleStruct.cpp b/layout/style/nsStyleStruct.cpp index e1f11bc9b175..3ed0ff057135 100644 --- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -255,8 +255,6 @@ static nscoord CalcCoord(const nsStyleCoord& aCoord, } nsStyleMargin::nsStyleMargin(StyleStructContext aContext) - : mHasCachedMargin(false) - , mCachedMargin(0, 0, 0, 0) { MOZ_COUNT_CTOR(nsStyleMargin); nsStyleCoord zero(0, nsStyleCoord::CoordConstructor); @@ -267,8 +265,6 @@ nsStyleMargin::nsStyleMargin(StyleStructContext aContext) nsStyleMargin::nsStyleMargin(const nsStyleMargin& aSrc) : mMargin(aSrc.mMargin) - , mHasCachedMargin(false) - , mCachedMargin(0, 0, 0, 0) { MOZ_COUNT_CTOR(nsStyleMargin); } @@ -280,19 +276,6 @@ nsStyleMargin::Destroy(nsPresContext* aContext) { FreeByObjectID(eArenaObjectID_nsStyleMargin, this); } - -void nsStyleMargin::RecalcData() -{ - if (mMargin.ConvertsToLength()) { - NS_FOR_CSS_SIDES(side) { - mCachedMargin.Side(side) = CalcCoord(mMargin.Get(side), nullptr, 0); - } - mHasCachedMargin = true; - } - else - mHasCachedMargin = false; -} - nsChangeHint nsStyleMargin::CalcDifference(const nsStyleMargin& aOther) const { if (mMargin == aOther.mMargin) { diff --git a/layout/style/nsStyleStruct.h b/layout/style/nsStyleStruct.h index 01131f819ed8..cca4193b19eb 100644 --- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -853,7 +853,6 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleMargin } void Destroy(nsPresContext* aContext); - void RecalcData(); nsChangeHint CalcDifference(const nsStyleMargin& aOther) const; static nsChangeHint MaxDifference() { return nsChangeHint_NeedReflow | @@ -868,19 +867,27 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStyleMargin nsStyleSides mMargin; // [reset] coord, percent, calc, auto - bool IsWidthDependent() const { return !mHasCachedMargin; } + bool IsWidthDependent() const { + return !mMargin.ConvertsToLength(); + } + bool GetMargin(nsMargin& aMargin) const { - if (mHasCachedMargin) { - aMargin = mCachedMargin; + if (mMargin.ConvertsToLength()) { + GetMarginNoPercentage(aMargin); return true; } + return false; } -protected: - bool mHasCachedMargin; - nsMargin mCachedMargin; + void GetMarginNoPercentage(nsMargin& aMargin) const + { + MOZ_ASSERT(mMargin.ConvertsToLength()); + NS_FOR_CSS_SIDES(side) { + aMargin.Side(side) = mMargin.Get(side).ToLength(); + } + } }; struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePadding