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

Unified Diff: Source/core/layout/LayoutBlockFlowLine.cpp

Issue 1203743002: Include glyph overflows caused by negative spacing into visual overflow (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Add comments about negative word-spacing/letter-spacing Created 5 years, 6 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
« no previous file with comments | « LayoutTests/fast/text/international/rtl-negative-letter-spacing.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/layout/LayoutBlockFlowLine.cpp
diff --git a/Source/core/layout/LayoutBlockFlowLine.cpp b/Source/core/layout/LayoutBlockFlowLine.cpp
index d2f019afb8326c13d52344df1aeed22f5ecdb944..c39387c323646137d2bd88f1e53b49812cecd5d9 100644
--- a/Source/core/layout/LayoutBlockFlowLine.cpp
+++ b/Source/core/layout/LayoutBlockFlowLine.cpp
@@ -398,7 +398,7 @@ static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru
int lastEndOffset = run->m_start;
for (size_t i = 0, size = wordMeasurements.size(); i < size && lastEndOffset < run->m_stop; ++i) {
const WordMeasurement& wordMeasurement = wordMeasurements[i];
- if (wordMeasurement.width <=0 || wordMeasurement.startOffset == wordMeasurement.endOffset)
+ if (wordMeasurement.startOffset == wordMeasurement.endOffset)
continue;
if (wordMeasurement.layoutText != layoutText || wordMeasurement.startOffset != lastEndOffset || wordMeasurement.endOffset > run->m_stop)
continue;
@@ -421,16 +421,24 @@ static inline void setLogicalWidthForTextRun(RootInlineBox* lineBox, BidiRun* ru
fallbackFonts.add(*it);
}
}
- if (measuredWidth && lastEndOffset != run->m_stop) {
+ if (lastEndOffset != run->m_stop) {
// If we don't have enough cached data, we'll measure the run again.
- measuredWidth = 0;
+ canUseSimpleFontCodePath = false;
fallbackFonts.clear();
}
}
- if (!measuredWidth)
+ // Don't put this into 'else' part of the above 'if' because canUseSimpleFontCodePath may be modified in the 'if' block.
+ if (!canUseSimpleFontCodePath)
measuredWidth = layoutText->width(run->m_start, run->m_stop - run->m_start, xPos, run->direction(), lineInfo.isFirstLine(), &fallbackFonts, &glyphBounds);
+ // Negative word-spacing and/or letter-spacing may cause some glyphs to overflow the left boundary and result
+ // negative measured width. Reset measured width to 0 and adjust glyph bounds accordingly to cover the overflow.
+ if (measuredWidth < 0) {
+ glyphBounds.move(measuredWidth, 0);
+ measuredWidth = 0;
+ }
+
glyphOverflow.setFromBounds(glyphBounds, font.fontMetrics().floatAscent(), font.fontMetrics().floatDescent(), measuredWidth);
run->m_box->setLogicalWidth(measuredWidth + hyphenWidth);
« no previous file with comments | « LayoutTests/fast/text/international/rtl-negative-letter-spacing.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698