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

Side by Side Diff: Source/core/css/RuntimeCSSEnabled.cpp

Issue 290793004: Use a BitArray in RuntimeCSSEnabled instead of a Vector<bool> (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Fix bug in clear() Created 6 years, 7 months 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | Source/wtf/BitArray.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 * 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
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/BitArray.h"
34 35
35 namespace WebCore { 36 namespace WebCore {
36 37
37 // FIXME: We should use a real BitVector class instead! 38 typedef BitArray<numCSSProperties> CSSPropertySwitches;
38 typedef Vector<bool> BoolVector;
39 39
40 static void setCSSPropertiesEnabled(CSSPropertyID* properties, size_t length, bo ol featureFlag) 40 static void setCSSPropertiesEnabled(CSSPropertyID* properties, size_t length, bo ol featureFlag)
41 { 41 {
42 for (size_t i = 0; i < length; i++) 42 for (size_t i = 0; i < length; i++)
43 RuntimeCSSEnabled::setCSSPropertyEnabled(properties[i], featureFlag); 43 RuntimeCSSEnabled::setCSSPropertyEnabled(properties[i], featureFlag);
44 } 44 }
45 45
46 static void setPropertySwitchesFromRuntimeFeatures() 46 static void setPropertySwitchesFromRuntimeFeatures()
47 { 47 {
48 CSSPropertyID exclusionProperties[] = { 48 CSSPropertyID exclusionProperties[] = {
(...skipping 74 matching lines...) Expand 10 before | Expand all | Expand 10 after
123 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyPaintOrder, RuntimeEnabl edFeatures::svgPaintOrderEnabled()); 123 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyPaintOrder, RuntimeEnabl edFeatures::svgPaintOrderEnabled());
124 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMaskSourceType, RuntimeE nabledFeatures::cssMaskSourceTypeEnabled()); 124 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyMaskSourceType, RuntimeE nabledFeatures::cssMaskSourceTypeEnabled());
125 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyColumnFill, RuntimeEnabl edFeatures::regionBasedColumnsEnabled()); 125 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyColumnFill, RuntimeEnabl edFeatures::regionBasedColumnsEnabled());
126 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyScrollBehavior, RuntimeE nabledFeatures::cssomSmoothScrollEnabled()); 126 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyScrollBehavior, RuntimeE nabledFeatures::cssomSmoothScrollEnabled());
127 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyWillChange, RuntimeEnabl edFeatures::cssWillChangeEnabled()); 127 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyWillChange, RuntimeEnabl edFeatures::cssWillChangeEnabled());
128 128
129 // InternalCallback is an implementation detail, rather than an experimental feature, and should never be exposed to the web. 129 // InternalCallback is an implementation detail, rather than an experimental feature, and should never be exposed to the web.
130 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyInternalCallback, false) ; 130 RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyInternalCallback, false) ;
131 } 131 }
132 132
133 static BoolVector& propertySwitches() 133 static CSSPropertySwitches& propertySwitches()
134 { 134 {
135 static BoolVector* switches = 0; 135 static CSSPropertySwitches* switches = 0;
136 if (!switches) { 136 if (!switches) {
137 switches = new BoolVector; 137 switches = new CSSPropertySwitches(true); // All bits sets to 1.
138 switches->fill(true, numCSSProperties);
139 setPropertySwitchesFromRuntimeFeatures(); 138 setPropertySwitchesFromRuntimeFeatures();
140 } 139 }
141 return *switches; 140 return *switches;
142 } 141 }
143 142
144 size_t indexForProperty(CSSPropertyID propertyId) 143 size_t indexForProperty(CSSPropertyID propertyId)
145 { 144 {
146 RELEASE_ASSERT(propertyId >= firstCSSProperty && propertyId <= lastCSSProper ty); 145 RELEASE_ASSERT(propertyId >= firstCSSProperty && propertyId <= lastCSSProper ty);
147 // Values all start at 0. Vector RELEASE_ASSERTS will catch if we're ever wr ong. 146 // Values all start at 0. BitArray ASSERTS will catch if we're ever wrong.
148 return static_cast<size_t>(propertyId - firstCSSProperty); 147 return static_cast<size_t>(propertyId - firstCSSProperty);
149 } 148 }
150 149
151 bool RuntimeCSSEnabled::isCSSPropertyEnabled(CSSPropertyID propertyId) 150 bool RuntimeCSSEnabled::isCSSPropertyEnabled(CSSPropertyID propertyId)
152 { 151 {
153 // Internal properties shouldn't be exposed to the web 152 // Internal properties shouldn't be exposed to the web
154 // so they are considered to be always disabled. 153 // so they are considered to be always disabled.
155 if (isInternalProperty(propertyId)) 154 if (isInternalProperty(propertyId))
156 return false; 155 return false;
157 156
158 return propertySwitches()[indexForProperty(propertyId)]; 157 return propertySwitches().get(indexForProperty(propertyId));
159 } 158 }
160 159
161 void RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyID propertyId, bool ena ble) 160 void RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyID propertyId, bool ena ble)
162 { 161 {
163 propertySwitches()[indexForProperty(propertyId)] = enable; 162 size_t propertyIndex = indexForProperty(propertyId);
163 if (enable)
164 propertySwitches().set(propertyIndex);
165 else
166 propertySwitches().clear(propertyIndex);
164 } 167 }
165 168
166 void RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID * properties, size_t propertyCount, Vector<CSSPropertyID>& outVector) 169 void RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID * properties, size_t propertyCount, Vector<CSSPropertyID>& outVector)
167 { 170 {
168 for (unsigned i = 0; i < propertyCount; i++) { 171 for (unsigned i = 0; i < propertyCount; i++) {
169 CSSPropertyID property = properties[i]; 172 CSSPropertyID property = properties[i];
170 if (RuntimeCSSEnabled::isCSSPropertyEnabled(property)) 173 if (RuntimeCSSEnabled::isCSSPropertyEnabled(property))
171 outVector.append(property); 174 outVector.append(property);
172 } 175 }
173 } 176 }
174 177
175 } // namespace WebCore 178 } // namespace WebCore
OLDNEW
« no previous file with comments | « no previous file | Source/wtf/BitArray.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698