1 | /* |
2 | * (C) 1999-2003 Lars Knoll ([email protected]) |
3 | * Copyright (C) 2004, 2005, 2006, 2008, 2012 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 | #pragma once |
22 | |
23 | #include "CSSPropertyNames.h" |
24 | #include "ExceptionOr.h" |
25 | #include "ScriptWrappable.h" |
26 | |
27 | namespace WebCore { |
28 | |
29 | class CSSProperty; |
30 | class CSSRule; |
31 | class CSSStyleSheet; |
32 | class CSSValue; |
33 | class DeprecatedCSSOMValue; |
34 | class MutableStyleProperties; |
35 | class StyleProperties; |
36 | class StyledElement; |
37 | |
38 | class CSSStyleDeclaration : public ScriptWrappable { |
39 | WTF_MAKE_NONCOPYABLE(CSSStyleDeclaration); |
40 | WTF_MAKE_ISO_ALLOCATED(CSSStyleDeclaration); |
41 | public: |
42 | virtual ~CSSStyleDeclaration() = default; |
43 | |
44 | virtual void ref() = 0; |
45 | virtual void deref() = 0; |
46 | |
47 | virtual StyledElement* parentElement() const { return nullptr; } |
48 | virtual CSSRule* parentRule() const = 0; |
49 | virtual String cssText() const = 0; |
50 | virtual ExceptionOr<void> setCssText(const String&) = 0; |
51 | virtual unsigned length() const = 0; |
52 | virtual String item(unsigned index) const = 0; |
53 | virtual RefPtr<DeprecatedCSSOMValue> getPropertyCSSValue(const String& propertyName) = 0; |
54 | virtual String getPropertyValue(const String& propertyName) = 0; |
55 | virtual String getPropertyPriority(const String& propertyName) = 0; |
56 | virtual String getPropertyShorthand(const String& propertyName) = 0; |
57 | virtual bool isPropertyImplicit(const String& propertyName) = 0; |
58 | virtual ExceptionOr<void> setProperty(const String& propertyName, const String& value, const String& priority) = 0; |
59 | virtual ExceptionOr<String> removeProperty(const String& propertyName) = 0; |
60 | |
61 | String cssFloat(); |
62 | ExceptionOr<void> setCssFloat(const String&); |
63 | |
64 | // CSSPropertyID versions of the CSSOM functions to support bindings and editing. |
65 | // Use the non-virtual methods in the concrete subclasses when possible. |
66 | // The CSSValue returned by this function should not be exposed to the web as it may be used by multiple documents at the same time. |
67 | virtual RefPtr<CSSValue> getPropertyCSSValueInternal(CSSPropertyID) = 0; |
68 | virtual String getPropertyValueInternal(CSSPropertyID) = 0; |
69 | virtual ExceptionOr<bool> setPropertyInternal(CSSPropertyID, const String& value, bool important) = 0; |
70 | |
71 | virtual Ref<MutableStyleProperties> copyProperties() const = 0; |
72 | |
73 | virtual CSSStyleSheet* parentStyleSheet() const { return nullptr; } |
74 | |
75 | // Bindings support. |
76 | Optional<Variant<String, double>> namedItem(const AtomString&); |
77 | ExceptionOr<void> setNamedItem(const AtomString& name, String value, bool& propertySupported); |
78 | Vector<AtomString> supportedPropertyNames() const; |
79 | |
80 | static CSSPropertyID getCSSPropertyIDFromJavaScriptPropertyName(const AtomString&); |
81 | protected: |
82 | CSSStyleDeclaration() = default; |
83 | }; |
84 | |
85 | } // namespace WebCore |
86 | |