Bug 1269901 - Remove mCachedMargin. r=dbaron

This commit is contained in:
Bobby Holley 2016-05-03 15:08:05 -07:00
parent f2c9cdf0d8
commit 60bd9ae61b
5 changed files with 16 additions and 30 deletions

View File

@ -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;

View File

@ -966,8 +966,7 @@ nsIFrame::GetUsedMargin() const
if (m) {
margin = *m;
} else {
DebugOnly<bool> hasMargin = StyleMargin()->GetMargin(margin);
NS_ASSERTION(hasMargin, "We should have a margin here! (out of memory?)");
StyleMargin()->GetMarginNoPercentage(margin);
}
return margin;
}

View File

@ -7217,7 +7217,6 @@ nsRuleNode::ComputeMarginData(void* aStartStruct,
}
}
margin->RecalcData();
COMPUTE_END_RESET(Margin, margin)
}

View File

@ -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) {

View File

@ -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