diff --git a/gfx/thebes/gfxTextRun.cpp b/gfx/thebes/gfxTextRun.cpp index 691014e93399..e199f8f34a33 100644 --- a/gfx/thebes/gfxTextRun.cpp +++ b/gfx/thebes/gfxTextRun.cpp @@ -2573,10 +2573,13 @@ gfxFontGroup::InitScriptRun(gfxContext *aContext, } gfxTextRun * -gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, +gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags, LazyReferenceContextGetter& aRefContextGetter) { + MOZ_ASSERT(!(aFlags & ~TEXT_ORIENT_MASK), + "flags here should only be used to specify orientation"); if (mCachedEllipsisTextRun && + (mCachedEllipsisTextRun->GetFlags() & TEXT_ORIENT_MASK) == aFlags && mCachedEllipsisTextRun->GetAppUnitsPerDevUnit() == aAppUnitsPerDevPixel) { return mCachedEllipsisTextRun; } @@ -2596,7 +2599,7 @@ gfxFontGroup::GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, }; gfxTextRun* textRun = MakeTextRun(ellipsis.get(), ellipsis.Length(), ¶ms, - TEXT_IS_PERSISTENT, nullptr); + aFlags | TEXT_IS_PERSISTENT, nullptr); if (!textRun) { return nullptr; } diff --git a/gfx/thebes/gfxTextRun.h b/gfx/thebes/gfxTextRun.h index afc0e1e7938e..a5cf38f4c459 100644 --- a/gfx/thebes/gfxTextRun.h +++ b/gfx/thebes/gfxTextRun.h @@ -878,10 +878,10 @@ public: }; // The gfxFontGroup keeps ownership of this textrun. // It is only guaranteed to exist until the next call to GetEllipsisTextRun - // (which might use a different appUnitsPerDev value) for the font group, - // or until UpdateUserFonts is called, or the fontgroup is destroyed. + // (which might use a different appUnitsPerDev value or flags) for the font + // group, or until UpdateUserFonts is called, or the fontgroup is destroyed. // Get it/use it/forget it :) - don't keep a reference that might go stale. - gfxTextRun* GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, + gfxTextRun* GetEllipsisTextRun(int32_t aAppUnitsPerDevPixel, uint32_t aFlags, LazyReferenceContextGetter& aRefContextGetter); // helper method for resolving generic font families @@ -1042,7 +1042,7 @@ protected: gfxTextPerfMetrics *mTextPerf; // Cache a textrun representing an ellipsis (useful for CSS text-overflow) - // at a specific appUnitsPerDevPixel size + // at a specific appUnitsPerDevPixel size and orientation nsAutoPtr mCachedEllipsisTextRun; // cache the most recent pref font to avoid general pref font lookup diff --git a/layout/base/nsLayoutUtils.cpp b/layout/base/nsLayoutUtils.cpp index 5a63d09e29ce..2e293e3775a3 100644 --- a/layout/base/nsLayoutUtils.cpp +++ b/layout/base/nsLayoutUtils.cpp @@ -6472,42 +6472,42 @@ nsLayoutUtils::GetTextRunFlagsForStyle(nsStyleContext* aStyleContext, default: break; } + return result | GetTextRunOrientFlagsForStyle(aStyleContext); +} + +/* static */ uint32_t +nsLayoutUtils::GetTextRunOrientFlagsForStyle(nsStyleContext* aStyleContext) +{ WritingMode wm(aStyleContext); if (wm.IsVertical()) { switch (aStyleContext->StyleVisibility()->mTextOrientation) { case NS_STYLE_TEXT_ORIENTATION_MIXED: - result |= gfxTextRunFactory::TEXT_ORIENT_VERTICAL_MIXED; - break; + return gfxTextRunFactory::TEXT_ORIENT_VERTICAL_MIXED; case NS_STYLE_TEXT_ORIENTATION_UPRIGHT: - result |= gfxTextRunFactory::TEXT_ORIENT_VERTICAL_UPRIGHT; - break; + return gfxTextRunFactory::TEXT_ORIENT_VERTICAL_UPRIGHT; case NS_STYLE_TEXT_ORIENTATION_SIDEWAYS: // This should depend on writing mode vertical-lr vs vertical-rl, // but until we support SIDEWAYS_LEFT, we'll treat this the same // as SIDEWAYS_RIGHT and simply fall through. /* if (wm.IsVerticalLR()) { - result |= gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT; + return gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT; } else { - result |= gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT; + return gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT; } - break; */ case NS_STYLE_TEXT_ORIENTATION_SIDEWAYS_RIGHT: - result |= gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT; - break; + return gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_RIGHT; case NS_STYLE_TEXT_ORIENTATION_SIDEWAYS_LEFT: // Not yet supported, so fall through to the default (error) case. /* - result |= gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT; - break; + return gfxTextRunFactory::TEXT_ORIENT_VERTICAL_SIDEWAYS_LEFT; */ default: NS_NOTREACHED("unknown text-orientation"); - break; } } - return result; + return 0; } /* static */ void diff --git a/layout/base/nsLayoutUtils.h b/layout/base/nsLayoutUtils.h index 2653455c048a..8a5df1164698 100644 --- a/layout/base/nsLayoutUtils.h +++ b/layout/base/nsLayoutUtils.h @@ -1923,6 +1923,11 @@ public: const nsStyleText* aStyleText, nscoord aLetterSpacing); + /** + * Get orientation flags for textrun construction. + */ + static uint32_t GetTextRunOrientFlagsForStyle(nsStyleContext* aStyleContext); + /** * Takes two rectangles whose origins must be the same, and computes * the difference between their union and their intersection as two diff --git a/layout/generic/TextOverflow.cpp b/layout/generic/TextOverflow.cpp index 39f814c4a425..a71719c7dbdd 100644 --- a/layout/generic/TextOverflow.cpp +++ b/layout/generic/TextOverflow.cpp @@ -49,7 +49,9 @@ GetEllipsisTextRun(nsIFrame* aFrame) nsLayoutUtils::FontSizeInflationFor(aFrame)); LazyReferenceRenderingContextGetterFromFrame lazyRefContextGetter(aFrame); return fm->GetThebesFontGroup()->GetEllipsisTextRun( - aFrame->PresContext()->AppUnitsPerDevPixel(), lazyRefContextGetter); + aFrame->PresContext()->AppUnitsPerDevPixel(), + nsLayoutUtils::GetTextRunOrientFlagsForStyle(aFrame->StyleContext()), + lazyRefContextGetter); } static nsIFrame*