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

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: Remove bad assert. 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 c7e62a0106e8c9b0e26d1951828b3128130d2564..30b53803e6fda58ba2cc1c7594bcb5d29a200178 100644
--- a/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
+++ b/third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp
@@ -145,10 +145,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;
@@ -437,10 +434,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