Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 /* | 1 /* |
| 2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
| 6 * met: | 6 * met: |
| 7 * | 7 * |
| 8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
| 9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
| 10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
| (...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 46 } | 46 } |
| 47 | 47 |
| 48 bool foundDescriptor() const | 48 bool foundDescriptor() const |
| 49 { | 49 { |
| 50 return (scaleFactor >= 0 || resourceWidth >= 0); | 50 return (scaleFactor >= 0 || resourceWidth >= 0); |
| 51 } | 51 } |
| 52 }; | 52 }; |
| 53 | 53 |
| 54 class ImageCandidate { | 54 class ImageCandidate { |
| 55 public: | 55 public: |
| 56 enum Origin { | |
|
eseidel
2014/04/13 20:57:55
Is this OriginSource? This is controlling where t
| |
| 57 SrcsetOrigin, | |
| 58 SrcOrigin | |
| 59 }; | |
| 60 | |
| 56 ImageCandidate() | 61 ImageCandidate() |
| 57 : m_scaleFactor(1.0) | 62 : m_scaleFactor(1.0) |
| 58 { | 63 { |
| 59 } | 64 } |
| 60 | 65 |
| 61 ImageCandidate(const String& source, unsigned start, unsigned length, const DescriptorParsingResult& result) | 66 ImageCandidate(const String& source, unsigned start, unsigned length, const DescriptorParsingResult& result, Origin origin) |
| 62 : m_string(source.createView(start, length)) | 67 : m_string(source.createView(start, length)) |
| 63 , m_scaleFactor(result.scaleFactor) | 68 , m_scaleFactor(result.scaleFactor) |
| 64 , m_resourceWidth(result.resourceWidth) | 69 , m_resourceWidth(result.resourceWidth) |
| 70 , m_origin(origin) | |
| 65 { | 71 { |
| 66 } | 72 } |
| 67 | 73 |
| 68 String toString() const | 74 String toString() const |
| 69 { | 75 { |
| 70 return String(m_string.toString()); | 76 return String(m_string.toString()); |
| 71 } | 77 } |
| 72 | 78 |
| 73 AtomicString toAtomicString() const | 79 AtomicString toAtomicString() const |
| 74 { | 80 { |
| 75 return AtomicString(m_string.toString()); | 81 return AtomicString(m_string.toString()); |
| 76 } | 82 } |
| 77 | 83 |
| 78 void setScaleFactor(float factor) | 84 void setScaleFactor(float factor) |
| 79 { | 85 { |
| 80 m_scaleFactor = factor; | 86 m_scaleFactor = factor; |
| 81 } | 87 } |
| 82 | 88 |
| 83 float scaleFactor() const | 89 float scaleFactor() const |
| 84 { | 90 { |
| 85 return m_scaleFactor; | 91 return m_scaleFactor; |
| 86 } | 92 } |
| 87 | 93 |
| 88 int resourceWidth() const | 94 int resourceWidth() const |
| 89 { | 95 { |
| 90 return m_resourceWidth; | 96 return m_resourceWidth; |
| 91 } | 97 } |
| 92 | 98 |
| 99 bool srcOrigin() const | |
| 100 { | |
| 101 return (m_origin == SrcOrigin); | |
| 102 } | |
| 103 | |
| 93 inline bool isEmpty() const | 104 inline bool isEmpty() const |
| 94 { | 105 { |
| 95 return m_string.isEmpty(); | 106 return m_string.isEmpty(); |
| 96 } | 107 } |
| 97 | 108 |
| 98 private: | 109 private: |
| 99 StringView m_string; | 110 StringView m_string; |
| 100 float m_scaleFactor; | 111 float m_scaleFactor; |
| 101 int m_resourceWidth; | 112 int m_resourceWidth; |
| 113 Origin m_origin; | |
| 102 }; | 114 }; |
| 103 | 115 |
| 104 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, int effe ctiveSize, const String& srcsetAttribute); | 116 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, int effe ctiveSize, const String& srcsetAttribute); |
| 105 | 117 |
| 106 ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, int effe ctiveSize, const String& srcAttribute, const String& srcsetAttribute); | 118 ImageCandidate bestFitSourceForImageAttributes(float deviceScaleFactor, int effe ctiveSize, const String& srcAttribute, const String& srcsetAttribute); |
| 107 | 119 |
| 108 String bestFitSourceForImageAttributes(float deviceScaleFactor, int effectiveSiz e, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); | 120 String bestFitSourceForImageAttributes(float deviceScaleFactor, int effectiveSiz e, const String& srcAttribute, ImageCandidate& srcsetImageCandidate); |
| 109 | 121 |
| 110 } | 122 } |
| 111 | 123 |
| 112 #endif | 124 #endif |
| OLD | NEW |