зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1063857 - Improve selecting on justified characters. r=roc
This commit is contained in:
Родитель
9a699374b5
Коммит
08641f507e
|
@ -949,7 +949,8 @@ gfxTextRun::BreakAndMeasureText(uint32_t aStart, uint32_t aMaxLength,
|
|||
|
||||
gfxFloat
|
||||
gfxTextRun::GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider *aProvider)
|
||||
PropertyProvider *aProvider,
|
||||
PropertyProvider::Spacing* aSpacing)
|
||||
{
|
||||
NS_ASSERTION(aStart + aLength <= GetLength(), "Substring out of range");
|
||||
|
||||
|
@ -960,6 +961,10 @@ gfxTextRun::GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
|
|||
gfxFloat result = ComputePartialLigatureWidth(aStart, ligatureRunStart, aProvider) +
|
||||
ComputePartialLigatureWidth(ligatureRunEnd, aStart + aLength, aProvider);
|
||||
|
||||
if (aSpacing) {
|
||||
aSpacing->mBefore = aSpacing->mAfter = 0;
|
||||
}
|
||||
|
||||
// Account for all remaining spacing here. This is more efficient than
|
||||
// processing it along with the glyphs.
|
||||
if (aProvider && (mFlags & gfxTextRunFactory::TEXT_ENABLE_SPACING)) {
|
||||
|
@ -972,6 +977,10 @@ gfxTextRun::GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
|
|||
PropertyProvider::Spacing *space = &spacingBuffer[i];
|
||||
result += space->mBefore + space->mAfter;
|
||||
}
|
||||
if (aSpacing) {
|
||||
aSpacing->mBefore = spacingBuffer[0].mBefore;
|
||||
aSpacing->mAfter = spacingBuffer.LastElement().mAfter;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -267,9 +267,13 @@ public:
|
|||
/**
|
||||
* Computes just the advance width for a substring.
|
||||
* Uses GetSpacing from aBreakProvider.
|
||||
* If aSpacing is not null, the spacing attached before and after
|
||||
* the substring would be returned in it. NOTE: the spacing is
|
||||
* included in the advance width.
|
||||
*/
|
||||
gfxFloat GetAdvanceWidth(uint32_t aStart, uint32_t aLength,
|
||||
PropertyProvider *aProvider);
|
||||
PropertyProvider *aProvider,
|
||||
PropertyProvider::Spacing* aSpacing = nullptr);
|
||||
|
||||
/**
|
||||
* Clear all stored line breaks for the given range (both before and after),
|
||||
|
|
|
@ -6376,11 +6376,14 @@ nsTextFrame::GetCharacterOffsetAtFramePointInternal(nsPoint aPoint,
|
|||
FindClusterEnd(mTextRun,
|
||||
provider.GetStart().GetOriginalOffset() + provider.GetOriginalLength(),
|
||||
&extraClusterLastChar);
|
||||
PropertyProvider::Spacing spacing;
|
||||
gfxFloat charWidth =
|
||||
mTextRun->GetAdvanceWidth(extraCluster.GetSkippedOffset(),
|
||||
GetSkippedDistance(extraCluster, extraClusterLastChar) + 1,
|
||||
&provider);
|
||||
selectedOffset = !aForInsertionPoint || width <= fitWidth + charWidth/2
|
||||
&provider, &spacing);
|
||||
charWidth -= spacing.mBefore + spacing.mAfter;
|
||||
selectedOffset = !aForInsertionPoint ||
|
||||
width <= fitWidth + spacing.mBefore + charWidth/2
|
||||
? extraCluster.GetOriginalOffset()
|
||||
: extraClusterLastChar.GetOriginalOffset() + 1;
|
||||
} else {
|
||||
|
|
Загрузка…
Ссылка в новой задаче