OLD | NEW |
---|---|
1 /* | 1 /* |
2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. | 2 * Copyright (C) 2013 Adobe Systems Incorporated. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
6 * are met: | 6 * are met: |
7 * | 7 * |
8 * 1. Redistributions of source code must retain the above | 8 * 1. Redistributions of source code must retain the above |
9 * copyright notice, this list of conditions and the following | 9 * copyright notice, this list of conditions and the following |
10 * disclaimer. | 10 * disclaimer. |
(...skipping 13 matching lines...) Expand all Loading... | |
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, | 24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, |
25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) | 25 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) |
26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED | 26 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED |
27 * OF THE POSSIBILITY OF SUCH DAMAGE. | 27 * OF THE POSSIBILITY OF SUCH DAMAGE. |
28 */ | 28 */ |
29 | 29 |
30 #include "config.h" | 30 #include "config.h" |
31 #include "core/css/RuntimeCSSEnabled.h" | 31 #include "core/css/RuntimeCSSEnabled.h" |
32 | 32 |
33 #include "RuntimeEnabledFeatures.h" | 33 #include "RuntimeEnabledFeatures.h" |
34 #include "wtf/BitVector.h" | |
34 | 35 |
35 namespace WebCore { | 36 namespace WebCore { |
36 | 37 |
37 // FIXME: We should use a real BitVector class instead! | |
38 typedef Vector<bool> BoolVector; | |
39 | |
40 static void setCSSPropertiesEnabled(CSSPropertyID* properties, size_t length, bo ol featureFlag) | 38 static void setCSSPropertiesEnabled(CSSPropertyID* properties, size_t length, bo ol featureFlag) |
41 { | 39 { |
42 for (size_t i = 0; i < length; i++) | 40 for (size_t i = 0; i < length; i++) |
43 RuntimeCSSEnabled::setCSSPropertyEnabled(properties[i], featureFlag); | 41 RuntimeCSSEnabled::setCSSPropertyEnabled(properties[i], featureFlag); |
44 } | 42 } |
45 | 43 |
46 static void setPropertySwitchesFromRuntimeFeatures() | 44 static void setPropertySwitchesFromRuntimeFeatures() |
47 { | 45 { |
48 CSSPropertyID exclusionProperties[] = { | 46 CSSPropertyID exclusionProperties[] = { |
49 CSSPropertyWebkitWrapFlow, | 47 CSSPropertyWebkitWrapFlow, |
(...skipping 73 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
123 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyPaintOrder, RuntimeEnabl edFeatures::svgPaintOrderEnabled()); | 121 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyPaintOrder, RuntimeEnabl edFeatures::svgPaintOrderEnabled()); |
124 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMaskSourceType, RuntimeE nabledFeatures::cssMaskSourceTypeEnabled()); | 122 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMaskSourceType, RuntimeE nabledFeatures::cssMaskSourceTypeEnabled()); |
125 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyColumnFill, RuntimeEnabl edFeatures::regionBasedColumnsEnabled()); | 123 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyColumnFill, RuntimeEnabl edFeatures::regionBasedColumnsEnabled()); |
126 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyScrollBehavior, RuntimeE nabledFeatures::cssomSmoothScrollEnabled()); | 124 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyScrollBehavior, RuntimeE nabledFeatures::cssomSmoothScrollEnabled()); |
127 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyWillChange, RuntimeEnabl edFeatures::cssWillChangeEnabled()); | 125 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyWillChange, RuntimeEnabl edFeatures::cssWillChangeEnabled()); |
128 | 126 |
129 // InternalCallback is an implementation detail, rather than an experimental feature, and should never be exposed to the web. | 127 // InternalCallback is an implementation detail, rather than an experimental feature, and should never be exposed to the web. |
130 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyInternalCallback, false) ; | 128 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyInternalCallback, false) ; |
131 } | 129 } |
132 | 130 |
133 static BoolVector& propertySwitches() | 131 static BitVector& propertySwitches() |
134 { | 132 { |
135 static BoolVector* switches = 0; | 133 static BitVector* switches = 0; |
dstockwell
2014/05/21 00:45:41
A BitArray might be more appropriate.
Inactive
2014/05/21 01:04:49
Ah, I didn't know we had one. This is more suitabl
| |
136 if (!switches) { | 134 if (!switches) { |
137 switches = new BoolVector; | 135 switches = new BitVector(numCSSProperties); |
138 switches->fill(true, numCSSProperties); | 136 switches->setAll(); |
139 setPropertySwitchesFromRuntimeFeatures(); | 137 setPropertySwitchesFromRuntimeFeatures(); |
140 } | 138 } |
141 return *switches; | 139 return *switches; |
142 } | 140 } |
143 | 141 |
144 size_t indexForProperty(CSSPropertyID propertyId) | 142 size_t indexForProperty(CSSPropertyID propertyId) |
145 { | 143 { |
146 RELEASE_ASSERT(propertyId >= firstCSSProperty && propertyId <= lastCSSProper ty); | 144 RELEASE_ASSERT(propertyId >= firstCSSProperty && propertyId <= lastCSSProper ty); |
147 // Values all start at 0. Vector RELEASE_ASSERTS will catch if we're ever wr ong. | 145 // Values all start at 0. Vector RELEASE_ASSERTS will catch if we're ever wr ong. |
dstockwell
2014/05/21 00:45:41
This is no longer true, shouldn't be necessary tho
| |
148 return static_cast<size_t>(propertyId - firstCSSProperty); | 146 return static_cast<size_t>(propertyId - firstCSSProperty); |
149 } | 147 } |
150 | 148 |
151 bool RuntimeCSSEnabled::isCSSPropertyEnabled(CSSPropertyID propertyId) | 149 bool RuntimeCSSEnabled::isCSSPropertyEnabled(CSSPropertyID propertyId) |
152 { | 150 { |
153 // Internal properties shouldn't be exposed to the web | 151 // Internal properties shouldn't be exposed to the web |
154 // so they are considered to be always disabled. | 152 // so they are considered to be always disabled. |
155 if (isInternalProperty(propertyId)) | 153 if (isInternalProperty(propertyId)) |
156 return false; | 154 return false; |
157 | 155 |
158 return propertySwitches()[indexForProperty(propertyId)]; | 156 return propertySwitches().quickGet(indexForProperty(propertyId)); |
159 } | 157 } |
160 | 158 |
161 void RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyID propertyId, bool ena ble) | 159 void RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyID propertyId, bool ena ble) |
162 { | 160 { |
163 propertySwitches()[indexForProperty(propertyId)] = enable; | 161 propertySwitches().quickSet(indexForProperty(propertyId), enable); |
164 } | 162 } |
165 | 163 |
166 void RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID * properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) | 164 void RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID * properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) |
167 { | 165 { |
168 for (unsigned i = 0; i < propertyCount; i++) { | 166 for (unsigned i = 0; i < propertyCount; i++) { |
169 CSSPropertyID property = properties[i]; | 167 CSSPropertyID property = properties[i]; |
170 if (RuntimeCSSEnabled::isCSSPropertyEnabled(property)) | 168 if (RuntimeCSSEnabled::isCSSPropertyEnabled(property)) |
171 outVector.append(property); | 169 outVector.append(property); |
172 } | 170 } |
173 } | 171 } |
174 | 172 |
175 } // namespace WebCore | 173 } // namespace WebCore |
OLD | NEW |