Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(682)

Side by Side Diff: Source/core/html/HTMLMetaElement.cpp

Issue 19555002: Translate viewport related meta tags into @viewport descriptors as suggested by the CSS Device Adap… (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
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, 2010 Apple Inc. All rights reserved.
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
23 #include "config.h"
24 #include "core/html/HTMLMetaElement.h"
25
26 #include "HTMLNames.h"
27 #include "core/dom/Document.h"
28
29 namespace WebCore {
30
31 using namespace HTMLNames;
32
33 inline HTMLMetaElement::HTMLMetaElement(const QualifiedName& tagName, Document* document)
34 : HTMLElement(tagName, document)
35 {
36 ASSERT(hasTagName(metaTag));
37 ScriptWrappable::init(this);
38 }
39
40 PassRefPtr<HTMLMetaElement> HTMLMetaElement::create(Document* document)
41 {
42 return adoptRef(new HTMLMetaElement(metaTag, document));
43 }
44
45 PassRefPtr<HTMLMetaElement> HTMLMetaElement::create(const QualifiedName& tagName , Document* document)
46 {
47 return adoptRef(new HTMLMetaElement(tagName, document));
48 }
49
50 void HTMLMetaElement::parseAttribute(const QualifiedName& name, const AtomicStri ng& value)
51 {
52 if (name == http_equivAttr)
53 process();
54 else if (name == contentAttr)
55 process();
56 else if (name == nameAttr) {
57 // Do nothing
58 } else
59 HTMLElement::parseAttribute(name, value);
60 }
61
62 Node::InsertionNotificationRequest HTMLMetaElement::insertedInto(ContainerNode* insertionPoint)
63 {
64 HTMLElement::insertedInto(insertionPoint);
65 if (insertionPoint->inDocument())
66 process();
67 return InsertionDone;
68 }
69
70 void HTMLMetaElement::process()
71 {
72 if (!inDocument())
73 return;
74
75 const AtomicString& contentValue = fastGetAttribute(contentAttr);
76 if (contentValue.isNull())
77 return;
78
79 if (equalIgnoringCase(name(), "viewport"))
80 document()->processViewport(contentValue, ViewportArguments::ViewportMet a);
81 else if (equalIgnoringCase(name(), "referrer"))
82 document()->processReferrerPolicy(contentValue);
83 else if (equalIgnoringCase(name(), "handheldfriendly") && equalIgnoringCase( contentValue, "true"))
84 document()->processViewport("width=device-width", ViewportArguments::Han dheldFriendlyMeta);
85 else if (equalIgnoringCase(name(), "mobileoptimized"))
86 document()->processViewport("width=device-width, initial-scale=1", Viewp ortArguments::MobileOptimizedMeta);
87
88 // Get the document to process the tag, but only if we're actually part of D OM tree (changing a meta tag while
89 // it's not in the tree shouldn't have any effect on the document)
90 const AtomicString& httpEquivValue = fastGetAttribute(http_equivAttr);
91 if (!httpEquivValue.isNull())
92 document()->processHttpEquiv(httpEquivValue, contentValue);
93 }
94
95 String HTMLMetaElement::content() const
96 {
97 return getAttribute(contentAttr);
98 }
99
100 String HTMLMetaElement::httpEquiv() const
101 {
102 return getAttribute(http_equivAttr);
103 }
104
105 String HTMLMetaElement::name() const
106 {
107 return getNameAttribute();
108 }
109
110 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698