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

Unified Diff: Source/core/css/StylePropertySet.cpp

Issue 14324009: Add support for disabling CSS Properties at runtime (Closed) Base URL: http://src.chromium.org/blink/trunk/Source/
Patch Set: Runtime guard more uses of CSSPropertyID, per Elliot's request. Created 7 years, 8 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 | « Source/core/css/StylePropertySet.h ('k') | Source/core/editing/EditingStyle.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/css/StylePropertySet.cpp
diff --git a/Source/core/css/StylePropertySet.cpp b/Source/core/css/StylePropertySet.cpp
index bbaa452346644a69d18ea2eb9a67ac819d8f36cc..7834472d7cc7b89ad25356f5a99ce00c3f02be2c 100644
--- a/Source/core/css/StylePropertySet.cpp
+++ b/Source/core/css/StylePropertySet.cpp
@@ -22,6 +22,7 @@
#include "config.h"
#include "StylePropertySet.h"
+#include "core/page/RuntimeCSSEnabled.h"
#include "CSSParser.h"
#include "CSSValueKeywords.h"
#include "CSSValueList.h"
@@ -1065,7 +1066,7 @@ bool StylePropertySet::hasFailedOrCanceledSubresources() const
// This is the list of properties we want to copy in the copyBlockProperties() function.
// It is the list of CSS properties that apply specially to block-level elements.
-static const CSSPropertyID blockProperties[] = {
+static const CSSPropertyID staticBlockProperties[] = {
CSSPropertyOrphans,
CSSPropertyOverflow, // This can be also be applied to replaced elements
CSSPropertyWebkitAspectRatio,
@@ -1094,22 +1095,28 @@ static const CSSPropertyID blockProperties[] = {
CSSPropertyWidows
};
+static const Vector<CSSPropertyID>& blockProperties()
+{
+ DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
+ if (properties.isEmpty())
+ RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticBlockProperties, WTF_ARRAY_LENGTH(staticBlockProperties), properties);
+ return properties;
+}
+
void StylePropertySet::clear()
{
ASSERT(isMutable());
mutablePropertyVector().clear();
}
-const unsigned numBlockProperties = WTF_ARRAY_LENGTH(blockProperties);
-
PassRefPtr<StylePropertySet> StylePropertySet::copyBlockProperties() const
{
- return copyPropertiesInSet(blockProperties, numBlockProperties);
+ return copyPropertiesInSet(blockProperties());
}
void StylePropertySet::removeBlockProperties()
{
- removePropertiesInSet(blockProperties, numBlockProperties);
+ removePropertiesInSet(blockProperties().data(), blockProperties().size());
}
bool StylePropertySet::removePropertiesInSet(const CSSPropertyID* set, unsigned length)
@@ -1203,14 +1210,14 @@ PassRefPtr<StylePropertySet> StylePropertySet::copy() const
return adoptRef(new MutableStylePropertySet(*this));
}
-PassRefPtr<StylePropertySet> StylePropertySet::copyPropertiesInSet(const CSSPropertyID* set, unsigned length) const
+PassRefPtr<StylePropertySet> StylePropertySet::copyPropertiesInSet(const Vector<CSSPropertyID>& properties) const
{
Vector<CSSProperty, 256> list;
- list.reserveInitialCapacity(length);
- for (unsigned i = 0; i < length; ++i) {
- RefPtr<CSSValue> value = getPropertyCSSValue(set[i]);
+ list.reserveInitialCapacity(properties.size());
+ for (unsigned i = 0; i < properties.size(); ++i) {
+ RefPtr<CSSValue> value = getPropertyCSSValue(properties[i]);
if (value)
- list.append(CSSProperty(set[i], value.release(), false));
+ list.append(CSSProperty(properties[i], value.release(), false));
}
return StylePropertySet::create(list.data(), list.size());
}
« no previous file with comments | « Source/core/css/StylePropertySet.h ('k') | Source/core/editing/EditingStyle.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698