caret loc refac

This commit is contained in:
daboe01 committed 2015-07-01 07:20:17 +02:00
1 parent 0f347cd0b4
commit 59162155de
2 files changed
+8 -10

No files matched your search

+3 -4
View File
@@ -693,17 +693,16 @@ _oncontextmenuhandler = function () { return false; };
return nil;
}
- (CGPoint)_realCharacterLocationAtLocation:(unsigned)location
- (double)_characterOffsetAtLocation:(unsigned)location inTextContainer:(CPTextContainer)aContainer
{
var lineFragment = _objectWithLocationInRange(_lineFragments, location);
if (!lineFragment)
return CGPointMake(0, 0);
return 0.0;
var index = location - lineFragment._range.location;
return CGPointMake(lineFragment._glyphsFrames[index].origin.x,
lineFragment._glyphsFrames[index].origin.y + lineFragment._glyphsOffsets[index]);
return lineFragment._glyphsOffsets[index];
}
- (void)setLineFragmentRect:(CGRect)fragmentRect forGlyphRange:(CPRange)glyphRange usedRect:(CGRect)usedRect
+5 -6
View File
@@ -663,7 +663,8 @@ var kDelegateRespondsTo_textShouldBeginEditing
var placeholderString = [[CPAttributedString alloc] initWithString:aNativeField.innerHTML attributes:attributes];
[self insertText:placeholderString]; // FIXME: this hack to provide the visual space for the inputmanager should at least bypass the undomanager
var caretOrigin = [_layoutManager _realCharacterLocationAtLocation:MAX(0, _selectionRange.location - 1)];
var caretOrigin = [_layoutManager boundingRectForGlyphRange:CPMakeRange(MAX(0, _selectionRange.location - 1), 1) inTextContainer:_textContainer].origin;
caretOrigin.y += [_layoutManager _characterOffsetAtLocation:MAX(0, _selectionRange.location - 1) inTextContainer:_textContainer];
caretOrigin.x += 2; // two pixel offset to the LHS character
#if PLATFORM(DOM)
@@ -1775,16 +1776,14 @@ var kDelegateRespondsTo_textShouldBeginEditing
}
}
else
{
caretRect = [_layoutManager boundingRectForGlyphRange:CPMakeRange(_selectionRange.location, 1) inTextContainer:_textContainer];
}
var caretOrigin = [_layoutManager _realCharacterLocationAtLocation:_selectionRange.location],
var caretOffset = [_layoutManager _characterOffsetAtLocation:_selectionRange.location inTextContainer:_textContainer],
oldYPosition = CGRectGetMaxY(caretRect);
if (caretOrigin.x > 0 || caretOrigin.y > 0)
if (caretOffset > 0)
{
caretRect.origin = caretOrigin;
caretRect.origin.y += caretOffset;
caretRect.size.height = oldYPosition - caretRect.origin.y;
}