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

Issue 2007103003: Expand WTF::StringView's API to be more like StringPiece. (Closed)

Created:
4 years, 7 months ago by esprehn
Modified:
4 years, 6 months ago
CC:
blink-reviews, blink-reviews-html_chromium.org, blink-reviews-layout_chromium.org, blink-reviews-paint_chromium.org, blink-reviews-wtf_chromium.org, chromium-reviews, dglazkov+blink, dshwang, eae+blinkwatch, jchaffraix+rendering, kinuko+watch, leviw+renderwatch, Mikhail, pdr+renderingwatchlist_chromium.org, slimming-paint-reviews_chromium.org, szager+layoutwatch_chromium.org, zoltan1
Base URL:
https://chromium.googlesource.com/chromium/src.git@master
Target Ref:
refs/pending/heads/master
Project:
chromium
Visibility:
Public.

Description

Expand WTF::StringView's API to be more like StringPiece. StringView no longer owns the string passed into it, and can now wrap a raw ptr to some characters. This allows us to leverage the inline strlen optimization where the compiler will embed the length of literal strings into the binary. It also allows the deletion many overloaded methods that used to take an LChar*, UChar* or String and can now just take a StringView instead. For example the two constructors in TextRun are now a single one that takes a StringView. This needed to be done in this patch to avoid ambiguous constructors. Future patches will replace CSSParserString with StringView, and also vastly simplify the huge number of overloads on various methods. We'll also expand the API surface of StringView to include the many useful operations that StringPiece has. This was originally committed as: https://crrev.com/330deea56e27bc760fa52101040a51428bb7f582 but was reverted due an incorrect assert in the StringView(const UChar*, unsigned length) constructor. The assert was incorrectly calling lengthOfNullTerminatedString on the UChar in the assert, but this constructor is used for byte sequences which are not null terminated. BUG=615174 Committed: https://crrev.com/9b0aad1eca55ac75f437789514224e9b922fe514 Cr-Commit-Position: refs/heads/master@{#396942}

Patch Set 1 #

Patch Set 2 : Make it non-owning. #

Patch Set 3 : Null StringView. #

Patch Set 4 : Try again. #

Patch Set 5 : fix typo for length access. #

Total comments: 11

Patch Set 6 : haraken@ review. #

Patch Set 7 : Don't assert about strlen for length specific constructor. #

Patch Set 8 : Add a lot of tests, fix a bunch of bugs. #

Total comments: 2

Patch Set 9 : Don't treat characters8() or characters16() like they're null terminated. #

Patch Set 10 : Move the constructors into StringView.h #

Patch Set 11 : clean up comments. #

Patch Set 12 : Add comments. #

Patch Set 13 : Remove bad assert. #

Unified diffs Side-by-side diffs Delta from patch set Stats (+595 lines, -171 lines) Patch
M third_party/WebKit/Source/core/css/parser/CSSParserString.h View 1 2 chunks +4 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h View 1 2 3 4 5 6 7 8 9 3 chunks +8 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutListMarker.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/LayoutText.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/line/BreakingContextInlineHeaders.h View 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/core/layout/line/InlineTextBox.cpp View 2 chunks +3 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/core/paint/InlineTextBoxPainter.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +2 lines, -8 lines 0 comments Download
M third_party/WebKit/Source/core/testing/MockHyphenation.cpp View 1 1 chunk +7 lines, -7 lines 0 comments Download
M third_party/WebKit/Source/core/testing/UnionTypesTest.cpp View 1 1 chunk +8 lines, -5 lines 0 comments Download
M third_party/WebKit/Source/platform/animation/TimingFunction.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +3 lines, -1 line 0 comments Download
M third_party/WebKit/Source/platform/exported/WebString.cpp View 1 2 chunks +6 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/platform/inspector_protocol/String16WTF.h View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/platform/mhtml/MHTMLArchive.cpp View 1 2 chunks +4 lines, -2 lines 0 comments Download
M third_party/WebKit/Source/platform/text/TextRun.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +1 line, -27 lines 0 comments Download
M third_party/WebKit/Source/platform/text/mac/HyphenationMac.cpp View 1 1 chunk +1 line, -1 line 0 comments Download
M third_party/WebKit/Source/wtf/Forward.h View 1 2 chunks +2 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringBuilder.h View 1 2 3 4 5 6 7 8 9 4 chunks +4 lines, -27 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/StringView.h View 1 2 3 4 5 6 7 8 9 10 11 1 chunk +154 lines, -73 lines 0 comments Download
A third_party/WebKit/Source/wtf/text/StringView.cpp View 1 2 3 4 5 6 7 8 9 10 11 12 1 chunk +54 lines, -0 lines 0 comments Download
A third_party/WebKit/Source/wtf/text/StringViewTest.cpp View 1 2 3 4 5 6 7 8 1 chunk +326 lines, -0 lines 0 comments Download
M third_party/WebKit/Source/wtf/text/WTFString.h View 1 2 3 4 5 6 7 8 9 10 11 12 2 chunks +0 lines, -4 lines 0 comments Download
M third_party/WebKit/Source/wtf/wtf.gypi View 1 2 3 4 5 6 7 2 chunks +2 lines, -0 lines 0 comments Download
M third_party/WebKit/public/platform/WebString.h View 1 1 chunk +2 lines, -0 lines 0 comments Download

Messages

Total messages: 60 (24 generated)
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/20001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/20001
4 years, 7 months ago (2016-05-26 02:22:45 UTC) #2
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: android_compile_dbg on tryserver.chromium.android (JOB_FAILED, https://build.chromium.org/p/tryserver.chromium.android/builders/android_compile_dbg/builds/72224)
4 years, 7 months ago (2016-05-26 02:52:59 UTC) #4
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/80001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/80001
4 years, 7 months ago (2016-05-26 20:07:17 UTC) #7
esprehn
4 years, 7 months ago (2016-05-26 20:57:53 UTC) #10
esprehn
https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringBuilder.h File third_party/WebKit/Source/wtf/text/StringBuilder.h (left): https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringBuilder.h#oldcode60 third_party/WebKit/Source/wtf/text/StringBuilder.h:60: if (!m_length && !m_buffer) { I did actually remove ...
4 years, 7 months ago (2016-05-26 20:59:08 UTC) #11
haraken
LGTM https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.cpp File third_party/WebKit/Source/wtf/text/StringView.cpp (right): https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.cpp#newcode25 third_party/WebKit/Source/wtf/text/StringView.cpp:25: if (!m_data.bytes) isNull() https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.cpp#newcode37 third_party/WebKit/Source/wtf/text/StringView.cpp:37: return a.isNull() == ...
4 years, 7 months ago (2016-05-26 22:27:22 UTC) #12
esprehn
ASAN bot also seems to have found a bug: ==28713==ERROR: AddressSanitizer: heap-buffer-overflow on address 0x60d00000b864 ...
4 years, 7 months ago (2016-05-26 22:40:22 UTC) #14
commit-bot: I haz the power
Dry run: None
4 years, 7 months ago (2016-05-26 22:40:25 UTC) #15
haraken
https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h File third_party/WebKit/Source/wtf/text/StringView.h (right): https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h#newcode80 third_party/WebKit/Source/wtf/text/StringView.h:80: bool isEmpty() const { return !m_length; } On 2016/05/26 ...
4 years, 7 months ago (2016-05-26 22:45:25 UTC) #16
esprehn
The bug that ASAN caught is that the constructor StringView(const LChar* chars, unsigned length) had ...
4 years, 7 months ago (2016-05-26 22:45:25 UTC) #17
haraken
On 2016/05/26 22:45:25, esprehn wrote: > The bug that ASAN caught is that the constructor ...
4 years, 7 months ago (2016-05-26 22:47:39 UTC) #18
esprehn
https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h File third_party/WebKit/Source/wtf/text/StringView.h (right): https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h#newcode80 third_party/WebKit/Source/wtf/text/StringView.h:80: bool isEmpty() const { return !m_length; } On 2016/05/26 ...
4 years, 7 months ago (2016-05-26 22:48:40 UTC) #19
esprehn
https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h File third_party/WebKit/Source/wtf/text/StringView.h (right): https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h#newcode80 third_party/WebKit/Source/wtf/text/StringView.h:80: bool isEmpty() const { return !m_length; } On 2016/05/26 ...
4 years, 7 months ago (2016-05-26 22:57:41 UTC) #20
haraken
On 2016/05/26 22:57:41, esprehn wrote: > https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h > File third_party/WebKit/Source/wtf/text/StringView.h (right): > > https://codereview.chromium.org/2007103003/diff/80001/third_party/WebKit/Source/wtf/text/StringView.h#newcode80 > ...
4 years, 7 months ago (2016-05-26 22:58:42 UTC) #21
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/140001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/140001
4 years, 7 months ago (2016-05-27 03:39:48 UTC) #23
commit-bot: I haz the power
Dry run: Try jobs failed on following builders: linux_chromium_asan_rel_ng on tryserver.chromium.linux (JOB_FAILED, http://build.chromium.org/p/tryserver.chromium.linux/builders/linux_chromium_asan_rel_ng/builds/168501)
4 years, 7 months ago (2016-05-27 04:42:52 UTC) #25
Yuta Kitamura
Generally seems okay but I'm concerned about having inlined definitions in different headers. https://codereview.chromium.org/2007103003/diff/140001/third_party/WebKit/Source/wtf/text/StringView.cpp File ...
4 years, 7 months ago (2016-05-27 04:47:41 UTC) #26
esprehn
Hmm, so all the tests pass on my machine, but the character ptr to StringView ...
4 years, 7 months ago (2016-05-27 05:31:28 UTC) #27
esprehn
I figured this out, you can never implicitly construct a StringView (or String, AtomicString, etc.) ...
4 years, 7 months ago (2016-05-27 05:57:24 UTC) #28
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/160001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/160001
4 years, 7 months ago (2016-05-27 05:58:00 UTC) #30
esprehn
On 2016/05/27 at 04:47:41, yutak wrote: > Generally seems okay but I'm concerned about having ...
4 years, 6 months ago (2016-05-27 06:22:23 UTC) #31
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 6 months ago (2016-05-27 08:10:37 UTC) #33
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/180001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/180001
4 years, 6 months ago (2016-05-27 08:24:57 UTC) #35
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/220001
4 years, 6 months ago (2016-05-27 08:42:57 UTC) #37
esprehn
Okay this is ready for a review from everyone. Once this lands I'll start adding ...
4 years, 6 months ago (2016-05-27 08:44:51 UTC) #38
Yuta Kitamura
lgtm
4 years, 6 months ago (2016-05-27 09:11:22 UTC) #39
commit-bot: I haz the power
Dry run: This issue passed the CQ dry run.
4 years, 6 months ago (2016-05-27 10:38:21 UTC) #41
esprehn
jyasskin@ said to go ahead and land this, he can add comments after if needed ...
4 years, 6 months ago (2016-05-27 16:52:47 UTC) #42
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/220001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/220001
4 years, 6 months ago (2016-05-27 16:53:11 UTC) #45
commit-bot: I haz the power
Committed patchset #12 (id:220001)
4 years, 6 months ago (2016-05-27 16:58:32 UTC) #46
commit-bot: I haz the power
Patchset 12 (id:??) landed as https://crrev.com/330deea56e27bc760fa52101040a51428bb7f582 Cr-Commit-Position: refs/heads/master@{#396493}
4 years, 6 months ago (2016-05-27 17:00:26 UTC) #48
sof
A revert of this CL (patchset #12 id:220001) has been created in https://codereview.chromium.org/2025503002/ by sigbjornf@opera.com. ...
4 years, 6 months ago (2016-05-28 11:38:05 UTC) #49
commit-bot: I haz the power
Dry run: CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/240001
4 years, 6 months ago (2016-05-31 19:44:13 UTC) #51
commit-bot: I haz the power
CQ is trying da patch. Follow status at https://chromium-cq-status.appspot.com/patch-status/2007103003/240001 View timeline at https://chromium-cq-status.appspot.com/patch-timeline/2007103003/240001
4 years, 6 months ago (2016-05-31 20:25:35 UTC) #57
commit-bot: I haz the power
Committed patchset #13 (id:240001)
4 years, 6 months ago (2016-05-31 21:51:46 UTC) #58
commit-bot: I haz the power
4 years, 6 months ago (2016-05-31 21:53:49 UTC) #60
Message was sent while issue was closed.
Patchset 13 (id:??) landed as
https://crrev.com/9b0aad1eca55ac75f437789514224e9b922fe514
Cr-Commit-Position: refs/heads/master@{#396942}

Powered by Google App Engine
This is Rietveld 408576698