Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / html / parser / HTMLSrcsetParser.h
index 861df34..8e8cd1c 100644 (file)
 
 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)
     {
     }
 
@@ -58,11 +81,26 @@ public:
         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();
@@ -71,13 +109,15 @@ public:
 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);
 
 }