OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | 2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org) |
3 * (C) 1999 Antti Koivisto (koivisto@kde.org) | 3 * (C) 1999 Antti Koivisto (koivisto@kde.org) |
4 * (C) 2001 Dirk Mueller (mueller@kde.org) | 4 * (C) 2001 Dirk Mueller (mueller@kde.org) |
5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. | 5 * Copyright (C) 2003, 2006, 2007, 2008, 2009, 2010 Apple Inc. All rights reserv ed. |
6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) | 6 * Copyright (C) 2009 Rob Buis (rwlbuis@gmail.com) |
7 * Copyright (C) 2011 Google Inc. All rights reserved. | 7 * Copyright (C) 2011 Google Inc. All rights reserved. |
8 * | 8 * |
9 * This library is free software; you can redistribute it and/or | 9 * This library is free software; you can redistribute it and/or |
10 * modify it under the terms of the GNU Library General Public | 10 * modify it under the terms of the GNU Library General Public |
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
45 #include "core/frame/csp/ContentSecurityPolicy.h" | 45 #include "core/frame/csp/ContentSecurityPolicy.h" |
46 #include "core/html/imports/LinkImport.h" | 46 #include "core/html/imports/LinkImport.h" |
47 #include "core/loader/FrameLoader.h" | 47 #include "core/loader/FrameLoader.h" |
48 #include "core/loader/FrameLoaderClient.h" | 48 #include "core/loader/FrameLoaderClient.h" |
49 #include "wtf/StdLibExtras.h" | 49 #include "wtf/StdLibExtras.h" |
50 | 50 |
51 namespace WebCore { | 51 namespace WebCore { |
52 | 52 |
53 using namespace HTMLNames; | 53 using namespace HTMLNames; |
54 | 54 |
55 const String sizeSeparator = "x"; | |
Inactive
2014/03/12 20:09:52
This could be a UChar.
| |
56 | |
55 static LinkEventSender& linkLoadEventSender() | 57 static LinkEventSender& linkLoadEventSender() |
56 { | 58 { |
57 DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (EventTypeNames: :load)); | 59 DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (EventTypeNames: :load)); |
58 return sharedLoadEventSender; | 60 return sharedLoadEventSender; |
59 } | 61 } |
60 | 62 |
63 void HTMLLinkElement::parseSizesAttribute(const AtomicString& value, Vector<IntS ize>* iconSizes) | |
Inactive
2014/03/12 20:09:52
The Vector could be passed by reference instead of
michaelbai
2014/03/12 23:08:41
iconSizes will change and should be pass as pointe
Inactive
2014/03/12 23:14:38
I said a by reference, not by *const* reference.
michaelbai
2014/03/13 05:50:10
I has been told to use pointer in this case, I sea
| |
64 { | |
Inactive
2014/03/12 20:09:52
Should we add an assertion to make sure the Vector
michaelbai
2014/03/12 23:08:41
Done.
| |
65 RefPtr<DOMSettableTokenList> tokenList = DOMSettableTokenList::create(); | |
abarth-chromium
2014/03/12 19:42:34
Why are we using a DOMSettableTokenList here?
| |
66 tokenList->setValue(value.lower()); | |
67 const SpaceSplitString& tokens = tokenList->tokens(); | |
68 bool successful = true; | |
69 for (unsigned i = 0; i < tokens.size(); i++) { | |
abarth-chromium
2014/03/12 19:42:34
++i
| |
70 const String& sizeString = (String&)tokens[i]; | |
abarth-chromium
2014/03/12 19:42:34
Why is (String&) needed here? We generally don't
| |
71 Vector<String> result; | |
72 sizeString.split(sizeSeparator, result); | |
73 if (result.size() != 2) { | |
74 successful = false; | |
75 break; | |
76 } | |
77 bool ok = false; | |
78 int width = result[0].toUInt(&ok); | |
79 if (!ok) { | |
80 successful = false; | |
81 break; | |
82 } | |
83 ok = false; | |
84 int height = result[1].toUInt(&ok); | |
85 if (!ok) { | |
86 successful = false; | |
87 break; | |
88 } | |
89 iconSizes->append(IntSize(width, height)); | |
90 } | |
91 if (!successful) | |
92 iconSizes->clear(); | |
93 } | |
abarth-chromium
2014/03/12 19:42:34
This function is very slow. Why not write a versi
michaelbai
2014/03/12 23:08:41
I were thinking I should use existing utility, cha
| |
94 | |
61 inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser ) | 95 inline HTMLLinkElement::HTMLLinkElement(Document& document, bool createdByParser ) |
62 : HTMLElement(linkTag, document) | 96 : HTMLElement(linkTag, document) |
63 , m_linkLoader(this) | 97 , m_linkLoader(this) |
64 , m_sizes(DOMSettableTokenList::create()) | 98 , m_sizes(DOMSettableTokenList::create()) |
65 , m_createdByParser(createdByParser) | 99 , m_createdByParser(createdByParser) |
66 , m_isInShadowTree(false) | 100 , m_isInShadowTree(false) |
67 , m_beforeLoadRecurseCount(0) | 101 , m_beforeLoadRecurseCount(0) |
68 { | 102 { |
69 ScriptWrappable::init(this); | 103 ScriptWrappable::init(this); |
70 } | 104 } |
(...skipping 18 matching lines...) Expand all Loading... | |
89 if (name == relAttr) { | 123 if (name == relAttr) { |
90 m_relAttribute = LinkRelAttribute(value); | 124 m_relAttribute = LinkRelAttribute(value); |
91 process(); | 125 process(); |
92 } else if (name == hrefAttr) { | 126 } else if (name == hrefAttr) { |
93 process(); | 127 process(); |
94 } else if (name == typeAttr) { | 128 } else if (name == typeAttr) { |
95 m_type = value; | 129 m_type = value; |
96 process(); | 130 process(); |
97 } else if (name == sizesAttr) { | 131 } else if (name == sizesAttr) { |
98 m_sizes->setValue(value); | 132 m_sizes->setValue(value); |
133 parseSizesAttribute(value, &m_iconSizes); | |
99 process(); | 134 process(); |
100 } else if (name == mediaAttr) { | 135 } else if (name == mediaAttr) { |
101 m_media = value.string().lower(); | 136 m_media = value.string().lower(); |
102 process(); | 137 process(); |
103 } else if (name == disabledAttr) { | 138 } else if (name == disabledAttr) { |
104 if (LinkStyle* link = linkStyle()) | 139 if (LinkStyle* link = linkStyle()) |
105 link->setDisabledState(!value.isNull()); | 140 link->setDisabledState(!value.isNull()); |
106 } else if (name == onbeforeloadAttr) | 141 } else if (name == onbeforeloadAttr) |
107 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve ntListener(this, name, value)); | 142 setAttributeEventListener(EventTypeNames::beforeload, createAttributeEve ntListener(this, name, value)); |
108 else { | 143 else { |
(...skipping 231 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
340 const AtomicString& HTMLLinkElement::type() const | 375 const AtomicString& HTMLLinkElement::type() const |
341 { | 376 { |
342 return getAttribute(typeAttr); | 377 return getAttribute(typeAttr); |
343 } | 378 } |
344 | 379 |
345 IconType HTMLLinkElement::iconType() const | 380 IconType HTMLLinkElement::iconType() const |
346 { | 381 { |
347 return m_relAttribute.iconType(); | 382 return m_relAttribute.iconType(); |
348 } | 383 } |
349 | 384 |
350 const AtomicString& HTMLLinkElement::iconSizes() const | 385 const Vector<IntSize>& HTMLLinkElement::iconSizes() const |
351 { | 386 { |
352 return m_sizes->toString(); | 387 return m_iconSizes; |
353 } | 388 } |
354 | 389 |
355 DOMSettableTokenList* HTMLLinkElement::sizes() const | 390 DOMSettableTokenList* HTMLLinkElement::sizes() const |
356 { | 391 { |
357 return m_sizes.get(); | 392 return m_sizes.get(); |
358 } | 393 } |
359 | 394 |
360 PassOwnPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner) | 395 PassOwnPtr<LinkStyle> LinkStyle::create(HTMLLinkElement* owner) |
361 { | 396 { |
362 return adoptPtr(new LinkStyle(owner)); | 397 return adoptPtr(new LinkStyle(owner)); |
(...skipping 263 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
626 void LinkStyle::ownerRemoved() | 661 void LinkStyle::ownerRemoved() |
627 { | 662 { |
628 if (m_sheet) | 663 if (m_sheet) |
629 clearSheet(); | 664 clearSheet(); |
630 | 665 |
631 if (styleSheetIsLoading()) | 666 if (styleSheetIsLoading()) |
632 removePendingSheet(RemovePendingSheetNotifyLater); | 667 removePendingSheet(RemovePendingSheetNotifyLater); |
633 } | 668 } |
634 | 669 |
635 } // namespace WebCore | 670 } // namespace WebCore |
OLD | NEW |