--- a/layout/generic/nsTextFrame.cpp
+++ b/layout/generic/nsTextFrame.cpp
@@ -781,17 +781,17 @@ static bool IsSpaceCombiningSequenceTail
return false;
return nsTextFrameUtils::IsSpaceCombiningSequenceTail(
aFrag->Get2b() + aPos, aFrag->GetLength() - aPos);
}
// Check whether aPos is a space for CSS 'word-spacing' purposes
static bool
IsCSSWordSpacingSpace(const nsTextFragment* aFrag, uint32_t aPos,
- nsTextFrame* aFrame, const nsStyleText* aStyleText)
+ const nsTextFrame* aFrame, const nsStyleText* aStyleText)
{
NS_ASSERTION(aPos < aFrag->GetLength(), "No text for IsSpace!");
char16_t ch = aFrag->CharAt(aPos);
switch (ch) {
case ' ':
case CH_NBSP:
return !IsSpaceCombiningSequenceTail(aFrag, aPos + 1);
@@ -1961,17 +1961,17 @@ BuildTextRunsScanner::GetNextBreakBefore
uint32_t index = *aIndex;
if (index >= mLineBreakBeforeFrames.Length())
return nullptr;
*aIndex = index + 1;
return static_cast<nsTextFrame*>(mLineBreakBeforeFrames.ElementAt(index));
}
static gfxFontGroup*
-GetFontGroupForFrame(nsIFrame* aFrame, float aFontSizeInflation,
+GetFontGroupForFrame(const nsIFrame* aFrame, float aFontSizeInflation,
nsFontMetrics** aOutFontMetrics = nullptr)
{
RefPtr<nsFontMetrics> metrics =
nsLayoutUtils::GetFontMetricsForFrame(aFrame, aFontSizeInflation);
gfxFontGroup* fontGroup = metrics->GetThebesFontGroup();
// Populate outparam before we return:
if (aOutFontMetrics) {
@@ -1980,17 +1980,17 @@ GetFontGroupForFrame(nsIFrame* aFrame, f
// XXX this is a bit bogus, we're releasing 'metrics' so the
// returned font-group might actually be torn down, although because
// of the way the device context caches font metrics, this seems to
// not actually happen. But we should fix this.
return fontGroup;
}
static already_AddRefed<DrawTarget>
-CreateReferenceDrawTarget(nsTextFrame* aTextFrame)
+CreateReferenceDrawTarget(const nsTextFrame* aTextFrame)
{
RefPtr<gfxContext> ctx =
aTextFrame->PresContext()->PresShell()->CreateReferenceRenderingContext();
RefPtr<DrawTarget> dt = ctx->GetDrawTarget();
return dt.forget();
}
static already_AddRefed<gfxTextRun>
@@ -2917,17 +2917,17 @@ GetEndOfTrimmedText(const nsTextFragment
if (!IsTrimmableSpace(aFrag, aIterator->GetOriginalOffset(), aStyleText))
return aIterator->GetSkippedOffset() + 1;
}
return aStart;
}
nsTextFrame::TrimmedOffsets
nsTextFrame::GetTrimmedOffsets(const nsTextFragment* aFrag,
- bool aTrimAfter, bool aPostReflow)
+ bool aTrimAfter, bool aPostReflow) const
{
NS_ASSERTION(mTextRun, "Need textrun here");
if (aPostReflow) {
// This should not be used during reflow. We need our TEXT_REFLOW_FLAGS
// to be set correctly. If our parent wasn't reflowed due to the frame
// tree being too deep then the return value doesn't matter.
NS_ASSERTION(!(GetStateBits() & NS_FRAME_FIRST_REFLOW) ||
(GetParent()->GetStateBits() &
@@ -3059,17 +3059,17 @@ static int32_t FindChar(const nsTextFrag
const void* p = memchr(str, ch, aLength);
if (p)
return (static_cast<const char*>(p) - str) + aOffset;
}
}
return -1;
}
-static bool IsChineseOrJapanese(nsTextFrame* aFrame)
+static bool IsChineseOrJapanese(const nsTextFrame* aFrame)
{
if (aFrame->ShouldSuppressLineBreak()) {
// Always treat ruby as CJ language so that those characters can
// be expanded properly even when surrounded by other language.
return true;
}
nsIAtom* language = aFrame->StyleFont()->mLanguage;
@@ -3177,17 +3177,17 @@ public:
/**
* Compute the justification information in given DOM range, return
* justification info and assignments if requested.
*/
JustificationInfo ComputeJustification(
Range aRange, nsTArray<JustificationAssignment>* aAssignments = nullptr);
- nsTextFrame* GetFrame() const { return mFrame; }
+ const nsTextFrame* GetFrame() const { return mFrame; }
// This may not be equal to the frame offset/length in because we may have
// adjusted for whitespace trimming according to the state bits set in the frame
// (for the static provider)
const gfxSkipCharsIterator& GetStart() const { return mStart; }
// 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;
@@ -3215,46 +3215,46 @@ protected:
void InitFontGroupAndFontMetrics() const {
float inflation = (mWhichTextRun == nsTextFrame::eInflated)
? mFrame->GetFontSizeInflation() : 1.0f;
mFontGroup = GetFontGroupForFrame(mFrame, inflation,
getter_AddRefs(mFontMetrics));
}
- RefPtr<gfxTextRun> mTextRun;
+ const RefPtr<gfxTextRun> mTextRun;
mutable gfxFontGroup* mFontGroup;
mutable RefPtr<nsFontMetrics> mFontMetrics;
const nsStyleText* mTextStyle;
const nsTextFragment* mFrag;
- nsIFrame* mLineContainer;
- nsTextFrame* mFrame;
+ const nsIFrame* mLineContainer;
+ const nsTextFrame* mFrame;
gfxSkipCharsIterator mStart; // Offset in original and transformed string
- gfxSkipCharsIterator mTempIterator;
+ const gfxSkipCharsIterator mTempIterator;
// Either null, or pointing to the frame's TabWidthProperty.
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
- gfxFloat mWordSpacing; // space for each whitespace char
- gfxFloat mLetterSpacing; // space for each letter
+ 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;
- bool mReflowing;
- nsTextFrame::TextRunType mWhichTextRun;
+ 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)
@@ -3388,17 +3388,17 @@ CanAddSpacingAfter(const gfxTextRun* aTe
{
if (aOffset + 1 >= aTextRun->GetLength())
return true;
return aTextRun->IsClusterStart(aOffset + 1) &&
aTextRun->IsLigatureGroupStart(aOffset + 1);
}
static gfxFloat
-ComputeTabWidthAppUnits(nsIFrame* aFrame, gfxTextRun* aTextRun)
+ComputeTabWidthAppUnits(const nsIFrame* aFrame, gfxTextRun* aTextRun)
{
const nsStyleText* textStyle = aFrame->StyleText();
if (textStyle->mTabSize.GetUnit() != eStyleUnit_Factor) {
nscoord w = textStyle->mTabSize.GetCoordValue();
MOZ_ASSERT(w >= 0);
return w;
}
@@ -3490,18 +3490,17 @@ PropertyProvider::GetSpacingInternal(Ran
aSpacing[offset].mBefore += spacing.mBefore;
aSpacing[offset].mAfter += spacing.mAfter;
}
}
}
// aX and the result are in whole appunits.
static gfxFloat
-AdvanceToNextTab(gfxFloat aX, nsIFrame* aFrame,
- gfxTextRun* aTextRun, gfxFloat aTabWidth)
+AdvanceToNextTab(gfxFloat aX, gfxFloat aTabWidth)
{
// Advance aX to the next multiple of *aCachedTabWidth. We must advance
// by at least 1 appunit.
// XXX should we make this 1 CSS pixel?
return ceil((aX + 1) / aTabWidth) * aTabWidth;
}
@@ -3560,17 +3559,17 @@ PropertyProvider::CalcTabWidths(Range aR
mTextRun->GetAdvanceWidth(Range(i, clusterEnd), nullptr);
}
} else {
if (!mTabWidths) {
mTabWidths = new TabWidthStore(mFrame->GetContentOffset());
mFrame->Properties().Set(TabWidthProperty(), mTabWidths);
}
double nextTab = AdvanceToNextTab(mOffsetFromBlockOriginForTabs,
- mFrame, mTextRun, aTabWidth);
+ aTabWidth);
mTabWidths->mWidths.AppendElement(TabWidth(i - startOffset,
NSToIntRound(nextTab - mOffsetFromBlockOriginForTabs)));
mOffsetFromBlockOriginForTabs = nextTab;
}
mOffsetFromBlockOriginForTabs += spacing.mAfter;
}
@@ -8468,17 +8467,17 @@ nsTextFrame::AddInlineMinISizeForFlow(ns
if (preformattedTab) {
PropertyProvider::Spacing spacing;
provider.GetSpacing(Range(i, i + 1), &spacing);
aData->mCurrentLine += nscoord(spacing.mBefore);
if (tabWidth < 0) {
tabWidth = ComputeTabWidthAppUnits(this, textRun);
}
gfxFloat afterTab =
- AdvanceToNextTab(aData->mCurrentLine, this, textRun, tabWidth);
+ AdvanceToNextTab(aData->mCurrentLine, tabWidth);
aData->mCurrentLine = nscoord(afterTab + spacing.mAfter);
wordStart = i + 1;
} else if (i < flowEndInTextRun ||
(i == textRun->GetLength() &&
(textRun->GetFlags() & nsTextFrameUtils::TEXT_HAS_TRAILING_BREAK))) {
if (preformattedNewline) {
aData->ForceBreak();
} else if (i < flowEndInTextRun && hyphenating &&
@@ -8631,17 +8630,17 @@ nsTextFrame::AddInlinePrefISizeForFlow(n
if (preformattedTab) {
PropertyProvider::Spacing spacing;
provider.GetSpacing(Range(i, i + 1), &spacing);
aData->mCurrentLine += nscoord(spacing.mBefore);
if (tabWidth < 0) {
tabWidth = ComputeTabWidthAppUnits(this, textRun);
}
gfxFloat afterTab =
- AdvanceToNextTab(aData->mCurrentLine, this, textRun, tabWidth);
+ AdvanceToNextTab(aData->mCurrentLine, tabWidth);
aData->mCurrentLine = nscoord(afterTab + spacing.mAfter);
aData->mLineIsEmpty = false;
lineStart = i + 1;
} else if (preformattedNewline) {
aData->ForceBreak();
lineStart = i;
}
}
--- a/layout/generic/nsTextFrame.h
+++ b/layout/generic/nsTextFrame.h
@@ -636,17 +636,17 @@ public:
struct TrimmedOffsets
{
int32_t mStart;
int32_t mLength;
int32_t GetEnd() const { return mStart + mLength; }
};
TrimmedOffsets GetTrimmedOffsets(const nsTextFragment* aFrag,
bool aTrimAfter,
- bool aPostReflow = true);
+ bool aPostReflow = true) const;
// Similar to Reflow(), but for use from nsLineLayout
void ReflowText(nsLineLayout& aLineLayout,
nscoord aAvailableWidth,
DrawTarget* aDrawTarget,
ReflowOutput& aMetrics,
nsReflowStatus& aStatus);