| 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 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 79 }; | 79 }; |
| 80 | 80 |
| 81 ImageCandidate() | 81 ImageCandidate() |
| 82 : m_density(1.0) | 82 : m_density(1.0) |
| 83 , m_resourceWidth(UninitializedDescriptor) | 83 , m_resourceWidth(UninitializedDescriptor) |
| 84 , m_originAttribute(SrcsetOrigin) | 84 , m_originAttribute(SrcsetOrigin) |
| 85 { | 85 { |
| 86 } | 86 } |
| 87 | 87 |
| 88 ImageCandidate(const String& source, unsigned start, unsigned length, const
DescriptorParsingResult& result, OriginAttribute originAttribute) | 88 ImageCandidate(const String& source, unsigned start, unsigned length, const
DescriptorParsingResult& result, OriginAttribute originAttribute) |
| 89 : m_string(source.createView(start, length)) | 89 : m_source(source) |
| 90 , m_density(result.hasDensity()?result.density():UninitializedDescriptor
) | 90 , m_string(source, start, length) |
| 91 , m_resourceWidth(result.hasWidth()?result.getResourceWidth():Uninitiali
zedDescriptor) | 91 , m_density(result.hasDensity() ? result.density() : UninitializedDescri
ptor) |
| 92 , m_resourceWidth(result.hasWidth() ? result.getResourceWidth() : Uninit
ializedDescriptor) |
| 92 , m_originAttribute(originAttribute) | 93 , m_originAttribute(originAttribute) |
| 93 { | 94 { |
| 94 } | 95 } |
| 95 | 96 |
| 96 String toString() const | 97 String toString() const |
| 97 { | 98 { |
| 98 return String(m_string.toString()); | 99 return m_string.toString(); |
| 99 } | 100 } |
| 100 | 101 |
| 101 AtomicString url() const | 102 AtomicString url() const |
| 102 { | 103 { |
| 103 return AtomicString(m_string.toString()); | 104 return AtomicString(toString()); |
| 104 } | 105 } |
| 105 | 106 |
| 106 void setDensity(float factor) | 107 void setDensity(float factor) |
| 107 { | 108 { |
| 108 m_density = factor; | 109 m_density = factor; |
| 109 } | 110 } |
| 110 | 111 |
| 111 float density() const | 112 float density() const |
| 112 { | 113 { |
| 113 return m_density; | 114 return m_density; |
| 114 } | 115 } |
| 115 | 116 |
| 116 int getResourceWidth() const | 117 int getResourceWidth() const |
| 117 { | 118 { |
| 118 return m_resourceWidth; | 119 return m_resourceWidth; |
| 119 } | 120 } |
| 120 | 121 |
| 121 bool srcOrigin() const | 122 bool srcOrigin() const |
| 122 { | 123 { |
| 123 return (m_originAttribute == SrcOrigin); | 124 return (m_originAttribute == SrcOrigin); |
| 124 } | 125 } |
| 125 | 126 |
| 126 inline bool isEmpty() const | 127 inline bool isEmpty() const |
| 127 { | 128 { |
| 128 return m_string.isEmpty(); | 129 return m_string.isEmpty(); |
| 129 } | 130 } |
| 130 | 131 |
| 131 private: | 132 private: |
| 133 String m_source; // Keep the StringView buffer alive. |
| 132 StringView m_string; | 134 StringView m_string; |
| 133 float m_density; | 135 float m_density; |
| 134 int m_resourceWidth; | 136 int m_resourceWidth; |
| 135 OriginAttribute m_originAttribute; | 137 OriginAttribute m_originAttribute; |
| 136 }; | 138 }; |
| 137 | 139 |
| 138 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, float so
urceSize, const String& srcsetAttribute, Document* = nullptr); | 140 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, float so
urceSize, const String& srcsetAttribute, Document* = nullptr); |
| 139 | 141 |
| 140 CORE_EXPORT ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFact
or, float sourceSize, const String& srcAttribute, const String& srcsetAttribute,
Document* = nullptr); | 142 CORE_EXPORT ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFact
or, float sourceSize, const String& srcAttribute, const String& srcsetAttribute,
Document* = nullptr); |
| 141 | 143 |
| 142 String bestFitSourceForImageAttributes(float deviceScaleFactor, float sourceSize
, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); | 144 String bestFitSourceForImageAttributes(float deviceScaleFactor, float sourceSize
, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); |
| 143 | 145 |
| 144 } // namespace blink | 146 } // namespace blink |
| 145 | 147 |
| 146 #endif | 148 #endif |
| OLD | NEW |