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

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/custom/V8CSSStyleDeclarationCustom.cpp

Issue 1993593003: binding: Check the type of property names in FooCallback instead of Foo. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 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 unified diff | Download patch
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLPlugInElementCustom.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2007-2011 Google Inc. All rights reserved. 2 * Copyright (C) 2007-2011 Google Inc. All rights reserved.
3 * 3 *
4 * Redistribution and use in source and binary forms, with or without 4 * Redistribution and use in source and binary forms, with or without
5 * modification, are permitted provided that the following conditions are 5 * modification, are permitted provided that the following conditions are
6 * met: 6 * met:
7 * 7 *
8 * * Redistributions of source code must retain the above copyright 8 * * Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer. 9 * notice, this list of conditions and the following disclaimer.
10 * * Redistributions in binary form must reproduce the above 10 * * Redistributions in binary form must reproduce the above
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
168 ASSERT(!key.isNull()); 168 ASSERT(!key.isNull());
169 if (!v8CallBoolean(properties->CreateDataProperty(context, i, v8String(i nfo.GetIsolate(), key)))) 169 if (!v8CallBoolean(properties->CreateDataProperty(context, i, v8String(i nfo.GetIsolate(), key))))
170 return; 170 return;
171 } 171 }
172 172
173 v8SetReturnValue(info, properties); 173 v8SetReturnValue(info, properties);
174 } 174 }
175 175
176 void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::Name> v8Name, const v8::PropertyCallbackInfo<v8::Integer>& info) 176 void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::Name> v8Name, const v8::PropertyCallbackInfo<v8::Integer>& info)
177 { 177 {
178 if (!v8Name->IsString())
179 return;
180 // NOTE: cssPropertyInfo lookups incur several mallocs. 178 // NOTE: cssPropertyInfo lookups incur several mallocs.
181 // Successful lookups have the same cost the first time, but are cached. 179 // Successful lookups have the same cost the first time, but are cached.
182 if (cssPropertyInfo(v8Name.As<v8::String>())) { 180 if (cssPropertyInfo(v8Name.As<v8::String>())) {
183 v8SetReturnValueInt(info, 0); 181 v8SetReturnValueInt(info, 0);
184 return; 182 return;
185 } 183 }
186 } 184 }
187 185
188 void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info) 186 void V8CSSStyleDeclaration::namedPropertyGetterCustom(v8::Local<v8::Name> name, const v8::PropertyCallbackInfo<v8::Value>& info)
189 { 187 {
190 if (!name->IsString())
191 return;
192
193 // Search the style declaration. 188 // Search the style declaration.
194 CSSPropertyID unresolvedProperty = cssPropertyInfo(name.As<v8::String>()); 189 CSSPropertyID unresolvedProperty = cssPropertyInfo(name.As<v8::String>());
195 190
196 // Do not handle non-property names. 191 // Do not handle non-property names.
197 if (!unresolvedProperty) 192 if (!unresolvedProperty)
198 return; 193 return;
199 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty); 194 CSSPropertyID resolvedProperty = resolveCSSPropertyID(unresolvedProperty);
200 195
201 CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder()); 196 CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder());
202 // TODO(leviw): This API doesn't support custom properties. 197 // TODO(leviw): This API doesn't support custom properties.
203 CSSValue* cssValue = impl->getPropertyCSSValueInternal(resolvedProperty); 198 CSSValue* cssValue = impl->getPropertyCSSValueInternal(resolvedProperty);
204 if (cssValue) { 199 if (cssValue) {
205 v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate( )); 200 v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate( ));
206 return; 201 return;
207 } 202 }
208 203
209 String result = impl->getPropertyValueInternal(resolvedProperty); 204 String result = impl->getPropertyValueInternal(resolvedProperty);
210 v8SetReturnValueString(info, result, info.GetIsolate()); 205 v8SetReturnValueString(info, result, info.GetIsolate());
211 } 206 }
212 207
213 void V8CSSStyleDeclaration::namedPropertySetterCustom(v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info) 208 void V8CSSStyleDeclaration::namedPropertySetterCustom(v8::Local<v8::Name> name, v8::Local<v8::Value> value, const v8::PropertyCallbackInfo<v8::Value>& info)
214 { 209 {
215 if (!name->IsString())
216 return;
217 CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder()); 210 CSSStyleDeclaration* impl = V8CSSStyleDeclaration::toImpl(info.Holder());
218 CSSPropertyID unresolvedProperty = cssPropertyInfo(name.As<v8::String>()); 211 CSSPropertyID unresolvedProperty = cssPropertyInfo(name.As<v8::String>());
219 if (!unresolvedProperty) 212 if (!unresolvedProperty)
220 return; 213 return;
221 214
222 TOSTRING_VOID(V8StringResource<TreatNullAsNullString>, propertyValue, value) ; 215 TOSTRING_VOID(V8StringResource<TreatNullAsNullString>, propertyValue, value) ;
223 ExceptionState exceptionState(ExceptionState::SetterContext, getPropertyName (resolveCSSPropertyID(unresolvedProperty)), "CSSStyleDeclaration", info.Holder() , info.GetIsolate()); 216 ExceptionState exceptionState(ExceptionState::SetterContext, getPropertyName (resolveCSSPropertyID(unresolvedProperty)), "CSSStyleDeclaration", info.Holder() , info.GetIsolate());
224 // TODO(leviw): This API doesn't support custom properties. 217 // TODO(leviw): This API doesn't support custom properties.
225 impl->setPropertyInternal(unresolvedProperty, String(), propertyValue, false , exceptionState); 218 impl->setPropertyInternal(unresolvedProperty, String(), propertyValue, false , exceptionState);
226 219
227 if (exceptionState.throwIfNeeded()) 220 if (exceptionState.throwIfNeeded())
228 return; 221 return;
229 222
230 v8SetReturnValue(info, value); 223 v8SetReturnValue(info, value);
231 } 224 }
232 225
233 } // namespace blink 226 } // namespace blink
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/Source/bindings/core/v8/custom/V8HTMLPlugInElementCustom.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698