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..cb437b07290f371b71e95032e4bd01e12788986b 100644 |
--- a/Source/core/html/parser/HTMLSrcsetParser.h |
+++ b/Source/core/html/parser/HTMLSrcsetParser.h |
@@ -35,20 +35,31 @@ |
namespace WebCore { |
-struct DescriptorParsingResult { |
- float scaleFactor; |
- int resourceWidth; |
- |
+class DescriptorParsingResult { |
eseidel
2014/05/29 06:59:53
Much nicer, thanks.
|
+public: |
DescriptorParsingResult() |
+ : m_density(-1.0) |
+ , m_resourceWidth(-1) |
+ , m_resourceHeight(-1) |
{ |
- scaleFactor = -1.0; |
- resourceWidth = -1; |
} |
- bool foundDescriptor() const |
- { |
- return (scaleFactor >= 0 || resourceWidth >= 0); |
- } |
+ bool hasDensity() { return m_density >= 0; } |
+ bool hasWidth() { return m_resourceWidth >= 0; } |
+ bool hasHeight() { return m_resourceHeight >= 0; } |
+ |
+ float density() const { ASSERT(hasDensity()); return m_density; } |
+ unsigned resourceWidth() const { ASSERT(hasWidth()); return m_resourceWidth; } |
+ unsigned resourceHeight() const { ASSERT(hasHeight()); return m_resourceHeight; } |
+ |
+ void setResourceWidth(int width) { ASSERT(width >= 0); m_resourceWidth = (unsigned)width; } |
+ void setResourceHeight(int height) { ASSERT(height >= 0); m_resourceHeight = (unsigned)height; } |
+ void setDensity(float densityToSet) { ASSERT(densityToSet >= 0); m_density = densityToSet; } |
+ |
+private: |
+ float m_density; |
+ int m_resourceWidth; |
+ int m_resourceHeight; |
}; |
class ImageCandidate { |
@@ -59,14 +70,14 @@ 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_resourceWidth(result.resourceWidth) |
+ , m_density(result.density()) |
+ , m_resourceWidth(result.resourceWidth()) |
, m_originAttribute(originAttribute) |
{ |
} |
@@ -81,14 +92,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 +119,7 @@ public: |
private: |
StringView m_string; |
- float m_scaleFactor; |
+ float m_density; |
int m_resourceWidth; |
OriginAttribute m_originAttribute; |
}; |