mirror of
https://github.com/cappuccino/cappuccino.git
synced 2026-08-25 04:57:03 +00:00
Merge pull request #3218 from daboe01/cptextview-fixes
Fixed: rare layout issue after inserting multiple newlines and text layout performance improvement
This commit is contained in:
@@ -286,6 +286,8 @@ _oncontextmenuhandler = function () { return false; };
|
||||
|
||||
if (removeRange.length)
|
||||
_removeInvalidLineFragmentsRange = CPMakeRangeCopy(removeRange);
|
||||
else
|
||||
_removeInvalidLineFragmentsRange = nil;
|
||||
|
||||
// We erased all lines
|
||||
if (!startIndex)
|
||||
|
||||
@@ -365,6 +365,17 @@ var CPSystemTypesetterFactory,
|
||||
wrapWidth = rangeWidth;
|
||||
wrapRange._height = _lineHeight;
|
||||
wrapRange._base = _lineBase;
|
||||
|
||||
// Optimization: Start measuring from the next character to avoid O(n^2)
|
||||
// string width calculation within a line since spaces do not carry ligatures or kerning.
|
||||
// Only reset the measuring range if the next character is NOT another space.
|
||||
// This prevents compounded subpixel rounding errors with contiguous spaces.
|
||||
if (theString.charCodeAt(glyphIndex + 1) !== 32)
|
||||
{
|
||||
currentAnchor = rangeWidth;
|
||||
measuringRange = CPMakeRange(glyphIndex + 1, 0);
|
||||
}
|
||||
|
||||
break;
|
||||
|
||||
case 10:
|
||||
|
||||
Reference in New Issue
Block a user