OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2011 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 14 matching lines...) Expand all Loading... |
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 | 31 |
32 #include "config.h" | 32 #include "config.h" |
33 #include "core/html/LinkRelAttribute.h" | 33 #include "core/html/LinkRelAttribute.h" |
34 | 34 |
| 35 #include "RuntimeEnabledFeatures.h" |
35 #include "wtf/text/WTFString.h" | 36 #include "wtf/text/WTFString.h" |
36 | 37 |
37 namespace WebCore { | 38 namespace WebCore { |
38 | 39 |
39 LinkRelAttribute::LinkRelAttribute() | 40 LinkRelAttribute::LinkRelAttribute() |
40 : m_iconType(InvalidIcon) | 41 : m_iconType(InvalidIcon) |
41 , m_isStyleSheet(false) | 42 , m_isStyleSheet(false) |
42 , m_isAlternate(false) | 43 , m_isAlternate(false) |
43 , m_isDNSPrefetch(false) | 44 , m_isDNSPrefetch(false) |
44 , m_isLinkPrefetch(false) | 45 , m_isLinkPrefetch(false) |
45 , m_isLinkSubresource(false) | 46 , m_isLinkSubresource(false) |
46 , m_isLinkPrerender(false) | 47 , m_isLinkPrerender(false) |
47 , m_isImport(false) | 48 , m_isImport(false) |
48 { | 49 { |
49 } | 50 } |
50 | 51 |
51 LinkRelAttribute::LinkRelAttribute(const String& rel) | 52 LinkRelAttribute::LinkRelAttribute(const String& rel) |
52 : m_iconType(InvalidIcon) | 53 : m_iconType(InvalidIcon) |
53 , m_isStyleSheet(false) | 54 , m_isStyleSheet(false) |
54 , m_isAlternate(false) | 55 , m_isAlternate(false) |
55 , m_isDNSPrefetch(false) | 56 , m_isDNSPrefetch(false) |
56 , m_isLinkPrefetch(false) | 57 , m_isLinkPrefetch(false) |
57 , m_isLinkSubresource(false) | 58 , m_isLinkSubresource(false) |
58 , m_isLinkPrerender(false) | 59 , m_isLinkPrerender(false) |
59 , m_isImport(false) | 60 , m_isImport(false) |
60 { | 61 { |
61 if (equalIgnoringCase(rel, "stylesheet")) | 62 if (equalIgnoringCase(rel, "stylesheet")) { |
62 m_isStyleSheet = true; | 63 m_isStyleSheet = true; |
63 else if (equalIgnoringCase(rel, "icon") || equalIgnoringCase(rel, "shortcut
icon")) | 64 } else if (equalIgnoringCase(rel, "icon") || equalIgnoringCase(rel, "shortcu
t icon")) { |
64 m_iconType = Favicon; | 65 m_iconType = Favicon; |
65 #if ENABLE(TOUCH_ICON_LOADING) | 66 } else if (equalIgnoringCase(rel, "dns-prefetch")) { |
66 else if (equalIgnoringCase(rel, "apple-touch-icon")) | |
67 m_iconType = TouchIcon; | |
68 else if (equalIgnoringCase(rel, "apple-touch-icon-precomposed")) | |
69 m_iconType = TouchPrecomposedIcon; | |
70 #endif | |
71 else if (equalIgnoringCase(rel, "dns-prefetch")) | |
72 m_isDNSPrefetch = true; | 67 m_isDNSPrefetch = true; |
73 else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCase
(rel, "stylesheet alternate")) { | 68 } else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCa
se(rel, "stylesheet alternate")) { |
74 m_isStyleSheet = true; | 69 m_isStyleSheet = true; |
75 m_isAlternate = true; | 70 m_isAlternate = true; |
76 } else if (equalIgnoringCase(rel, "import")) { | 71 } else if (equalIgnoringCase(rel, "import")) { |
77 m_isImport = true; | 72 m_isImport = true; |
| 73 } else if (RuntimeEnabledFeatures::touchIconLoadingEnabled()) { |
| 74 if (equalIgnoringCase(rel, "apple-touch-icon")) |
| 75 m_iconType = TouchIcon; |
| 76 else if (equalIgnoringCase(rel, "apple-touch-icon-precomposed")) |
| 77 m_iconType = TouchPrecomposedIcon; |
78 } else { | 78 } else { |
79 // Tokenize the rel attribute and set bits based on specific keywords th
at we find. | 79 // Tokenize the rel attribute and set bits based on specific keywords th
at we find. |
80 String relCopy = rel; | 80 String relCopy = rel; |
81 relCopy.replace('\n', ' '); | 81 relCopy.replace('\n', ' '); |
82 Vector<String> list; | 82 Vector<String> list; |
83 relCopy.split(' ', list); | 83 relCopy.split(' ', list); |
84 Vector<String>::const_iterator end = list.end(); | 84 Vector<String>::const_iterator end = list.end(); |
85 for (Vector<String>::const_iterator it = list.begin(); it != end; ++it)
{ | 85 for (Vector<String>::const_iterator it = list.begin(); it != end; ++it)
{ |
86 if (equalIgnoringCase(*it, "stylesheet")) | 86 if (equalIgnoringCase(*it, "stylesheet")) { |
87 m_isStyleSheet = true; | 87 m_isStyleSheet = true; |
88 else if (equalIgnoringCase(*it, "alternate")) | 88 } else if (equalIgnoringCase(*it, "alternate")) { |
89 m_isAlternate = true; | 89 m_isAlternate = true; |
90 else if (equalIgnoringCase(*it, "icon")) | 90 } else if (equalIgnoringCase(*it, "icon")) { |
91 m_iconType = Favicon; | 91 m_iconType = Favicon; |
92 #if ENABLE(TOUCH_ICON_LOADING) | 92 } else if (equalIgnoringCase(*it, "prefetch")) { |
93 else if (equalIgnoringCase(*it, "apple-touch-icon")) | 93 m_isLinkPrefetch = true; |
94 m_iconType = TouchIcon; | 94 } else if (equalIgnoringCase(*it, "subresource")) { |
95 else if (equalIgnoringCase(*it, "apple-touch-icon-precomposed")) | 95 m_isLinkSubresource = true; |
96 m_iconType = TouchPrecomposedIcon; | 96 } else if (equalIgnoringCase(*it, "prerender")) { |
97 #endif | 97 m_isLinkPrerender = true; |
98 else if (equalIgnoringCase(*it, "prefetch")) | 98 } else if (RuntimeEnabledFeatures::touchIconLoadingEnabled()) { |
99 m_isLinkPrefetch = true; | 99 if (equalIgnoringCase(*it, "apple-touch-icon")) |
100 else if (equalIgnoringCase(*it, "subresource")) | 100 m_iconType = TouchIcon; |
101 m_isLinkSubresource = true; | 101 else if (equalIgnoringCase(*it, "apple-touch-icon-precomposed")) |
102 else if (equalIgnoringCase(*it, "prerender")) | 102 m_iconType = TouchPrecomposedIcon; |
103 m_isLinkPrerender = true; | 103 } |
104 } | 104 } |
105 } | 105 } |
106 } | 106 } |
107 | 107 |
108 } | 108 } |
OLD | NEW |