| 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 10 matching lines...) Expand all Loading... |
| 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | 21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT |
| 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | 22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, |
| 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | 23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #ifndef LayerRect_h | 31 #ifndef HTMLSrcsetParser_h |
| 32 #define LayerRect_h | 32 #define HTMLSrcsetParser_h |
| 33 | 33 |
| 34 #include "core/dom/ClientRect.h" | |
| 35 | |
| 36 #include "wtf/PassRefPtr.h" | |
| 37 #include "wtf/RefCounted.h" | |
| 38 #include "wtf/RefPtr.h" | |
| 39 #include "wtf/text/WTFString.h" | 34 #include "wtf/text/WTFString.h" |
| 40 | 35 |
| 41 namespace WebCore { | 36 namespace WebCore { |
| 42 | 37 |
| 43 class Node; | 38 class ImageCandidate { |
| 44 | |
| 45 class LayerRect : public RefCounted<LayerRect> { | |
| 46 public: | 39 public: |
| 47 static PassRefPtr<LayerRect> create(PassRefPtr<Node> node, const String& lay
erType, PassRefPtr<ClientRect> rect) | 40 ImageCandidate() |
| 48 { | 41 : m_scaleFactor(1.0) |
| 49 return adoptRef(new LayerRect(node, layerType, rect)); | |
| 50 } | |
| 51 | |
| 52 Node* layerRootNode() const { return m_layerRootNode.get(); } | |
| 53 String layerType() const { return m_layerType; } | |
| 54 ClientRect* layerRelativeRect() const { return m_rect.get(); } | |
| 55 | |
| 56 private: | |
| 57 LayerRect(PassRefPtr<Node> node, const String& layerName, PassRefPtr<ClientR
ect> rect) | |
| 58 : m_layerRootNode(node) | |
| 59 , m_layerType(layerName) | |
| 60 , m_rect(rect) | |
| 61 { | 42 { |
| 62 } | 43 } |
| 63 | 44 |
| 64 RefPtr<Node> m_layerRootNode; | 45 ImageCandidate(const String& source, unsigned start, unsigned length, float
scaleFactor) |
| 65 String m_layerType; | 46 : m_string(source.createView(start, length)) |
| 66 RefPtr<ClientRect> m_rect; | 47 , m_scaleFactor(scaleFactor) |
| 48 { |
| 49 } |
| 50 |
| 51 String toString() const |
| 52 { |
| 53 return m_string.toString(); |
| 54 } |
| 55 |
| 56 inline float scaleFactor() const |
| 57 { |
| 58 return m_scaleFactor; |
| 59 } |
| 60 |
| 61 inline bool isEmpty() const |
| 62 { |
| 63 return m_string.isEmpty(); |
| 64 } |
| 65 |
| 66 private: |
| 67 StringView m_string; |
| 68 float m_scaleFactor; |
| 67 }; | 69 }; |
| 68 | 70 |
| 69 } // namespace WebCore | 71 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const St
ring& srcsetAttribute); |
| 72 |
| 73 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr
cAttribute, const String& srcsetAttribute); |
| 74 |
| 75 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr
cAttribute, ImageCandidate& srcsetImageCandidate); |
| 76 |
| 77 } |
| 70 | 78 |
| 71 #endif | 79 #endif |
| OLD | NEW |