2007-01-16 23:51:52 +03:00
|
|
|
/* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*-
|
2012-05-21 15:12:37 +04:00
|
|
|
* This Source Code Form is subject to the terms of the Mozilla Public
|
|
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
|
|
|
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
2007-01-16 23:51:52 +03:00
|
|
|
|
|
|
|
#include "nsTextRunTransformations.h"
|
|
|
|
|
2013-06-30 20:26:39 +04:00
|
|
|
#include "mozilla/MemoryReporting.h"
|
2015-02-15 21:45:48 +03:00
|
|
|
#include "mozilla/Move.h"
|
2013-06-30 20:26:39 +04:00
|
|
|
|
2012-03-31 10:08:46 +04:00
|
|
|
#include "nsGkAtoms.h"
|
2007-01-16 23:51:52 +03:00
|
|
|
#include "nsStyleConsts.h"
|
2014-05-26 17:23:31 +04:00
|
|
|
#include "nsUnicharUtils.h"
|
2012-04-15 18:52:47 +04:00
|
|
|
#include "nsUnicodeProperties.h"
|
2012-04-24 21:53:39 +04:00
|
|
|
#include "nsSpecialCasingData.h"
|
2013-10-08 03:15:59 +04:00
|
|
|
#include "mozilla/gfx/2D.h"
|
2013-12-02 20:49:27 +04:00
|
|
|
#include "nsTextFrameUtils.h"
|
|
|
|
#include "nsIPersistentProperties2.h"
|
|
|
|
#include "nsNetUtil.h"
|
2014-06-02 02:17:41 +04:00
|
|
|
#include "GreekCasing.h"
|
2014-06-02 02:18:03 +04:00
|
|
|
#include "IrishCasing.h"
|
2007-01-16 23:51:52 +03:00
|
|
|
|
2015-02-15 21:45:48 +03:00
|
|
|
using namespace mozilla;
|
|
|
|
|
2012-03-27 19:49:03 +04:00
|
|
|
// Unicode characters needing special casing treatment in tr/az languages
|
|
|
|
#define LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE 0x0130
|
|
|
|
#define LATIN_SMALL_LETTER_DOTLESS_I 0x0131
|
|
|
|
|
2012-04-15 18:52:47 +04:00
|
|
|
// Greek sigma needs custom handling for the lowercase transform; for details
|
|
|
|
// see comments under "case NS_STYLE_TEXT_TRANSFORM_LOWERCASE" within
|
|
|
|
// nsCaseTransformTextRunFactory::RebuildTextRun(), and bug 740120.
|
2012-05-03 11:57:18 +04:00
|
|
|
#define GREEK_CAPITAL_LETTER_SIGMA 0x03A3
|
|
|
|
#define GREEK_SMALL_LETTER_FINAL_SIGMA 0x03C2
|
|
|
|
#define GREEK_SMALL_LETTER_SIGMA 0x03C3
|
|
|
|
|
2007-11-16 04:43:47 +03:00
|
|
|
nsTransformedTextRun *
|
|
|
|
nsTransformedTextRun::Create(const gfxTextRunFactory::Parameters* aParams,
|
|
|
|
nsTransformingTextRunFactory* aFactory,
|
|
|
|
gfxFontGroup* aFontGroup,
|
2014-01-04 19:02:17 +04:00
|
|
|
const char16_t* aString, uint32_t aLength,
|
2015-02-10 13:30:25 +03:00
|
|
|
const uint32_t aFlags,
|
|
|
|
nsTArray<nsRefPtr<nsTransformedCharStyle>>&& aStyles,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool aOwnsFactory)
|
2007-11-16 04:43:47 +03:00
|
|
|
{
|
2010-02-18 14:52:34 +03:00
|
|
|
NS_ASSERTION(!(aFlags & gfxTextRunFactory::TEXT_IS_8BIT),
|
|
|
|
"didn't expect text to be marked as 8-bit here");
|
|
|
|
|
2012-01-05 15:54:45 +04:00
|
|
|
void *storage = AllocateStorageForTextRun(sizeof(nsTransformedTextRun), aLength);
|
|
|
|
if (!storage) {
|
2012-07-30 18:20:58 +04:00
|
|
|
return nullptr;
|
2010-02-18 14:52:34 +03:00
|
|
|
}
|
|
|
|
|
2012-01-05 15:54:45 +04:00
|
|
|
return new (storage) nsTransformedTextRun(aParams, aFactory, aFontGroup,
|
|
|
|
aString, aLength,
|
2015-02-10 13:30:25 +03:00
|
|
|
aFlags, Move(aStyles),
|
|
|
|
aOwnsFactory);
|
2007-11-16 04:43:47 +03:00
|
|
|
}
|
|
|
|
|
2007-11-12 04:51:31 +03:00
|
|
|
void
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTransformedTextRun::SetCapitalization(uint32_t aStart, uint32_t aLength,
|
2011-09-29 10:19:26 +04:00
|
|
|
bool* aCapitalization,
|
2007-06-27 08:22:21 +04:00
|
|
|
gfxContext* aRefContext)
|
2007-11-12 04:51:31 +03:00
|
|
|
{
|
|
|
|
if (mCapitalize.IsEmpty()) {
|
|
|
|
if (!mCapitalize.AppendElements(GetLength()))
|
|
|
|
return;
|
2011-09-29 10:19:26 +04:00
|
|
|
memset(mCapitalize.Elements(), 0, GetLength()*sizeof(bool));
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
2011-09-29 10:19:26 +04:00
|
|
|
memcpy(mCapitalize.Elements() + aStart, aCapitalization, aLength*sizeof(bool));
|
2011-10-17 18:59:28 +04:00
|
|
|
mNeedsRebuild = true;
|
2007-11-12 04:51:31 +03:00
|
|
|
}
|
2007-01-16 23:51:52 +03:00
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTransformedTextRun::SetPotentialLineBreaks(uint32_t aStart, uint32_t aLength,
|
|
|
|
uint8_t* aBreakBefore,
|
2007-11-12 04:51:31 +03:00
|
|
|
gfxContext* aRefContext)
|
|
|
|
{
|
2011-09-29 10:19:26 +04:00
|
|
|
bool changed = gfxTextRun::SetPotentialLineBreaks(aStart, aLength,
|
2007-11-12 04:51:31 +03:00
|
|
|
aBreakBefore, aRefContext);
|
2009-01-09 03:23:28 +03:00
|
|
|
if (changed) {
|
2011-10-17 18:59:28 +04:00
|
|
|
mNeedsRebuild = true;
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
2009-01-09 03:23:28 +03:00
|
|
|
return changed;
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
|
|
|
|
2011-11-28 07:03:14 +04:00
|
|
|
size_t
|
2013-06-23 16:03:39 +04:00
|
|
|
nsTransformedTextRun::SizeOfExcludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
2011-10-14 11:06:35 +04:00
|
|
|
{
|
2011-11-28 07:03:14 +04:00
|
|
|
size_t total = gfxTextRun::SizeOfExcludingThis(aMallocSizeOf);
|
2011-12-16 02:59:53 +04:00
|
|
|
total += mStyles.SizeOfExcludingThis(aMallocSizeOf);
|
|
|
|
total += mCapitalize.SizeOfExcludingThis(aMallocSizeOf);
|
2011-10-14 11:06:35 +04:00
|
|
|
if (mOwnsFactory) {
|
2012-01-25 12:52:51 +04:00
|
|
|
total += aMallocSizeOf(mFactory);
|
2011-10-14 11:06:35 +04:00
|
|
|
}
|
|
|
|
return total;
|
|
|
|
}
|
|
|
|
|
2011-11-28 07:03:14 +04:00
|
|
|
size_t
|
2013-06-23 16:03:39 +04:00
|
|
|
nsTransformedTextRun::SizeOfIncludingThis(mozilla::MallocSizeOf aMallocSizeOf)
|
2011-11-28 07:03:14 +04:00
|
|
|
{
|
2012-01-25 12:52:51 +04:00
|
|
|
return aMallocSizeOf(this) + SizeOfExcludingThis(aMallocSizeOf);
|
2011-11-28 07:03:14 +04:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:17:46 +03:00
|
|
|
nsTransformedTextRun*
|
2014-01-04 19:02:17 +04:00
|
|
|
nsTransformingTextRunFactory::MakeTextRun(const char16_t* aString, uint32_t aLength,
|
2007-05-10 02:04:56 +04:00
|
|
|
const gfxTextRunFactory::Parameters* aParams,
|
2012-08-22 19:56:38 +04:00
|
|
|
gfxFontGroup* aFontGroup, uint32_t aFlags,
|
2015-02-10 13:30:25 +03:00
|
|
|
nsTArray<nsRefPtr<nsTransformedCharStyle>>&& aStyles,
|
|
|
|
bool aOwnsFactory)
|
2007-01-16 23:51:52 +03:00
|
|
|
{
|
2009-01-09 03:23:28 +03:00
|
|
|
return nsTransformedTextRun::Create(aParams, this, aFontGroup,
|
2015-02-10 13:30:25 +03:00
|
|
|
aString, aLength, aFlags, Move(aStyles),
|
|
|
|
aOwnsFactory);
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
|
|
|
|
2009-01-16 11:17:46 +03:00
|
|
|
nsTransformedTextRun*
|
2012-08-22 19:56:38 +04:00
|
|
|
nsTransformingTextRunFactory::MakeTextRun(const uint8_t* aString, uint32_t aLength,
|
2007-05-10 02:04:56 +04:00
|
|
|
const gfxTextRunFactory::Parameters* aParams,
|
2012-08-22 19:56:38 +04:00
|
|
|
gfxFontGroup* aFontGroup, uint32_t aFlags,
|
2015-02-10 13:30:25 +03:00
|
|
|
nsTArray<nsRefPtr<nsTransformedCharStyle>>&& aStyles,
|
|
|
|
bool aOwnsFactory)
|
2007-01-16 23:51:52 +03:00
|
|
|
{
|
2007-03-23 02:13:12 +03:00
|
|
|
// We'll only have a Unicode code path to minimize the amount of code needed
|
|
|
|
// for these rarely used features
|
2007-07-08 11:08:04 +04:00
|
|
|
NS_ConvertASCIItoUTF16 unicodeString(reinterpret_cast<const char*>(aString), aLength);
|
2007-05-10 02:04:56 +04:00
|
|
|
return MakeTextRun(unicodeString.get(), aLength, aParams, aFontGroup,
|
|
|
|
aFlags & ~(gfxFontGroup::TEXT_IS_PERSISTENT | gfxFontGroup::TEXT_IS_8BIT),
|
2015-02-10 13:30:25 +03:00
|
|
|
Move(aStyles), aOwnsFactory);
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
|
|
|
|
2013-12-02 20:49:27 +04:00
|
|
|
void
|
2007-03-23 02:13:12 +03:00
|
|
|
MergeCharactersInTextRun(gfxTextRun* aDest, gfxTextRun* aSrc,
|
2012-05-03 11:57:18 +04:00
|
|
|
const bool* aCharsToMerge, const bool* aDeletedChars)
|
2007-01-16 23:51:52 +03:00
|
|
|
{
|
2007-03-23 02:13:12 +03:00
|
|
|
aDest->ResetGlyphRuns();
|
|
|
|
|
2007-11-09 09:27:23 +03:00
|
|
|
gfxTextRun::GlyphRunIterator iter(aSrc, 0, aSrc->GetLength());
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t offset = 0;
|
2007-11-09 09:27:23 +03:00
|
|
|
nsAutoTArray<gfxTextRun::DetailedGlyph,2> glyphs;
|
|
|
|
while (iter.NextRun()) {
|
|
|
|
gfxTextRun::GlyphRun* run = iter.GetGlyphRun();
|
2011-06-16 10:31:37 +04:00
|
|
|
nsresult rv = aDest->AddGlyphRun(run->mFont, run->mMatchType,
|
2014-09-16 15:25:45 +04:00
|
|
|
offset, false, run->mOrientation);
|
2007-03-23 02:13:12 +03:00
|
|
|
if (NS_FAILED(rv))
|
|
|
|
return;
|
|
|
|
|
2011-09-29 10:19:26 +04:00
|
|
|
bool anyMissing = false;
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t mergeRunStart = iter.GetStringStart();
|
2012-04-24 21:53:39 +04:00
|
|
|
const gfxTextRun::CompressedGlyph *srcGlyphs = aSrc->GetCharacterGlyphs();
|
|
|
|
gfxTextRun::CompressedGlyph mergedGlyph = srcGlyphs[mergeRunStart];
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t stringEnd = iter.GetStringEnd();
|
|
|
|
for (uint32_t k = iter.GetStringStart(); k < stringEnd; ++k) {
|
2012-04-24 21:53:39 +04:00
|
|
|
const gfxTextRun::CompressedGlyph g = srcGlyphs[k];
|
2007-11-09 09:27:23 +03:00
|
|
|
if (g.IsSimpleGlyph()) {
|
|
|
|
if (!anyMissing) {
|
|
|
|
gfxTextRun::DetailedGlyph details;
|
|
|
|
details.mGlyphID = g.GetSimpleGlyph();
|
|
|
|
details.mAdvance = g.GetSimpleAdvance();
|
|
|
|
details.mXOffset = 0;
|
|
|
|
details.mYOffset = 0;
|
|
|
|
glyphs.AppendElement(details);
|
2007-11-08 10:41:06 +03:00
|
|
|
}
|
2007-11-09 09:27:23 +03:00
|
|
|
} else {
|
|
|
|
if (g.IsMissing()) {
|
2011-10-17 18:59:28 +04:00
|
|
|
anyMissing = true;
|
2007-11-09 09:27:23 +03:00
|
|
|
glyphs.Clear();
|
2007-11-08 10:41:06 +03:00
|
|
|
}
|
2011-02-12 01:05:09 +03:00
|
|
|
if (g.GetGlyphCount() > 0) {
|
|
|
|
glyphs.AppendElements(aSrc->GetDetailedGlyphs(k), g.GetGlyphCount());
|
|
|
|
}
|
2007-11-09 09:27:23 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
if (k + 1 < iter.GetStringEnd() && aCharsToMerge[k + 1]) {
|
2012-04-24 21:53:39 +04:00
|
|
|
// next char is supposed to merge with current, so loop without
|
|
|
|
// writing current merged glyph to the destination
|
2007-11-09 09:27:23 +03:00
|
|
|
continue;
|
|
|
|
}
|
|
|
|
|
2008-01-10 02:33:34 +03:00
|
|
|
// If the start of the merge run is actually a character that should
|
|
|
|
// have been merged with the previous character (this can happen
|
2012-04-24 21:53:39 +04:00
|
|
|
// if there's a font change in the middle of a case-mapped character,
|
|
|
|
// that decomposed into a sequence of base+diacritics, for example),
|
2008-01-10 02:33:34 +03:00
|
|
|
// just discard the entire merge run. See comment at start of this
|
|
|
|
// function.
|
2012-04-24 21:53:39 +04:00
|
|
|
NS_WARN_IF_FALSE(!aCharsToMerge[mergeRunStart],
|
|
|
|
"unable to merge across a glyph run boundary, "
|
|
|
|
"glyph(s) discarded");
|
2008-01-10 02:33:34 +03:00
|
|
|
if (!aCharsToMerge[mergeRunStart]) {
|
|
|
|
if (anyMissing) {
|
2012-04-24 21:53:39 +04:00
|
|
|
mergedGlyph.SetMissing(glyphs.Length());
|
2008-01-10 02:33:34 +03:00
|
|
|
} else {
|
2012-04-24 21:53:39 +04:00
|
|
|
mergedGlyph.SetComplex(mergedGlyph.IsClusterStart(),
|
|
|
|
mergedGlyph.IsLigatureGroupStart(),
|
|
|
|
glyphs.Length());
|
2008-01-10 02:33:34 +03:00
|
|
|
}
|
2012-04-24 21:53:39 +04:00
|
|
|
aDest->SetGlyphs(offset, mergedGlyph, glyphs.Elements());
|
2008-01-10 02:33:34 +03:00
|
|
|
++offset;
|
2012-05-03 11:57:18 +04:00
|
|
|
|
|
|
|
while (offset < aDest->GetLength() && aDeletedChars[offset]) {
|
2012-07-30 18:20:58 +04:00
|
|
|
aDest->SetGlyphs(offset++, gfxTextRun::CompressedGlyph(), nullptr);
|
2012-05-03 11:57:18 +04:00
|
|
|
}
|
2007-03-23 02:13:12 +03:00
|
|
|
}
|
2008-01-10 02:33:34 +03:00
|
|
|
|
2007-11-09 09:27:23 +03:00
|
|
|
glyphs.Clear();
|
2011-10-17 18:59:28 +04:00
|
|
|
anyMissing = false;
|
2007-11-09 09:27:23 +03:00
|
|
|
mergeRunStart = k + 1;
|
2012-04-24 21:53:39 +04:00
|
|
|
if (mergeRunStart < stringEnd) {
|
|
|
|
mergedGlyph = srcGlyphs[mergeRunStart];
|
|
|
|
}
|
2007-03-23 02:13:12 +03:00
|
|
|
}
|
2007-11-09 09:27:23 +03:00
|
|
|
NS_ASSERTION(glyphs.Length() == 0,
|
|
|
|
"Leftover glyphs, don't request merging of the last character with its next!");
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
2007-03-23 02:13:12 +03:00
|
|
|
NS_ASSERTION(offset == aDest->GetLength(), "Bad offset calculations");
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
|
|
|
|
2013-12-02 20:49:27 +04:00
|
|
|
gfxTextRunFactory::Parameters
|
2012-08-22 19:56:38 +04:00
|
|
|
GetParametersForInner(nsTransformedTextRun* aTextRun, uint32_t* aFlags,
|
2007-06-27 08:22:21 +04:00
|
|
|
gfxContext* aRefContext)
|
2007-01-16 23:51:52 +03:00
|
|
|
{
|
|
|
|
gfxTextRunFactory::Parameters params =
|
2012-07-30 18:20:58 +04:00
|
|
|
{ aRefContext, nullptr, nullptr,
|
|
|
|
nullptr, 0, aTextRun->GetAppUnitsPerDevUnit()
|
2007-05-10 02:04:56 +04:00
|
|
|
};
|
|
|
|
*aFlags = aTextRun->GetFlags() & ~gfxFontGroup::TEXT_IS_PERSISTENT;
|
2007-01-16 23:51:52 +03:00
|
|
|
return params;
|
|
|
|
}
|
|
|
|
|
2014-05-26 17:23:30 +04:00
|
|
|
// Some languages have special casing conventions that differ from the
|
|
|
|
// default Unicode mappings.
|
|
|
|
// The enum values here are named for well-known exemplar languages that
|
|
|
|
// exhibit the behavior in question; multiple lang tags may map to the
|
|
|
|
// same setting here, if the behavior is shared by other languages.
|
|
|
|
enum LanguageSpecificCasingBehavior {
|
|
|
|
eLSCB_None, // default non-lang-specific behavior
|
|
|
|
eLSCB_Dutch, // treat "ij" digraph as a unit for capitalization
|
2014-06-02 02:18:03 +04:00
|
|
|
eLSCB_Greek, // strip accent when uppercasing Greek vowels
|
|
|
|
eLSCB_Irish, // keep prefix letters as lowercase when uppercasing Irish
|
|
|
|
eLSCB_Turkish // preserve dotted/dotless-i distinction in uppercase
|
2014-05-26 17:23:30 +04:00
|
|
|
};
|
|
|
|
|
|
|
|
static LanguageSpecificCasingBehavior
|
|
|
|
GetCasingFor(const nsIAtom* aLang)
|
2007-01-16 23:51:52 +03:00
|
|
|
{
|
2014-08-11 12:49:11 +04:00
|
|
|
if (!aLang) {
|
|
|
|
return eLSCB_None;
|
|
|
|
}
|
2014-05-26 17:23:30 +04:00
|
|
|
if (aLang == nsGkAtoms::tr ||
|
|
|
|
aLang == nsGkAtoms::az ||
|
|
|
|
aLang == nsGkAtoms::ba ||
|
|
|
|
aLang == nsGkAtoms::crh ||
|
|
|
|
aLang == nsGkAtoms::tt) {
|
|
|
|
return eLSCB_Turkish;
|
|
|
|
}
|
|
|
|
if (aLang == nsGkAtoms::nl) {
|
|
|
|
return eLSCB_Dutch;
|
|
|
|
}
|
|
|
|
if (aLang == nsGkAtoms::el) {
|
|
|
|
return eLSCB_Greek;
|
|
|
|
}
|
2014-08-11 12:49:11 +04:00
|
|
|
if (aLang == nsGkAtoms::ga) {
|
2014-06-02 02:18:03 +04:00
|
|
|
return eLSCB_Irish;
|
|
|
|
}
|
2014-08-11 12:49:11 +04:00
|
|
|
|
|
|
|
// Is there a region subtag we should ignore?
|
|
|
|
nsAtomString langStr(const_cast<nsIAtom*>(aLang));
|
|
|
|
int index = langStr.FindChar('-');
|
|
|
|
if (index > 0) {
|
|
|
|
langStr.Truncate(index);
|
|
|
|
nsCOMPtr<nsIAtom> truncatedLang = do_GetAtom(langStr);
|
|
|
|
return GetCasingFor(truncatedLang);
|
|
|
|
}
|
|
|
|
|
2014-05-26 17:23:30 +04:00
|
|
|
return eLSCB_None;
|
|
|
|
}
|
|
|
|
|
|
|
|
bool
|
|
|
|
nsCaseTransformTextRunFactory::TransformString(
|
|
|
|
const nsAString& aString,
|
|
|
|
nsString& aConvertedString,
|
|
|
|
bool aAllUppercase,
|
|
|
|
const nsIAtom* aLanguage,
|
|
|
|
nsTArray<bool>& aCharsToMergeArray,
|
|
|
|
nsTArray<bool>& aDeletedCharsArray,
|
|
|
|
nsTransformedTextRun* aTextRun,
|
|
|
|
nsTArray<uint8_t>* aCanBreakBeforeArray,
|
2015-02-10 13:30:25 +03:00
|
|
|
nsTArray<nsRefPtr<nsTransformedCharStyle>>* aStyleArray)
|
2014-05-26 17:23:30 +04:00
|
|
|
{
|
|
|
|
NS_PRECONDITION(!aTextRun || (aCanBreakBeforeArray && aStyleArray),
|
|
|
|
"either none or all three optional parameters required");
|
|
|
|
|
|
|
|
uint32_t length = aString.Length();
|
|
|
|
const char16_t* str = aString.BeginReading();
|
2007-01-16 23:51:52 +03:00
|
|
|
|
2012-05-03 11:57:18 +04:00
|
|
|
bool mergeNeeded = false;
|
2007-01-16 23:51:52 +03:00
|
|
|
|
2012-04-15 18:52:47 +04:00
|
|
|
bool capitalizeDutchIJ = false;
|
|
|
|
bool prevIsLetter = false;
|
2014-06-02 15:48:01 +04:00
|
|
|
bool ntPrefix = false; // true immediately after a word-initial 'n' or 't'
|
|
|
|
// when doing Irish lowercasing
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t sigmaIndex = uint32_t(-1);
|
2012-04-15 18:52:47 +04:00
|
|
|
nsIUGenCategory::nsUGenCategory cat;
|
2014-05-26 17:23:30 +04:00
|
|
|
|
|
|
|
uint8_t style = aAllUppercase ? NS_STYLE_TEXT_TRANSFORM_UPPERCASE : 0;
|
|
|
|
const nsIAtom* lang = aLanguage;
|
|
|
|
|
|
|
|
LanguageSpecificCasingBehavior languageSpecificCasing = GetCasingFor(lang);
|
2014-06-02 02:17:41 +04:00
|
|
|
mozilla::GreekCasing::State greekState;
|
2014-06-02 02:18:03 +04:00
|
|
|
mozilla::IrishCasing::State irishState;
|
|
|
|
uint32_t irishMark = uint32_t(-1); // location of possible prefix letter(s)
|
2014-05-26 17:23:30 +04:00
|
|
|
|
|
|
|
for (uint32_t i = 0; i < length; ++i) {
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t ch = str[i];
|
2007-03-23 02:13:12 +03:00
|
|
|
|
2015-02-10 13:30:25 +03:00
|
|
|
nsRefPtr<nsTransformedCharStyle> charStyle;
|
2014-05-26 17:23:30 +04:00
|
|
|
if (aTextRun) {
|
2015-02-10 13:30:25 +03:00
|
|
|
charStyle = aTextRun->mStyles[i];
|
2014-05-26 17:23:30 +04:00
|
|
|
style = aAllUppercase ? NS_STYLE_TEXT_TRANSFORM_UPPERCASE :
|
2015-02-10 13:30:25 +03:00
|
|
|
charStyle->mTextTransform;
|
2014-05-26 17:23:30 +04:00
|
|
|
|
2015-02-10 13:30:25 +03:00
|
|
|
nsIAtom* newLang = charStyle->mExplicitLanguage
|
|
|
|
? charStyle->mLanguage : nullptr;
|
2014-12-23 15:50:10 +03:00
|
|
|
if (lang != newLang) {
|
|
|
|
lang = newLang;
|
2014-05-26 17:23:30 +04:00
|
|
|
languageSpecificCasing = GetCasingFor(lang);
|
2014-05-26 17:23:31 +04:00
|
|
|
greekState.Reset();
|
2014-06-02 02:18:03 +04:00
|
|
|
irishState.Reset();
|
|
|
|
irishMark = uint32_t(-1);
|
2014-05-26 17:23:30 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2012-04-24 21:53:39 +04:00
|
|
|
int extraChars = 0;
|
|
|
|
const mozilla::unicode::MultiCharMapping *mcm;
|
2014-06-02 02:18:03 +04:00
|
|
|
bool inhibitBreakBefore = false; // have we just deleted preceding hyphen?
|
2007-01-16 23:51:52 +03:00
|
|
|
|
2014-05-26 17:23:30 +04:00
|
|
|
if (NS_IS_HIGH_SURROGATE(ch) && i < length - 1 &&
|
|
|
|
NS_IS_LOW_SURROGATE(str[i + 1])) {
|
2012-03-14 10:45:11 +04:00
|
|
|
ch = SURROGATE_TO_UCS4(ch, str[i + 1]);
|
|
|
|
}
|
|
|
|
|
2007-01-16 23:51:52 +03:00
|
|
|
switch (style) {
|
|
|
|
case NS_STYLE_TEXT_TRANSFORM_LOWERCASE:
|
2014-05-26 17:23:30 +04:00
|
|
|
if (languageSpecificCasing == eLSCB_Turkish) {
|
2012-04-24 21:53:39 +04:00
|
|
|
if (ch == 'I') {
|
|
|
|
ch = LATIN_SMALL_LETTER_DOTLESS_I;
|
|
|
|
prevIsLetter = true;
|
2012-08-22 19:56:38 +04:00
|
|
|
sigmaIndex = uint32_t(-1);
|
2012-04-24 21:53:39 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (ch == LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE) {
|
|
|
|
ch = 'i';
|
|
|
|
prevIsLetter = true;
|
2012-08-22 19:56:38 +04:00
|
|
|
sigmaIndex = uint32_t(-1);
|
2012-04-24 21:53:39 +04:00
|
|
|
break;
|
|
|
|
}
|
2012-04-15 18:52:47 +04:00
|
|
|
}
|
|
|
|
|
2014-06-02 15:48:01 +04:00
|
|
|
cat = mozilla::unicode::GetGenCategory(ch);
|
|
|
|
|
|
|
|
if (languageSpecificCasing == eLSCB_Irish &&
|
|
|
|
cat == nsIUGenCategory::kLetter) {
|
|
|
|
// See bug 1018805 for Irish lowercasing requirements
|
|
|
|
if (!prevIsLetter && (ch == 'n' || ch == 't')) {
|
|
|
|
ntPrefix = true;
|
|
|
|
} else {
|
|
|
|
if (ntPrefix && mozilla::IrishCasing::IsUpperVowel(ch)) {
|
|
|
|
aConvertedString.Append('-');
|
|
|
|
++extraChars;
|
|
|
|
}
|
|
|
|
ntPrefix = false;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ntPrefix = false;
|
|
|
|
}
|
|
|
|
|
2012-04-15 18:52:47 +04:00
|
|
|
// Special lowercasing behavior for Greek Sigma: note that this is listed
|
|
|
|
// as context-sensitive in Unicode's SpecialCasing.txt, but is *not* a
|
|
|
|
// language-specific mapping; it applies regardless of the language of
|
|
|
|
// the element.
|
|
|
|
//
|
|
|
|
// The lowercase mapping for CAPITAL SIGMA should be to SMALL SIGMA (i.e.
|
|
|
|
// the non-final form) whenever there is a following letter, or when the
|
|
|
|
// CAPITAL SIGMA occurs in isolation (neither preceded nor followed by a
|
|
|
|
// LETTER); and to FINAL SIGMA when it is preceded by another letter but
|
|
|
|
// not followed by one.
|
|
|
|
//
|
|
|
|
// To implement the context-sensitive nature of this mapping, we keep
|
|
|
|
// track of whether the previous character was a letter. If not, CAPITAL
|
|
|
|
// SIGMA will map directly to SMALL SIGMA. If the previous character
|
|
|
|
// was a letter, CAPITAL SIGMA maps to FINAL SIGMA and we record the
|
|
|
|
// position in the converted string; if we then encounter another letter,
|
|
|
|
// that FINAL SIGMA is replaced with a standard SMALL SIGMA.
|
|
|
|
|
|
|
|
// If sigmaIndex is not -1, it marks where we have provisionally mapped
|
|
|
|
// a CAPITAL SIGMA to FINAL SIGMA; if we now find another letter, we
|
|
|
|
// need to change it to SMALL SIGMA.
|
2012-08-22 19:56:38 +04:00
|
|
|
if (sigmaIndex != uint32_t(-1)) {
|
2012-04-15 18:52:47 +04:00
|
|
|
if (cat == nsIUGenCategory::kLetter) {
|
2014-05-26 17:23:30 +04:00
|
|
|
aConvertedString.SetCharAt(GREEK_SMALL_LETTER_SIGMA, sigmaIndex);
|
2012-04-15 18:52:47 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (ch == GREEK_CAPITAL_LETTER_SIGMA) {
|
|
|
|
// If preceding char was a letter, map to FINAL instead of SMALL,
|
|
|
|
// and note where it occurred by setting sigmaIndex; we'll change it
|
|
|
|
// to standard SMALL SIGMA later if another letter follows
|
|
|
|
if (prevIsLetter) {
|
|
|
|
ch = GREEK_SMALL_LETTER_FINAL_SIGMA;
|
2014-05-26 17:23:30 +04:00
|
|
|
sigmaIndex = aConvertedString.Length();
|
2012-04-15 18:52:47 +04:00
|
|
|
} else {
|
|
|
|
// CAPITAL SIGMA not preceded by a letter is unconditionally mapped
|
|
|
|
// to SMALL SIGMA
|
|
|
|
ch = GREEK_SMALL_LETTER_SIGMA;
|
2012-08-22 19:56:38 +04:00
|
|
|
sigmaIndex = uint32_t(-1);
|
2012-04-15 18:52:47 +04:00
|
|
|
}
|
|
|
|
prevIsLetter = true;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
// ignore diacritics for the purpose of contextual sigma mapping;
|
|
|
|
// otherwise, reset prevIsLetter appropriately and clear the
|
|
|
|
// sigmaIndex marker
|
|
|
|
if (cat != nsIUGenCategory::kMark) {
|
|
|
|
prevIsLetter = (cat == nsIUGenCategory::kLetter);
|
2012-08-22 19:56:38 +04:00
|
|
|
sigmaIndex = uint32_t(-1);
|
2012-03-27 19:49:03 +04:00
|
|
|
}
|
2012-04-15 18:52:47 +04:00
|
|
|
|
2012-04-24 21:53:39 +04:00
|
|
|
mcm = mozilla::unicode::SpecialLower(ch);
|
|
|
|
if (mcm) {
|
|
|
|
int j = 0;
|
|
|
|
while (j < 2 && mcm->mMappedChars[j + 1]) {
|
2014-05-26 17:23:30 +04:00
|
|
|
aConvertedString.Append(mcm->mMappedChars[j]);
|
2012-04-24 21:53:39 +04:00
|
|
|
++extraChars;
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
ch = mcm->mMappedChars[j];
|
2012-04-15 18:52:47 +04:00
|
|
|
break;
|
|
|
|
}
|
2012-04-24 21:53:39 +04:00
|
|
|
|
|
|
|
ch = ToLowerCase(ch);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case NS_STYLE_TEXT_TRANSFORM_UPPERCASE:
|
2014-05-26 17:23:30 +04:00
|
|
|
if (languageSpecificCasing == eLSCB_Turkish && ch == 'i') {
|
2012-03-27 19:49:03 +04:00
|
|
|
ch = LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE;
|
2012-04-15 18:52:47 +04:00
|
|
|
break;
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
2012-04-24 21:53:39 +04:00
|
|
|
|
2014-05-26 17:23:30 +04:00
|
|
|
if (languageSpecificCasing == eLSCB_Greek) {
|
2014-06-02 02:17:41 +04:00
|
|
|
ch = mozilla::GreekCasing::UpperCase(ch, greekState);
|
2012-05-03 11:57:18 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2014-06-02 02:18:03 +04:00
|
|
|
if (languageSpecificCasing == eLSCB_Irish) {
|
|
|
|
bool mark;
|
|
|
|
uint8_t action;
|
|
|
|
ch = mozilla::IrishCasing::UpperCase(ch, irishState, mark, action);
|
|
|
|
if (mark) {
|
|
|
|
irishMark = aConvertedString.Length();
|
|
|
|
break;
|
|
|
|
} else if (action) {
|
|
|
|
nsString& str = aConvertedString; // shorthand
|
|
|
|
switch (action) {
|
|
|
|
case 1:
|
|
|
|
// lowercase a single prefix letter
|
|
|
|
NS_ASSERTION(str.Length() > 0 && irishMark < str.Length(),
|
|
|
|
"bad irishMark!");
|
|
|
|
str.SetCharAt(ToLowerCase(str[irishMark]), irishMark);
|
|
|
|
irishMark = uint32_t(-1);
|
|
|
|
break;
|
|
|
|
case 2:
|
|
|
|
// lowercase two prefix letters (immediately before current pos)
|
|
|
|
NS_ASSERTION(str.Length() >= 2 && irishMark == str.Length() - 2,
|
|
|
|
"bad irishMark!");
|
|
|
|
str.SetCharAt(ToLowerCase(str[irishMark]), irishMark);
|
|
|
|
str.SetCharAt(ToLowerCase(str[irishMark + 1]), irishMark + 1);
|
|
|
|
irishMark = uint32_t(-1);
|
|
|
|
break;
|
|
|
|
case 3:
|
|
|
|
// lowercase one prefix letter, and delete following hyphen
|
|
|
|
// (which must be the immediately-preceding char)
|
|
|
|
NS_ASSERTION(str.Length() >= 2 && irishMark == str.Length() - 2,
|
|
|
|
"bad irishMark!");
|
|
|
|
str.Replace(irishMark, 2, ToLowerCase(str[irishMark]));
|
|
|
|
aDeletedCharsArray[irishMark + 1] = true;
|
|
|
|
// Remove the trailing entries (corresponding to the deleted hyphen)
|
|
|
|
// from the auxiliary arrays.
|
|
|
|
aCharsToMergeArray.SetLength(aCharsToMergeArray.Length() - 1);
|
|
|
|
if (aTextRun) {
|
|
|
|
aStyleArray->SetLength(aStyleArray->Length() - 1);
|
|
|
|
aCanBreakBeforeArray->SetLength(aCanBreakBeforeArray->Length() - 1);
|
|
|
|
inhibitBreakBefore = true;
|
|
|
|
}
|
|
|
|
mergeNeeded = true;
|
|
|
|
irishMark = uint32_t(-1);
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// ch has been set to the uppercase for current char;
|
|
|
|
// No need to check for SpecialUpper here as none of the characters
|
|
|
|
// that could trigger an Irish casing action have special mappings.
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
// If we didn't have any special action to perform, fall through
|
|
|
|
// to check for special uppercase (ß)
|
|
|
|
}
|
|
|
|
|
2012-04-24 21:53:39 +04:00
|
|
|
mcm = mozilla::unicode::SpecialUpper(ch);
|
|
|
|
if (mcm) {
|
|
|
|
int j = 0;
|
|
|
|
while (j < 2 && mcm->mMappedChars[j + 1]) {
|
2014-05-26 17:23:30 +04:00
|
|
|
aConvertedString.Append(mcm->mMappedChars[j]);
|
2012-04-24 21:53:39 +04:00
|
|
|
++extraChars;
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
ch = mcm->mMappedChars[j];
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-04-15 18:52:47 +04:00
|
|
|
ch = ToUpperCase(ch);
|
2007-01-16 23:51:52 +03:00
|
|
|
break;
|
2012-04-15 18:52:47 +04:00
|
|
|
|
2007-01-16 23:51:52 +03:00
|
|
|
case NS_STYLE_TEXT_TRANSFORM_CAPITALIZE:
|
2014-05-26 17:23:30 +04:00
|
|
|
if (aTextRun) {
|
|
|
|
if (capitalizeDutchIJ && ch == 'j') {
|
|
|
|
ch = 'J';
|
|
|
|
capitalizeDutchIJ = false;
|
2012-04-15 18:52:47 +04:00
|
|
|
break;
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
2014-05-26 17:23:30 +04:00
|
|
|
capitalizeDutchIJ = false;
|
|
|
|
if (i < aTextRun->mCapitalize.Length() && aTextRun->mCapitalize[i]) {
|
|
|
|
if (languageSpecificCasing == eLSCB_Turkish && ch == 'i') {
|
|
|
|
ch = LATIN_CAPITAL_LETTER_I_WITH_DOT_ABOVE;
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
if (languageSpecificCasing == eLSCB_Dutch && ch == 'i') {
|
|
|
|
ch = 'I';
|
|
|
|
capitalizeDutchIJ = true;
|
|
|
|
break;
|
|
|
|
}
|
2012-04-24 21:53:39 +04:00
|
|
|
|
2014-05-26 17:23:30 +04:00
|
|
|
mcm = mozilla::unicode::SpecialTitle(ch);
|
|
|
|
if (mcm) {
|
|
|
|
int j = 0;
|
|
|
|
while (j < 2 && mcm->mMappedChars[j + 1]) {
|
|
|
|
aConvertedString.Append(mcm->mMappedChars[j]);
|
|
|
|
++extraChars;
|
|
|
|
++j;
|
|
|
|
}
|
|
|
|
ch = mcm->mMappedChars[j];
|
|
|
|
break;
|
2012-04-24 21:53:39 +04:00
|
|
|
}
|
|
|
|
|
2014-05-26 17:23:30 +04:00
|
|
|
ch = ToTitleCase(ch);
|
|
|
|
}
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
|
|
|
break;
|
2012-04-15 18:52:47 +04:00
|
|
|
|
2012-11-09 13:43:48 +04:00
|
|
|
case NS_STYLE_TEXT_TRANSFORM_FULLWIDTH:
|
|
|
|
ch = mozilla::unicode::GetFullWidth(ch);
|
|
|
|
break;
|
|
|
|
|
2007-01-16 23:51:52 +03:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
if (ch == uint32_t(-1)) {
|
2014-05-26 17:23:30 +04:00
|
|
|
aDeletedCharsArray.AppendElement(true);
|
2012-05-03 11:57:18 +04:00
|
|
|
mergeNeeded = true;
|
2012-03-14 10:45:11 +04:00
|
|
|
} else {
|
2014-05-26 17:23:30 +04:00
|
|
|
aDeletedCharsArray.AppendElement(false);
|
|
|
|
aCharsToMergeArray.AppendElement(false);
|
|
|
|
if (aTextRun) {
|
2015-02-10 13:30:25 +03:00
|
|
|
aStyleArray->AppendElement(charStyle);
|
2015-02-22 22:39:36 +03:00
|
|
|
aCanBreakBeforeArray->AppendElement(
|
|
|
|
inhibitBreakBefore ? gfxShapedText::CompressedGlyph::FLAG_BREAK_TYPE_NONE
|
|
|
|
: aTextRun->CanBreakBefore(i));
|
2014-05-26 17:23:30 +04:00
|
|
|
}
|
2012-03-14 10:45:11 +04:00
|
|
|
|
2012-05-03 11:57:18 +04:00
|
|
|
if (IS_IN_BMP(ch)) {
|
2014-05-26 17:23:30 +04:00
|
|
|
aConvertedString.Append(ch);
|
2012-05-03 11:57:18 +04:00
|
|
|
} else {
|
2014-05-26 17:23:30 +04:00
|
|
|
aConvertedString.Append(H_SURROGATE(ch));
|
|
|
|
aConvertedString.Append(L_SURROGATE(ch));
|
2012-05-03 11:57:18 +04:00
|
|
|
++i;
|
2014-05-26 17:23:30 +04:00
|
|
|
aDeletedCharsArray.AppendElement(true); // not exactly deleted, but the
|
|
|
|
// trailing surrogate is skipped
|
2012-05-03 11:57:18 +04:00
|
|
|
++extraChars;
|
|
|
|
}
|
|
|
|
|
|
|
|
while (extraChars-- > 0) {
|
|
|
|
mergeNeeded = true;
|
2014-05-26 17:23:30 +04:00
|
|
|
aCharsToMergeArray.AppendElement(true);
|
|
|
|
if (aTextRun) {
|
2015-02-10 13:30:25 +03:00
|
|
|
aStyleArray->AppendElement(charStyle);
|
2015-02-22 22:39:36 +03:00
|
|
|
aCanBreakBeforeArray->AppendElement(
|
|
|
|
gfxShapedText::CompressedGlyph::FLAG_BREAK_TYPE_NONE);
|
2014-05-26 17:23:30 +04:00
|
|
|
}
|
2012-05-03 11:57:18 +04:00
|
|
|
}
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-05-26 17:23:30 +04:00
|
|
|
return mergeNeeded;
|
|
|
|
}
|
|
|
|
|
|
|
|
void
|
|
|
|
nsCaseTransformTextRunFactory::RebuildTextRun(nsTransformedTextRun* aTextRun,
|
2014-12-22 19:35:54 +03:00
|
|
|
gfxContext* aRefContext, gfxMissingFontRecorder *aMFR)
|
2014-05-26 17:23:30 +04:00
|
|
|
{
|
|
|
|
nsAutoString convertedString;
|
|
|
|
nsAutoTArray<bool,50> charsToMergeArray;
|
|
|
|
nsAutoTArray<bool,50> deletedCharsArray;
|
|
|
|
nsAutoTArray<uint8_t,50> canBreakBeforeArray;
|
2015-02-10 13:30:25 +03:00
|
|
|
nsAutoTArray<nsRefPtr<nsTransformedCharStyle>,50> styleArray;
|
2014-05-26 17:23:30 +04:00
|
|
|
|
|
|
|
bool mergeNeeded = TransformString(aTextRun->mString,
|
|
|
|
convertedString,
|
|
|
|
mAllUppercase,
|
|
|
|
nullptr,
|
|
|
|
charsToMergeArray,
|
|
|
|
deletedCharsArray,
|
|
|
|
aTextRun,
|
|
|
|
&canBreakBeforeArray,
|
|
|
|
&styleArray);
|
|
|
|
|
2012-08-22 19:56:38 +04:00
|
|
|
uint32_t flags;
|
2007-06-27 08:22:21 +04:00
|
|
|
gfxTextRunFactory::Parameters innerParams =
|
|
|
|
GetParametersForInner(aTextRun, &flags, aRefContext);
|
2007-05-10 02:04:56 +04:00
|
|
|
gfxFontGroup* fontGroup = aTextRun->GetFontGroup();
|
2007-01-16 23:51:52 +03:00
|
|
|
|
2009-01-16 11:17:46 +03:00
|
|
|
nsAutoPtr<nsTransformedTextRun> transformedChild;
|
2011-12-06 16:39:18 +04:00
|
|
|
nsAutoPtr<gfxTextRun> cachedChild;
|
2007-07-04 07:39:01 +04:00
|
|
|
gfxTextRun* child;
|
2009-01-09 03:23:28 +03:00
|
|
|
|
2007-01-16 23:51:52 +03:00
|
|
|
if (mInnerTransformingTextRunFactory) {
|
2007-07-04 07:39:01 +04:00
|
|
|
transformedChild = mInnerTransformingTextRunFactory->MakeTextRun(
|
2007-03-23 02:13:12 +03:00
|
|
|
convertedString.BeginReading(), convertedString.Length(),
|
2015-02-10 13:30:25 +03:00
|
|
|
&innerParams, fontGroup, flags, Move(styleArray), false);
|
2007-07-04 07:39:01 +04:00
|
|
|
child = transformedChild.get();
|
2007-03-23 02:13:12 +03:00
|
|
|
} else {
|
2011-12-06 16:39:18 +04:00
|
|
|
cachedChild = fontGroup->MakeTextRun(
|
|
|
|
convertedString.BeginReading(), convertedString.Length(),
|
2014-12-22 19:35:54 +03:00
|
|
|
&innerParams, flags, aMFR);
|
2007-07-04 07:39:01 +04:00
|
|
|
child = cachedChild.get();
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|
2007-03-23 02:13:12 +03:00
|
|
|
if (!child)
|
|
|
|
return;
|
|
|
|
// Copy potential linebreaks into child so they're preserved
|
|
|
|
// (and also child will be shaped appropriately)
|
|
|
|
NS_ASSERTION(convertedString.Length() == canBreakBeforeArray.Length(),
|
|
|
|
"Dropped characters or break-before values somewhere!");
|
2007-06-27 08:22:21 +04:00
|
|
|
child->SetPotentialLineBreaks(0, canBreakBeforeArray.Length(),
|
|
|
|
canBreakBeforeArray.Elements(), aRefContext);
|
2009-01-16 11:17:46 +03:00
|
|
|
if (transformedChild) {
|
2014-12-22 19:35:54 +03:00
|
|
|
transformedChild->FinishSettingProperties(aRefContext, aMFR);
|
2009-01-16 11:17:46 +03:00
|
|
|
}
|
2007-11-09 09:27:23 +03:00
|
|
|
|
2012-05-03 11:57:18 +04:00
|
|
|
if (mergeNeeded) {
|
2007-11-09 09:27:23 +03:00
|
|
|
// Now merge multiple characters into one multi-glyph character as required
|
2012-05-03 11:57:18 +04:00
|
|
|
// and deal with skipping deleted accent chars
|
|
|
|
NS_ASSERTION(charsToMergeArray.Length() == child->GetLength(),
|
|
|
|
"source length mismatch");
|
|
|
|
NS_ASSERTION(deletedCharsArray.Length() == aTextRun->GetLength(),
|
|
|
|
"destination length mismatch");
|
|
|
|
MergeCharactersInTextRun(aTextRun, child, charsToMergeArray.Elements(),
|
|
|
|
deletedCharsArray.Elements());
|
2007-11-09 09:27:23 +03:00
|
|
|
} else {
|
|
|
|
// No merging to do, so just copy; this produces a more optimized textrun.
|
|
|
|
// We can't steal the data because the child may be cached and stealing
|
|
|
|
// the data would break the cache.
|
|
|
|
aTextRun->ResetGlyphRuns();
|
2011-02-10 09:50:47 +03:00
|
|
|
aTextRun->CopyGlyphDataFrom(child, 0, child->GetLength(), 0);
|
2007-11-09 09:27:23 +03:00
|
|
|
}
|
2007-01-16 23:51:52 +03:00
|
|
|
}
|