|
1 /* |
|
2 * Copyright (C) 2009 Torch Mobile Inc. All rights reserved. (http://www.torchmobile.com/) |
|
3 * Copyright (C) 2010 Apple Inc. All rights reserved. |
|
4 * |
|
5 * This library is free software; you can redistribute it and/or |
|
6 * modify it under the terms of the GNU Library General Public |
|
7 * License as published by the Free Software Foundation; either |
|
8 * version 2 of the License, or (at your option) any later version. |
|
9 * |
|
10 * This library is distributed in the hope that it will be useful, |
|
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
|
13 * Library General Public License for more details. |
|
14 * |
|
15 * You should have received a copy of the GNU Library General Public License |
|
16 * along with this library; see the file COPYING.LIB. If not, write to |
|
17 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
|
18 * Boston, MA 02110-1301, USA. |
|
19 */ |
|
20 |
|
21 #include "config.h" |
|
22 |
|
23 #if ENABLE(XHTMLMP) |
|
24 #include "HTMLNoScriptElement.h" |
|
25 |
|
26 #include "CSSStyleSelector.h" |
|
27 #include "HTMLNames.h" |
|
28 #include "RenderObject.h" |
|
29 |
|
30 namespace WebCore { |
|
31 |
|
32 using namespace HTMLNames; |
|
33 |
|
34 inline HTMLNoScriptElement::HTMLNoScriptElement(const QualifiedName& tagName, Document* document) |
|
35 : HTMLElement(tagName, document) |
|
36 { |
|
37 ASSERT(hasTagName(noscriptTag)); |
|
38 } |
|
39 |
|
40 PassRefPtr<HTMLNoScriptElement> HTMLNoScriptElement::create(const QualifiedName& tagName, Document* document) |
|
41 { |
|
42 return adoptRef(new HTMLNoScriptElement(tagName, document)); |
|
43 } |
|
44 |
|
45 bool HTMLNoScriptElement::checkDTD(const Node* newChild) |
|
46 { |
|
47 return newChild->isTextNode() || inBlockTagList(newChild); |
|
48 } |
|
49 |
|
50 void HTMLNoScriptElement::attach() |
|
51 { |
|
52 HTMLElement::attach(); |
|
53 |
|
54 // If no need to process <noscript>, we hide it by setting display:none temporarily |
|
55 if (!document()->shouldProcessNoscriptElement()) { |
|
56 if (renderer() && renderer()->style()) |
|
57 renderer()->style()->setDisplay(NONE); |
|
58 setNeedsStyleRecalc(); |
|
59 } |
|
60 } |
|
61 |
|
62 void HTMLNoScriptElement::recalcStyle(StyleChange change) |
|
63 { |
|
64 if (!document()->shouldProcessNoscriptElement() || !renderer() || !renderer()->style()) |
|
65 return; |
|
66 |
|
67 // If <noscript> needs processing, we make it visiable here, including its visible children |
|
68 RefPtr<RenderStyle> style = renderer()->style(); |
|
69 if (style->display() == NONE) { |
|
70 style->setDisplay(INLINE); |
|
71 |
|
72 // Create renderers for its children |
|
73 if (hasChildNodes()) { |
|
74 for (Node* n = firstChild(); n; n = n->traverseNextNode(this)) |
|
75 if (!n->renderer()) |
|
76 n->createRendererIfNeeded(); |
|
77 } |
|
78 } |
|
79 } |
|
80 |
|
81 bool HTMLNoScriptElement::childShouldCreateRenderer(Node*) const |
|
82 { |
|
83 return document()->shouldProcessNoscriptElement(); |
|
84 } |
|
85 |
|
86 } |
|
87 |
|
88 #endif |