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

Unified Diff: Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp

Issue 98793002: Get rid of extra NULL check when indexing CSSStyleDeclaration (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 7 years 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 | no next file » | 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 274b2a810117baef802acacdf74132f9294b11d6..914dd3408e9eb0b0902a170b7fdbe96396b816bb 100644
--- a/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
+++ b/Source/bindings/v8/custom/V8CSSStyleDeclarationCustom.cpp
@@ -86,6 +86,14 @@ struct CSSPropertyInfo {
unsigned nameWithCssPrefix: 1;
};
+static inline void countCssPropertyInfoUsage(const CSSPropertyInfo& propInfo)
+{
+ if (propInfo.nameWithDash)
+ UseCounter::count(activeDOMWindow(), UseCounter::CSSStyleDeclarationPropertyName);
+ if (propInfo.propID == CSSPropertyFloat && !propInfo.nameWithCssPrefix)
+ UseCounter::count(activeDOMWindow(), UseCounter::CSSStyleDeclarationFloatPropertyName);
+}
+
// When getting properties on CSSStyleDeclarations, the name used from
// Javascript and the actual name of the property are not the same, so
// we have to do the following translation. The translation turns upper
@@ -147,14 +155,6 @@ static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String> v8PropertyName)
map.add(propertyName, propInfo);
}
}
-
- if (propInfo) {
- if (propInfo->nameWithDash)
- UseCounter::count(activeDOMWindow(), UseCounter::CSSStyleDeclarationPropertyName);
- if (propInfo->propID == CSSPropertyFloat && !propInfo->nameWithCssPrefix)
- UseCounter::count(activeDOMWindow(), UseCounter::CSSStyleDeclarationFloatPropertyName);
- }
-
return propInfo;
}
@@ -188,7 +188,8 @@ void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::String> v8Nam
{
// NOTE: cssPropertyInfo lookups incur several mallocs.
// Successful lookups have the same cost the first time, but are cached.
- if (cssPropertyInfo(v8Name)) {
+ if (CSSPropertyInfo* propInfo = cssPropertyInfo(v8Name)) {
+ countCssPropertyInfoUsage(*propInfo);
v8SetReturnValueInt(info, 0);
return;
}
@@ -207,6 +208,7 @@ void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::String> name
if (!propInfo)
return;
+ countCssPropertyInfoUsage(*propInfo);
CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSSPropertyID>(propInfo->propID));
if (cssValue) {
@@ -228,6 +230,7 @@ void V8CSSStyleDeclaration::namedPropertySetterCustom(v8::Local<v8::String> name
if (!propInfo)
return;
+ countCssPropertyInfoUsage(*propInfo);
V8TRYCATCH_FOR_V8STRINGRESOURCE_VOID(V8StringResource<WithNullCheck>, propertyValue, value);
ExceptionState exceptionState(info.Holder(), info.GetIsolate());
imp->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), propertyValue, false, exceptionState);
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698