Bug 1139709. Cache nsMathMLContainerFrame's intrinsic width. r=mats

For me, this reduces the load time of the testcase in bug 1139709 from
68s to 34s.
This commit is contained in:
Robert O'Callahan
2015-03-05 14:30:07 +13:00
parent fc5dc44a74
commit 243150e068
2 changed files with 38 additions and 15 deletions

View File

@@ -973,18 +973,34 @@ nsMathMLContainerFrame::Reflow(nsPresContext* aPresContext,
static nscoord AddInterFrameSpacingToSize(nsHTMLReflowMetrics& aDesiredSize,
nsMathMLContainerFrame* aFrame);
/* virtual */ void
nsMathMLContainerFrame::MarkIntrinsicISizesDirty()
{
mIntrinsicWidth = NS_INTRINSIC_WIDTH_UNKNOWN;
nsContainerFrame::MarkIntrinsicISizesDirty();
}
void
nsMathMLContainerFrame::UpdateIntrinsicWidth(nsRenderingContext *aRenderingContext)
{
if (mIntrinsicWidth == NS_INTRINSIC_WIDTH_UNKNOWN) {
nsHTMLReflowMetrics desiredSize(GetWritingMode());
GetIntrinsicISizeMetrics(aRenderingContext, desiredSize);
// Include the additional width added by FixInterFrameSpacing to ensure
// consistent width calculations.
AddInterFrameSpacingToSize(desiredSize, this);
mIntrinsicWidth = desiredSize.ISize(GetWritingMode());
}
}
/* virtual */ nscoord
nsMathMLContainerFrame::GetMinISize(nsRenderingContext *aRenderingContext)
{
nscoord result;
DISPLAY_MIN_WIDTH(this, result);
nsHTMLReflowMetrics desiredSize(GetWritingMode());
GetIntrinsicISizeMetrics(aRenderingContext, desiredSize);
// Include the additional width added by FixInterFrameSpacing to ensure
// consistent width calculations.
AddInterFrameSpacingToSize(desiredSize, this);
result = desiredSize.ISize(GetWritingMode());
UpdateIntrinsicWidth(aRenderingContext);
result = mIntrinsicWidth;
return result;
}
@@ -993,13 +1009,8 @@ nsMathMLContainerFrame::GetPrefISize(nsRenderingContext *aRenderingContext)
{
nscoord result;
DISPLAY_PREF_WIDTH(this, result);
nsHTMLReflowMetrics desiredSize(GetWritingMode());
GetIntrinsicISizeMetrics(aRenderingContext, desiredSize);
// Include the additional width added by FixInterFrameSpacing to ensure
// consistent width calculations.
AddInterFrameSpacingToSize(desiredSize, this);
result = desiredSize.ISize(GetWritingMode());
UpdateIntrinsicWidth(aRenderingContext);
result = mIntrinsicWidth;
return result;
}

View File

@@ -31,7 +31,10 @@ class nsMathMLContainerFrame : public nsContainerFrame,
public nsMathMLFrame {
friend class nsMathMLmfencedFrame;
public:
explicit nsMathMLContainerFrame(nsStyleContext* aContext) : nsContainerFrame(aContext) {}
explicit nsMathMLContainerFrame(nsStyleContext* aContext)
: nsContainerFrame(aContext)
, mIntrinsicWidth(NS_INTRINSIC_WIDTH_UNKNOWN)
{}
NS_DECL_QUERYFRAME_TARGET(nsMathMLContainerFrame)
NS_DECL_QUERYFRAME
@@ -134,6 +137,8 @@ public:
virtual bool UpdateOverflow() MOZ_OVERRIDE;
virtual void MarkIntrinsicISizesDirty() MOZ_OVERRIDE;
// Notification when an attribute is changed. The MathML module uses the
// following paradigm:
//
@@ -391,6 +396,13 @@ protected:
*/
static void DidReflowChildren(nsIFrame* aFirst, nsIFrame* aStop = nullptr);
/**
* Recompute mIntrinsicWidth if it's not already up to date.
*/
void UpdateIntrinsicWidth(nsRenderingContext *aRenderingContext);
nscoord mIntrinsicWidth;
private:
class RowChildFrameIterator;
friend class RowChildFrameIterator;