Bug 1169088 - Remove unused nsBidiPresUtils methods. r=dbaron

These were used only in nsSVGGlyphFrame which was removed in bug 889736.
This commit is contained in:
Matt Brubeck 2015-05-27 19:06:33 -07:00
parent a75105bac9
commit 9c9ab9548c
2 changed files with 0 additions and 147 deletions

View File

@ -2250,125 +2250,6 @@ nsresult nsBidiPresUtils::ProcessTextForRenderingContext(const char16_t* a
aMode, aPosResolve, aPosResolveCount, aWidth, &bidiEngine);
}
/* static */
void nsBidiPresUtils::WriteReverse(const char16_t* aSrc,
uint32_t aSrcLength,
char16_t* aDest)
{
char16_t* dest = aDest + aSrcLength;
mozilla::unicode::ClusterIterator iter(aSrc, aSrcLength);
while (!iter.AtEnd()) {
iter.Next();
for (const char16_t *cp = iter; cp > aSrc; ) {
// Here we rely on the fact that there are no non-BMP mirrored pairs
// currently in Unicode, so we don't need to look for surrogates
*--dest = mozilla::unicode::GetMirroredChar(*--cp);
}
aSrc = iter;
}
NS_ASSERTION(dest == aDest, "Whole string not copied");
}
/* static */
bool nsBidiPresUtils::WriteLogicalToVisual(const char16_t* aSrc,
uint32_t aSrcLength,
char16_t* aDest,
nsBidiLevel aBaseDirection,
nsBidi* aBidiEngine)
{
const char16_t* src = aSrc;
nsresult rv = aBidiEngine->SetPara(src, aSrcLength, aBaseDirection, nullptr);
if (NS_FAILED(rv)) {
return false;
}
nsBidiDirection dir;
rv = aBidiEngine->GetDirection(&dir);
// NSBIDI_LTR returned from GetDirection means the whole text is LTR
if (NS_FAILED(rv) || dir == NSBIDI_LTR) {
return false;
}
int32_t runCount;
rv = aBidiEngine->CountRuns(&runCount);
if (NS_FAILED(rv)) {
return false;
}
int32_t runIndex, start, length;
char16_t* dest = aDest;
for (runIndex = 0; runIndex < runCount; ++runIndex) {
rv = aBidiEngine->GetVisualRun(runIndex, &start, &length, &dir);
if (NS_FAILED(rv)) {
return false;
}
src = aSrc + start;
if (dir == NSBIDI_RTL) {
WriteReverse(src, length, dest);
dest += length;
} else {
do {
NS_ASSERTION(src >= aSrc && src < aSrc + aSrcLength,
"logical index out of range");
NS_ASSERTION(dest < aDest + aSrcLength, "visual index out of range");
*(dest++) = *(src++);
} while (--length);
}
}
NS_ASSERTION(static_cast<uint32_t>(dest - aDest) == aSrcLength,
"whole string not copied");
return true;
}
void nsBidiPresUtils::CopyLogicalToVisual(const nsAString& aSource,
nsAString& aDest,
nsBidiLevel aBaseDirection,
bool aOverride)
{
aDest.SetLength(0);
uint32_t srcLength = aSource.Length();
if (srcLength == 0)
return;
if (!aDest.SetLength(srcLength, fallible)) {
return;
}
nsAString::const_iterator fromBegin, fromEnd;
nsAString::iterator toBegin;
aSource.BeginReading(fromBegin);
aSource.EndReading(fromEnd);
aDest.BeginWriting(toBegin);
if (aOverride) {
if (aBaseDirection == NSBIDI_RTL) {
// no need to use the converter -- just copy the string in reverse order
WriteReverse(fromBegin.get(), srcLength, toBegin.get());
} else {
// if aOverride && aBaseDirection == NSBIDI_LTR, fall through to the
// simple copy
aDest.SetLength(0);
}
} else {
nsBidi bidiEngine;
if (!WriteLogicalToVisual(fromBegin.get(), srcLength, toBegin.get(),
aBaseDirection, &bidiEngine)) {
aDest.SetLength(0);
}
}
if (aDest.IsEmpty()) {
// Either there was an error or the source is unidirectional
// left-to-right. In either case, just copy source to dest.
CopyUnicodeTo(aSource.BeginReading(fromBegin), aSource.EndReading(fromEnd),
aDest);
}
}
/* static */
nsBidiLevel
nsBidiPresUtils::BidiLevelFromStyle(nsStyleContext* aStyleContext)

View File

@ -354,24 +354,6 @@ public:
nscoord* aWidth,
nsBidi* aBidiEngine);
/**
* Make a copy of a string, converting from logical to visual order
*
* @param aSource the source string
* @param aDest the destination string
* @param aBaseDirection the base direction of the string
* (NSBIDI_LTR or NSBIDI_RTL to force the base direction;
* NSBIDI_DEFAULT_LTR or NSBIDI_DEFAULT_RTL to let the bidi engine
* determine the direction from rules P2 and P3 of the bidi algorithm.
* @see nsBidi::GetPara
* @param aOverride if TRUE, the text has a bidi override, according to
* the direction in aDir
*/
static void CopyLogicalToVisual(const nsAString& aSource,
nsAString& aDest,
nsBidiLevel aBaseDirection,
bool aOverride);
/**
* Use style attributes to determine the base paragraph level to pass to the
* bidi algorithm.
@ -557,16 +539,6 @@ private:
static void StripBidiControlCharacters(char16_t* aText,
int32_t& aTextLength);
static bool WriteLogicalToVisual(const char16_t* aSrc,
uint32_t aSrcLength,
char16_t* aDest,
nsBidiLevel aBaseDirection,
nsBidi* aBidiEngine);
static void WriteReverse(const char16_t* aSrc,
uint32_t aSrcLength,
char16_t* aDest);
};
#endif /* nsBidiPresUtils_h___ */