From 36c5e3637e8f37676b4ec8db5c8d19f666b43ebf Mon Sep 17 00:00:00 2001 From: Jonathan Kew Date: Thu, 1 Jan 2009 16:34:13 +0330 Subject: [PATCH] Bug 470418 - Leak nsStyleContext with RTL, text-transform; r,sr=roc --- gfx/thebes/public/gfxTextRunWordCache.h | 10 +++++++++- layout/generic/nsTextFrameThebes.cpp | 8 ++++---- layout/generic/nsTextFrameUtils.h | 9 ++++++--- 3 files changed, 19 insertions(+), 8 deletions(-) diff --git a/gfx/thebes/public/gfxTextRunWordCache.h b/gfx/thebes/public/gfxTextRunWordCache.h index 9375192f6bb..8a712f693e1 100644 --- a/gfx/thebes/public/gfxTextRunWordCache.h +++ b/gfx/thebes/public/gfxTextRunWordCache.h @@ -20,6 +20,8 @@ * * Contributor(s): * Vladimir Vukicevic + * Ehsan Akhgari + * Jonathan Kew * * Alternatively, the contents of this file may be used under the terms of * either the GNU General Public License Version 2 or later (the "GPL"), or @@ -48,12 +50,18 @@ class THEBES_API gfxTextRunWordCache { public: enum { TEXT_IN_CACHE = 0x10000000, + + /** + * nsTextFrameThebes sets these, but they're defined here rather than in + * nsTextFrameUtils.h because the cache also needs to check the _INCOMING flag + */ + TEXT_TRAILING_ARABICCHAR = 0x20000000, /** * When set, the previous character for this textrun was an Arabic * character. This is used for the context detection necessary for * bidi.numeral implementation. */ - TEXT_INCOMING_ARABICCHAR = 0x10000000 + TEXT_INCOMING_ARABICCHAR = 0x40000000 }; /** diff --git a/layout/generic/nsTextFrameThebes.cpp b/layout/generic/nsTextFrameThebes.cpp index bff14f371c0..85559e6fc87 100644 --- a/layout/generic/nsTextFrameThebes.cpp +++ b/layout/generic/nsTextFrameThebes.cpp @@ -1136,7 +1136,7 @@ void BuildTextRunsScanner::FlushFrames(PRBool aFlushLineBreaks, PRBool aSuppress if (!mSkipIncompleteTextRuns && mCurrentFramesAllSameTextRun && ((mCurrentFramesAllSameTextRun->GetFlags() & nsTextFrameUtils::TEXT_INCOMING_WHITESPACE) != 0) == ((mCurrentRunContextInfo & nsTextFrameUtils::INCOMING_WHITESPACE) != 0) && - ((mCurrentFramesAllSameTextRun->GetFlags() & nsTextFrameUtils::TEXT_INCOMING_ARABICCHAR) != 0) == + ((mCurrentFramesAllSameTextRun->GetFlags() & gfxTextRunWordCache::TEXT_INCOMING_ARABICCHAR) != 0) == ((mCurrentRunContextInfo & nsTextFrameUtils::INCOMING_ARABICCHAR) != 0) && IsTextRunValidForMappedFlows(mCurrentFramesAllSameTextRun)) { // Optimization: We do not need to (re)build the textrun. @@ -1149,7 +1149,7 @@ void BuildTextRunsScanner::FlushFrames(PRBool aFlushLineBreaks, PRBool aSuppress if (textRun->GetFlags() & nsTextFrameUtils::TEXT_TRAILING_WHITESPACE) { mNextRunContextInfo |= nsTextFrameUtils::INCOMING_WHITESPACE; } - if (textRun->GetFlags() & nsTextFrameUtils::TEXT_TRAILING_ARABICCHAR) { + if (textRun->GetFlags() & gfxTextRunWordCache::TEXT_TRAILING_ARABICCHAR) { mNextRunContextInfo |= nsTextFrameUtils::INCOMING_ARABICCHAR; } } else { @@ -1485,7 +1485,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer) textFlags |= nsTextFrameUtils::TEXT_INCOMING_WHITESPACE; } if (mCurrentRunContextInfo & nsTextFrameUtils::INCOMING_ARABICCHAR) { - textFlags |= nsTextFrameUtils::TEXT_INCOMING_ARABICCHAR; + textFlags |= gfxTextRunWordCache::TEXT_INCOMING_ARABICCHAR; } nsAutoTArray textBreakPoints; @@ -1658,7 +1658,7 @@ BuildTextRunsScanner::BuildTextRunForFrames(void* aTextBuffer) textFlags |= nsTextFrameUtils::TEXT_TRAILING_WHITESPACE; } if (mNextRunContextInfo & nsTextFrameUtils::INCOMING_ARABICCHAR) { - textFlags |= nsTextFrameUtils::TEXT_TRAILING_ARABICCHAR; + textFlags |= gfxTextRunWordCache::TEXT_TRAILING_ARABICCHAR; } // ContinueTextRunAcrossFrames guarantees that it doesn't matter which // frame's style is used, so use the last frame's diff --git a/layout/generic/nsTextFrameUtils.h b/layout/generic/nsTextFrameUtils.h index 1d8905e8d08..92b8bb7b5e6 100644 --- a/layout/generic/nsTextFrameUtils.h +++ b/layout/generic/nsTextFrameUtils.h @@ -79,9 +79,12 @@ public: // We normally don't use this break opportunity because the following text // will have a break opportunity at the start, but it's useful for line // layout to know about it in case the following content is not text - TEXT_HAS_TRAILING_BREAK = 0x4000000, - TEXT_TRAILING_ARABICCHAR = 0x8000000, - TEXT_INCOMING_ARABICCHAR = 0x10000000 + TEXT_HAS_TRAILING_BREAK = 0x4000000 + + // The following are defined by gfxTextRunWordCache rather than here, + // so that it also has access to the _INCOMING flag + // TEXT_TRAILING_ARABICCHAR + // TEXT_INCOMING_ARABICCHAR }; // These constants are used in TransformText to represent context information