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

Unified Diff: Source/core/editing/EditingStyle.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.cpp ('k') | Source/core/page/RuntimeCSSEnabled.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/EditingStyle.cpp
diff --git a/Source/core/editing/EditingStyle.cpp b/Source/core/editing/EditingStyle.cpp
index d4b3e74a0e71de6f26253e636527e055f6eebc87..0c693bb7fb79b9e9f815a9c21d0ac085f8bcc548 100644
--- a/Source/core/editing/EditingStyle.cpp
+++ b/Source/core/editing/EditingStyle.cpp
@@ -50,6 +50,7 @@
#include "core/editing/VisibleUnits.h"
#include "core/editing/htmlediting.h"
#include "core/page/Frame.h"
+#include "core/page/RuntimeCSSEnabled.h"
#include "core/rendering/style/RenderStyle.h"
#include <wtf/HashSet.h>
@@ -57,7 +58,12 @@ namespace WebCore {
// Editing style properties must be preserved during editing operation.
// e.g. when a user inserts a new paragraph, all properties listed here must be copied to the new paragraph.
-static const CSSPropertyID editingProperties[] = {
+// NOTE: Use editingProperties() to respect runtime enabling of properties.
+static const unsigned nonInheritedStaticPropertiesCount = 2;
+
+static const CSSPropertyID staticEditingProperties[] = {
+ // NOTE: inheritableEditingProperties depends on these two properties being first.
+ // If you change this list, make sure to update nonInheritedPropertyCount.
CSSPropertyBackgroundColor,
CSSPropertyTextDecoration,
@@ -85,21 +91,33 @@ static const CSSPropertyID editingProperties[] = {
enum EditingPropertiesType { OnlyInheritableEditingProperties, AllEditingProperties };
+static const Vector<CSSPropertyID>& allEditingProperties()
+{
+ DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
+ if (properties.isEmpty())
+ RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingProperties, WTF_ARRAY_LENGTH(staticEditingProperties), properties);
+ return properties;
+}
+
+static const Vector<CSSPropertyID>& inheritableEditingProperties()
+{
+ DEFINE_STATIC_LOCAL(Vector<CSSPropertyID>, properties, ());
+ if (properties.isEmpty())
+ RuntimeCSSEnabled::filterEnabledCSSPropertiesIntoVector(staticEditingProperties + nonInheritedStaticPropertiesCount, WTF_ARRAY_LENGTH(staticEditingProperties) - nonInheritedStaticPropertiesCount, properties);
+ return properties;
+}
+
template <class StyleDeclarationType>
static PassRefPtr<StylePropertySet> copyEditingProperties(StyleDeclarationType* style, EditingPropertiesType type = OnlyInheritableEditingProperties)
{
if (type == AllEditingProperties)
- return style->copyPropertiesInSet(editingProperties, WTF_ARRAY_LENGTH(editingProperties));
- return style->copyPropertiesInSet(editingProperties + 2, WTF_ARRAY_LENGTH(editingProperties) - 2);
+ return style->copyPropertiesInSet(allEditingProperties());
+ return style->copyPropertiesInSet(inheritableEditingProperties());
}
static inline bool isEditingProperty(int id)
{
- for (size_t i = 0; i < WTF_ARRAY_LENGTH(editingProperties); ++i) {
- if (editingProperties[i] == id)
- return true;
- }
- return false;
+ return allEditingProperties().contains(static_cast<CSSPropertyID>(id));
}
static PassRefPtr<StylePropertySet> editingStyleFromComputedStyle(PassRefPtr<CSSComputedStyleDeclaration> style, EditingPropertiesType type = OnlyInheritableEditingProperties)
« no previous file with comments | « Source/core/css/StylePropertySet.cpp ('k') | Source/core/page/RuntimeCSSEnabled.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698