| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Apple Inc. All rights reserved. | 2 * Copyright (C) 2013 Apple Inc. All rights reserved. |
| 3 * Copyright (C) 2013 Google Inc. All rights reserved. | 3 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 4 * | 4 * |
| 5 * Redistribution and use in source and binary forms, with or without | 5 * Redistribution and use in source and binary forms, with or without |
| 6 * modification, are permitted provided that the following conditions are | 6 * modification, are permitted provided that the following conditions are |
| 7 * met: | 7 * met: |
| 8 * | 8 * |
| 9 * * Redistributions of source code must retain the above copyright | 9 * * Redistributions of source code must retain the above copyright |
| 10 * notice, this list of conditions and the following disclaimer. | 10 * notice, this list of conditions and the following disclaimer. |
| (...skipping 15 matching lines...) Expand all Loading... |
| 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 26 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 27 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 28 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 29 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 30 */ | 30 */ |
| 31 | 31 |
| 32 #ifndef HTMLSrcsetParser_h | 32 #ifndef HTMLSrcsetParser_h |
| 33 #define HTMLSrcsetParser_h | 33 #define HTMLSrcsetParser_h |
| 34 | 34 |
| 35 #include "core/CoreExport.h" | 35 #include "core/CoreExport.h" |
| 36 #include "wtf/Allocator.h" |
| 36 #include "wtf/text/WTFString.h" | 37 #include "wtf/text/WTFString.h" |
| 37 | 38 |
| 38 namespace blink { | 39 namespace blink { |
| 39 | 40 |
| 40 class Document; | 41 class Document; |
| 41 | 42 |
| 42 enum { UninitializedDescriptor = -1 }; | 43 enum { UninitializedDescriptor = -1 }; |
| 43 | 44 |
| 44 class DescriptorParsingResult { | 45 class DescriptorParsingResult { |
| 46 STACK_ALLOCATED(); |
| 45 public: | 47 public: |
| 46 DescriptorParsingResult() | 48 DescriptorParsingResult() |
| 47 : m_density(UninitializedDescriptor) | 49 : m_density(UninitializedDescriptor) |
| 48 , m_resourceWidth(UninitializedDescriptor) | 50 , m_resourceWidth(UninitializedDescriptor) |
| 49 , m_resourceHeight(UninitializedDescriptor) | 51 , m_resourceHeight(UninitializedDescriptor) |
| 50 { | 52 { |
| 51 } | 53 } |
| 52 | 54 |
| 53 bool hasDensity() const { return m_density >= 0; } | 55 bool hasDensity() const { return m_density >= 0; } |
| 54 bool hasWidth() const { return m_resourceWidth >= 0; } | 56 bool hasWidth() const { return m_resourceWidth >= 0; } |
| 55 bool hasHeight() const { return m_resourceHeight >= 0; } | 57 bool hasHeight() const { return m_resourceHeight >= 0; } |
| 56 | 58 |
| 57 float density() const { ASSERT(hasDensity()); return m_density; } | 59 float density() const { ASSERT(hasDensity()); return m_density; } |
| 58 unsigned resourceWidth() const { ASSERT(hasWidth()); return m_resourceWidth;
} | 60 unsigned resourceWidth() const { ASSERT(hasWidth()); return m_resourceWidth;
} |
| 59 unsigned resourceHeight() const { ASSERT(hasHeight()); return m_resourceHeig
ht; } | 61 unsigned resourceHeight() const { ASSERT(hasHeight()); return m_resourceHeig
ht; } |
| 60 | 62 |
| 61 void setResourceWidth(int width) { ASSERT(width >= 0); m_resourceWidth = (un
signed)width; } | 63 void setResourceWidth(int width) { ASSERT(width >= 0); m_resourceWidth = (un
signed)width; } |
| 62 void setResourceHeight(int height) { ASSERT(height >= 0); m_resourceHeight =
(unsigned)height; } | 64 void setResourceHeight(int height) { ASSERT(height >= 0); m_resourceHeight =
(unsigned)height; } |
| 63 void setDensity(float densityToSet) { ASSERT(densityToSet >= 0); m_density =
densityToSet; } | 65 void setDensity(float densityToSet) { ASSERT(densityToSet >= 0); m_density =
densityToSet; } |
| 64 | 66 |
| 65 private: | 67 private: |
| 66 float m_density; | 68 float m_density; |
| 67 int m_resourceWidth; | 69 int m_resourceWidth; |
| 68 int m_resourceHeight; | 70 int m_resourceHeight; |
| 69 }; | 71 }; |
| 70 | 72 |
| 71 class ImageCandidate { | 73 class ImageCandidate { |
| 74 ALLOW_ONLY_INLINE_ALLOCATION(); |
| 72 public: | 75 public: |
| 73 enum OriginAttribute { | 76 enum OriginAttribute { |
| 74 SrcsetOrigin, | 77 SrcsetOrigin, |
| 75 SrcOrigin | 78 SrcOrigin |
| 76 }; | 79 }; |
| 77 | 80 |
| 78 ImageCandidate() | 81 ImageCandidate() |
| 79 : m_density(1.0) | 82 : m_density(1.0) |
| 80 , m_resourceWidth(UninitializedDescriptor) | 83 , m_resourceWidth(UninitializedDescriptor) |
| 81 , m_originAttribute(SrcsetOrigin) | 84 , m_originAttribute(SrcsetOrigin) |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 134 | 137 |
| 135 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, float so
urceSize, const String& srcsetAttribute, Document* = nullptr); | 138 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, float so
urceSize, const String& srcsetAttribute, Document* = nullptr); |
| 136 | 139 |
| 137 CORE_EXPORT ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFact
or, float sourceSize, const String& srcAttribute, const String& srcsetAttribute,
Document* = nullptr); | 140 CORE_EXPORT ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFact
or, float sourceSize, const String& srcAttribute, const String& srcsetAttribute,
Document* = nullptr); |
| 138 | 141 |
| 139 String bestFitSourceForImageAttributes(float deviceScaleFactor, float sourceSize
, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); | 142 String bestFitSourceForImageAttributes(float deviceScaleFactor, float sourceSize
, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); |
| 140 | 143 |
| 141 } | 144 } |
| 142 | 145 |
| 143 #endif | 146 #endif |
| OLD | NEW |