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

Unified Diff: third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp

Issue 2007103003: Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Add a lot of tests, fix a bunch of bugs. 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/paint/InlineTextBoxPainter.cpp
diff --git a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
index e1d33b2f0d04da0ffe5e1530cd660e95ee791347..14db122e6bb6fbde188dce5be2080c6e855de1f3 100644
--- a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
@@ -149,10 +149,7 @@ void InlineTextBoxPainter::paint(const PaintInfo& paintInfo, const LayoutPoint&
// 2. Now paint the foreground, including text and decorations like underline/overline (in quirks mode only).
int length = m_inlineTextBox.len();
- StringView string = m_inlineTextBox.getLineLayoutItem().text().createView();
- ASSERT(m_inlineTextBox.start() + length <= string.length());
- if (static_cast<unsigned>(length) != string.length() || m_inlineTextBox.start())
- string.narrow(m_inlineTextBox.start(), length);
+ StringView string = StringView(m_inlineTextBox.getLineLayoutItem().text(), m_inlineTextBox.start(), length);
int maximumLength = m_inlineTextBox.getLineLayoutItem().textLength() - m_inlineTextBox.start();
StringBuilder charactersWithHyphen;
@@ -441,10 +438,7 @@ void InlineTextBoxPainter::paintSelection(GraphicsContext& context, const Layout
// If the text is truncated, let the thing being painted in the truncation
// draw its own highlight.
int length = m_inlineTextBox.truncation() != cNoTruncation ? m_inlineTextBox.truncation() : m_inlineTextBox.len();
- StringView string = m_inlineTextBox.getLineLayoutItem().text().createView();
-
- if (string.length() != static_cast<unsigned>(length) || m_inlineTextBox.start())
- string.narrow(m_inlineTextBox.start(), length);
+ StringView string(m_inlineTextBox.getLineLayoutItem().text(), m_inlineTextBox.start(), static_cast<unsigned>(length));
StringBuilder charactersWithHyphen;
bool respectHyphen = ePos == length && m_inlineTextBox.hasHyphen();

Powered by Google App Engine
This is Rietveld 408576698