Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(148)

Side by Side Diff: sky/engine/core/css/StyleRule.cpp

Issue 758573005: Remove CSSOM mutability in StyleRule. (Closed) Base URL: git@github.com:domokit/mojo.git@master
Patch Set: Created 6 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « sky/engine/core/css/StyleRule.h ('k') | sky/engine/core/css/StyleRuleKeyframes.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 *
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
55 delete toStyleRuleFilter(this); 55 delete toStyleRuleFilter(this);
56 return; 56 return;
57 case Unknown: 57 case Unknown:
58 case Keyframe: 58 case Keyframe:
59 ASSERT_NOT_REACHED(); 59 ASSERT_NOT_REACHED();
60 return; 60 return;
61 } 61 }
62 ASSERT_NOT_REACHED(); 62 ASSERT_NOT_REACHED();
63 } 63 }
64 64
65 PassRefPtr<StyleRuleBase> StyleRuleBase::copy() const
66 {
67 switch (type()) {
68 case Style:
69 return toStyleRule(this)->copy();
70 case FontFace:
71 return toStyleRuleFontFace(this)->copy();
72 case Media:
73 return toStyleRuleMedia(this)->copy();
74 case Supports:
75 return toStyleRuleSupports(this)->copy();
76 case Keyframes:
77 return toStyleRuleKeyframes(this)->copy();
78 case Filter:
79 return toStyleRuleFilter(this)->copy();
80 case Unknown:
81 case Keyframe:
82 ASSERT_NOT_REACHED();
83 return nullptr;
84 }
85 ASSERT_NOT_REACHED();
86 return nullptr;
87 }
88
89 unsigned StyleRule::averageSizeInBytes() 65 unsigned StyleRule::averageSizeInBytes()
90 { 66 {
91 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi zeInBytes(); 67 return sizeof(StyleRule) + sizeof(CSSSelector) + StylePropertySet::averageSi zeInBytes();
92 } 68 }
93 69
94 StyleRule::StyleRule() 70 StyleRule::StyleRule()
95 : StyleRuleBase(Style) 71 : StyleRuleBase(Style)
96 { 72 {
97 } 73 }
98 74
99 StyleRule::StyleRule(const StyleRule& o)
100 : StyleRuleBase(o)
101 , m_properties(o.m_properties->mutableCopy())
102 , m_selectorList(o.m_selectorList)
103 {
104 }
105
106 StyleRule::~StyleRule() 75 StyleRule::~StyleRule()
107 { 76 {
108 } 77 }
109 78
110 MutableStylePropertySet& StyleRule::mutableProperties()
111 {
112 if (!m_properties->isMutable())
113 m_properties = m_properties->mutableCopy();
114 return *toMutableStylePropertySet(m_properties.get());
115 }
116
117 void StyleRule::setProperties(PassRefPtr<StylePropertySet> properties) 79 void StyleRule::setProperties(PassRefPtr<StylePropertySet> properties)
118 { 80 {
119 m_properties = properties; 81 m_properties = properties;
120 } 82 }
121 83
122 StyleRuleFontFace::StyleRuleFontFace() 84 StyleRuleFontFace::StyleRuleFontFace()
123 : StyleRuleBase(FontFace) 85 : StyleRuleBase(FontFace)
124 { 86 {
125 } 87 }
126 88
127 StyleRuleFontFace::StyleRuleFontFace(const StyleRuleFontFace& o)
128 : StyleRuleBase(o)
129 , m_properties(o.m_properties->mutableCopy())
130 {
131 }
132
133 StyleRuleFontFace::~StyleRuleFontFace() 89 StyleRuleFontFace::~StyleRuleFontFace()
134 { 90 {
135 } 91 }
136 92
137 MutableStylePropertySet& StyleRuleFontFace::mutableProperties()
138 {
139 if (!m_properties->isMutable())
140 m_properties = m_properties->mutableCopy();
141 return *toMutableStylePropertySet(m_properties);
142 }
143
144 void StyleRuleFontFace::setProperties(PassRefPtr<StylePropertySet> properties) 93 void StyleRuleFontFace::setProperties(PassRefPtr<StylePropertySet> properties)
145 { 94 {
146 m_properties = properties; 95 m_properties = properties;
147 } 96 }
148 97
149 StyleRuleGroup::StyleRuleGroup(Type type, Vector<RefPtr<StyleRuleBase> >& adoptR ule) 98 StyleRuleGroup::StyleRuleGroup(Type type, Vector<RefPtr<StyleRuleBase> >& adoptR ule)
150 : StyleRuleBase(type) 99 : StyleRuleBase(type)
151 { 100 {
152 m_childRules.swap(adoptRule); 101 m_childRules.swap(adoptRule);
153 } 102 }
154 103
155 StyleRuleGroup::StyleRuleGroup(const StyleRuleGroup& o)
156 : StyleRuleBase(o)
157 , m_childRules(o.m_childRules.size())
158 {
159 for (unsigned i = 0; i < m_childRules.size(); ++i)
160 m_childRules[i] = o.m_childRules[i]->copy();
161 }
162
163 void StyleRuleGroup::wrapperInsertRule(unsigned index, PassRefPtr<StyleRuleBase> rule)
164 {
165 m_childRules.insert(index, rule);
166 }
167
168 void StyleRuleGroup::wrapperRemoveRule(unsigned index)
169 {
170 m_childRules.remove(index);
171 }
172
173 StyleRuleMedia::StyleRuleMedia(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<St yleRuleBase> >& adoptRules) 104 StyleRuleMedia::StyleRuleMedia(PassRefPtr<MediaQuerySet> media, Vector<RefPtr<St yleRuleBase> >& adoptRules)
174 : StyleRuleGroup(Media, adoptRules) 105 : StyleRuleGroup(Media, adoptRules)
175 , m_mediaQueries(media) 106 , m_mediaQueries(media)
176 { 107 {
177 } 108 }
178 109
179 StyleRuleMedia::StyleRuleMedia(const StyleRuleMedia& o)
180 : StyleRuleGroup(o)
181 {
182 if (o.m_mediaQueries)
183 m_mediaQueries = o.m_mediaQueries->copy();
184 }
185
186 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition IsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules) 110 StyleRuleSupports::StyleRuleSupports(const String& conditionText, bool condition IsSupported, Vector<RefPtr<StyleRuleBase> >& adoptRules)
187 : StyleRuleGroup(Supports, adoptRules) 111 : StyleRuleGroup(Supports, adoptRules)
188 , m_conditionText(conditionText) 112 , m_conditionText(conditionText)
189 , m_conditionIsSupported(conditionIsSupported) 113 , m_conditionIsSupported(conditionIsSupported)
190 { 114 {
191 } 115 }
192 116
193 StyleRuleSupports::StyleRuleSupports(const StyleRuleSupports& o)
194 : StyleRuleGroup(o)
195 , m_conditionText(o.m_conditionText)
196 , m_conditionIsSupported(o.m_conditionIsSupported)
197 {
198 }
199
200 StyleRuleFilter::StyleRuleFilter(const String& filterName) 117 StyleRuleFilter::StyleRuleFilter(const String& filterName)
201 : StyleRuleBase(Filter) 118 : StyleRuleBase(Filter)
202 , m_filterName(filterName) 119 , m_filterName(filterName)
203 { 120 {
204 } 121 }
205 122
206 StyleRuleFilter::StyleRuleFilter(const StyleRuleFilter& o)
207 : StyleRuleBase(o)
208 , m_filterName(o.m_filterName)
209 , m_properties(o.m_properties->mutableCopy())
210 {
211 }
212
213 StyleRuleFilter::~StyleRuleFilter() 123 StyleRuleFilter::~StyleRuleFilter()
214 { 124 {
215 } 125 }
216 126
217 MutableStylePropertySet& StyleRuleFilter::mutableProperties()
218 {
219 if (!m_properties->isMutable())
220 m_properties = m_properties->mutableCopy();
221 return *toMutableStylePropertySet(m_properties);
222 }
223
224 void StyleRuleFilter::setProperties(PassRefPtr<StylePropertySet> properties) 127 void StyleRuleFilter::setProperties(PassRefPtr<StylePropertySet> properties)
225 { 128 {
226 m_properties = properties; 129 m_properties = properties;
227 } 130 }
228 131
229 } // namespace blink 132 } // namespace blink
OLDNEW
« no previous file with comments | « sky/engine/core/css/StyleRule.h ('k') | sky/engine/core/css/StyleRuleKeyframes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698