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

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

Issue 1897853004: Fix InlineTextBox::characterWidths() not to measure every substring (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix AutomationApiTest.BoundsForRange, use width() to simplify the logic Created 4 years, 8 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 | « no previous file | 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/InlineTextBox.cpp
diff --git a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
index f21e69a26a4ce6342e13bdbde6506129e6a648aa..6d48d9f5af7ec82a95bb363901322e41c776d65a 100644
--- a/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
+++ b/third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp
@@ -30,6 +30,7 @@
#include "core/layout/line/AbstractInlineTextBox.h"
#include "core/layout/line/EllipsisBox.h"
#include "core/paint/InlineTextBoxPainter.h"
+#include "platform/fonts/CharacterRange.h"
#include "platform/fonts/FontCache.h"
#include "platform/fonts/shaping/SimpleShaper.h"
#include "wtf/Vector.h"
@@ -544,15 +545,13 @@ void InlineTextBox::characterWidths(Vector<float>& widths) const
const ComputedStyle& styleToUse = getLineLayoutItem().styleRef(isFirstLineStyle());
const Font& font = styleToUse.font();
- float lastWidth = 0;
- widths.resize(m_len);
- for (unsigned i = 0; i < m_len; i++) {
- StringView substringView = getLineLayoutItem().text().createView();
- substringView.narrow(start(), 1 + i);
- TextRun textRun = constructTextRun(styleToUse, font, substringView, m_len);
- widths[i] = font.width(textRun, nullptr, nullptr) - lastWidth;
- lastWidth = font.width(textRun, nullptr, nullptr);
- }
+ TextRun textRun = constructTextRun(styleToUse, font);
+ Vector<CharacterRange> ranges = font.individualCharacterRanges(textRun);
+ DCHECK_EQ(ranges.size(), m_len);
+
+ widths.resize(ranges.size());
+ for (unsigned i = 0; i < ranges.size(); i++)
+ widths[i] = ranges[i].width();
}
TextRun InlineTextBox::constructTextRun(const ComputedStyle& style, const Font& font, StringBuilder* charactersWithHyphen) const
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698