]>
Commit | Line | Data |
---|---|---|
a90939db JF |
1 | /* |
2 | * Copyright (C) 1999 Lars Knoll (knoll@kde.org) | |
3 | * (C) 1999 Antti Koivisto (koivisto@kde.org) | |
4 | * (C) 2001 Peter Kelly (pmk@post.com) | |
5 | * (C) 2001 Dirk Mueller (mueller@kde.org) | |
6 | * Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008 Apple Inc. All rights reserved. | |
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 | ||
25 | #ifndef StyledElement_h | |
26 | #define StyledElement_h | |
27 | ||
28 | #include "Element.h" | |
29 | #include "NamedMappedAttrMap.h" | |
30 | ||
31 | namespace WebCore { | |
32 | ||
33 | class CSSMappedAttributeDeclaration; | |
34 | class MappedAttribute; | |
35 | ||
36 | class StyledElement : public Element { | |
37 | public: | |
38 | StyledElement(const QualifiedName&, Document*); | |
39 | virtual ~StyledElement(); | |
40 | ||
41 | virtual bool isStyledElement() const { return true; } | |
42 | ||
43 | NamedMappedAttrMap* mappedAttributes() { return static_cast<NamedMappedAttrMap*>(namedAttrMap.get()); } | |
44 | const NamedMappedAttrMap* mappedAttributes() const { return static_cast<NamedMappedAttrMap*>(namedAttrMap.get()); } | |
45 | bool hasMappedAttributes() const { return namedAttrMap && mappedAttributes()->hasMappedAttributes(); } | |
46 | bool isMappedAttribute(const QualifiedName& name) const { MappedAttributeEntry res = eNone; mapToEntry(name, res); return res != eNone; } | |
47 | ||
48 | void addCSSLength(MappedAttribute* attr, int id, const String &value); | |
49 | void addCSSProperty(MappedAttribute* attr, int id, const String &value); | |
50 | void addCSSProperty(MappedAttribute* attr, int id, int value); | |
51 | void addCSSStringProperty(MappedAttribute* attr, int id, const String &value, CSSPrimitiveValue::UnitTypes = CSSPrimitiveValue::CSS_STRING); | |
52 | void addCSSImageProperty(MappedAttribute*, int propertyID, const String& url); | |
53 | void addCSSColor(MappedAttribute* attr, int id, const String &c); | |
54 | void createMappedDecl(MappedAttribute* attr); | |
55 | ||
56 | static CSSMappedAttributeDeclaration* getMappedAttributeDecl(MappedAttributeEntry type, const QualifiedName& name, const AtomicString& value); | |
57 | static void setMappedAttributeDecl(MappedAttributeEntry, const QualifiedName& name, const AtomicString& value, CSSMappedAttributeDeclaration*); | |
58 | static void removeMappedAttributeDecl(MappedAttributeEntry type, const QualifiedName& name, const AtomicString& value); | |
59 | ||
60 | static CSSMappedAttributeDeclaration* getMappedAttributeDecl(MappedAttributeEntry, Attribute*); | |
61 | static void setMappedAttributeDecl(MappedAttributeEntry, Attribute*, CSSMappedAttributeDeclaration*); | |
62 | ||
63 | CSSMutableStyleDeclaration* inlineStyleDecl() const { return m_inlineStyleDecl.get(); } | |
64 | virtual bool canHaveAdditionalAttributeStyleDecls() const { return false; } | |
65 | virtual void additionalAttributeStyleDecls(Vector<CSSMutableStyleDeclaration*>&) {}; | |
66 | CSSMutableStyleDeclaration* getInlineStyleDecl(); | |
67 | CSSStyleDeclaration* style(); | |
68 | void createInlineStyleDecl(); | |
69 | void destroyInlineStyleDecl(); | |
70 | void invalidateStyleAttribute(); | |
71 | virtual void updateStyleAttribute() const; | |
72 | ||
73 | const ClassNames& classNames() const { ASSERT(hasClass()); ASSERT(mappedAttributes()); return mappedAttributes()->classNames(); } | |
74 | ||
75 | virtual void attributeChanged(Attribute*, bool preserveDecls = false); | |
76 | virtual void parseMappedAttribute(MappedAttribute*); | |
77 | virtual bool mapToEntry(const QualifiedName& attrName, MappedAttributeEntry& result) const; | |
78 | virtual void createAttributeMap() const; | |
79 | virtual PassRefPtr<Attribute> createAttribute(const QualifiedName&, const AtomicString& value); | |
80 | ||
81 | virtual void copyNonAttributeProperties(const Element*); | |
82 | ||
83 | virtual void addSubresourceAttributeURLs(ListHashSet<KURL>&) const; | |
84 | ||
85 | protected: | |
86 | // classAttributeChanged() exists to share code between | |
87 | // parseMappedAttribute (called via setAttribute()) and | |
88 | // svgAttributeChanged (called when element.className.baseValue is set) | |
89 | void classAttributeChanged(const AtomicString& newClassString); | |
90 | ||
91 | RefPtr<CSSMutableStyleDeclaration> m_inlineStyleDecl; | |
92 | }; | |
93 | ||
94 | } //namespace | |
95 | ||
96 | #endif |