2 * (C) 1999-2003 Lars Knoll (knoll@kde.org)
3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org)
4 * Copyright (C) 2002, 2006, 2007, 2012 Apple Inc. All rights reserved.
5 * Copyright (C) 2011 Andreas Kling (kling@webkit.org)
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.
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.
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.
26 #include "bindings/core/v8/ScriptWrappable.h"
27 #include "platform/heap/Handle.h"
28 #include "wtf/RefCounted.h"
29 #include "wtf/text/WTFString.h"
33 class CSSParserContext
;
38 class CSSRule
: public RefCountedWillBeGarbageCollectedFinalized
<CSSRule
>, public ScriptWrappable
{
39 DEFINE_WRAPPERTYPEINFO();
41 virtual ~CSSRule() { }
51 WEBKIT_KEYFRAMES_RULE
= KEYFRAMES_RULE
,
53 WEBKIT_KEYFRAME_RULE
= KEYFRAME_RULE
,
59 virtual Type
type() const = 0;
60 virtual String
cssText() const = 0;
61 virtual void reattach(StyleRuleBase
*) = 0;
63 virtual CSSRuleList
* cssRules() const { return 0; }
65 void setParentStyleSheet(CSSStyleSheet
* styleSheet
)
67 m_parentIsRule
= false;
68 m_parentStyleSheet
= styleSheet
;
71 void setParentRule(CSSRule
* rule
)
73 m_parentIsRule
= true;
77 DECLARE_VIRTUAL_TRACE();
79 CSSStyleSheet
* parentStyleSheet() const
82 return m_parentRule
? m_parentRule
->parentStyleSheet() : nullptr;
83 return m_parentStyleSheet
;
86 CSSRule
* parentRule() const { return m_parentIsRule
? m_parentRule
: nullptr; }
88 // NOTE: Just calls notImplemented().
89 void setCSSText(const String
&);
92 CSSRule(CSSStyleSheet
* parent
)
93 : m_hasCachedSelectorText(false)
94 , m_parentIsRule(false)
95 , m_parentStyleSheet(parent
)
99 bool hasCachedSelectorText() const { return m_hasCachedSelectorText
; }
100 void setHasCachedSelectorText(bool hasCachedSelectorText
) const { m_hasCachedSelectorText
= hasCachedSelectorText
; }
102 const CSSParserContext
& parserContext() const;
105 mutable unsigned char m_hasCachedSelectorText
: 1;
106 unsigned char m_parentIsRule
: 1;
108 // These should be Members, but no Members in unions.
110 CSSRule
* m_parentRule
;
111 CSSStyleSheet
* m_parentStyleSheet
;
115 #define DEFINE_CSS_RULE_TYPE_CASTS(ToType, TYPE_NAME) \
116 DEFINE_TYPE_CASTS(ToType, CSSRule, rule, rule->type() == CSSRule::TYPE_NAME, rule.type() == CSSRule::TYPE_NAME)