Bug 1343516 - coding style fix for nsTextFrame's PropertyProvider.
I'm doing this at the last part of the patchset because we couldn't know
the length for horizontal alignment until we finish the refactoring work,
which is presented in the previous parts of the patchset.
MozReview-Commit-ID: C4BtMYZajpZ
--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -3190,24 +3190,26 @@ public:
// May return INT32_MAX if that was given to the constructor
uint32_t GetOriginalLength() const {
NS_ASSERTION(mLength != INT32_MAX, "Length not known");
return mLength;
}
const nsTextFragment* GetFragment() const { return mFrag; }
gfxFontGroup* GetFontGroup() const {
- if (!mFontGroup)
+ if (!mFontGroup) {
InitFontGroupAndFontMetrics();
+ }
return mFontGroup;
}
nsFontMetrics* GetFontMetrics() const {
- if (!mFontMetrics)
+ if (!mFontMetrics) {
InitFontGroupAndFontMetrics();
+ }
return mFontMetrics;
}
void CalcTabWidths(Range aTransformedRange, gfxFloat aTabWidth) const;
const gfxSkipCharsIterator& GetEndHint() const { return mTempIterator; }
protected:
@@ -3215,46 +3217,46 @@ protected:
void InitFontGroupAndFontMetrics() const {
float inflation = (mWhichTextRun == nsTextFrame::eInflated)
? mFrame->GetFontSizeInflation() : 1.0f;
mFontGroup = GetFontGroupForFrame(mFrame, inflation,
getter_AddRefs(mFontMetrics));
}
- const RefPtr<gfxTextRun> mTextRun;
- mutable gfxFontGroup* mFontGroup;
- mutable RefPtr<nsFontMetrics> mFontMetrics;
- const nsStyleText* mTextStyle;
- const nsTextFragment* mFrag;
- const nsIFrame* mLineContainer;
- const nsTextFrame* mFrame;
- gfxSkipCharsIterator mStart; // Offset in original and transformed string
- const gfxSkipCharsIterator mTempIterator;
+ const RefPtr<gfxTextRun> mTextRun;
+ mutable gfxFontGroup* mFontGroup;
+ mutable RefPtr<nsFontMetrics> mFontMetrics;
+ const nsStyleText* mTextStyle;
+ const nsTextFragment* mFrag;
+ const nsIFrame* mLineContainer;
+ const nsTextFrame* mFrame;
+ gfxSkipCharsIterator mStart; // Offset in original and transformed string
+ const gfxSkipCharsIterator mTempIterator;
// Either null, or pointing to the frame's TabWidthProperty.
- mutable TabWidthStore* mTabWidths;
+ mutable TabWidthStore* mTabWidths;
// How far we've done tab-width calculation; this is ONLY valid when
// mTabWidths is nullptr (otherwise rely on mTabWidths->mLimit instead).
// It's a DOM offset relative to the current frame's offset.
- mutable uint32_t mTabWidthsAnalyzedLimit;
-
- int32_t mLength; // DOM string length, may be INT32_MAX
- const gfxFloat mWordSpacing; // space for each whitespace char
- const gfxFloat mLetterSpacing; // space for each letter
- mutable gfxFloat mHyphenWidth;
- mutable gfxFloat mOffsetFromBlockOriginForTabs;
+ mutable uint32_t mTabWidthsAnalyzedLimit;
+
+ int32_t mLength; // DOM string length, may be INT32_MAX
+ const gfxFloat mWordSpacing; // space for each whitespace char
+ const gfxFloat mLetterSpacing; // space for each letter
+ mutable gfxFloat mHyphenWidth;
+ mutable gfxFloat mOffsetFromBlockOriginForTabs;
// The values in mJustificationSpacings corresponds to unskipped
// characters start from mJustificationArrayStart.
- uint32_t mJustificationArrayStart;
- nsTArray<Spacing> mJustificationSpacings;
-
- const bool mReflowing;
- const nsTextFrame::TextRunType mWhichTextRun;
+ uint32_t mJustificationArrayStart;
+ nsTArray<Spacing> mJustificationSpacings;
+
+ const bool mReflowing;
+ const nsTextFrame::TextRunType mWhichTextRun;
};
/**
* Finds the offset of the first character of the cluster containing aPos
*/
static void FindClusterStart(const gfxTextRun* aTextRun,
int32_t aOriginalStart,
gfxSkipCharsIterator* aPos)
@@ -3694,18 +3696,19 @@ PropertyProvider::InitializeForMeasure()
}
void
PropertyProvider::SetupJustificationSpacing(bool aPostReflow)
{
NS_PRECONDITION(mLength != INT32_MAX, "Can't call this with undefined length");
- if (!(mFrame->GetStateBits() & TEXT_JUSTIFICATION_ENABLED))
+ if (!(mFrame->GetStateBits() & TEXT_JUSTIFICATION_ENABLED)) {
return;
+ }
gfxSkipCharsIterator start(mStart), end(mStart);
// We can't just use our mLength here; when InitializeForDisplay is
// called with false for aTrimAfter, we still shouldn't be assigning
// justification space to any trailing whitespace.
nsTextFrame::TrimmedOffsets trimmed =
mFrame->GetTrimmedOffsets(mFrag, true, aPostReflow);
end.AdvanceOriginal(trimmed.mLength);