initial import
[vuplus_webkit] / Source / WebCore / html / HTMLStyleElement.cpp
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  *           (C) 2007 Rob Buis (buis@kde.org)
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Library General Public
10  * License as published by the Free Software Foundation; either
11  * version 2 of the License, or (at your option) any later version.
12  *
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Library General Public License for more details.
17  *
18  * You should have received a copy of the GNU Library General Public License
19  * along with this library; see the file COPYING.LIB.  If not, write to
20  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21  * Boston, MA 02110-1301, USA.
22  */
23
24 #include "config.h"
25 #include "HTMLStyleElement.h"
26
27 #include "Attribute.h"
28 #include "Document.h"
29 #include "HTMLNames.h"
30 #include "ScriptEventListener.h"
31 #include "ScriptableDocumentParser.h"
32
33
34 namespace WebCore {
35
36 using namespace HTMLNames;
37
38 inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document* document, bool createdByParser)
39     : HTMLElement(tagName, document)
40     , StyleElement(document, createdByParser)
41 {
42     ASSERT(hasTagName(styleTag));
43 }
44
45 HTMLStyleElement::~HTMLStyleElement()
46 {
47     StyleElement::clearDocumentData(document(), this);
48 }
49
50 PassRefPtr<HTMLStyleElement> HTMLStyleElement::create(const QualifiedName& tagName, Document* document, bool createdByParser)
51 {
52     return adoptRef(new HTMLStyleElement(tagName, document, createdByParser));
53 }
54
55 void HTMLStyleElement::parseMappedAttribute(Attribute* attr)
56 {
57     if (attr->name() == titleAttr && m_sheet)
58         m_sheet->setTitle(attr->value());
59     else
60         HTMLElement::parseMappedAttribute(attr);
61 }
62
63 void HTMLStyleElement::finishParsingChildren()
64 {
65     StyleElement::finishParsingChildren(this);
66     HTMLElement::finishParsingChildren();
67 }
68
69 void HTMLStyleElement::insertedIntoDocument()
70 {
71     HTMLElement::insertedIntoDocument();
72     StyleElement::insertedIntoDocument(document(), this);
73 }
74
75 void HTMLStyleElement::removedFromDocument()
76 {
77     HTMLElement::removedFromDocument();
78     StyleElement::removedFromDocument(document(), this);
79 }
80
81 void HTMLStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
82 {
83     StyleElement::childrenChanged(this);
84     HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
85 }
86
87 const AtomicString& HTMLStyleElement::media() const
88 {
89     return getAttribute(mediaAttr);
90 }
91
92 const AtomicString& HTMLStyleElement::type() const
93 {
94     return getAttribute(typeAttr);
95 }
96
97 void HTMLStyleElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
98 {    
99     HTMLElement::addSubresourceAttributeURLs(urls);
100
101     if (StyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet())
102         styleSheet->addSubresourceStyleURLs(urls);
103 }
104
105 bool HTMLStyleElement::disabled() const
106 {
107     StyleSheet* styleSheet = sheet();
108     if (!styleSheet)
109         return false;
110
111     return styleSheet->disabled();
112 }
113
114 void HTMLStyleElement::setDisabled(bool setDisabled)
115 {
116     if (StyleSheet* styleSheet = sheet())
117         styleSheet->setDisabled(setDisabled);
118 }
119
120 }