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

Unified Diff: Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.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 | « no previous file | Source/core/core.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
diff --git a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
index da11a3dce800d8376adf3a0cc9c628cbdba4a767..74ccf4f095a32570cc03a47e3b879f0b6873a55b 100644
--- a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
@@ -37,6 +37,7 @@
#include "core/css/CSSStyleDeclaration.h"
#include "core/css/CSSValue.h"
#include "core/dom/EventTarget.h"
+#include "core/page/RuntimeCSSEnabled.h"
#include "bindings/v8/V8Binding.h"
@@ -99,7 +100,7 @@ public:
// Also, certain prefixes such as 'pos', 'css-' and 'pixel-' are stripped
// and the hadPixelOrPosPrefix out parameter is used to indicate whether or
// not the property name was prefixed with 'pos-' or 'pixel-'.
-static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName)
+static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String> v8PropertyName)
{
String propertyName = toWebCoreString(v8PropertyName);
typedef HashMap<String, CSSPropertyInfo*> CSSPropertyInfoMap;
@@ -141,7 +142,7 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String>v8PropertyName)
String propName = builder.toString();
CSSPropertyID propertyID = cssPropertyID(propName);
- if (propertyID) {
+ if (propertyID && RuntimeCSSEnabled::isCSSPropertyEnabled(propertyID)) {
propInfo = new CSSPropertyInfo();
propInfo->hadPixelOrPosPrefix = hadPixelOrPosPrefix;
propInfo->propID = propertyID;
@@ -158,8 +159,11 @@ v8::Handle<v8::Array> V8CSSStyleDeclaration::namedPropertyEnumerator(const v8::A
static unsigned propertyNamesLength = 0;
if (propertyNames.isEmpty()) {
- for (int id = firstCSSProperty; id < firstCSSProperty + numCSSProperties; ++id)
- propertyNames.append(getJSPropertyName(static_cast<CSSPropertyID>(id)));
+ for (int id = firstCSSProperty; id <= lastCSSProperty; ++id) {
+ CSSPropertyID propertyId = static_cast<CSSPropertyID>(id);
+ if (RuntimeCSSEnabled::isCSSPropertyEnabled(propertyId))
+ propertyNames.append(getJSPropertyName(propertyId));
+ }
sort(propertyNames.begin(), propertyNames.end(), codePointCompareLessThan);
propertyNamesLength = propertyNames.size();
}
@@ -176,6 +180,8 @@ v8::Handle<v8::Array> V8CSSStyleDeclaration::namedPropertyEnumerator(const v8::A
v8::Handle<v8::Integer> V8CSSStyleDeclaration::namedPropertyQuery(v8::Local<v8::String> v8Name, const v8::AccessorInfo& info)
{
+ // NOTE: cssPropertyInfo lookups incur several mallocs.
+ // Successful lookups have the same cost the first time, but are cached.
if (cssPropertyInfo(v8Name))
return v8Integer(0, info.GetIsolate());
« no previous file with comments | « no previous file | Source/core/core.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698