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

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

Issue 15690020: [binding] Check own property on named property accessor (Closed) Base URL: https://chromium.googlesource.com/chromium/blink@master
Patch Set: Created 7 years, 6 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
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 175 matching lines...) Expand 10 before | Expand all | Expand 10 after
186 // Successful lookups have the same cost the first time, but are cached. 186 // Successful lookups have the same cost the first time, but are cached.
187 if (cssPropertyInfo(v8Name)) 187 if (cssPropertyInfo(v8Name))
188 return v8Integer(0, info.GetIsolate()); 188 return v8Integer(0, info.GetIsolate());
189 189
190 return v8::Handle<v8::Integer>(); 190 return v8::Handle<v8::Integer>();
191 } 191 }
192 192
193 v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::S tring> name, const v8::AccessorInfo& info) 193 v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertyGetter(v8::Local<v8::S tring> name, const v8::AccessorInfo& info)
194 { 194 {
195 // First look for API defined attributes on the style declaration object. 195 // First look for API defined attributes on the style declaration object.
196 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
197 return v8Undefined();
196 if (info.Holder()->HasRealNamedCallbackProperty(name)) 198 if (info.Holder()->HasRealNamedCallbackProperty(name))
197 return v8Undefined(); 199 return v8Undefined();
200 if (info.Holder()->HasRealNamedProperty(name))
201 return v8Undefined();
198 202
199 // Search the style declaration. 203 // Search the style declaration.
200 CSSPropertyInfo* propInfo = cssPropertyInfo(name); 204 CSSPropertyInfo* propInfo = cssPropertyInfo(name);
201 205
202 // Do not handle non-property names. 206 // Do not handle non-property names.
203 if (!propInfo) 207 if (!propInfo)
204 return v8Undefined(); 208 return v8Undefined();
205 209
206 CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder()); 210 CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
207 RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSS PropertyID>(propInfo->propID)); 211 RefPtr<CSSValue> cssValue = imp->getPropertyCSSValueInternal(static_cast<CSS PropertyID>(propInfo->propID));
208 if (cssValue) { 212 if (cssValue) {
209 if (propInfo->hadPixelOrPosPrefix 213 if (propInfo->hadPixelOrPosPrefix
210 && cssValue->isPrimitiveValue()) { 214 && cssValue->isPrimitiveValue()) {
211 return v8::Number::New(static_cast<CSSPrimitiveValue*>( 215 return v8::Number::New(static_cast<CSSPrimitiveValue*>(
212 cssValue.get())->getFloatValue(CSSPrimitiveValue::CSS_PX)); 216 cssValue.get())->getFloatValue(CSSPrimitiveValue::CSS_PX));
213 } 217 }
214 return v8StringOrNull(cssValue->cssText(), info.GetIsolate()); 218 return v8StringOrNull(cssValue->cssText(), info.GetIsolate());
215 } 219 }
216 220
217 String result = imp->getPropertyValueInternal(static_cast<CSSPropertyID>(pro pInfo->propID)); 221 String result = imp->getPropertyValueInternal(static_cast<CSSPropertyID>(pro pInfo->propID));
218 if (result.isNull()) 222 if (result.isNull())
219 result = ""; // convert null to empty string. 223 result = ""; // convert null to empty string.
220 224
221 return v8String(result, info.GetIsolate()); 225 return v8String(result, info.GetIsolate());
222 } 226 }
223 227
224 v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertySetter(v8::Local<v8::S tring> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info) 228 v8::Handle<v8::Value> V8CSSStyleDeclaration::namedPropertySetter(v8::Local<v8::S tring> name, v8::Local<v8::Value> value, const v8::AccessorInfo& info)
225 { 229 {
230 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(name).IsEmpty())
231 return v8Undefined();
232 if (info.Holder()->HasRealNamedCallbackProperty(name))
233 return v8Undefined();
234 if (info.Holder()->HasRealNamedProperty(name))
235 return v8Undefined();
236
226 CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder()); 237 CSSStyleDeclaration* imp = V8CSSStyleDeclaration::toNative(info.Holder());
227 CSSPropertyInfo* propInfo = cssPropertyInfo(name); 238 CSSPropertyInfo* propInfo = cssPropertyInfo(name);
228 if (!propInfo) 239 if (!propInfo)
229 return v8Undefined(); 240 return v8Undefined();
230 241
231 String propertyValue = toWebCoreStringWithNullCheck(value); 242 String propertyValue = toWebCoreStringWithNullCheck(value);
232 if (propInfo->hadPixelOrPosPrefix) 243 if (propInfo->hadPixelOrPosPrefix)
233 propertyValue.append("px"); 244 propertyValue.append("px");
234 245
235 ExceptionCode ec = 0; 246 ExceptionCode ec = 0;
236 imp->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), prope rtyValue, false, ec); 247 imp->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), prope rtyValue, false, ec);
237 248
238 if (ec) 249 if (ec)
239 setDOMException(ec, info.GetIsolate()); 250 setDOMException(ec, info.GetIsolate());
240 251
241 return value; 252 return value;
242 } 253 }
243 254
244 } // namespace WebCore 255 } // namespace WebCore
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698