Remove width determination parameters from font inflation methods. (Bug 747720, patch 5) r=roc

These are no longer needed since we're getting the width from the
nsFontInflationData.
This commit is contained in:
L. David Baron 2012-05-20 22:18:28 -07:00
Родитель aa10696284
Коммит 0074311d88
19 изменённых файлов: 37 добавлений и 100 удалений

Просмотреть файл

@ -2562,8 +2562,7 @@ GetScrollableLineHeight(nsIFrame* aTargetFrame)
// Fall back to the font height of the target frame.
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(aTargetFrame, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(aTargetFrame,
nsLayoutUtils::eNotInReflow));
nsLayoutUtils::FontSizeInflationFor(aTargetFrame));
NS_ASSERTION(fm, "FontMetrics is null!");
if (fm)
return fm->MaxHeight();

Просмотреть файл

@ -351,7 +351,7 @@ nsCaret::GetGeometryForFrame(nsIFrame* aFrame,
nscoord ascent = 0, descent = 0;
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(aFrame, nsLayoutUtils::eNotInReflow));
nsLayoutUtils::FontSizeInflationFor(aFrame));
NS_ASSERTION(fm, "We should be able to get the font metrics");
if (fm) {
ascent = fm->MaxAscent();

Просмотреть файл

@ -4785,8 +4785,7 @@ ShouldInflateFontsForContainer(const nsIFrame *aFrame)
}
nscoord
nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame *aFrame,
WidthDetermination aWidthDetermination)
nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame *aFrame)
{
nsPresContext *presContext = aFrame->PresContext();
if (!FontSizeInflationEnabled(presContext) ||
@ -4819,16 +4818,13 @@ nsLayoutUtils::InflationMinFontSizeFor(const nsIFrame *aFrame,
}
float
nsLayoutUtils::FontSizeInflationFor(const nsIFrame *aFrame,
WidthDetermination aWidthDetermination)
nsLayoutUtils::FontSizeInflationFor(const nsIFrame *aFrame)
{
if (!FontSizeInflationEnabled(aFrame->PresContext())) {
return 1.0;
}
return FontSizeInflationInner(aFrame,
InflationMinFontSizeFor(aFrame,
aWidthDetermination));
return FontSizeInflationInner(aFrame, InflationMinFontSizeFor(aFrame));
}
/* static */ bool

Просмотреть файл

@ -1529,15 +1529,8 @@ public:
* Return the font size inflation *ratio* for a given frame. This is
* the factor by which font sizes should be inflated; it is never
* smaller than 1.
*
* The WidthDetermination parameter says how we determine the width of
* the nearest inflation container: when not in reflow we look at the
* frame tree; when in reflow we look at state stored on the pres
* context.
*/
enum WidthDetermination { eNotInReflow, eInReflow };
static float FontSizeInflationFor(const nsIFrame *aFrame,
WidthDetermination aWidthDetermination);
static float FontSizeInflationFor(const nsIFrame *aFrame);
/**
* Perform the first half of the computation of FontSizeInflationFor
@ -1552,9 +1545,7 @@ public:
* above the minimum should always be adjusted as done by
* FontSizeInflationInner.
*/
static nscoord InflationMinFontSizeFor(const nsIFrame *aFrame,
WidthDetermination
aWidthDetermination);
static nscoord InflationMinFontSizeFor(const nsIFrame *aFrame);
/**
* Perform the second half of the computation done by

Просмотреть файл

@ -120,8 +120,7 @@ nsFormControlFrame::Reflow(nsPresContext* aPresContext,
}
if (nsLayoutUtils::FontSizeInflationEnabled(aPresContext)) {
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
aDesiredSize.width *= inflation;
aDesiredSize.height *= inflation;
aDesiredSize.UnionOverflowAreasWithDesiredBounds();

Просмотреть файл

@ -256,8 +256,7 @@ void nsListControlFrame::PaintFocus(nsRenderingContext& aRC, nsPoint aPt)
// get it into our coordinates
fRect.MoveBy(childframe->GetParent()->GetOffsetTo(this));
} else {
float inflation = nsLayoutUtils::FontSizeInflationFor(this,
nsLayoutUtils::eNotInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
fRect.x = fRect.y = 0;
fRect.width = GetScrollPortRect().width;
fRect.height = CalcFallbackRowHeight(inflation);
@ -284,7 +283,7 @@ void nsListControlFrame::PaintFocus(nsRenderingContext& aRC, nsPoint aPt)
}
void
nsListControlFrame::InvalidateFocus(const nsHTMLReflowState *aReflowState)
nsListControlFrame::InvalidateFocus()
{
if (mFocused != this)
return;
@ -294,9 +293,7 @@ nsListControlFrame::InvalidateFocus(const nsHTMLReflowState *aReflowState)
// Invalidating from the containerFrame because that's where our focus
// is drawn.
// The origin of the scrollport is the origin of containerFrame.
float inflation = nsLayoutUtils::FontSizeInflationFor(this,
aReflowState ? nsLayoutUtils::eInReflow
: nsLayoutUtils::eNotInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
nsRect invalidateArea = containerFrame->GetVisualOverflowRect();
nsRect emptyFallbackArea(0, 0, GetScrollPortRect().width,
CalcFallbackRowHeight(inflation));
@ -362,8 +359,7 @@ nsListControlFrame::CalcHeightOfARow()
// Check to see if we have zero items (and optimize by checking
// heightOfARow first)
if (heightOfARow == 0 && GetNumberOfOptions() == 0) {
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
heightOfARow = CalcFallbackRowHeight(inflation);
}
@ -1154,8 +1150,7 @@ nsListControlFrame::OnContentReset()
}
void
nsListControlFrame::ResetList(bool aAllowScrolling,
const nsHTMLReflowState *aReflowState)
nsListControlFrame::ResetList(bool aAllowScrolling)
{
// if all the frames aren't here
// don't bother reseting
@ -1179,7 +1174,7 @@ nsListControlFrame::ResetList(bool aAllowScrolling,
mStartSelectionIndex = kNothingSelected;
mEndSelectionIndex = kNothingSelected;
InvalidateFocus(aReflowState);
InvalidateFocus();
// Combobox will redisplay itself with the OnOptionSelected event
}
@ -1732,7 +1727,7 @@ nsListControlFrame::DidReflow(nsPresContext* aPresContext,
// The idea is that we want scroll history restoration to trump ResetList
// scrolling to the selected element, when the ResetList was probably only
// caused by content loading normally.
ResetList(!DidHistoryRestore() || mPostChildrenLoadedReset, aReflowState);
ResetList(!DidHistoryRestore() || mPostChildrenLoadedReset);
}
mHasPendingInterruptAtStartOfReflow = false;

Просмотреть файл

@ -239,10 +239,8 @@ public:
* that PaintFocus will or could have painted --- basically the whole
* GetOptionsContainer, plus some extra stuff if there are no options. This
* must be called every time mEndSelectionIndex changes.
*
* Pass non-null aReflowState if during reflow.
*/
void InvalidateFocus(const nsHTMLReflowState* aReflowState = nsnull);
void InvalidateFocus();
/**
* Function to calculate the height a row, for use with the "size" attribute.
@ -334,11 +332,8 @@ protected:
/**
* Resets the select back to it's original default values;
* those values as determined by the original HTML
*
* Pass non-null aReflowState if during reflow.
*/
virtual void ResetList(bool aAllowScrolling,
const nsHTMLReflowState* aReflowState = nsnull);
virtual void ResetList(bool aAllowScrolling);
nsListControlFrame(nsIPresShell* aShell, nsIDocument* aDocument, nsStyleContext* aContext);
virtual ~nsListControlFrame();

Просмотреть файл

@ -269,8 +269,7 @@ nsProgressFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
nsSize aMargin, nsSize aBorder,
nsSize aPadding, bool aShrinkWrap)
{
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
nsRefPtr<nsFontMetrics> fontMet;
NS_ENSURE_SUCCESS(nsLayoutUtils::GetFontMetricsForFrame(this,
getter_AddRefs(fontMet),

Просмотреть файл

@ -493,8 +493,7 @@ nsTextControlFrame::ComputeAutoSize(nsRenderingContext *aRenderingContext,
nsSize aMargin, nsSize aBorder,
nsSize aPadding, bool aShrinkWrap)
{
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
nsSize autoSize;
nsresult rv = CalcIntrinsicSize(aRenderingContext, autoSize, inflation);
if (NS_FAILED(rv)) {
@ -601,8 +600,7 @@ nsTextControlFrame::GetBoxAscent(nsBoxLayoutState& aState)
// Return the baseline of the first (nominal) row, with centering for
// single-line controls.
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
// First calculate the ascent wrt the client rect
nsRect clientRect;

Просмотреть файл

@ -243,7 +243,7 @@ nsDisplayTextOverflowMarker::PaintTextToContext(nsRenderingContext* aCtx,
{
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(mFrame, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(mFrame, nsLayoutUtils::eNotInReflow));
nsLayoutUtils::FontSizeInflationFor(mFrame));
aCtx->SetFont(fm);
gfxFloat y = nsLayoutUtils::GetSnappedBaselineY(mFrame, aCtx->ThebesContext(),
mRect.y, mAscent);
@ -761,7 +761,7 @@ TextOverflow::Marker::SetupString(nsIFrame* aFrame)
aFrame->PresContext()->PresShell()->GetReferenceRenderingContext();
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(aFrame, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(aFrame, nsLayoutUtils::eNotInReflow));
nsLayoutUtils::FontSizeInflationFor(aFrame));
rc->SetFont(fm);
mMarkerString = mStyle->mType == NS_STYLE_TEXT_OVERFLOW_ELLIPSIS ?

Просмотреть файл

@ -151,7 +151,7 @@ BRFrame::Reflow(nsPresContext* aPresContext,
// here for cases where the line-height is less than 1.
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow));
nsLayoutUtils::FontSizeInflationFor(this));
aReflowState.rendContext->SetFont(fm); // FIXME: maybe not needed?
if (fm) {
nscoord logicalHeight = aReflowState.CalcLineHeight();

Просмотреть файл

@ -573,8 +573,7 @@ nsBlockFrame::GetCaretBaseline() const
}
}
nsRefPtr<nsFontMetrics> fm;
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eNotInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation);
return nsLayoutUtils::GetCenteredFontBaseline(fm, nsHTMLReflowState::
CalcLineHeight(GetStyleContext(), contentRect.height, inflation)) +
@ -2376,7 +2375,7 @@ nsBlockFrame::ReflowDirtyLines(nsBlockReflowState& aState)
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow));
nsLayoutUtils::FontSizeInflationFor(this));
aState.mReflowState.rendContext->SetFont(fm); // FIXME: needed?
nscoord minAscent =

Просмотреть файл

@ -1420,8 +1420,7 @@ nsBulletFrame::Reflow(nsPresContext* aPresContext,
DO_GLOBAL_REFLOW_COUNT("nsBulletFrame");
DISPLAY_REFLOW(aPresContext, this, aReflowState, aMetrics, aStatus);
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
SetFontSizeInflation(inflation);
// Get the base size

Просмотреть файл

@ -2570,7 +2570,7 @@ nsGfxScrollFrameInner::GetLineScrollAmount() const
{
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(mOuter, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(mOuter, nsLayoutUtils::eNotInReflow));
nsLayoutUtils::FontSizeInflationFor(mOuter));
NS_ASSERTION(fm, "FontMetrics is null, assuming fontHeight == 1 appunit");
nscoord fontHeight = 1;
if (fm) {

Просмотреть файл

@ -2262,8 +2262,7 @@ nsHTMLReflowState::CalcLineHeight() const
(mCBReflowState ? mCBReflowState->mComputedHeight : NS_AUTOHEIGHT);
return CalcLineHeight(frame->GetStyleContext(), blockHeight,
nsLayoutUtils::FontSizeInflationFor(frame,
nsLayoutUtils::eInReflow));
nsLayoutUtils::FontSizeInflationFor(frame));
}
/* static */ nscoord

Просмотреть файл

@ -1006,7 +1006,7 @@ nsImageFrame::DisplayAltText(nsPresContext* aPresContext,
aRenderingContext.SetColor(GetStyleColor()->mColor);
nsRefPtr<nsFontMetrics> fm;
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm),
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eNotInReflow));
nsLayoutUtils::FontSizeInflationFor(this));
aRenderingContext.SetFont(fm);
// Format the text to display within the formatting rect

Просмотреть файл

@ -660,8 +660,7 @@ nsInlineFrame::ReflowFrames(nsPresContext* aPresContext,
}
nsRefPtr<nsFontMetrics> fm;
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
nsLayoutUtils::GetFontMetricsForFrame(this, getter_AddRefs(fm), inflation);
aReflowState.rendContext->SetFont(fm);

Просмотреть файл

@ -120,8 +120,7 @@ nsLineLayout::nsLineLayout(nsPresContext* aPresContext,
mTrimmableWidth = 0;
mInflationMinFontSize =
nsLayoutUtils::InflationMinFontSizeFor(aOuterReflowState->frame,
nsLayoutUtils::eInReflow);
nsLayoutUtils::InflationMinFontSizeFor(aOuterReflowState->frame);
// Instead of always pre-initializing the free-lists for frames and
// spans, we do it on demand so that situations that only use a few

Просмотреть файл

@ -1895,33 +1895,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer)
if (mWhichTextRun == nsTextFrame::eNotInflated) {
fontInflation = 1.0f;
} else {
nsPresContext* presContext = firstFrame->PresContext();
nsLayoutUtils::WidthDetermination widthDeter = nsLayoutUtils::eNotInReflow;
if (presContext->PresShell()->IsReflowLocked()) {
widthDeter = nsLayoutUtils::eInReflow;
}
#ifdef DEBUG
if (widthDeter == nsLayoutUtils::eInReflow) {
// Make sure that the font inflation container is correct.
nsIFrame* inflationContainer = nsnull;
for (nsIFrame* f = firstFrame; f; f = f->GetParent()) {
if (nsLayoutUtils::IsContainerForFontSizeInflation(f)) {
inflationContainer = f;
break;
}
}
// FIXME: When we support variable width containers (e.g. for regions or
// differing-width columns, we should revisit this assertion.
NS_ASSERTION(inflationContainer->GetFirstInFlow() ==
presContext->mCurrentInflationContainer->GetFirstInFlow(),
"Current inflation container for text frame is wrong");
}
#endif // #ifdef DEBUG
fontInflation = nsLayoutUtils::FontSizeInflationFor(firstFrame, widthDeter);
fontInflation = nsLayoutUtils::FontSizeInflationFor(firstFrame);
}
gfxFontGroup* fontGroup = GetFontGroupForFrame(firstFrame, fontInflation);
@ -4678,8 +4652,7 @@ nsTextFrame::UnionAdditionalOverflow(nsPresContext* aPresContext,
GetTextDecorations(aPresContext, textDecs);
if (textDecs.HasDecorationLines()) {
nscoord inflationMinFontSize =
nsLayoutUtils::InflationMinFontSizeFor(aBlockReflowState.frame,
nsLayoutUtils::eInReflow);
nsLayoutUtils::InflationMinFontSizeFor(aBlockReflowState.frame);
const nscoord width = GetSize().width;
const gfxFloat appUnitsPerDevUnit = aPresContext->AppUnitsPerDevPixel(),
@ -5675,7 +5648,7 @@ nsTextFrame::DrawTextRunAndDecorations(
aDirtyRect.Width() / app, aDirtyRect.Height() / app);
nscoord inflationMinFontSize =
nsLayoutUtils::InflationMinFontSizeFor(this, nsLayoutUtils::eNotInReflow);
nsLayoutUtils::InflationMinFontSizeFor(this);
// Underlines
for (PRUint32 i = aDecorations.mUnderlines.Length(); i-- > 0; ) {
@ -6762,8 +6735,7 @@ nsTextFrame::AddInlineMinWidthForFlow(nsRenderingContext *aRenderingContext,
nsTextFrame::AddInlineMinWidth(nsRenderingContext *aRenderingContext,
nsIFrame::InlineMinWidthData *aData)
{
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
TextRunType trtype = (inflation == 1.0f) ? eNotInflated : eInflated;
nsTextFrame* f;
@ -6893,8 +6865,7 @@ nsTextFrame::AddInlinePrefWidthForFlow(nsRenderingContext *aRenderingContext,
nsTextFrame::AddInlinePrefWidth(nsRenderingContext *aRenderingContext,
nsIFrame::InlinePrefWidthData *aData)
{
float inflation =
nsLayoutUtils::FontSizeInflationFor(this, nsLayoutUtils::eInReflow);
float inflation = nsLayoutUtils::FontSizeInflationFor(this);
TextRunType trtype = (inflation == 1.0f) ? eNotInflated : eInflated;
nsTextFrame* f;
@ -7419,8 +7390,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth,
}
}
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this,
nsLayoutUtils::eInReflow);
float fontSizeInflation = nsLayoutUtils::FontSizeInflationFor(this);
if (fontSizeInflation != GetFontSizeInflation()) {
// FIXME: Ideally, if we already have a text run, we'd move it to be