Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(707)

Unified Diff: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h

Issue 1966703002: Support includePartialGlyphs=false in Font::offsetForPositionForComplexText (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add comment as per eae review Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
diff --git a/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h b/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
index 8b3502759df223b06e87e735178546322d2795d8..7b5d2a0a98770914df9efc22daa3aa66bbd6a2a1 100644
--- a/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
+++ b/third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h
@@ -604,34 +604,21 @@ ALWAYS_INLINE bool BreakingContext::rewindToMidWordBreak(LineLayoutText text,
// TODO(kojii): should be replaced with safe-to-break when hb is ready.
float x = m_width.availableWidth() + LayoutUnit::epsilon() - m_width.currentWidth();
+ if (run.rtl())
+ x = wordMeasurement.width - x;
len = font.offsetForPosition(run, x, false);
if (!len && !m_width.currentWidth())
return rewindToFirstMidWordBreak(text, style, font, breakAll, wordMeasurement);
- FloatRect rect = font.selectionRectForText(run, FloatPoint(), 0, 0, len);
- // HarfBuzzShaper ignores includePartialGlyphs=false, so we need to find the
- // real width that fits. Usually a few loops at maximum.
- if (len && !m_width.fitsOnLine(rect.width())) {
- for (; ; ) {
- --len;
- if (!len) {
- rect.setWidth(0);
- break;
- }
- rect = font.selectionRectForText(run, FloatPoint(), 0, 0, len);
- if (m_width.fitsOnLine(rect.width()))
- break;
- }
- }
-
int end = start + len;
if (breakAll) {
end = lastBreakablePositionForBreakAll(text, style, start, end);
if (!end)
return false;
- rect = font.selectionRectForText(run, FloatPoint(), 0, 0, end - start);
+ len = end - start;
}
-
+ FloatRect rect = font.selectionRectForText(run, FloatPoint(), 0, 0, len);
+ DCHECK(m_width.fitsOnLine(rect.width() - 1)); // avoid failure when rect is rounded up.
return rewindToMidWordBreak(wordMeasurement, end, rect.width());
}

Powered by Google App Engine
This is Rietveld 408576698