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)
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.
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.
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.
25 #include "HTMLStyleElement.h"
27 #include "Attribute.h"
29 #include "HTMLNames.h"
30 #include "ScriptEventListener.h"
31 #include "ScriptableDocumentParser.h"
36 using namespace HTMLNames;
38 inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document* document, bool createdByParser)
39 : HTMLElement(tagName, document)
40 , StyleElement(document, createdByParser)
42 ASSERT(hasTagName(styleTag));
45 HTMLStyleElement::~HTMLStyleElement()
47 StyleElement::clearDocumentData(document(), this);
50 PassRefPtr<HTMLStyleElement> HTMLStyleElement::create(const QualifiedName& tagName, Document* document, bool createdByParser)
52 return adoptRef(new HTMLStyleElement(tagName, document, createdByParser));
55 void HTMLStyleElement::parseMappedAttribute(Attribute* attr)
57 if (attr->name() == titleAttr && m_sheet)
58 m_sheet->setTitle(attr->value());
60 HTMLElement::parseMappedAttribute(attr);
63 void HTMLStyleElement::finishParsingChildren()
65 StyleElement::finishParsingChildren(this);
66 HTMLElement::finishParsingChildren();
69 void HTMLStyleElement::insertedIntoDocument()
71 HTMLElement::insertedIntoDocument();
72 StyleElement::insertedIntoDocument(document(), this);
75 void HTMLStyleElement::removedFromDocument()
77 HTMLElement::removedFromDocument();
78 StyleElement::removedFromDocument(document(), this);
81 void HTMLStyleElement::childrenChanged(bool changedByParser, Node* beforeChange, Node* afterChange, int childCountDelta)
83 StyleElement::childrenChanged(this);
84 HTMLElement::childrenChanged(changedByParser, beforeChange, afterChange, childCountDelta);
87 const AtomicString& HTMLStyleElement::media() const
89 return getAttribute(mediaAttr);
92 const AtomicString& HTMLStyleElement::type() const
94 return getAttribute(typeAttr);
97 void HTMLStyleElement::addSubresourceAttributeURLs(ListHashSet<KURL>& urls) const
99 HTMLElement::addSubresourceAttributeURLs(urls);
101 if (StyleSheet* styleSheet = const_cast<HTMLStyleElement*>(this)->sheet())
102 styleSheet->addSubresourceStyleURLs(urls);
105 bool HTMLStyleElement::disabled() const
107 StyleSheet* styleSheet = sheet();
111 return styleSheet->disabled();
114 void HTMLStyleElement::setDisabled(bool setDisabled)
116 if (StyleSheet* styleSheet = sheet())
117 styleSheet->setDisabled(setDisabled);