diff --git a/layout/generic/nsFrameStateBits.h b/layout/generic/nsFrameStateBits.h index 61c0b6662959..c04aafc1c282 100644 --- a/layout/generic/nsFrameStateBits.h +++ b/layout/generic/nsFrameStateBits.h @@ -408,6 +408,9 @@ FRAME_STATE_BIT(Text, 60, TEXT_IN_UNINFLATED_TEXTRUN_USER_DATA) FRAME_STATE_BIT(Text, 61, TEXT_HAS_FONT_INFLATION) +// Set when this text frame contains nothing that will actually render +FRAME_STATE_BIT(Text, 62, TEXT_NO_RENDERED_GLYPHS) + // Whether this frame is cached in the Offset Frame Cache // (OffsetToFrameProperty) FRAME_STATE_BIT(Text, 63, TEXT_IN_OFFSET_CACHE) diff --git a/layout/generic/nsTextFrame.cpp b/layout/generic/nsTextFrame.cpp index 7930aab35657..f6953c6d32d9 100644 --- a/layout/generic/nsTextFrame.cpp +++ b/layout/generic/nsTextFrame.cpp @@ -200,13 +200,20 @@ static void DestroyGlyphObserverList(void* aPropertyValue) */ NS_DECLARE_FRAME_PROPERTY(TextFrameGlyphObservers, DestroyGlyphObserverList); -#define TEXT_REFLOW_FLAGS \ - (TEXT_FIRST_LETTER|TEXT_START_OF_LINE|TEXT_END_OF_LINE|TEXT_HYPHEN_BREAK| \ - TEXT_TRIMMED_TRAILING_WHITESPACE|TEXT_JUSTIFICATION_ENABLED| \ - TEXT_HAS_NONCOLLAPSED_CHARACTERS|TEXT_SELECTION_UNDERLINE_OVERFLOWED) +static const nsFrameState TEXT_REFLOW_FLAGS = + TEXT_FIRST_LETTER | + TEXT_START_OF_LINE | + TEXT_END_OF_LINE | + TEXT_HYPHEN_BREAK | + TEXT_TRIMMED_TRAILING_WHITESPACE | + TEXT_JUSTIFICATION_ENABLED | + TEXT_HAS_NONCOLLAPSED_CHARACTERS | + TEXT_SELECTION_UNDERLINE_OVERFLOWED | + TEXT_NO_RENDERED_GLYPHS; -#define TEXT_WHITESPACE_FLAGS (TEXT_IS_ONLY_WHITESPACE | \ - TEXT_ISNOT_ONLY_WHITESPACE) +static const nsFrameState TEXT_WHITESPACE_FLAGS = + TEXT_IS_ONLY_WHITESPACE | + TEXT_ISNOT_ONLY_WHITESPACE; /* * Some general notes @@ -2742,6 +2749,8 @@ nsTextFrame::ClearMetrics(nsHTMLReflowMetrics& aMetrics) aMetrics.ClearSize(); aMetrics.SetBlockStartAscent(0); mAscent = 0; + + AddStateBits(TEXT_NO_RENDERED_GLYPHS); } static int32_t FindChar(const nsTextFragment* frag, @@ -4650,8 +4659,9 @@ nsTextFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder, DO_GLOBAL_REFLOW_COUNT_DSP("nsTextFrame"); - if (NS_GET_A(StyleColor()->mColor) == 0 && - !IsSVGText() && !IsSelected() && !StyleText()->HasTextShadow()) { + if (((GetStateBits() & TEXT_NO_RENDERED_GLYPHS) || + (NS_GET_A(StyleColor()->mColor) == 0 && !StyleText()->HasTextShadow())) && + aBuilder->IsForPainting() && !IsSVGText() && !IsSelected()) { TextDecorations textDecs; GetTextDecorations(PresContext(), eResolvedColors, textDecs); if (!textDecs.HasDecorationLines()) { @@ -8257,7 +8267,7 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, gfxFloat availWidth = aAvailableWidth; bool canTrimTrailingWhitespace = !textStyle->WhiteSpaceIsSignificant() || (GetStateBits() & TEXT_IS_IN_TOKEN_MATHML); - int32_t unusedOffset; + int32_t unusedOffset; gfxBreakPriority breakPriority; aLineLayout.GetLastOptionalBreakPosition(&unusedOffset, &breakPriority); gfxTextRun::SuppressBreak suppressBreak = gfxTextRun::eNoSuppressBreak; @@ -8321,6 +8331,9 @@ nsTextFrame::ReflowText(nsLineLayout& aLineLayout, nscoord aAvailableWidth, AddHyphenToMetrics(this, mTextRun, &textMetrics, boundingBoxType, ctx); AddStateBits(TEXT_HYPHEN_BREAK | TEXT_HAS_NONCOLLAPSED_CHARACTERS); } + if (textMetrics.mBoundingBox.IsEmpty()) { + AddStateBits(TEXT_NO_RENDERED_GLYPHS); + } gfxFloat trimmableWidth = 0; bool brokeText = forceBreak >= 0 || transformedCharsFit < transformedLength;