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

Unified Diff: third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp

Issue 2688413002: Calculate glyph overflow when computing overflow outside of layout (Closed)
Patch Set: 667245 Created 3 years, 10 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 | « third_party/WebKit/ManualTests/overflow-on-text-beside-form-element.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp
index c99a80a9d223a434ab7161328f1b80811064bbba..3d1618bf95d8add60049c2bde95db2ad9e02aac6 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/InlineFlowBox.cpp
@@ -1161,6 +1161,41 @@ inline void InlineFlowBox::addReplacedChildOverflow(
logicalLayoutOverflow.unite(childLogicalLayoutOverflow);
}
+static void computeGlyphOverflow(
+ InlineTextBox* text,
+ const LineLayoutText& layoutText,
+ GlyphOverflowAndFallbackFontsMap& textBoxDataMap) {
+ HashSet<const SimpleFontData*> fallbackFonts;
+ FloatRect glyphBounds;
+ GlyphOverflow glyphOverflow;
+ float measuredWidth =
+ layoutText.width(text->start(), text->len(), LayoutUnit(),
+ text->direction(), false, &fallbackFonts, &glyphBounds);
+ const Font& font = layoutText.style()->font();
+ const SimpleFontData* fontData = font.primaryFont();
+ DCHECK(fontData);
+ glyphOverflow.setFromBounds(
+ glyphBounds, fontData ? fontData->getFontMetrics().floatAscent() : 0,
+ fontData ? fontData->getFontMetrics().floatDescent() : 0, measuredWidth);
+ if (!fallbackFonts.isEmpty()) {
+ GlyphOverflowAndFallbackFontsMap::ValueType* it =
+ textBoxDataMap
+ .insert(text, std::make_pair(Vector<const SimpleFontData*>(),
+ GlyphOverflow()))
+ .storedValue;
+ DCHECK(it->value.first.isEmpty());
+ copyToVector(fallbackFonts, it->value.first);
+ }
+ if (!glyphOverflow.isApproximatelyZero()) {
+ GlyphOverflowAndFallbackFontsMap::ValueType* it =
+ textBoxDataMap
+ .insert(text, std::make_pair(Vector<const SimpleFontData*>(),
+ GlyphOverflow()))
+ .storedValue;
+ it->value.second = glyphOverflow;
+ }
+}
+
void InlineFlowBox::computeOverflow(
LayoutUnit lineTop,
LayoutUnit lineBottom,
@@ -1196,7 +1231,15 @@ void InlineFlowBox::computeOverflow(
if (rt.isBR())
continue;
LayoutRect textBoxOverflow(text->logicalFrameRect());
- addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow);
+ if (textBoxDataMap.isEmpty()) {
+ // An empty glyph map means that we're computing overflow without
+ // a layout, so calculate the glyph overflow on the fly.
+ GlyphOverflowAndFallbackFontsMap glyphOverflowForText;
+ computeGlyphOverflow(text, rt, glyphOverflowForText);
+ addTextBoxVisualOverflow(text, glyphOverflowForText, textBoxOverflow);
+ } else {
+ addTextBoxVisualOverflow(text, textBoxDataMap, textBoxOverflow);
+ }
logicalVisualOverflow.unite(textBoxOverflow);
} else if (curr->getLineLayoutItem().isLayoutInline()) {
InlineFlowBox* flow = toInlineFlowBox(curr);
« no previous file with comments | « third_party/WebKit/ManualTests/overflow-on-text-beside-form-element.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698