Index: Source/core/html/parser/HTMLSrcsetParser.h |
diff --git a/Source/core/html/parser/HTMLSrcsetParser.h b/Source/core/html/parser/HTMLSrcsetParser.h |
new file mode 100644 |
index 0000000000000000000000000000000000000000..5a8ed98b9aadef2c10a52940543ff244903abc05 |
--- /dev/null |
+++ b/Source/core/html/parser/HTMLSrcsetParser.h |
@@ -0,0 +1,61 @@ |
+// Copyright 2013 The Chromium Authors. All rights reserved. |
+// Use of this source code is governed by a BSD-style license that can be |
+// found in the LICENSE file. |
abarth-chromium
2013/09/19 18:09:52
This isn't the correct license block. Please use
|
+ |
+#ifndef HTMLSrcsetParser_h |
+#define HTMLSrcsetParser_h |
+ |
+#include "wtf/text/WTFString.h" |
+ |
+namespace WebCore { |
+ |
+class ImageCandidate { |
+public: |
+ ImageCandidate() |
abarth-chromium
2013/09/19 18:09:52
Please initialize m_scaleFactor. Otherwise m_scal
|
+ { |
+ } |
+ |
+ ImageCandidate& operator=(const ImageCandidate& candidate) |
+ { |
+ m_string = candidate.m_string; |
+ m_scaleFactor = candidate.m_scaleFactor; |
+ return *this; |
+ } |
abarth-chromium
2013/09/19 18:09:52
No need to write this code explicitly. The compil
|
+ |
+ ImageCandidate(const String& source, unsigned start, unsigned length, float scaleFactor) |
+ : m_string(source.createView(start, length)) |
+ , m_scaleFactor(scaleFactor) |
+ { |
+ } |
+ |
+ inline String toString() const |
+ { |
+ if (m_string.is8Bit()) |
+ return String(m_string.characters8(), m_string.length()); |
+ return String(m_string.characters16(), m_string.length()); |
+ } |
abarth-chromium
2013/09/19 18:09:52
There's no need for the |inline| keyword here. Th
Yoav Weiss
2013/09/20 07:31:36
m_string is a StringView, so it doesn't have toStr
abarth-chromium
2013/09/20 16:08:07
Thanks!
|
+ |
+ inline float scaleFactor() const |
+ { |
+ return m_scaleFactor; |
+ } |
+ |
+ inline bool isEmpty() const |
+ { |
+ return m_string.isEmpty(); |
+ } |
+ |
+private: |
+ StringView m_string; |
+ float m_scaleFactor; |
+}; |
+ |
+ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const String& srcsetAttribute); |
+ |
+String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, const String& srcsetAttribute); |
+ |
+String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); |
+ |
+} |
+ |
+#endif |