2 * Copyright (C) 2011 Google Inc. All rights reserved.
4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are
8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above
11 * copyright notice, this list of conditions and the following disclaimer
12 * in the documentation and/or other materials provided with the
14 * * Neither the name of Google Inc. nor the names of its
15 * contributors may be used to endorse or promote products derived from
16 * this software without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
22 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
23 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
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.
33 #include "core/html/LinkRelAttribute.h"
35 #include "RuntimeEnabledFeatures.h"
36 #include "wtf/text/WTFString.h"
40 LinkRelAttribute::LinkRelAttribute()
41 : m_iconType(InvalidIcon)
42 , m_isStyleSheet(false)
43 , m_isAlternate(false)
44 , m_isDNSPrefetch(false)
45 , m_isLinkPrefetch(false)
46 , m_isLinkSubresource(false)
47 , m_isLinkPrerender(false)
53 LinkRelAttribute::LinkRelAttribute(const String& rel)
54 : m_iconType(InvalidIcon)
55 , m_isStyleSheet(false)
56 , m_isAlternate(false)
57 , m_isDNSPrefetch(false)
58 , m_isLinkPrefetch(false)
59 , m_isLinkSubresource(false)
60 , m_isLinkPrerender(false)
64 if (equalIgnoringCase(rel, "stylesheet")) {
65 m_isStyleSheet = true;
66 } else if (equalIgnoringCase(rel, "icon") || equalIgnoringCase(rel, "shortcut icon")) {
68 } else if (equalIgnoringCase(rel, "dns-prefetch")) {
69 m_isDNSPrefetch = true;
70 } else if (equalIgnoringCase(rel, "alternate stylesheet") || equalIgnoringCase(rel, "stylesheet alternate")) {
71 m_isStyleSheet = true;
73 } else if (equalIgnoringCase(rel, "import")) {
75 } else if (equalIgnoringCase(rel, "apple-touch-icon")) {
76 if (RuntimeEnabledFeatures::touchIconLoadingEnabled()) {
77 m_iconType = TouchIcon;
79 } else if (equalIgnoringCase(rel, "apple-touch-icon-precomposed")) {
80 if (RuntimeEnabledFeatures::touchIconLoadingEnabled()) {
81 m_iconType = TouchPrecomposedIcon;
84 // Tokenize the rel attribute and set bits based on specific keywords that we find.
86 relCopy.replace('\n', ' ');
88 relCopy.split(' ', list);
89 Vector<String>::const_iterator end = list.end();
90 for (Vector<String>::const_iterator it = list.begin(); it != end; ++it) {
91 if (equalIgnoringCase(*it, "stylesheet")) {
92 m_isStyleSheet = true;
93 } else if (equalIgnoringCase(*it, "alternate")) {
95 } else if (equalIgnoringCase(*it, "icon")) {
97 } else if (equalIgnoringCase(*it, "prefetch")) {
98 m_isLinkPrefetch = true;
99 } else if (equalIgnoringCase(*it, "subresource")) {
100 m_isLinkSubresource = true;
101 } else if (equalIgnoringCase(*it, "prerender")) {
102 m_isLinkPrerender = true;
103 } else if (equalIgnoringCase(*it, "next")) {
105 } else if (equalIgnoringCase(*it, "apple-touch-icon")) {
106 if (RuntimeEnabledFeatures::touchIconLoadingEnabled()) {
107 m_iconType = TouchIcon;
109 } else if (equalIgnoringCase(*it, "apple-touch-icon-precomposed")) {
110 if (RuntimeEnabledFeatures::touchIconLoadingEnabled()) {
111 m_iconType = TouchPrecomposedIcon;