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

Unified Diff: third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h

Issue 2007103003: Expand WTF::StringView's API to be more like StringPiece. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove bad assert. 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/core/html/parser/HTMLSrcsetParser.h
diff --git a/third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h b/third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h
index 16492ee1c58b5f9af60161b893e3b278a74e4150..612b4425d0466e4f72fa20257bbdde108510e4aa 100644
--- a/third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h
+++ b/third_party/WebKit/Source/core/html/parser/HTMLSrcsetParser.h
@@ -34,6 +34,7 @@
#include "core/CoreExport.h"
#include "wtf/Allocator.h"
+#include "wtf/text/StringView.h"
#include "wtf/text/WTFString.h"
namespace blink {
@@ -86,21 +87,22 @@ public:
}
ImageCandidate(const String& source, unsigned start, unsigned length, const DescriptorParsingResult& result, OriginAttribute originAttribute)
- : m_string(source.createView(start, length))
- , m_density(result.hasDensity()?result.density():UninitializedDescriptor)
- , m_resourceWidth(result.hasWidth()?result.getResourceWidth():UninitializedDescriptor)
+ : m_source(source)
+ , m_string(source, start, length)
+ , m_density(result.hasDensity() ? result.density() : UninitializedDescriptor)
+ , m_resourceWidth(result.hasWidth() ? result.getResourceWidth() : UninitializedDescriptor)
, m_originAttribute(originAttribute)
{
}
String toString() const
{
- return String(m_string.toString());
+ return m_string.toString();
}
AtomicString url() const
{
- return AtomicString(m_string.toString());
+ return AtomicString(toString());
}
void setDensity(float factor)
@@ -129,6 +131,7 @@ public:
}
private:
+ String m_source; // Keep the StringView buffer alive.
StringView m_string;
float m_density;
int m_resourceWidth;

Powered by Google App Engine
This is Rietveld 408576698