author | Bobby Holley <bobbyholley@gmail.com> |
Tue, 03 May 2016 14:55:38 -0700 | |
changeset 296148 | 1abdf346b87259240c11f24ed9fe0165165d916a |
parent 296147 | a923340a036f267c8f46d341764bfba3d86933bc |
child 296149 | 581279cd287e34b4af6b2544daff4589b6a2e580 |
push id | 76222 |
push user | bholley@mozilla.com |
push date | Wed, 04 May 2016 23:56:22 +0000 |
treeherder | mozilla-inbound@581279cd287e [default view] [failures only] |
perfherder | [talos] [build metrics] [platform microbench] (compared to previous push) |
reviewers | dbaron |
bugs | 1269901 |
milestone | 49.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
|
--- a/layout/forms/nsButtonFrameRenderer.cpp +++ b/layout/forms/nsButtonFrameRenderer.cpp @@ -381,19 +381,17 @@ nsButtonFrameRenderer::GetButtonInnerFoc nsMargin nsButtonFrameRenderer::GetButtonOuterFocusBorderAndPadding() { nsMargin result(0,0,0,0); if (mOuterFocusStyle) { - if (!mOuterFocusStyle->StylePadding()->GetPadding(result)) { - NS_NOTYETIMPLEMENTED("percentage padding"); - } + mOuterFocusStyle->StylePadding()->GetPaddingNoPercentage(result); result += mOuterFocusStyle->StyleBorder()->GetComputedBorder(); } return result; } nsMargin nsButtonFrameRenderer::GetButtonBorderAndPadding() @@ -420,19 +418,17 @@ nsButtonFrameRenderer::GetButtonInnerFoc } nsMargin nsButtonFrameRenderer::GetButtonInnerFocusBorderAndPadding() { nsMargin result(0,0,0,0); if (mInnerFocusStyle) { - if (!mInnerFocusStyle->StylePadding()->GetPadding(result)) { - NS_NOTYETIMPLEMENTED("percentage padding"); - } + mInnerFocusStyle->StylePadding()->GetPaddingNoPercentage(result); result += mInnerFocusStyle->StyleBorder()->GetComputedBorder(); } return result; } // gets all the focus borders and padding that will be added to the regular border nsMargin
--- a/layout/generic/nsFrame.cpp +++ b/layout/generic/nsFrame.cpp @@ -1036,18 +1036,17 @@ nsIFrame::GetUsedPadding() const } } nsMargin *p = static_cast<nsMargin*> (Properties().Get(UsedPaddingProperty())); if (p) { padding = *p; } else { - DebugOnly<bool> hasPadding = StylePadding()->GetPadding(padding); - NS_ASSERTION(hasPadding, "We should have padding here! (out of memory?)"); + StylePadding()->GetPaddingNoPercentage(padding); } return padding; } nsIFrame::Sides nsIFrame::GetSkipSides(const nsHTMLReflowState* aReflowState) const { if (MOZ_UNLIKELY(StyleBorder()->mBoxDecorationBreak ==
--- a/layout/style/nsRuleNode.cpp +++ b/layout/style/nsRuleNode.cpp @@ -7634,17 +7634,16 @@ nsRuleNode::ComputePaddingData(void* aSt coord, parentCoord, SETCOORD_LPH | SETCOORD_INITIAL_ZERO | SETCOORD_STORE_CALC | SETCOORD_UNSET_INITIAL, aContext, mPresContext, conditions)) { padding->mPadding.Set(side, coord); } } - padding->RecalcData(); COMPUTE_END_RESET(Padding, padding) } const void* nsRuleNode::ComputeOutlineData(void* aStartStruct, const nsRuleData* aRuleData, nsStyleContext* aContext, nsRuleNode* aHighestNode,
--- a/layout/style/nsStyleStruct.cpp +++ b/layout/style/nsStyleStruct.cpp @@ -301,55 +301,37 @@ nsChangeHint nsStyleMargin::CalcDifferen // Margin differences can't affect descendant intrinsic sizes and // don't need to force children to reflow. return nsChangeHint_NeedReflow | nsChangeHint_ReflowChangesSizeOrPosition | nsChangeHint_ClearAncestorIntrinsics; } nsStylePadding::nsStylePadding(StyleStructContext aContext) - : mHasCachedPadding(false) - , mCachedPadding(0, 0, 0, 0) { MOZ_COUNT_CTOR(nsStylePadding); nsStyleCoord zero(0, nsStyleCoord::CoordConstructor); NS_FOR_CSS_SIDES(side) { mPadding.Set(side, zero); } } nsStylePadding::nsStylePadding(const nsStylePadding& aSrc) : mPadding(aSrc.mPadding) - , mHasCachedPadding(false) - , mCachedPadding(0, 0, 0, 0) { MOZ_COUNT_CTOR(nsStylePadding); } void nsStylePadding::Destroy(nsPresContext* aContext) { this->~nsStylePadding(); aContext->PresShell()-> FreeByObjectID(eArenaObjectID_nsStylePadding, this); } -void nsStylePadding::RecalcData() -{ - if (mPadding.ConvertsToLength()) { - NS_FOR_CSS_SIDES(side) { - // Clamp negative calc() to 0. - mCachedPadding.Side(side) = - std::max(CalcCoord(mPadding.Get(side), nullptr, 0), 0); - } - mHasCachedPadding = true; - } - else - mHasCachedPadding = false; -} - nsChangeHint nsStylePadding::CalcDifference(const nsStylePadding& aOther) const { if (mPadding == aOther.mPadding) { return NS_STYLE_HINT_NONE; } // Padding differences can't affect descendant intrinsic sizes, but do need // to force children to reflow so that we can reposition them, since their // offsets are from our frame bounds but our content rect's position within
--- a/layout/style/nsStyleStruct.h +++ b/layout/style/nsStyleStruct.h @@ -878,33 +878,31 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt return false; } protected: bool mHasCachedMargin; nsMargin mCachedMargin; }; - struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsStylePadding { explicit nsStylePadding(StyleStructContext aContext); nsStylePadding(const nsStylePadding& aPadding); ~nsStylePadding() { MOZ_COUNT_DTOR(nsStylePadding); } void* operator new(size_t sz, nsStylePadding* aSelf) CPP_THROW_NEW { return aSelf; } void* operator new(size_t sz, nsPresContext* aContext) CPP_THROW_NEW { return aContext->PresShell()-> AllocateByObjectID(mozilla::eArenaObjectID_nsStylePadding, sz); } void Destroy(nsPresContext* aContext); - void RecalcData(); nsChangeHint CalcDifference(const nsStylePadding& aOther) const; static nsChangeHint MaxDifference() { return NS_SubtractHint(NS_STYLE_HINT_REFLOW, nsChangeHint_ClearDescendantIntrinsics); } static nsChangeHint DifferenceAlwaysHandledForDescendants() { // CalcDifference can return nsChangeHint_ClearAncestorIntrinsics as // a hint not handled for descendants. We could (and perhaps @@ -914,29 +912,38 @@ struct MOZ_NEEDS_MEMMOVABLE_MEMBERS nsSt // with nsChangeHint_ClearAncestorIntrinsics (which is not), it // won't ever lead to any optimization in // nsStyleContext::CalcStyleDifference. return nsChangeHint(0); } nsStyleSides mPadding; // [reset] coord, percent, calc - bool IsWidthDependent() const { return !mHasCachedPadding; } + bool IsWidthDependent() const { + return !mPadding.ConvertsToLength(); + } + bool GetPadding(nsMargin& aPadding) const { - if (mHasCachedPadding) { - aPadding = mCachedPadding; + if (mPadding.ConvertsToLength()) { + GetPaddingNoPercentage(aPadding); return true; } + return false; } -protected: - bool mHasCachedPadding; - nsMargin mCachedPadding; + void GetPaddingNoPercentage(nsMargin& aPadding) const + { + MOZ_ASSERT(mPadding.ConvertsToLength()); + NS_FOR_CSS_SIDES(side) { + // Clamp negative calc() to 0. + aPadding.Side(side) = std::max(mPadding.Get(side).ToLength(), 0); + } + } }; struct nsBorderColors { nsBorderColors* mNext; nscolor mColor; nsBorderColors() : mNext(nullptr), mColor(NS_RGB(0,0,0)) {}
--- a/layout/xul/tree/nsTreeBodyFrame.cpp +++ b/layout/xul/tree/nsTreeBodyFrame.cpp @@ -145,19 +145,17 @@ nsTreeBodyFrame::~nsTreeBodyFrame() DetachImageListeners(); delete mSlots; } static void GetBorderPadding(nsStyleContext* aContext, nsMargin& aMargin) { aMargin.SizeTo(0, 0, 0, 0); - if (!aContext->StylePadding()->GetPadding(aMargin)) { - NS_NOTYETIMPLEMENTED("percentage padding"); - } + aContext->StylePadding()->GetPaddingNoPercentage(aMargin); aMargin += aContext->StyleBorder()->GetComputedBorder(); } static void AdjustForBorderPadding(nsStyleContext* aContext, nsRect& aRect) { nsMargin borderPadding(0, 0, 0, 0); GetBorderPadding(aContext, borderPadding);