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

Unified Diff: third_party/WebKit/Source/wtf/text/StringView.h

Issue 2024373002: Replace CSSParserString with StringView. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Match arguments to equalStringView. 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/wtf/text/StringView.h
diff --git a/third_party/WebKit/Source/wtf/text/StringView.h b/third_party/WebKit/Source/wtf/text/StringView.h
index b595bc980131b5f6f751edbe1a0b01fd9d0d8d93..94b33fd33eb6140b51bf2545de84af6f69e790a2 100644
--- a/third_party/WebKit/Source/wtf/text/StringView.h
+++ b/third_party/WebKit/Source/wtf/text/StringView.h
@@ -70,6 +70,14 @@ public:
StringView(const UChar* chars);
StringView(const UChar* chars, unsigned length);
+ // From a byte pointer.
+ StringView(const void* bytes, unsigned length, bool is8Bit)
+ : m_length(length)
+ , m_is8Bit(is8Bit)
+ {
+ m_data.bytes = bytes;
+ }
+
#if DCHECK_IS_ON()
~StringView();
#endif
@@ -83,6 +91,14 @@ public:
void clear();
+ UChar operator[](unsigned i) const
+ {
+ SECURITY_DCHECK(i < length());
+ if (is8Bit())
+ return characters8()[i];
+ return characters16()[i];
+ }
+
const LChar* characters8() const
{
ASSERT(is8Bit());
@@ -95,6 +111,8 @@ public:
return m_data.characters16;
}
+ const void* bytes() const { return m_data.bytes; }
+
String toString() const;
private:
@@ -169,6 +187,8 @@ inline void StringView::set(StringImpl& impl, unsigned offset, unsigned length)
m_data.characters16 = impl.characters16() + offset;
}
+WTF_EXPORT bool equalIgnoringASCIICase(const StringView& a, const StringView& b);
+
// TODO(esprehn): Can't make this an overload of WTF::equal since that makes
// calls to equal() that pass literal strings ambiguous. Figure out if we can
// replace all the callers with equalStringView and then rename it to equal().
« no previous file with comments | « third_party/WebKit/Source/core/css/resolver/CSSVariableResolver.cpp ('k') | third_party/WebKit/Source/wtf/text/StringView.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698