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 a4ea6692240fd2a68a4f1b9e1034bff9ec30844a..f6e7576a8a7e9191206c81483223d19a0fd8ed9a 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*); |
|
haraken
2016/08/04 09:05:28
Add explicit.
esprehn
2016/08/04 18:30:08
It's implicit on purpose, otherwise doing
StringI
|
| + 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 a non-null StringImpl, avoids the null check. |
| StringView(StringImpl& impl) |
| @@ -133,7 +139,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 |
| @@ -162,23 +168,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(); |
| } |
| @@ -200,18 +206,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 |
| @@ -231,5 +240,8 @@ inline bool operator!=(const StringView& a, const StringView& b) |
| } // namespace WTF |
| using WTF::StringView; |
| +using WTF::equalIgnoringASCIICase; |
| +using WTF::equalIgnoringCase; |
| + |
| #endif |