Chromium Code Reviews| Index: Source/core/html/parser/HTMLSrcsetParser.h |
| diff --git a/Source/core/html/parser/HTMLSrcsetParser.h b/Source/core/html/parser/HTMLSrcsetParser.h |
| index 861df34a418c7e0a15efb08a88c96c0bfdb8c6d2..81e6a30913eb30041eff8aea1673eb580571b140 100644 |
| --- a/Source/core/html/parser/HTMLSrcsetParser.h |
| +++ b/Source/core/html/parser/HTMLSrcsetParser.h |
| @@ -35,6 +35,22 @@ |
| namespace WebCore { |
| +struct DescriptorParsingResult { |
| + float scaleFactor; |
| + int resourceWidth; |
| + |
| + DescriptorParsingResult() |
| + { |
| + scaleFactor = -1.0; |
| + resourceWidth = -1; |
| + } |
| + |
| + inline bool foundDescriptor() |
|
eseidel
2014/04/10 16:42:19
No need to mark "inline". "const" would be approp
|
| + { |
| + return (scaleFactor >= 0 || resourceWidth >= 0); |
| + } |
| +}; |
| + |
| class ImageCandidate { |
| public: |
| ImageCandidate() |
| @@ -42,9 +58,10 @@ public: |
| { |
| } |
| - ImageCandidate(const String& source, unsigned start, unsigned length, float scaleFactor) |
| + ImageCandidate(const String& source, unsigned start, unsigned length, const DescriptorParsingResult& result) |
| : m_string(source.createView(start, length)) |
| - , m_scaleFactor(scaleFactor) |
| + , m_scaleFactor(result.scaleFactor) |
| + , m_resourceWidth(result.resourceWidth) |
| { |
| } |
| @@ -58,11 +75,21 @@ public: |
| return AtomicString(m_string.toString()); |
| } |
| + void setScaleFactor(float factor) |
| + { |
| + m_scaleFactor = factor; |
| + } |
| + |
| inline float scaleFactor() const |
| { |
| return m_scaleFactor; |
| } |
| + inline int resourceWidth() const |
|
eseidel
2014/04/10 16:42:19
inline is not needed.
|
| + { |
| + return m_resourceWidth; |
| + } |
| + |
| inline bool isEmpty() const |
| { |
| return m_string.isEmpty(); |
| @@ -71,13 +98,14 @@ public: |
| private: |
| StringView m_string; |
| float m_scaleFactor; |
| + int m_resourceWidth; |
|
eseidel
2014/04/10 16:42:19
Can this be negative?
|
| }; |
| -ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const String& srcsetAttribute); |
| +ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, int effectiveSize, const String& srcsetAttribute); |
| -ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, const String& srcsetAttribute); |
| +ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, int effectiveSize, const String& srcAttribute, const String& srcsetAttribute); |
| -String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); |
| +String bestFitSourceForImageAttributes(float deviceScaleFactor, int effectiveSize, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); |
| } |