From 4ebcf40619d3290c8ced66a6f42ab0af44c9b284 Mon Sep 17 00:00:00 2001 From: Alexandre Wilhelm Date: Mon, 4 May 2015 14:03:33 -0700 Subject: [PATCH] Fixed: make travis happy with DOM elements in CPTextView --- AppKit/CPTextView/CPLayoutManager.j | 4 +++- AppKit/CPTextView/CPTypesetter.j | 14 ++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/AppKit/CPTextView/CPLayoutManager.j b/AppKit/CPTextView/CPLayoutManager.j index 4d70b82e2..bcc4a569c 100644 --- a/AppKit/CPTextView/CPLayoutManager.j +++ b/AppKit/CPTextView/CPLayoutManager.j @@ -285,10 +285,12 @@ _oncontextmenuhandler = function () { return false; }; // We erased all lines if (!startIndex) [self setExtraLineFragmentRect:CGRectMake(0, 0) usedRect:CGRectMake(0, 0) textContainer:nil]; - // document.title=startIndex; + [_typesetter layoutGlyphsInLayoutManager:self startingAtGlyphIndex:startIndex maxNumberOfLineFragments:-1 nextGlyphIndex:nil]; +#if PLATFORM(DOM) [self _cleanUpDOM]; +#endif _isValidatingLayoutAndGlyphs = NO; } diff --git a/AppKit/CPTextView/CPTypesetter.j b/AppKit/CPTextView/CPTypesetter.j index 12b79c987..0bf0bd1e6 100644 --- a/AppKit/CPTextView/CPTypesetter.j +++ b/AppKit/CPTextView/CPTypesetter.j @@ -345,8 +345,15 @@ var CPSystemTypesetterFactory; lineRange.length++; measuringRange.length++; - var currentChar = theString[glyphIndex], // use pure javascript methods for performance reasons - rangeWidth = _widthOfStringForFont(theString.substr(measuringRange.location, measuringRange.length), _currentFont).width + currentAnchor; + + var currentChar = theString[glyphIndex]; + +#if PLATFORM(DOM) + // use pure javascript methods for performance reasons -> why don't we use sizeWithFont ? + var rangeWidth = _widthOfStringForFont(theString.substr(measuringRange.location, measuringRange.length), _currentFont).width + currentAnchor; +#else + var rangeWidth = [theString.substr(measuringRange.location, measuringRange.length) sizeWithFont:_currentFont].width + currentAnchor; +#endif switch (currentChar) // faster than sending actionForControlCharacterAtIndex: called for each char. { @@ -365,11 +372,10 @@ var CPSystemTypesetterFactory; wrapRange = CPMakeRangeCopy(lineRange); wrapWidth = rangeWidth; break; + default: if (_isNewlineCharacter(currentChar)) - { isNewline = YES; - } } advancements.push(rangeWidth - prevRangeWidth);