antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 1 | /* |
| 2 | * (C) 1999-2003 Lars Knoll (knoll@kde.org) |
| 3 | * (C) 2002-2003 Dirk Mueller (mueller@kde.org) |
bfulgham@apple.com | f760c50 | 2022-05-10 16:48:31 +0000 | [diff] [blame] | 4 | * Copyright (C) 2002-2022 Apple Inc. All rights reserved. |
antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 5 | * |
| 6 | * This library is free software; you can redistribute it and/or |
| 7 | * modify it under the terms of the GNU Library General Public |
| 8 | * License as published by the Free Software Foundation; either |
| 9 | * version 2 of the License, or (at your option) any later version. |
| 10 | * |
| 11 | * This library is distributed in the hope that it will be useful, |
| 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 14 | * Library General Public License for more details. |
| 15 | * |
| 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 |
| 18 | * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, |
| 19 | * Boston, MA 02110-1301, USA. |
| 20 | */ |
| 21 | |
| 22 | #include "config.h" |
| 23 | #include "StyleRule.h" |
| 24 | |
antti@apple.com | c34471a | 2022-03-29 18:19:56 +0000 | [diff] [blame] | 25 | #include "CSSContainerRule.h" |
commit-queue@webkit.org | fef3093 | 2021-04-16 19:19:04 +0000 | [diff] [blame] | 26 | #include "CSSCounterStyleRule.h" |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 27 | #include "CSSFontFaceRule.h" |
mmaxfield@apple.com | 0e1f0c4 | 2021-09-21 08:24:36 +0000 | [diff] [blame] | 28 | #include "CSSFontPaletteValuesRule.h" |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 29 | #include "CSSImportRule.h" |
dino@apple.com | d2a5e4c | 2014-11-15 23:02:43 +0000 | [diff] [blame] | 30 | #include "CSSKeyframeRule.h" |
| 31 | #include "CSSKeyframesRule.h" |
antti@apple.com | 850cde4 | 2021-12-08 16:55:05 +0000 | [diff] [blame] | 32 | #include "CSSLayerBlockRule.h" |
| 33 | #include "CSSLayerStatementRule.h" |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 34 | #include "CSSMediaRule.h" |
hyatt@apple.com | 1f58965 | 2016-12-10 18:31:13 +0000 | [diff] [blame] | 35 | #include "CSSNamespaceRule.h" |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 36 | #include "CSSPageRule.h" |
| 37 | #include "CSSStyleRule.h" |
commit-queue@webkit.org | 03dd24f | 2013-01-16 11:30:50 +0000 | [diff] [blame] | 38 | #include "CSSSupportsRule.h" |
achristensen@apple.com | 26aaf30 | 2016-05-24 05:34:49 +0000 | [diff] [blame] | 39 | #include "MediaList.h" |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 40 | #include "StyleProperties.h" |
antti@apple.com | 1639642 | 2012-05-24 15:07:29 +0000 | [diff] [blame] | 41 | #include "StyleRuleImport.h" |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 42 | |
antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 43 | namespace WebCore { |
| 44 | |
commit-queue@webkit.org | 8177b03 | 2012-06-21 17:53:54 +0000 | [diff] [blame] | 45 | struct SameSizeAsStyleRuleBase : public WTF::RefCountedBase { |
hyatt@apple.com | da947f7 | 2016-12-03 21:22:49 +0000 | [diff] [blame] | 46 | unsigned bitfields : 5; |
commit-queue@webkit.org | 8177b03 | 2012-06-21 17:53:54 +0000 | [diff] [blame] | 47 | }; |
| 48 | |
ysuzuki@apple.com | 82d570e | 2022-03-26 22:19:31 +0000 | [diff] [blame] | 49 | static_assert(sizeof(StyleRuleBase) == sizeof(SameSizeAsStyleRuleBase), "StyleRuleBase should stay small"); |
commit-queue@webkit.org | 8177b03 | 2012-06-21 17:53:54 +0000 | [diff] [blame] | 50 | |
ysuzuki@apple.com | 4642e11 | 2020-01-03 02:36:43 +0000 | [diff] [blame] | 51 | DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StyleRuleBase); |
| 52 | DEFINE_ALLOCATOR_WITH_HEAP_IDENTIFIER(StyleRule); |
| 53 | |
yusukesuzuki@slowstart.org | ae5a8bd | 2018-12-22 06:37:39 +0000 | [diff] [blame] | 54 | Ref<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet) const |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 55 | { |
achristensen@apple.com | 26aaf30 | 2016-05-24 05:34:49 +0000 | [diff] [blame] | 56 | return createCSSOMWrapper(parentSheet, nullptr); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 57 | } |
| 58 | |
yusukesuzuki@slowstart.org | ae5a8bd | 2018-12-22 06:37:39 +0000 | [diff] [blame] | 59 | Ref<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSRule* parentRule) const |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 60 | { |
achristensen@apple.com | 26aaf30 | 2016-05-24 05:34:49 +0000 | [diff] [blame] | 61 | return createCSSOMWrapper(nullptr, parentRule); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 62 | } |
| 63 | |
| 64 | void StyleRuleBase::destroy() |
| 65 | { |
| 66 | switch (type()) { |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 67 | case StyleRuleType::Style: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 68 | delete downcast<StyleRule>(this); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 69 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 70 | case StyleRuleType::Page: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 71 | delete downcast<StyleRulePage>(this); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 72 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 73 | case StyleRuleType::FontFace: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 74 | delete downcast<StyleRuleFontFace>(this); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 75 | return; |
mmaxfield@apple.com | 0e1f0c4 | 2021-09-21 08:24:36 +0000 | [diff] [blame] | 76 | case StyleRuleType::FontPaletteValues: |
| 77 | delete downcast<StyleRuleFontPaletteValues>(this); |
| 78 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 79 | case StyleRuleType::Media: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 80 | delete downcast<StyleRuleMedia>(this); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 81 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 82 | case StyleRuleType::Supports: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 83 | delete downcast<StyleRuleSupports>(this); |
commit-queue@webkit.org | 03dd24f | 2013-01-16 11:30:50 +0000 | [diff] [blame] | 84 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 85 | case StyleRuleType::Import: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 86 | delete downcast<StyleRuleImport>(this); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 87 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 88 | case StyleRuleType::Keyframes: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 89 | delete downcast<StyleRuleKeyframes>(this); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 90 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 91 | case StyleRuleType::Namespace: |
hyatt@apple.com | b048c56 | 2016-09-11 18:11:42 +0000 | [diff] [blame] | 92 | delete downcast<StyleRuleNamespace>(this); |
| 93 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 94 | case StyleRuleType::Keyframe: |
hyatt@apple.com | e39aad3 | 2016-12-14 23:15:24 +0000 | [diff] [blame] | 95 | delete downcast<StyleRuleKeyframe>(this); |
hyatt@apple.com | b048c56 | 2016-09-11 18:11:42 +0000 | [diff] [blame] | 96 | return; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 97 | case StyleRuleType::Charset: |
hyatt@apple.com | 005da7c | 2016-10-24 18:18:09 +0000 | [diff] [blame] | 98 | delete downcast<StyleRuleCharset>(this); |
| 99 | return; |
commit-queue@webkit.org | fef3093 | 2021-04-16 19:19:04 +0000 | [diff] [blame] | 100 | case StyleRuleType::CounterStyle: |
| 101 | delete downcast<StyleRuleCounterStyle>(this); |
| 102 | return; |
antti@apple.com | 850cde4 | 2021-12-08 16:55:05 +0000 | [diff] [blame] | 103 | case StyleRuleType::LayerBlock: |
| 104 | case StyleRuleType::LayerStatement: |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 105 | delete downcast<StyleRuleLayer>(this); |
| 106 | return; |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 107 | case StyleRuleType::Container: |
| 108 | delete downcast<StyleRuleContainer>(this); |
| 109 | return; |
antti@apple.com | f25e19f | 2021-12-11 18:28:39 +0000 | [diff] [blame] | 110 | case StyleRuleType::Margin: |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 111 | case StyleRuleType::Unknown: |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 112 | ASSERT_NOT_REACHED(); |
| 113 | return; |
| 114 | } |
| 115 | ASSERT_NOT_REACHED(); |
| 116 | } |
| 117 | |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 118 | Ref<StyleRuleBase> StyleRuleBase::copy() const |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 119 | { |
| 120 | switch (type()) { |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 121 | case StyleRuleType::Style: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 122 | return downcast<StyleRule>(*this).copy(); |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 123 | case StyleRuleType::Page: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 124 | return downcast<StyleRulePage>(*this).copy(); |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 125 | case StyleRuleType::FontFace: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 126 | return downcast<StyleRuleFontFace>(*this).copy(); |
mmaxfield@apple.com | 0e1f0c4 | 2021-09-21 08:24:36 +0000 | [diff] [blame] | 127 | case StyleRuleType::FontPaletteValues: |
| 128 | return downcast<StyleRuleFontPaletteValues>(*this).copy(); |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 129 | case StyleRuleType::Media: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 130 | return downcast<StyleRuleMedia>(*this).copy(); |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 131 | case StyleRuleType::Supports: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 132 | return downcast<StyleRuleSupports>(*this).copy(); |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 133 | case StyleRuleType::Keyframes: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 134 | return downcast<StyleRuleKeyframes>(*this).copy(); |
commit-queue@webkit.org | fef3093 | 2021-04-16 19:19:04 +0000 | [diff] [blame] | 135 | case StyleRuleType::CounterStyle: |
| 136 | return downcast<StyleRuleCounterStyle>(*this).copy(); |
antti@apple.com | 850cde4 | 2021-12-08 16:55:05 +0000 | [diff] [blame] | 137 | case StyleRuleType::LayerBlock: |
| 138 | case StyleRuleType::LayerStatement: |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 139 | return downcast<StyleRuleLayer>(*this).copy(); |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 140 | case StyleRuleType::Container: |
| 141 | return downcast<StyleRuleContainer>(*this).copy(); |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 142 | case StyleRuleType::Import: |
| 143 | case StyleRuleType::Namespace: |
hyatt@apple.com | b048c56 | 2016-09-11 18:11:42 +0000 | [diff] [blame] | 144 | // FIXME: Copy import and namespace rules. |
akling@apple.com | 8c487df | 2013-10-20 10:49:10 +0000 | [diff] [blame] | 145 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 146 | case StyleRuleType::Unknown: |
| 147 | case StyleRuleType::Charset: |
| 148 | case StyleRuleType::Keyframe: |
antti@apple.com | f25e19f | 2021-12-11 18:28:39 +0000 | [diff] [blame] | 149 | case StyleRuleType::Margin: |
akling@apple.com | 8c487df | 2013-10-20 10:49:10 +0000 | [diff] [blame] | 150 | break; |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 151 | } |
akling@apple.com | 8c487df | 2013-10-20 10:49:10 +0000 | [diff] [blame] | 152 | CRASH(); |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 153 | } |
| 154 | |
yusukesuzuki@slowstart.org | ae5a8bd | 2018-12-22 06:37:39 +0000 | [diff] [blame] | 155 | Ref<CSSRule> StyleRuleBase::createCSSOMWrapper(CSSStyleSheet* parentSheet, CSSRule* parentRule) const |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 156 | { |
| 157 | RefPtr<CSSRule> rule; |
akling@apple.com | 39ce74c | 2014-10-03 04:38:19 +0000 | [diff] [blame] | 158 | StyleRuleBase& self = const_cast<StyleRuleBase&>(*this); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 159 | switch (type()) { |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 160 | case StyleRuleType::Style: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 161 | rule = CSSStyleRule::create(downcast<StyleRule>(self), parentSheet); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 162 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 163 | case StyleRuleType::Page: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 164 | rule = CSSPageRule::create(downcast<StyleRulePage>(self), parentSheet); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 165 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 166 | case StyleRuleType::FontFace: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 167 | rule = CSSFontFaceRule::create(downcast<StyleRuleFontFace>(self), parentSheet); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 168 | break; |
mmaxfield@apple.com | 0e1f0c4 | 2021-09-21 08:24:36 +0000 | [diff] [blame] | 169 | case StyleRuleType::FontPaletteValues: |
| 170 | rule = CSSFontPaletteValuesRule::create(downcast<StyleRuleFontPaletteValues>(self), parentSheet); |
| 171 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 172 | case StyleRuleType::Media: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 173 | rule = CSSMediaRule::create(downcast<StyleRuleMedia>(self), parentSheet); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 174 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 175 | case StyleRuleType::Supports: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 176 | rule = CSSSupportsRule::create(downcast<StyleRuleSupports>(self), parentSheet); |
commit-queue@webkit.org | 03dd24f | 2013-01-16 11:30:50 +0000 | [diff] [blame] | 177 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 178 | case StyleRuleType::Import: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 179 | rule = CSSImportRule::create(downcast<StyleRuleImport>(self), parentSheet); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 180 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 181 | case StyleRuleType::Keyframes: |
cdumez@apple.com | 7687ecf | 2014-12-12 20:28:17 +0000 | [diff] [blame] | 182 | rule = CSSKeyframesRule::create(downcast<StyleRuleKeyframes>(self), parentSheet); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 183 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 184 | case StyleRuleType::Namespace: |
hyatt@apple.com | 1f58965 | 2016-12-10 18:31:13 +0000 | [diff] [blame] | 185 | rule = CSSNamespaceRule::create(downcast<StyleRuleNamespace>(self), parentSheet); |
| 186 | break; |
commit-queue@webkit.org | fef3093 | 2021-04-16 19:19:04 +0000 | [diff] [blame] | 187 | case StyleRuleType::CounterStyle: |
| 188 | rule = CSSCounterStyleRule::create(downcast<StyleRuleCounterStyle>(self), parentSheet); |
| 189 | break; |
antti@apple.com | 850cde4 | 2021-12-08 16:55:05 +0000 | [diff] [blame] | 190 | case StyleRuleType::LayerBlock: |
| 191 | rule = CSSLayerBlockRule::create(downcast<StyleRuleLayer>(self), parentSheet); |
| 192 | break; |
| 193 | case StyleRuleType::LayerStatement: |
| 194 | rule = CSSLayerStatementRule::create(downcast<StyleRuleLayer>(self), parentSheet); |
antti@apple.com | 24b9b5d | 2021-09-28 15:40:24 +0000 | [diff] [blame] | 195 | break; |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 196 | case StyleRuleType::Container: |
antti@apple.com | c34471a | 2022-03-29 18:19:56 +0000 | [diff] [blame] | 197 | rule = CSSContainerRule::create(downcast<StyleRuleContainer>(self), parentSheet); |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 198 | break; |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 199 | case StyleRuleType::Unknown: |
| 200 | case StyleRuleType::Charset: |
| 201 | case StyleRuleType::Keyframe: |
antti@apple.com | f25e19f | 2021-12-11 18:28:39 +0000 | [diff] [blame] | 202 | case StyleRuleType::Margin: |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 203 | ASSERT_NOT_REACHED(); |
yusukesuzuki@slowstart.org | ae5a8bd | 2018-12-22 06:37:39 +0000 | [diff] [blame] | 204 | break; |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 205 | } |
yusukesuzuki@slowstart.org | ae5a8bd | 2018-12-22 06:37:39 +0000 | [diff] [blame] | 206 | ASSERT(rule); |
| 207 | |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 208 | if (parentRule) |
| 209 | rule->setParentRule(parentRule); |
yusukesuzuki@slowstart.org | ae5a8bd | 2018-12-22 06:37:39 +0000 | [diff] [blame] | 210 | return rule.releaseNonNull(); |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 211 | } |
| 212 | |
antti@apple.com | 52f660f | 2012-04-26 22:26:35 +0000 | [diff] [blame] | 213 | unsigned StyleRule::averageSizeInBytes() |
| 214 | { |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 215 | return sizeof(StyleRule) + sizeof(CSSSelector) + StyleProperties::averageSizeInBytes(); |
antti@apple.com | 52f660f | 2012-04-26 22:26:35 +0000 | [diff] [blame] | 216 | } |
| 217 | |
bfulgham@apple.com | 1ee843f | 2022-05-10 21:15:45 +0000 | [diff] [blame] | 218 | StyleRule::StyleRule(Ref<StyleProperties>&& properties, bool hasDocumentSecurityOrigin, CSSSelectorList&& selectors) |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 219 | : StyleRuleBase(StyleRuleType::Style, hasDocumentSecurityOrigin) |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 220 | , m_properties(WTFMove(properties)) |
achristensen@apple.com | 37ead0f | 2018-08-13 23:36:09 +0000 | [diff] [blame] | 221 | , m_selectorList(WTFMove(selectors)) |
antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 222 | { |
| 223 | } |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 224 | |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 225 | StyleRule::StyleRule(const StyleRule& o) |
| 226 | : StyleRuleBase(o) |
hyatt@apple.com | a703cf2 | 2016-12-14 21:02:07 +0000 | [diff] [blame] | 227 | , m_properties(o.properties().mutableCopy()) |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 228 | , m_selectorList(o.m_selectorList) |
pangle@apple.com | ebd2c58 | 2021-08-21 00:35:46 +0000 | [diff] [blame] | 229 | , m_isSplitRule(o.m_isSplitRule) |
| 230 | , m_isLastRuleInSplitRule(o.m_isLastRuleInSplitRule) |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 231 | { |
| 232 | } |
| 233 | |
dbates@webkit.org | f21f3ae | 2017-10-19 23:48:45 +0000 | [diff] [blame] | 234 | StyleRule::~StyleRule() = default; |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 235 | |
bfulgham@apple.com | 1ee843f | 2022-05-10 21:15:45 +0000 | [diff] [blame] | 236 | Ref<StyleRule> StyleRule::create(Ref<StyleProperties>&& properties, bool hasDocumentSecurityOrigin, CSSSelectorList&& selectors) |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 237 | { |
| 238 | return adoptRef(*new StyleRule(WTFMove(properties), hasDocumentSecurityOrigin, WTFMove(selectors))); |
| 239 | } |
| 240 | |
| 241 | Ref<StyleRule> StyleRule::copy() const |
| 242 | { |
| 243 | return adoptRef(*new StyleRule(*this)); |
| 244 | } |
| 245 | |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 246 | MutableStyleProperties& StyleRule::mutableProperties() |
kling@webkit.org | 5e60b73 | 2012-05-29 12:25:07 +0000 | [diff] [blame] | 247 | { |
drousso@apple.com | b706fa0 | 2021-09-24 18:04:35 +0000 | [diff] [blame] | 248 | if (!is<MutableStyleProperties>(m_properties)) |
hyatt@apple.com | a703cf2 | 2016-12-14 21:02:07 +0000 | [diff] [blame] | 249 | m_properties = properties().mutableCopy(); |
cdumez@apple.com | 9b2f708c | 2014-10-04 08:30:15 +0000 | [diff] [blame] | 250 | return downcast<MutableStyleProperties>(m_properties.get()); |
kling@webkit.org | 5e60b73 | 2012-05-29 12:25:07 +0000 | [diff] [blame] | 251 | } |
| 252 | |
antti@apple.com | c430d67 | 2017-12-07 23:58:39 +0000 | [diff] [blame] | 253 | Ref<StyleRule> StyleRule::createForSplitting(const Vector<const CSSSelector*>& selectors, Ref<StyleProperties>&& properties, bool hasDocumentSecurityOrigin) |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 254 | { |
antti@apple.com | feac3de | 2014-03-19 21:43:52 +0000 | [diff] [blame] | 255 | ASSERT_WITH_SECURITY_IMPLICATION(!selectors.isEmpty()); |
achristensen@apple.com | 37ead0f | 2018-08-13 23:36:09 +0000 | [diff] [blame] | 256 | auto selectorListArray = makeUniqueArray<CSSSelector>(selectors.size()); |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 257 | for (unsigned i = 0; i < selectors.size(); ++i) |
| 258 | new (NotNull, &selectorListArray[i]) CSSSelector(*selectors.at(i)); |
| 259 | selectorListArray[selectors.size() - 1].setLastInSelectorList(); |
pangle@apple.com | ebd2c58 | 2021-08-21 00:35:46 +0000 | [diff] [blame] | 260 | auto styleRule = StyleRule::create(WTFMove(properties), hasDocumentSecurityOrigin, CSSSelectorList(WTFMove(selectorListArray))); |
| 261 | styleRule->markAsSplitRule(); |
| 262 | return styleRule; |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 263 | } |
| 264 | |
andersca@apple.com | c3523f8 | 2013-10-18 23:41:24 +0000 | [diff] [blame] | 265 | Vector<RefPtr<StyleRule>> StyleRule::splitIntoMultipleRulesWithMaximumSelectorComponentCount(unsigned maxCount) const |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 266 | { |
akling@apple.com | ccc6245 | 2013-07-17 17:21:51 +0000 | [diff] [blame] | 267 | ASSERT(selectorList().componentCount() > maxCount); |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 268 | |
andersca@apple.com | c3523f8 | 2013-10-18 23:41:24 +0000 | [diff] [blame] | 269 | Vector<RefPtr<StyleRule>> rules; |
akling@apple.com | ccc6245 | 2013-07-17 17:21:51 +0000 | [diff] [blame] | 270 | Vector<const CSSSelector*> componentsSinceLastSplit; |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 271 | |
| 272 | for (const CSSSelector* selector = selectorList().first(); selector; selector = CSSSelectorList::next(selector)) { |
akling@apple.com | ccc6245 | 2013-07-17 17:21:51 +0000 | [diff] [blame] | 273 | Vector<const CSSSelector*, 8> componentsInThisSelector; |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 274 | for (const CSSSelector* component = selector; component; component = component->tagHistory()) |
akling@apple.com | ccc6245 | 2013-07-17 17:21:51 +0000 | [diff] [blame] | 275 | componentsInThisSelector.append(component); |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 276 | |
antti@apple.com | feac3de | 2014-03-19 21:43:52 +0000 | [diff] [blame] | 277 | if (componentsInThisSelector.size() + componentsSinceLastSplit.size() > maxCount && !componentsSinceLastSplit.isEmpty()) { |
antti@apple.com | c430d67 | 2017-12-07 23:58:39 +0000 | [diff] [blame] | 278 | rules.append(createForSplitting(componentsSinceLastSplit, const_cast<StyleProperties&>(properties()), hasDocumentSecurityOrigin())); |
akling@apple.com | ccc6245 | 2013-07-17 17:21:51 +0000 | [diff] [blame] | 279 | componentsSinceLastSplit.clear(); |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 280 | } |
akling@apple.com | ccc6245 | 2013-07-17 17:21:51 +0000 | [diff] [blame] | 281 | |
| 282 | componentsSinceLastSplit.appendVector(componentsInThisSelector); |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 283 | } |
| 284 | |
akling@apple.com | ccc6245 | 2013-07-17 17:21:51 +0000 | [diff] [blame] | 285 | if (!componentsSinceLastSplit.isEmpty()) |
antti@apple.com | c430d67 | 2017-12-07 23:58:39 +0000 | [diff] [blame] | 286 | rules.append(createForSplitting(componentsSinceLastSplit, const_cast<StyleProperties&>(properties()), hasDocumentSecurityOrigin())); |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 287 | |
pangle@apple.com | ebd2c58 | 2021-08-21 00:35:46 +0000 | [diff] [blame] | 288 | if (!rules.isEmpty()) |
| 289 | rules.last()->markAsLastRuleInSplitRule(); |
| 290 | |
akling@apple.com | 91d528d | 2013-07-08 15:53:54 +0000 | [diff] [blame] | 291 | return rules; |
| 292 | } |
| 293 | |
achristensen@apple.com | 37ead0f | 2018-08-13 23:36:09 +0000 | [diff] [blame] | 294 | StyleRulePage::StyleRulePage(Ref<StyleProperties>&& properties, CSSSelectorList&& selectors) |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 295 | : StyleRuleBase(StyleRuleType::Page) |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 296 | , m_properties(WTFMove(properties)) |
achristensen@apple.com | 37ead0f | 2018-08-13 23:36:09 +0000 | [diff] [blame] | 297 | , m_selectorList(WTFMove(selectors)) |
antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 298 | { |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 299 | } |
| 300 | |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 301 | StyleRulePage::StyleRulePage(const StyleRulePage& o) |
| 302 | : StyleRuleBase(o) |
akling@apple.com | 2420f86 | 2013-04-13 20:03:20 +0000 | [diff] [blame] | 303 | , m_properties(o.m_properties->mutableCopy()) |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 304 | , m_selectorList(o.m_selectorList) |
| 305 | { |
| 306 | } |
| 307 | |
dbates@webkit.org | f21f3ae | 2017-10-19 23:48:45 +0000 | [diff] [blame] | 308 | StyleRulePage::~StyleRulePage() = default; |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 309 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 310 | Ref<StyleRulePage> StyleRulePage::create(Ref<StyleProperties>&& properties, CSSSelectorList&& selectors) |
| 311 | { |
| 312 | return adoptRef(*new StyleRulePage(WTFMove(properties), WTFMove(selectors))); |
| 313 | } |
| 314 | |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 315 | MutableStyleProperties& StyleRulePage::mutableProperties() |
kling@webkit.org | 5e60b73 | 2012-05-29 12:25:07 +0000 | [diff] [blame] | 316 | { |
drousso@apple.com | b706fa0 | 2021-09-24 18:04:35 +0000 | [diff] [blame] | 317 | if (!is<MutableStyleProperties>(m_properties)) |
akling@apple.com | 2420f86 | 2013-04-13 20:03:20 +0000 | [diff] [blame] | 318 | m_properties = m_properties->mutableCopy(); |
cdumez@apple.com | 9b2f708c | 2014-10-04 08:30:15 +0000 | [diff] [blame] | 319 | return downcast<MutableStyleProperties>(m_properties.get()); |
kling@webkit.org | 5e60b73 | 2012-05-29 12:25:07 +0000 | [diff] [blame] | 320 | } |
| 321 | |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 322 | StyleRuleFontFace::StyleRuleFontFace(Ref<StyleProperties>&& properties) |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 323 | : StyleRuleBase(StyleRuleType::FontFace) |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 324 | , m_properties(WTFMove(properties)) |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 325 | { |
| 326 | } |
| 327 | |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 328 | StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o) |
| 329 | : StyleRuleBase(o) |
akling@apple.com | 2420f86 | 2013-04-13 20:03:20 +0000 | [diff] [blame] | 330 | , m_properties(o.m_properties->mutableCopy()) |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 331 | { |
| 332 | } |
| 333 | |
dbates@webkit.org | f21f3ae | 2017-10-19 23:48:45 +0000 | [diff] [blame] | 334 | StyleRuleFontFace::~StyleRuleFontFace() = default; |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 335 | |
antti@apple.com | e5428c5 | 2013-11-28 20:53:22 +0000 | [diff] [blame] | 336 | MutableStyleProperties& StyleRuleFontFace::mutableProperties() |
kling@webkit.org | 5e60b73 | 2012-05-29 12:25:07 +0000 | [diff] [blame] | 337 | { |
drousso@apple.com | b706fa0 | 2021-09-24 18:04:35 +0000 | [diff] [blame] | 338 | if (!is<MutableStyleProperties>(m_properties)) |
akling@apple.com | 2420f86 | 2013-04-13 20:03:20 +0000 | [diff] [blame] | 339 | m_properties = m_properties->mutableCopy(); |
cdumez@apple.com | 9b2f708c | 2014-10-04 08:30:15 +0000 | [diff] [blame] | 340 | return downcast<MutableStyleProperties>(m_properties.get()); |
kling@webkit.org | 5e60b73 | 2012-05-29 12:25:07 +0000 | [diff] [blame] | 341 | } |
| 342 | |
mmaxfield@apple.com | 3b791c5 | 2021-10-07 23:05:49 +0000 | [diff] [blame] | 343 | StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const AtomString& name, const AtomString& fontFamily, std::optional<FontPaletteIndex> basePalette, Vector<FontPaletteValues::OverriddenColor>&& overrideColors) |
mmaxfield@apple.com | 0e1f0c4 | 2021-09-21 08:24:36 +0000 | [diff] [blame] | 344 | : StyleRuleBase(StyleRuleType::FontPaletteValues) |
| 345 | , m_name(name) |
| 346 | , m_fontFamily(fontFamily) |
mmaxfield@apple.com | ebf86d8 | 2021-09-28 06:45:49 +0000 | [diff] [blame] | 347 | , m_fontPaletteValues(basePalette, WTFMove(overrideColors)) |
mmaxfield@apple.com | 0e1f0c4 | 2021-09-21 08:24:36 +0000 | [diff] [blame] | 348 | { |
| 349 | } |
| 350 | |
| 351 | StyleRuleFontPaletteValues::StyleRuleFontPaletteValues(const StyleRuleFontPaletteValues& o) |
| 352 | : StyleRuleBase(o) |
| 353 | , m_name(o.name()) |
| 354 | , m_fontFamily(o.fontFamily()) |
| 355 | , m_fontPaletteValues(o.m_fontPaletteValues) |
| 356 | { |
| 357 | } |
| 358 | |
| 359 | StyleRuleFontPaletteValues::~StyleRuleFontPaletteValues() = default; |
hyatt@apple.com | a703cf2 | 2016-12-14 21:02:07 +0000 | [diff] [blame] | 360 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 361 | StyleRuleGroup::StyleRuleGroup(StyleRuleType type, Vector<RefPtr<StyleRuleBase>>&& rules) |
hyatt@apple.com | da947f7 | 2016-12-03 21:22:49 +0000 | [diff] [blame] | 362 | : StyleRuleBase(type) |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 363 | , m_childRules(WTFMove(rules)) |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 364 | { |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 365 | } |
| 366 | |
tasak@google.com | 44b7f4c | 2013-01-21 10:33:19 +0000 | [diff] [blame] | 367 | StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o) |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 368 | : StyleRuleBase(o) |
cdumez@apple.com | da062e1 | 2022-02-17 17:17:46 +0000 | [diff] [blame] | 369 | , m_childRules(o.childRules().map([](auto& rule) -> RefPtr<StyleRuleBase> { return rule->copy(); })) |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 370 | { |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 371 | } |
| 372 | |
hyatt@apple.com | a703cf2 | 2016-12-14 21:02:07 +0000 | [diff] [blame] | 373 | const Vector<RefPtr<StyleRuleBase>>& StyleRuleGroup::childRules() const |
| 374 | { |
hyatt@apple.com | a703cf2 | 2016-12-14 21:02:07 +0000 | [diff] [blame] | 375 | return m_childRules; |
| 376 | } |
| 377 | |
akling@apple.com | 689f761 | 2014-12-14 08:21:05 +0000 | [diff] [blame] | 378 | void StyleRuleGroup::wrapperInsertRule(unsigned index, Ref<StyleRuleBase>&& rule) |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 379 | { |
aestes@apple.com | 13aae08 | 2016-01-02 08:03:08 +0000 | [diff] [blame] | 380 | m_childRules.insert(index, WTFMove(rule)); |
antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 381 | } |
| 382 | |
tasak@google.com | 44b7f4c | 2013-01-21 10:33:19 +0000 | [diff] [blame] | 383 | void StyleRuleGroup::wrapperRemoveRule(unsigned index) |
antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 384 | { |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 385 | m_childRules.remove(index); |
| 386 | } |
| 387 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 388 | StyleRuleMedia::StyleRuleMedia(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>&& rules) |
| 389 | : StyleRuleGroup(StyleRuleType::Media, WTFMove(rules)) |
achristensen@apple.com | 26aaf30 | 2016-05-24 05:34:49 +0000 | [diff] [blame] | 390 | , m_mediaQueries(WTFMove(media)) |
antti@apple.com | d09a792 | 2012-04-02 19:50:34 +0000 | [diff] [blame] | 391 | { |
| 392 | } |
| 393 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 394 | StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& other) |
| 395 | : StyleRuleGroup(other) |
| 396 | , m_mediaQueries(other.m_mediaQueries->copy()) |
antti@apple.com | ca0770b | 2012-04-24 21:56:48 +0000 | [diff] [blame] | 397 | { |
| 398 | } |
| 399 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 400 | Ref<StyleRuleMedia> StyleRuleMedia::create(Ref<MediaQuerySet>&& media, Vector<RefPtr<StyleRuleBase>>&& rules) |
| 401 | { |
| 402 | return adoptRef(*new StyleRuleMedia(WTFMove(media), WTFMove(rules))); |
| 403 | } |
commit-queue@webkit.org | 03dd24f | 2013-01-16 11:30:50 +0000 | [diff] [blame] | 404 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 405 | Ref<StyleRuleMedia> StyleRuleMedia::copy() const |
| 406 | { |
| 407 | return adoptRef(*new StyleRuleMedia(*this)); |
| 408 | } |
| 409 | |
| 410 | StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>&& rules) |
| 411 | : StyleRuleGroup(StyleRuleType::Supports, WTFMove(rules)) |
commit-queue@webkit.org | 03dd24f | 2013-01-16 11:30:50 +0000 | [diff] [blame] | 412 | , m_conditionText(conditionText) |
| 413 | , m_conditionIsSupported(conditionIsSupported) |
| 414 | { |
| 415 | } |
| 416 | |
| 417 | StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o) |
tasak@google.com | 44b7f4c | 2013-01-21 10:33:19 +0000 | [diff] [blame] | 418 | : StyleRuleGroup(o) |
commit-queue@webkit.org | 03dd24f | 2013-01-16 11:30:50 +0000 | [diff] [blame] | 419 | , m_conditionText(o.m_conditionText) |
| 420 | , m_conditionIsSupported(o.m_conditionIsSupported) |
| 421 | { |
| 422 | } |
commit-queue@webkit.org | 03dd24f | 2013-01-16 11:30:50 +0000 | [diff] [blame] | 423 | |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 424 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 425 | Ref<StyleRuleSupports> StyleRuleSupports::create(const String& conditionText, bool conditionIsSupported, Vector<RefPtr<StyleRuleBase>>&& rules) |
| 426 | { |
| 427 | return adoptRef(*new StyleRuleSupports(conditionText, conditionIsSupported, WTFMove(rules))); |
| 428 | } |
| 429 | |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 430 | StyleRuleLayer::StyleRuleLayer(Vector<CascadeLayerName>&& nameList) |
antti@apple.com | 850cde4 | 2021-12-08 16:55:05 +0000 | [diff] [blame] | 431 | : StyleRuleGroup(StyleRuleType::LayerStatement, Vector<RefPtr<StyleRuleBase>> { }) |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 432 | , m_nameVariant(WTFMove(nameList)) |
| 433 | { |
| 434 | } |
| 435 | |
| 436 | StyleRuleLayer::StyleRuleLayer(CascadeLayerName&& name, Vector<RefPtr<StyleRuleBase>>&& rules) |
antti@apple.com | 850cde4 | 2021-12-08 16:55:05 +0000 | [diff] [blame] | 437 | : StyleRuleGroup(StyleRuleType::LayerBlock, WTFMove(rules)) |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 438 | , m_nameVariant(WTFMove(name)) |
| 439 | { |
| 440 | } |
| 441 | |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 442 | StyleRuleLayer::StyleRuleLayer(const StyleRuleLayer& other) |
| 443 | : StyleRuleGroup(other) |
| 444 | , m_nameVariant(other.m_nameVariant) |
| 445 | { |
| 446 | } |
| 447 | |
antti@apple.com | 325beca | 2021-09-27 16:27:00 +0000 | [diff] [blame] | 448 | Ref<StyleRuleLayer> StyleRuleLayer::createStatement(Vector<CascadeLayerName>&& nameList) |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 449 | { |
| 450 | return adoptRef(*new StyleRuleLayer(WTFMove(nameList))); |
| 451 | } |
| 452 | |
antti@apple.com | 325beca | 2021-09-27 16:27:00 +0000 | [diff] [blame] | 453 | Ref<StyleRuleLayer> StyleRuleLayer::createBlock(CascadeLayerName&& name, Vector<RefPtr<StyleRuleBase>>&& rules) |
antti@apple.com | d237ffd | 2021-08-27 17:43:04 +0000 | [diff] [blame] | 454 | { |
| 455 | return adoptRef(*new StyleRuleLayer(WTFMove(name), WTFMove(rules))); |
| 456 | } |
| 457 | |
antti@apple.com | 3e729cb | 2022-02-13 12:21:50 +0000 | [diff] [blame] | 458 | StyleRuleContainer::StyleRuleContainer(FilteredContainerQuery&& query, Vector<RefPtr<StyleRuleBase>>&& rules) |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 459 | : StyleRuleGroup(StyleRuleType::Container, WTFMove(rules)) |
antti@apple.com | 3e729cb | 2022-02-13 12:21:50 +0000 | [diff] [blame] | 460 | , m_filteredQuery(WTFMove(query)) |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 461 | { |
| 462 | } |
| 463 | |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 464 | StyleRuleContainer::StyleRuleContainer(const StyleRuleContainer& other) |
| 465 | : StyleRuleGroup(other) |
antti@apple.com | 3e729cb | 2022-02-13 12:21:50 +0000 | [diff] [blame] | 466 | , m_filteredQuery(other.m_filteredQuery) |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 467 | { |
| 468 | } |
| 469 | |
antti@apple.com | 3e729cb | 2022-02-13 12:21:50 +0000 | [diff] [blame] | 470 | Ref<StyleRuleContainer> StyleRuleContainer::create(FilteredContainerQuery&& query, Vector<RefPtr<StyleRuleBase>>&& rules) |
antti@apple.com | 2ef5bc0 | 2021-12-10 13:28:28 +0000 | [diff] [blame] | 471 | { |
| 472 | return adoptRef(*new StyleRuleContainer(WTFMove(query), WTFMove(rules))); |
| 473 | } |
| 474 | |
hyatt@apple.com | b048c56 | 2016-09-11 18:11:42 +0000 | [diff] [blame] | 475 | StyleRuleCharset::StyleRuleCharset() |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 476 | : StyleRuleBase(StyleRuleType::Charset) |
hyatt@apple.com | b048c56 | 2016-09-11 18:11:42 +0000 | [diff] [blame] | 477 | { |
| 478 | } |
| 479 | |
| 480 | StyleRuleCharset::StyleRuleCharset(const StyleRuleCharset& o) |
| 481 | : StyleRuleBase(o) |
| 482 | { |
| 483 | } |
| 484 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 485 | StyleRuleNamespace::StyleRuleNamespace(const AtomString& prefix, const AtomString& uri) |
simon.fraser@apple.com | 7aa56734 | 2019-10-28 16:02:53 +0000 | [diff] [blame] | 486 | : StyleRuleBase(StyleRuleType::Namespace) |
hyatt@apple.com | b048c56 | 2016-09-11 18:11:42 +0000 | [diff] [blame] | 487 | , m_prefix(prefix) |
| 488 | , m_uri(uri) |
| 489 | { |
| 490 | } |
| 491 | |
| 492 | StyleRuleNamespace::StyleRuleNamespace(const StyleRuleNamespace& o) |
| 493 | : StyleRuleBase(o) |
| 494 | , m_prefix(o.m_prefix) |
| 495 | , m_uri(o.m_uri) |
| 496 | { |
| 497 | } |
| 498 | |
dbates@webkit.org | f21f3ae | 2017-10-19 23:48:45 +0000 | [diff] [blame] | 499 | StyleRuleNamespace::~StyleRuleNamespace() = default; |
hyatt@apple.com | b048c56 | 2016-09-11 18:11:42 +0000 | [diff] [blame] | 500 | |
darin@apple.com | 637194d | 2020-09-25 17:19:48 +0000 | [diff] [blame] | 501 | Ref<StyleRuleNamespace> StyleRuleNamespace::create(const AtomString& prefix, const AtomString& uri) |
| 502 | { |
| 503 | return adoptRef(*new StyleRuleNamespace(prefix, uri)); |
| 504 | } |
| 505 | |
antti@apple.com | 8be9b56 | 2012-02-28 17:44:18 +0000 | [diff] [blame] | 506 | } // namespace WebCore |