| Index: Source/core/html/HTMLLinkElement.cpp
|
| diff --git a/Source/core/html/HTMLLinkElement.cpp b/Source/core/html/HTMLLinkElement.cpp
|
| index b2a8f5b0e34898436374704bf04303866c09515a..97f89bc5859324db6e2f865946fb0645168991e9 100644
|
| --- a/Source/core/html/HTMLLinkElement.cpp
|
| +++ b/Source/core/html/HTMLLinkElement.cpp
|
| @@ -52,12 +52,84 @@ namespace WebCore {
|
|
|
| using namespace HTMLNames;
|
|
|
| +template <typename CharacterType>
|
| +static void parseSizes(const CharacterType* value, unsigned length, Vector<IntSize>& iconSizes)
|
| +{
|
| + enum State {
|
| + ParseStart,
|
| + ParseWidth,
|
| + ParseHeight
|
| + };
|
| + int width = 0;
|
| + unsigned start = 0;
|
| + unsigned i = 0;
|
| + State state = ParseStart;
|
| + bool invalid = false;
|
| + for (; i < length; ++i) {
|
| + if (state == ParseWidth) {
|
| + if (value[i] == 'x' || value[i] == 'X') {
|
| + if (i == start) {
|
| + invalid = true;
|
| + break;
|
| + }
|
| + width = charactersToInt(value + start, i - start);
|
| + start = i + 1;
|
| + state = ParseHeight;
|
| + } else if (value[i] < '0' || value[i] > '9') {
|
| + invalid = true;
|
| + break;
|
| + }
|
| + } else if (state == ParseHeight) {
|
| + if (value[i] == ' ') {
|
| + if (i == start) {
|
| + invalid = true;
|
| + break;
|
| + }
|
| + int height = charactersToInt(value + start, i - start);
|
| + iconSizes.append(IntSize(width, height));
|
| + start = i + 1;
|
| + state = ParseStart;
|
| + } else if (value[i] < '0' || value[i] > '9') {
|
| + invalid = true;
|
| + break;
|
| + }
|
| + } else if (state == ParseStart) {
|
| + if (value[i] >= '0' && value[i] <= '9') {
|
| + start = i;
|
| + state = ParseWidth;
|
| + } else if (value[i] != ' ') {
|
| + invalid = true;
|
| + break;
|
| + }
|
| + }
|
| + }
|
| + if (invalid || state == ParseWidth || (state == ParseHeight && start == i)) {
|
| + iconSizes.clear();
|
| + return;
|
| + }
|
| + if (state == ParseHeight && i > start) {
|
| + int height = charactersToInt(value + start, i - start);
|
| + iconSizes.append(IntSize(width, height));
|
| + }
|
| +}
|
| +
|
| static LinkEventSender& linkLoadEventSender()
|
| {
|
| DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (EventTypeNames::load));
|
| return sharedLoadEventSender;
|
| }
|
|
|
| +void HTMLLinkElement::parseSizesAttribute(const AtomicString& value, Vector<IntSize>& iconSizes)
|
| +{
|
| + ASSERT(iconSizes.isEmpty());
|
| + if (value.isEmpty())
|
| + return;
|
| + if (value.is8Bit())
|
| + parseSizes(value.characters8(), value.length(), iconSizes);
|
| + else
|
| + parseSizes(value.characters16(), value.length(), iconSizes);
|
| +}
|
| +
|
| inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser)
|
| : HTMLElement(linkTag, document)
|
| , m_linkLoader(this)
|
| @@ -96,6 +168,7 @@ void HTMLLinkElement::parseAttribute(const QualifiedName& name, const AtomicStri
|
| process();
|
| } else if (name == sizesAttr) {
|
| m_sizes->setValue(value);
|
| + parseSizesAttribute(value, m_iconSizes);
|
| process();
|
| } else if (name == mediaAttr) {
|
| m_media = value.string().lower();
|
| @@ -352,9 +425,9 @@ IconType HTMLLinkElement::iconType() const
|
| return m_relAttribute.iconType();
|
| }
|
|
|
| -const AtomicString& HTMLLinkElement::iconSizes() const
|
| +const Vector<IntSize>& HTMLLinkElement::iconSizes() const
|
| {
|
| - return m_sizes->toString();
|
| + return m_iconSizes;
|
| }
|
|
|
| DOMSettableTokenList* HTMLLinkElement::sizes() const
|
|
|