Update To 11.40.268.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / Source / core / svg / SVGStyleElement.cpp
1 /*
2  * Copyright (C) 2004, 2005 Nikolas Zimmermann <zimmermann@kde.org>
3  * Copyright (C) 2004, 2005, 2006, 2007 Rob Buis <buis@kde.org>
4  * Copyright (C) 2006 Apple Inc. All rights reserved.
5  * Copyright (C) 2009 Cameron McCormack <cam@mcc.id.au>
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/svg/SVGStyleElement.h"
25
26 #include "core/MediaTypeNames.h"
27 #include "core/css/CSSStyleSheet.h"
28 #include "wtf/StdLibExtras.h"
29
30 namespace blink {
31
32 inline SVGStyleElement::SVGStyleElement(Document& document, bool createdByParser)
33     : SVGElement(SVGNames::styleTag, document)
34     , StyleElement(&document, createdByParser)
35     , m_svgLoadEventTimer(this, &SVGElement::svgLoadEventTimerFired)
36 {
37 }
38
39 SVGStyleElement::~SVGStyleElement()
40 {
41 #if !ENABLE(OILPAN)
42     StyleElement::clearDocumentData(document(), this);
43 #endif
44 }
45
46 PassRefPtrWillBeRawPtr<SVGStyleElement> SVGStyleElement::create(Document& document, bool createdByParser)
47 {
48     return adoptRefWillBeNoop(new SVGStyleElement(document, createdByParser));
49 }
50
51 bool SVGStyleElement::disabled() const
52 {
53     if (!m_sheet)
54         return false;
55
56     return m_sheet->disabled();
57 }
58
59 void SVGStyleElement::setDisabled(bool setDisabled)
60 {
61     if (CSSStyleSheet* styleSheet = sheet())
62         styleSheet->setDisabled(setDisabled);
63 }
64
65 const AtomicString& SVGStyleElement::type() const
66 {
67     DEFINE_STATIC_LOCAL(const AtomicString, defaultValue, ("text/css", AtomicString::ConstructFromLiteral));
68     const AtomicString& n = getAttribute(SVGNames::typeAttr);
69     return n.isNull() ? defaultValue : n;
70 }
71
72 void SVGStyleElement::setType(const AtomicString& type)
73 {
74     setAttribute(SVGNames::typeAttr, type);
75 }
76
77 const AtomicString& SVGStyleElement::media() const
78 {
79     const AtomicString& n = fastGetAttribute(SVGNames::mediaAttr);
80     return n.isNull() ? MediaTypeNames::all : n;
81 }
82
83 void SVGStyleElement::setMedia(const AtomicString& media)
84 {
85     setAttribute(SVGNames::mediaAttr, media);
86 }
87
88 String SVGStyleElement::title() const
89 {
90     return fastGetAttribute(SVGNames::titleAttr);
91 }
92
93 void SVGStyleElement::setTitle(const AtomicString& title)
94 {
95     setAttribute(SVGNames::titleAttr, title);
96 }
97
98 void SVGStyleElement::parseAttribute(const QualifiedName& name, const AtomicString& value)
99 {
100     if (name == SVGNames::titleAttr) {
101         if (m_sheet)
102             m_sheet->setTitle(value);
103
104         return;
105     }
106
107     SVGElement::parseAttribute(name, value);
108 }
109
110 void SVGStyleElement::finishParsingChildren()
111 {
112     StyleElement::finishParsingChildren(this);
113     SVGElement::finishParsingChildren();
114 }
115
116 Node::InsertionNotificationRequest SVGStyleElement::insertedInto(ContainerNode* insertionPoint)
117 {
118     SVGElement::insertedInto(insertionPoint);
119     StyleElement::insertedInto(this, insertionPoint);
120     return InsertionShouldCallDidNotifySubtreeInsertions;
121 }
122
123 void SVGStyleElement::didNotifySubtreeInsertionsToDocument()
124 {
125     StyleElement::processStyleSheet(document(), this);
126 }
127
128 void SVGStyleElement::removedFrom(ContainerNode* insertionPoint)
129 {
130     SVGElement::removedFrom(insertionPoint);
131     StyleElement::removedFrom(this, insertionPoint);
132 }
133
134 void SVGStyleElement::childrenChanged(const ChildrenChange& change)
135 {
136     SVGElement::childrenChanged(change);
137     StyleElement::childrenChanged(this);
138 }
139
140 void SVGStyleElement::trace(Visitor* visitor)
141 {
142     StyleElement::trace(visitor);
143     SVGElement::trace(visitor);
144 }
145
146 }