• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 
HTMLNoScriptElement(const QualifiedName & tagName,Document * document)34 inline HTMLNoScriptElement::HTMLNoScriptElement(const QualifiedName& tagName, Document* document)
35     : HTMLElement(tagName, document)
36 {
37     ASSERT(hasTagName(noscriptTag));
38 }
39 
create(const QualifiedName & tagName,Document * document)40 PassRefPtr<HTMLNoScriptElement> HTMLNoScriptElement::create(const QualifiedName& tagName, Document* document)
41 {
42     return adoptRef(new HTMLNoScriptElement(tagName, document));
43 }
44 
attach()45 void HTMLNoScriptElement::attach()
46 {
47     HTMLElement::attach();
48 
49     // If no need to process <noscript>, we hide it by setting display:none temporarily
50     if (!document()->shouldProcessNoscriptElement()) {
51         if (renderer() && renderer()->style())
52             renderer()->style()->setDisplay(NONE);
53         setNeedsStyleRecalc();
54     }
55 }
56 
recalcStyle(StyleChange change)57 void HTMLNoScriptElement::recalcStyle(StyleChange change)
58 {
59     if (!document()->shouldProcessNoscriptElement() || !renderer() || !renderer()->style())
60         return;
61 
62     // If <noscript> needs processing, we make it visiable here, including its visible children
63     RefPtr<RenderStyle> style = renderer()->style();
64     if (style->display() == NONE) {
65         style->setDisplay(INLINE);
66 
67         // Create renderers for its children
68         if (hasChildNodes()) {
69             for (Node* n = firstChild(); n; n = n->traverseNextNode(this))
70                 if (!n->renderer())
71                     n->createRendererIfNeeded();
72         }
73     }
74 }
75 
childShouldCreateRenderer(Node *) const76 bool HTMLNoScriptElement::childShouldCreateRenderer(Node*) const
77 {
78     return document()->shouldProcessNoscriptElement();
79 }
80 
81 }
82 
83 #endif
84