| OLD | NEW |
| (Empty) |
| 1 /* | |
| 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) | |
| 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 #ifndef SKY_ENGINE_CORE_CSS_CSSRULE_H_ | |
| 24 #define SKY_ENGINE_CORE_CSS_CSSRULE_H_ | |
| 25 | |
| 26 #include "sky/engine/bindings/core/v8/ScriptWrappable.h" | |
| 27 #include "sky/engine/platform/heap/Handle.h" | |
| 28 #include "sky/engine/wtf/RefCounted.h" | |
| 29 #include "sky/engine/wtf/text/WTFString.h" | |
| 30 | |
| 31 namespace blink { | |
| 32 | |
| 33 class CSSParserContext; | |
| 34 class CSSStyleSheet; | |
| 35 class StyleRuleBase; | |
| 36 | |
| 37 class CSSRule : public RefCounted<CSSRule>, public ScriptWrappableBase { | |
| 38 public: | |
| 39 virtual ~CSSRule() { } | |
| 40 | |
| 41 enum Type { | |
| 42 UNKNOWN_RULE = 0, | |
| 43 STYLE_RULE = 1, | |
| 44 MEDIA_RULE = 4, | |
| 45 FONT_FACE_RULE = 5, | |
| 46 KEYFRAMES_RULE = 7, | |
| 47 KEYFRAME_RULE, | |
| 48 SUPPORTS_RULE = 12, | |
| 49 WEBKIT_FILTER_RULE = 17 | |
| 50 }; | |
| 51 | |
| 52 virtual Type type() const = 0; | |
| 53 virtual String cssText() const = 0; | |
| 54 virtual void reattach(StyleRuleBase*) = 0; | |
| 55 | |
| 56 void setParentStyleSheet(CSSStyleSheet* styleSheet) | |
| 57 { | |
| 58 m_parentIsRule = false; | |
| 59 m_parentStyleSheet = styleSheet; | |
| 60 } | |
| 61 | |
| 62 void setParentRule(CSSRule* rule) | |
| 63 { | |
| 64 m_parentIsRule = true; | |
| 65 m_parentRule = rule; | |
| 66 } | |
| 67 | |
| 68 CSSStyleSheet* parentStyleSheet() const | |
| 69 { | |
| 70 if (m_parentIsRule) | |
| 71 return m_parentRule ? m_parentRule->parentStyleSheet() : 0; | |
| 72 return m_parentStyleSheet; | |
| 73 } | |
| 74 | |
| 75 CSSRule* parentRule() const { return m_parentIsRule ? m_parentRule : 0; } | |
| 76 | |
| 77 // NOTE: Just calls notImplemented(). | |
| 78 void setCSSText(const String&); | |
| 79 | |
| 80 protected: | |
| 81 CSSRule(CSSStyleSheet* parent) | |
| 82 : m_hasCachedSelectorText(false) | |
| 83 , m_parentIsRule(false) | |
| 84 , m_parentStyleSheet(parent) | |
| 85 { | |
| 86 } | |
| 87 | |
| 88 bool hasCachedSelectorText() const { return m_hasCachedSelectorText; } | |
| 89 void setHasCachedSelectorText(bool hasCachedSelectorText) const { m_hasCache
dSelectorText = hasCachedSelectorText; } | |
| 90 | |
| 91 const CSSParserContext& parserContext() const; | |
| 92 | |
| 93 private: | |
| 94 mutable unsigned char m_hasCachedSelectorText : 1; | |
| 95 unsigned char m_parentIsRule : 1; | |
| 96 | |
| 97 // These should be Members, but no Members in unions. | |
| 98 union { | |
| 99 CSSRule* m_parentRule; | |
| 100 CSSStyleSheet* m_parentStyleSheet; | |
| 101 }; | |
| 102 }; | |
| 103 | |
| 104 #define DEFINE_CSS_RULE_TYPE_CASTS(ToType, TYPE_NAME) \ | |
| 105 DEFINE_TYPE_CASTS(ToType, CSSRule, rule, rule->type() == CSSRule::TYPE_NAME,
rule.type() == CSSRule::TYPE_NAME) | |
| 106 | |
| 107 } // namespace blink | |
| 108 | |
| 109 #endif // SKY_ENGINE_CORE_CSS_CSSRULE_H_ | |
| OLD | NEW |