mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-03-01 05:48:26 +00:00
bug 769303 - precompute intrinsic width of floats. r=roc
This commit is contained in:
parent
7e03b63996
commit
f8bf0a585d
@ -3647,10 +3647,7 @@ nsIFrame::InlineMinWidthData::ForceBreak(nsRenderingContext *aRenderingContext)
|
||||
currentLine = trailingWhitespace = 0;
|
||||
|
||||
for (PRUint32 i = 0, i_end = floats.Length(); i != i_end; ++i) {
|
||||
nsIFrame *floatFrame = floats[i];
|
||||
nscoord float_min =
|
||||
nsLayoutUtils::IntrinsicForContainer(aRenderingContext, floatFrame,
|
||||
nsLayoutUtils::MIN_WIDTH);
|
||||
nscoord float_min = floats[i].Width();
|
||||
if (float_min > prevLines)
|
||||
prevLines = float_min;
|
||||
}
|
||||
@ -3689,8 +3686,8 @@ nsIFrame::InlinePrefWidthData::ForceBreak(nsRenderingContext *aRenderingContext)
|
||||
floats_cur_right = 0;
|
||||
|
||||
for (PRUint32 i = 0, i_end = floats.Length(); i != i_end; ++i) {
|
||||
nsIFrame *floatFrame = floats[i];
|
||||
const nsStyleDisplay *floatDisp = floatFrame->GetStyleDisplay();
|
||||
const FloatInfo& floatInfo = floats[i];
|
||||
const nsStyleDisplay *floatDisp = floatInfo.Frame()->GetStyleDisplay();
|
||||
if (floatDisp->mBreakType == NS_STYLE_CLEAR_LEFT ||
|
||||
floatDisp->mBreakType == NS_STYLE_CLEAR_RIGHT ||
|
||||
floatDisp->mBreakType == NS_STYLE_CLEAR_LEFT_AND_RIGHT) {
|
||||
@ -3706,10 +3703,7 @@ nsIFrame::InlinePrefWidthData::ForceBreak(nsRenderingContext *aRenderingContext)
|
||||
|
||||
nscoord &floats_cur = floatDisp->mFloats == NS_STYLE_FLOAT_LEFT
|
||||
? floats_cur_left : floats_cur_right;
|
||||
nscoord floatWidth =
|
||||
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
||||
floatFrame,
|
||||
nsLayoutUtils::PREF_WIDTH);
|
||||
nscoord floatWidth = floatInfo.Width();
|
||||
// Negative-width floats don't change the available space so they
|
||||
// shouldn't change our intrinsic line width either.
|
||||
floats_cur =
|
||||
|
@ -1542,7 +1542,20 @@ public:
|
||||
nscoord trailingWhitespace;
|
||||
|
||||
// Floats encountered in the lines.
|
||||
nsTArray<nsIFrame*> floats;
|
||||
class FloatInfo {
|
||||
public:
|
||||
FloatInfo(const nsIFrame* aFrame, nscoord aWidth)
|
||||
: mFrame(aFrame), mWidth(aWidth)
|
||||
{ }
|
||||
const nsIFrame* Frame() const { return mFrame; }
|
||||
nscoord Width() const { return mWidth; }
|
||||
|
||||
private:
|
||||
const nsIFrame* mFrame;
|
||||
nscoord mWidth;
|
||||
};
|
||||
|
||||
nsTArray<FloatInfo> floats;
|
||||
};
|
||||
|
||||
struct InlineMinWidthData : public InlineIntrinsicWidthData {
|
||||
|
@ -82,8 +82,14 @@ nsPlaceholderFrame::AddInlineMinWidth(nsRenderingContext *aRenderingContext,
|
||||
// false.
|
||||
|
||||
// ...but push floats onto the list
|
||||
if (mOutOfFlowFrame->IsFloating())
|
||||
aData->floats.AppendElement(mOutOfFlowFrame);
|
||||
if (mOutOfFlowFrame->IsFloating()) {
|
||||
nscoord floatWidth =
|
||||
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
||||
mOutOfFlowFrame,
|
||||
nsLayoutUtils::MIN_WIDTH);
|
||||
aData->floats.AppendElement(
|
||||
InlineIntrinsicWidthData::FloatInfo(mOutOfFlowFrame, floatWidth));
|
||||
}
|
||||
}
|
||||
|
||||
/* virtual */ void
|
||||
@ -97,8 +103,14 @@ nsPlaceholderFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
|
||||
// false.
|
||||
|
||||
// ...but push floats onto the list
|
||||
if (mOutOfFlowFrame->IsFloating())
|
||||
aData->floats.AppendElement(mOutOfFlowFrame);
|
||||
if (mOutOfFlowFrame->IsFloating()) {
|
||||
nscoord floatWidth =
|
||||
nsLayoutUtils::IntrinsicForContainer(aRenderingContext,
|
||||
mOutOfFlowFrame,
|
||||
nsLayoutUtils::PREF_WIDTH);
|
||||
aData->floats.AppendElement(
|
||||
InlineIntrinsicWidthData::FloatInfo(mOutOfFlowFrame, floatWidth));
|
||||
}
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
Loading…
x
Reference in New Issue
Block a user