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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | Source/wtf/BitArray.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/RuntimeCSSEnabled.cpp
diff --git a/Source/core/css/RuntimeCSSEnabled.cpp b/Source/core/css/RuntimeCSSEnabled.cpp
index 4fc13b0f4b207a90177a6ee6771fdb4c31f8f832..f7bb8f0ca18a5f33ff188f21f202fc45bd8f6801 100644
--- a/Source/core/css/RuntimeCSSEnabled.cpp
+++ b/Source/core/css/RuntimeCSSEnabled.cpp
@@ -31,11 +31,11 @@
#include "core/css/RuntimeCSSEnabled.h"
#include "RuntimeEnabledFeatures.h"
+#include "wtf/BitArray.h"
namespace WebCore {
-// FIXME: We should use a real BitVector class instead!
-typedef Vector<bool> BoolVector;
+typedef BitArray<numCSSProperties> CSSPropertySwitches;
static void setCSSPropertiesEnabled(CSSPropertyID* properties, size_t length, bool featureFlag)
{
@@ -130,12 +130,11 @@ static void setPropertySwitchesFromRuntimeFeatures()
RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyInternalCallback, false);
}
-static BoolVector& propertySwitches()
+static CSSPropertySwitches& propertySwitches()
{
- static BoolVector* switches = 0;
+ static CSSPropertySwitches* switches = 0;
if (!switches) {
- switches = new BoolVector;
- switches->fill(true, numCSSProperties);
+ switches = new CSSPropertySwitches(true); // All bits sets to 1.
setPropertySwitchesFromRuntimeFeatures();
}
return *switches;
@@ -144,7 +143,7 @@ static BoolVector& propertySwitches()
size_t indexForProperty(CSSPropertyID propertyId)
{
RELEASE_ASSERT(propertyId >= firstCSSProperty && propertyId <= lastCSSProperty);
- // Values all start at 0. Vector RELEASE_ASSERTS will catch if we're ever wrong.
+ // Values all start at 0. BitArray ASSERTS will catch if we're ever wrong.
return static_cast<size_t>(propertyId - firstCSSProperty);
}
@@ -155,12 +154,16 @@ bool RuntimeCSSEnabled::isCSSPropertyEnabled(CSSPropertyID propertyId)
if (isInternalProperty(propertyId))
return false;
- return propertySwitches()[indexForProperty(propertyId)];
+ return propertySwitches().get(indexForProperty(propertyId));
}
void RuntimeCSSEnabled::setCSSPropertyEnabled(CSSPropertyID propertyId, bool enable)
{
- propertySwitches()[indexForProperty(propertyId)] = enable;
+ size_t propertyIndex = indexForProperty(propertyId);
+ if (enable)
+ propertySwitches().set(propertyIndex);
+ else
+ propertySwitches().clear(propertyIndex);
}
void RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(const CSSPropertyID* properties, size_t propertyCount, Vector<CSSPropertyID>& outVector)
« 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