Index: third_party/WebKit/Source/wtf/text/StringImpl.h |
diff --git a/third_party/WebKit/Source/wtf/text/StringImpl.h b/third_party/WebKit/Source/wtf/text/StringImpl.h |
index eaf077a7371ca90940ca996c9327900bc18c478d..a0bcc9a227c4b7a2b083b409c374a2a12983d392 100644 |
--- a/third_party/WebKit/Source/wtf/text/StringImpl.h |
+++ b/third_party/WebKit/Source/wtf/text/StringImpl.h |
@@ -29,6 +29,7 @@ |
#include "wtf/StringHasher.h" |
#include "wtf/Vector.h" |
#include "wtf/WTFExport.h" |
+#include "wtf/text/StringView.h" |
#include "wtf/text/Unicode.h" |
#include <limits.h> |
@@ -743,6 +744,32 @@ inline PassRefPtr<StringImpl> StringImpl::isolatedCopy() const |
return create(characters16(), m_length); |
} |
+inline void StringView::set(StringImpl& impl, unsigned offset, unsigned length) |
+{ |
+ SECURITY_DCHECK(offset + length <= impl.length()); |
+ m_length = length; |
+ m_is8Bit = impl.is8Bit(); |
+ if (m_is8Bit) |
+ m_data.characters8 = impl.characters8() + offset; |
+ else |
+ m_data.characters16 = impl.characters16() + offset; |
+} |
+ |
+inline StringView::StringView(StringImpl* impl) |
+{ |
+ impl ? set(*impl, 0, impl->length()) : clear(); |
+} |
+ |
+inline StringView::StringView(StringImpl* impl, unsigned offset) |
+{ |
+ impl ? set(*impl, offset, impl->length()) : clear(); |
+} |
+ |
+inline StringView::StringView(StringImpl* impl, unsigned offset, unsigned length) |
+{ |
+ impl ? set(*impl, offset, length) : clear(); |
+} |
+ |
// TODO(rob.buis) possibly find a better place for this method. |
// Turns a UChar32 to uppercase based on localeIdentifier. |
WTF_EXPORT UChar32 toUpper(UChar32, const AtomicString& localeIdentifier); |