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

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

Issue 233213003: Extend srcset's syntax to include 'w' descriptors (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Fixed nits and modified multiple descriptor layout test Created 6 years, 8 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
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | Source/core/html/parser/HTMLSrcsetParser.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..318992142e7dfeea3553b27819a39fd91a7d73ee 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;
+ }
+
+ bool foundDescriptor() const
+ {
+ 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());
}
- inline float scaleFactor() const
+ void setScaleFactor(float factor)
+ {
+ m_scaleFactor = factor;
+ }
+
+ float scaleFactor() const
{
return m_scaleFactor;
}
+ int resourceWidth() const
+ {
+ 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;
};
-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);
}
« no previous file with comments | « Source/core/html/parser/HTMLPreloadScanner.cpp ('k') | Source/core/html/parser/HTMLSrcsetParser.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698