Chromium Code Reviews| 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 6433c383e0bd17dd2a0022de3abf7697735fb371..fa9de38de2d8370625a6a859794b93e746094124 100644 |
| --- a/third_party/WebKit/Source/wtf/text/StringView.h |
| +++ b/third_party/WebKit/Source/wtf/text/StringView.h |
| @@ -39,9 +39,15 @@ public: |
| : StringView(view, offset, view.m_length - offset) {} |
| // From a StringImpl: |
| - StringView(StringImpl*); |
| - StringView(StringImpl*, unsigned offset); |
| - StringView(StringImpl*, unsigned offset, unsigned length); |
| + StringView(const StringImpl*); |
|
esprehn
2016/08/04 08:43:06
const StringImpl* is kind of silly since they're i
|
| + StringView(const StringImpl*, unsigned offset); |
| + StringView(const StringImpl*, unsigned offset, unsigned length); |
| + |
| + // From a non-null StringImpl. |
| + StringView(const StringImpl& impl) |
| + : m_impl(const_cast<StringImpl*>(&impl)) |
| + , m_bytes(impl.bytes()) |
| + , m_length(impl.length()) {} |
| // From an String, implemented in String.h |
| inline StringView(const String&, unsigned offset, unsigned length); |
| @@ -125,7 +131,7 @@ public: |
| AtomicString toAtomicString() const; |
| private: |
| - void set(StringImpl&, unsigned offset, unsigned length); |
| + void set(const StringImpl&, unsigned offset, unsigned length); |
| // We use the StringImpl to mark for 8bit or 16bit, even for strings where |
| // we were constructed from a char pointer. So m_impl->bytes() might have |
| @@ -154,23 +160,23 @@ inline StringView::StringView(const StringView& view, unsigned offset, unsigned |
| m_characters16 = view.characters16() + offset; |
| } |
| -inline StringView::StringView(StringImpl* impl) |
| +inline StringView::StringView(const StringImpl* impl) |
| { |
| if (!impl) { |
| clear(); |
| return; |
| } |
| - m_impl = impl; |
| + m_impl = const_cast<StringImpl*>(impl); |
| m_length = impl->length(); |
| m_bytes = impl->bytes(); |
| } |
| -inline StringView::StringView(StringImpl* impl, unsigned offset) |
| +inline StringView::StringView(const StringImpl* impl, unsigned offset) |
| { |
| impl ? set(*impl, offset, impl->length() - offset) : clear(); |
| } |
| -inline StringView::StringView(StringImpl* impl, unsigned offset, unsigned length) |
| +inline StringView::StringView(const StringImpl* impl, unsigned offset, unsigned length) |
| { |
| impl ? set(*impl, offset, length) : clear(); |
| } |
| @@ -182,18 +188,21 @@ inline void StringView::clear() |
| m_impl = StringImpl::empty(); // mark as 8 bit. |
| } |
| -inline void StringView::set(StringImpl& impl, unsigned offset, unsigned length) |
| +inline void StringView::set(const StringImpl& impl, unsigned offset, unsigned length) |
| { |
| SECURITY_DCHECK(offset + length <= impl.length()); |
| m_length = length; |
| - m_impl = &impl; |
| + m_impl = const_cast<StringImpl*>(&impl); |
| if (impl.is8Bit()) |
| m_characters8 = impl.characters8() + offset; |
| else |
| m_characters16 = impl.characters16() + offset; |
| } |
| -WTF_EXPORT bool equalIgnoringASCIICase(const StringView& a, const StringView& b); |
| +WTF_EXPORT bool equalIgnoringCase(const StringView&, const StringView&); |
| +WTF_EXPORT bool equalIgnoringASCIICase(const StringView&, const StringView&); |
| + |
| +WTF_EXPORT bool equalIgnoringCaseAndNullity(const StringView&, const StringView&); |
| // 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 |
| @@ -213,5 +222,8 @@ inline bool operator!=(const StringView& a, const StringView& b) |
| } // namespace WTF |
| using WTF::StringView; |
| +using WTF::equalIgnoringASCIICase; |
| +using WTF::equalIgnoringCase; |
| + |
| #endif |