1 /**
2 * Copyright (C) 1999 Lars Knoll (knoll@kde.org)
3 * (C) 1999 Antti Koivisto (koivisto@kde.org)
4 * (C) 2001 Dirk Mueller (mueller@kde.org)
5 * Copyright (C) 2003 Apple Computer, Inc.
6 *
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Library General Public
9 * License as published by the Free Software Foundation; either
10 * version 2 of the License, or (at your option) any later version.
11 *
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Library General Public License for more details.
16 *
17 * You should have received a copy of the GNU Library General Public License
18 * along with this library; see the file COPYING.LIB. If not, write to
19 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
20 * Boston, MA 02110-1301, USA.
21 */
22 #include "config.h"
23 #include "HTMLMetaElement.h"
24
25 #include "Document.h"
26 #include "HTMLNames.h"
27
28 namespace WebCore {
29
30 using namespace HTMLNames;
31
HTMLMetaElement(const QualifiedName & tagName,Document * doc)32 HTMLMetaElement::HTMLMetaElement(const QualifiedName& tagName, Document* doc)
33 : HTMLElement(tagName, doc)
34 {
35 ASSERT(hasTagName(metaTag));
36 }
37
~HTMLMetaElement()38 HTMLMetaElement::~HTMLMetaElement()
39 {
40 }
41
parseMappedAttribute(MappedAttribute * attr)42 void HTMLMetaElement::parseMappedAttribute(MappedAttribute* attr)
43 {
44 if (attr->name() == http_equivAttr) {
45 m_equiv = attr->value();
46 process();
47 } else if (attr->name() == contentAttr) {
48 m_content = attr->value();
49 process();
50 } else if (attr->name() == nameAttr) {
51 // Do nothing.
52 } else
53 HTMLElement::parseMappedAttribute(attr);
54 }
55
insertedIntoDocument()56 void HTMLMetaElement::insertedIntoDocument()
57 {
58 HTMLElement::insertedIntoDocument();
59 process();
60 }
61
process()62 void HTMLMetaElement::process()
63 {
64 #ifdef ANDROID_META_SUPPORT
65 if (!inDocument() || m_content.isNull())
66 return;
67 if (equalIgnoringCase(name(), "viewport") || equalIgnoringCase(name(), "format-detection"))
68 document()->processMetadataSettings(m_content);
69 #endif
70 // Get the document to process the tag, but only if we're actually part of DOM tree (changing a meta tag while
71 // it's not in the tree shouldn't have any effect on the document)
72 if (inDocument() && !m_equiv.isNull() && !m_content.isNull())
73 document()->processHttpEquiv(m_equiv, m_content);
74 }
75
content() const76 String HTMLMetaElement::content() const
77 {
78 return getAttribute(contentAttr);
79 }
80
setContent(const String & value)81 void HTMLMetaElement::setContent(const String& value)
82 {
83 setAttribute(contentAttr, value);
84 }
85
httpEquiv() const86 String HTMLMetaElement::httpEquiv() const
87 {
88 return getAttribute(http_equivAttr);
89 }
90
setHttpEquiv(const String & value)91 void HTMLMetaElement::setHttpEquiv(const String& value)
92 {
93 setAttribute(http_equivAttr, value);
94 }
95
name() const96 String HTMLMetaElement::name() const
97 {
98 return getAttribute(nameAttr);
99 }
100
setName(const String & value)101 void HTMLMetaElement::setName(const String& value)
102 {
103 setAttribute(nameAttr, value);
104 }
105
scheme() const106 String HTMLMetaElement::scheme() const
107 {
108 return getAttribute(schemeAttr);
109 }
110
setScheme(const String & value)111 void HTMLMetaElement::setScheme(const String &value)
112 {
113 setAttribute(schemeAttr, value);
114 }
115
116 }
117