| OLD | NEW |
| 1 /* | 1 /* |
| 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) | 2 * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) | 3 * (C) 2002-2003 Dirk Mueller (mueller@kde.org) |
| 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. | 4 * Copyright (C) 2002, 2005, 2006, 2008, 2012 Apple Inc. All rights reserved. |
| 5 * | 5 * |
| 6 * This library is free software; you can redistribute it and/or | 6 * This library is free software; you can redistribute it and/or |
| 7 * modify it under the terms of the GNU Library General Public | 7 * modify it under the terms of the GNU Library General Public |
| 8 * License as published by the Free Software Foundation; either | 8 * License as published by the Free Software Foundation; either |
| 9 * version 2 of the License, or (at your option) any later version. | 9 * version 2 of the License, or (at your option) any later version. |
| 10 * | 10 * |
| 11 * This library is distributed in the hope that it will be useful, | 11 * This library is distributed in the hope that it will be useful, |
| 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 * Library General Public License for more details. | 14 * Library General Public License for more details. |
| 15 * | 15 * |
| 16 * You should have received a copy of the GNU Library General Public License | 16 * You should have received a copy of the GNU Library General Public License |
| 17 * along with this library; see the file COPYING.LIB. If not, write to | 17 * along with this library; see the file COPYING.LIB. If not, write to |
| 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 18 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 * Boston, MA 02110-1301, USA. | 19 * Boston, MA 02110-1301, USA. |
| 20 */ | 20 */ |
| 21 | 21 |
| 22 #include "sky/engine/config.h" | 22 #include "sky/engine/config.h" |
| 23 #include "sky/engine/core/css/StyleRule.h" | 23 #include "sky/engine/core/css/StyleRule.h" |
| 24 | 24 |
| 25 #include "sky/engine/core/css/CSSFilterRule.h" | |
| 26 #include "sky/engine/core/css/CSSFontFaceRule.h" | |
| 27 #include "sky/engine/core/css/CSSKeyframesRule.h" | |
| 28 #include "sky/engine/core/css/CSSMediaRule.h" | |
| 29 #include "sky/engine/core/css/CSSStyleRule.h" | |
| 30 #include "sky/engine/core/css/CSSSupportsRule.h" | |
| 31 #include "sky/engine/core/css/StylePropertySet.h" | 25 #include "sky/engine/core/css/StylePropertySet.h" |
| 26 #include "sky/engine/core/css/StyleRuleKeyframes.h" |
| 32 | 27 |
| 33 namespace blink { | 28 namespace blink { |
| 34 | 29 |
| 35 struct SameSizeAsStyleRuleBase : public RefCounted<SameSizeAsStyleRuleBase> { | 30 struct SameSizeAsStyleRuleBase : public RefCounted<SameSizeAsStyleRuleBase> { |
| 36 unsigned bitfields; | 31 unsigned bitfields; |
| 37 }; | 32 }; |
| 38 | 33 |
| 39 COMPILE_ASSERT(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), StyleRu
leBase_should_stay_small); | 34 COMPILE_ASSERT(sizeof(StyleRuleBase) <= sizeof(SameSizeAsStyleRuleBase), StyleRu
leBase_should_stay_small); |
| 40 | 35 |
| 41 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
) const | |
| 42 { | |
| 43 return createCSSOMWrapper(parentSheet, 0); | |
| 44 } | |
| 45 | |
| 46 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const | |
| 47 { | |
| 48 return createCSSOMWrapper(0, parentRule); | |
| 49 } | |
| 50 | |
| 51 void StyleRuleBase::destroy() | 36 void StyleRuleBase::destroy() |
| 52 { | 37 { |
| 53 switch (type()) { | 38 switch (type()) { |
| 54 case Style: | 39 case Style: |
| 55 delete toStyleRule(this); | 40 delete toStyleRule(this); |
| 56 return; | 41 return; |
| 57 case FontFace: | 42 case FontFace: |
| 58 delete toStyleRuleFontFace(this); | 43 delete toStyleRuleFontFace(this); |
| 59 return; | 44 return; |
| 60 case Media: | 45 case Media: |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 94 return toStyleRuleFilter(this)->copy(); | 79 return toStyleRuleFilter(this)->copy(); |
| 95 case Unknown: | 80 case Unknown: |
| 96 case Keyframe: | 81 case Keyframe: |
| 97 ASSERT_NOT_REACHED(); | 82 ASSERT_NOT_REACHED(); |
| 98 return nullptr; | 83 return nullptr; |
| 99 } | 84 } |
| 100 ASSERT_NOT_REACHED(); | 85 ASSERT_NOT_REACHED(); |
| 101 return nullptr; | 86 return nullptr; |
| 102 } | 87 } |
| 103 | 88 |
| 104 PassRefPtr<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet
, CSSRule* parentRule) const | |
| 105 { | |
| 106 RefPtr<CSSRule> rule = nullptr; | |
| 107 StyleRuleBase* self = const_cast<StyleRuleBase*>(this); | |
| 108 switch (type()) { | |
| 109 case Style: | |
| 110 rule = CSSStyleRule::create(toStyleRule(self), parentSheet); | |
| 111 break; | |
| 112 case FontFace: | |
| 113 rule = CSSFontFaceRule::create(toStyleRuleFontFace(self), parentSheet); | |
| 114 break; | |
| 115 case Media: | |
| 116 rule = CSSMediaRule::create(toStyleRuleMedia(self), parentSheet); | |
| 117 break; | |
| 118 case Supports: | |
| 119 rule = CSSSupportsRule::create(toStyleRuleSupports(self), parentSheet); | |
| 120 break; | |
| 121 case Keyframes: | |
| 122 rule = CSSKeyframesRule::create(toStyleRuleKeyframes(self), parentSheet)
; | |
| 123 break; | |
| 124 case Filter: | |
| 125 rule = CSSFilterRule::create(toStyleRuleFilter(self), parentSheet); | |
| 126 break; | |
| 127 case Unknown: | |
| 128 case Keyframe: | |
| 129 ASSERT_NOT_REACHED(); | |
| 130 return nullptr; | |
| 131 } | |
| 132 if (parentRule) | |
| 133 rule->setParentRule(parentRule); | |
| 134 return rule.release(); | |
| 135 } | |
| 136 | |
| 137 unsigned StyleRule::averageSizeInBytes() | 89 unsigned StyleRule::averageSizeInBytes() |
| 138 { | 90 { |
| 139 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); | 91 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi
zeInBytes(); |
| 140 } | 92 } |
| 141 | 93 |
| 142 StyleRule::StyleRule() | 94 StyleRule::StyleRule() |
| 143 : StyleRuleBase(Style) | 95 : StyleRuleBase(Style) |
| 144 { | 96 { |
| 145 } | 97 } |
| 146 | 98 |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 268 m_properties = m_properties->mutableCopy(); | 220 m_properties = m_properties->mutableCopy(); |
| 269 return *toMutableStylePropertySet(m_properties); | 221 return *toMutableStylePropertySet(m_properties); |
| 270 } | 222 } |
| 271 | 223 |
| 272 void StyleRuleFilter::setProperties(PassRefPtr<StylePropertySet> properties) | 224 void StyleRuleFilter::setProperties(PassRefPtr<StylePropertySet> properties) |
| 273 { | 225 { |
| 274 m_properties = properties; | 226 m_properties = properties; |
| 275 } | 227 } |
| 276 | 228 |
| 277 } // namespace blink | 229 } // namespace blink |
| OLD | NEW |