Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 // Copyright 2013 The Chromium Authors. All rights reserved. | |
| 2 // Use of this source code is governed by a BSD-style license that can be | |
| 3 // found in the LICENSE file. | |
|
abarth-chromium
2013/09/19 18:09:52
This isn't the correct license block. Please use
| |
| 4 | |
| 5 #ifndef HTMLSrcsetParser_h | |
| 6 #define HTMLSrcsetParser_h | |
| 7 | |
| 8 #include "wtf/text/WTFString.h" | |
| 9 | |
| 10 namespace WebCore { | |
| 11 | |
| 12 class ImageCandidate { | |
| 13 public: | |
| 14 ImageCandidate() | |
|
abarth-chromium
2013/09/19 18:09:52
Please initialize m_scaleFactor. Otherwise m_scal
| |
| 15 { | |
| 16 } | |
| 17 | |
| 18 ImageCandidate& operator=(const ImageCandidate& candidate) | |
| 19 { | |
| 20 m_string = candidate.m_string; | |
| 21 m_scaleFactor = candidate.m_scaleFactor; | |
| 22 return *this; | |
| 23 } | |
|
abarth-chromium
2013/09/19 18:09:52
No need to write this code explicitly. The compil
| |
| 24 | |
| 25 ImageCandidate(const String& source, unsigned start, unsigned length, float scaleFactor) | |
| 26 : m_string(source.createView(start, length)) | |
| 27 , m_scaleFactor(scaleFactor) | |
| 28 { | |
| 29 } | |
| 30 | |
| 31 inline String toString() const | |
| 32 { | |
| 33 if (m_string.is8Bit()) | |
| 34 return String(m_string.characters8(), m_string.length()); | |
| 35 return String(m_string.characters16(), m_string.length()); | |
| 36 } | |
|
abarth-chromium
2013/09/19 18:09:52
There's no need for the |inline| keyword here. Th
Yoav Weiss
2013/09/20 07:31:36
m_string is a StringView, so it doesn't have toStr
abarth-chromium
2013/09/20 16:08:07
Thanks!
| |
| 37 | |
| 38 inline float scaleFactor() const | |
| 39 { | |
| 40 return m_scaleFactor; | |
| 41 } | |
| 42 | |
| 43 inline bool isEmpty() const | |
| 44 { | |
| 45 return m_string.isEmpty(); | |
| 46 } | |
| 47 | |
| 48 private: | |
| 49 StringView m_string; | |
| 50 float m_scaleFactor; | |
| 51 }; | |
| 52 | |
| 53 ImageCandidate bestFitSourceForSrcsetAttribute(float deviceScaleFactor, const St ring& srcsetAttribute); | |
| 54 | |
| 55 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr cAttribute, const String& srcsetAttribute); | |
| 56 | |
| 57 String bestFitSourceForImageAttributes(float deviceScaleFactor, const String& sr cAttribute, ImageCandidate& srcsetImageCandidate); | |
| 58 | |
| 59 } | |
| 60 | |
| 61 #endif | |
| OLD | NEW |