[webkit-reviews] review granted: [Bug 233259] InlineIterator::TextBox::offsetForPosition and positionForOffset should be layout path independent : [Attachment 444530] Patch
bugzilla-daemon at webkit.org
bugzilla-daemon at webkit.org
Wed Nov 17 10:12:08 PST 2021
zalan <zalan at apple.com> has granted Antti Koivisto <koivisto at iki.fi>'s request
for review:
Bug 233259: InlineIterator::TextBox::offsetForPosition and positionForOffset
should be layout path independent
https://bugs.webkit.org/show_bug.cgi?id=233259
Attachment 444530: Patch
https://bugs.webkit.org/attachment.cgi?id=444530&action=review
--- Comment #2 from zalan <zalan at apple.com> ---
Comment on attachment 444530
--> https://bugs.webkit.org/attachment.cgi?id=444530
Patch
View in context: https://bugs.webkit.org/attachment.cgi?id=444530&action=review
> Source/WebCore/rendering/LegacyInlineTextBox.cpp:-494
> -int LegacyInlineTextBox::offsetForPosition(float lineOffset, bool
includePartialGlyphs) const
> -{
> - if (isLineBreak())
> - return 0;
> - if (lineOffset - logicalLeft() > logicalWidth())
> - return isLeftToRightDirection() ? len() : 0;
> - if (lineOffset - logicalLeft() < 0)
> - return isLeftToRightDirection() ? 0 : len();
> - bool ignoreCombinedText = true;
> - bool ignoreHyphen = true;
> - return lineFont().offsetForPosition(createTextRun(ignoreCombinedText,
ignoreHyphen), lineOffset - logicalLeft(), includePartialGlyphs);
> -}
> -
> -float LegacyInlineTextBox::positionForOffset(unsigned offset) const
> -{
> - ASSERT(offset >= m_start);
> - ASSERT(offset <= m_start + len());
> -
> - if (isLineBreak())
> - return logicalLeft();
> -
> - unsigned startOffset;
> - unsigned endOffset;
> - if (isLeftToRightDirection()) {
> - startOffset = 0;
> - endOffset = selectableRange().clamp(offset);
> - } else {
> - startOffset = selectableRange().clamp(offset);
> - endOffset = m_len;
> - }
> -
> - // FIXME: Do we need to add rightBearing here?
> - LayoutRect selectionRect = LayoutRect(logicalLeft(), 0, 0, 0);
> - bool ignoreCombinedText = true;
> - bool ignoreHyphen = true;
> - TextRun textRun = createTextRun(ignoreCombinedText, ignoreHyphen);
> - lineFont().adjustSelectionRectForText(textRun, selectionRect,
startOffset, endOffset);
> - return snapRectToDevicePixelsWithWritingDirection(selectionRect,
renderer().document().deviceScaleFactor(), textRun.ltr()).maxX();
> -}
> -
nice.
More information about the webkit-reviews
mailing list