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

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

Issue 293423002: Refactor srcset parser to align it with spec changes (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Added tests and fixed a bug Created 6 years, 7 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
Index: Source/core/html/parser/HTMLSrcsetParser.h
diff --git a/Source/core/html/parser/HTMLSrcsetParser.h b/Source/core/html/parser/HTMLSrcsetParser.h
index cdf3c1d64ae4f34d372b848315cac30102f48f89..2efeacd952c1c731d5752b56ab0871a9cf4037e4 100644
--- a/Source/core/html/parser/HTMLSrcsetParser.h
+++ b/Source/core/html/parser/HTMLSrcsetParser.h
@@ -36,19 +36,20 @@
namespace WebCore {
struct DescriptorParsingResult {
- float scaleFactor;
+ float density;
int resourceWidth;
+ int resourceHeight;
DescriptorParsingResult()
{
- scaleFactor = -1.0;
+ density = -1.0;
eseidel 2014/05/28 22:24:59 Bleh. Sentinel values/in-band data. :( You migh
Yoav Weiss 2014/05/29 05:17:40 OK, I'll turn that into a class with proper getter
resourceWidth = -1;
+ resourceHeight = -1;
}
- bool foundDescriptor() const
- {
- return (scaleFactor >= 0 || resourceWidth >= 0);
- }
+ bool foundDensity() { return density >= 0; }
eseidel 2014/05/28 22:24:59 I think "hasDensitiy" might be more consistent wit
Yoav Weiss 2014/05/29 05:17:40 Sure
+ bool foundWidth() { return resourceWidth >= 0; }
eseidel 2014/05/28 22:24:59 Can these ever be set to negative numbers intentio
Yoav Weiss 2014/05/29 05:17:40 No
+ bool foundHeight() { return resourceHeight >= 0; }
};
class ImageCandidate {
@@ -59,13 +60,13 @@ public:
};
ImageCandidate()
- : m_scaleFactor(1.0)
+ : m_density(1.0)
{
}
ImageCandidate(const String& source, unsigned start, unsigned length, const DescriptorParsingResult& result, OriginAttribute originAttribute)
: m_string(source.createView(start, length))
- , m_scaleFactor(result.scaleFactor)
+ , m_density(result.density)
, m_resourceWidth(result.resourceWidth)
, m_originAttribute(originAttribute)
{
@@ -81,14 +82,14 @@ public:
return AtomicString(m_string.toString());
}
- void setScaleFactor(float factor)
+ void setDensity(float factor)
{
- m_scaleFactor = factor;
+ m_density = factor;
}
- float scaleFactor() const
+ float density() const
{
- return m_scaleFactor;
+ return m_density;
}
int resourceWidth() const
@@ -108,7 +109,7 @@ public:
private:
StringView m_string;
- float m_scaleFactor;
+ float m_density;
int m_resourceWidth;
OriginAttribute m_originAttribute;
};

Powered by Google App Engine
This is Rietveld 408576698