namespace WebCore {
+struct DescriptorParsingResult {
+ float scaleFactor;
+ int resourceWidth;
+
+ DescriptorParsingResult()
+ {
+ scaleFactor = -1.0;
+ resourceWidth = -1;
+ }
+
+ bool foundDescriptor() const
+ {
+ return (scaleFactor >= 0 || resourceWidth >= 0);
+ }
+};
+
class ImageCandidate {
public:
+ enum OriginAttribute {
+ SrcsetOrigin,
+ SrcOrigin
+ };
+
ImageCandidate()
: m_scaleFactor(1.0)
{
}
- ImageCandidate(const String& source, unsigned start, unsigned length, float scaleFactor)
+ ImageCandidate(const String& source, unsigned start, unsigned length, const DescriptorParsingResult& result, OriginAttribute originAttribute)
: m_string(source.createView(start, length))
- , m_scaleFactor(scaleFactor)
+ , m_scaleFactor(result.scaleFactor)
+ , m_resourceWidth(result.resourceWidth)
+ , m_originAttribute(originAttribute)
{
}
return AtomicString(m_string.toString());
}
- inline float scaleFactor() const
+ void setScaleFactor(float factor)
+ {
+ m_scaleFactor = factor;
+ }
+
+ float scaleFactor() const
{
return m_scaleFactor;
}
+ int resourceWidth() const
+ {
+ return m_resourceWidth;
+ }
+
+ bool srcOrigin() const
+ {
+ return (m_originAttribute == SrcOrigin);
+ }
+
inline bool isEmpty() const
{
return m_string.isEmpty();
private:
StringView m_string;
float m_scaleFactor;
+ int m_resourceWidth;
+ OriginAttribute m_originAttribute;
};
-ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const String& srcsetAttribute);
+ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, unsigned sourceSize, const String& srcsetAttribute);
-ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, const String& srcsetAttribute);
+ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, unsigned sourceSize, const String& srcAttribute, const String& srcsetAttribute);
-String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& srcAttribute, ImageCandidate& srcsetImageCandidate);
+String bestFitSourceForImageAttributes(float deviceScaleFactor, unsigned sourceSize, const String& srcAttribute, ImageCandidate& srcsetImageCandidate);
}