| OLD | NEW |
| 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 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 133 | 133 |
| 134 // When getting properties on CSSStyleDeclarations, the name used from | 134 // When getting properties on CSSStyleDeclarations, the name used from |
| 135 // Javascript and the actual name of the property are not the same, so | 135 // Javascript and the actual name of the property are not the same, so |
| 136 // we have to do the following translation. The translation turns upper | 136 // we have to do the following translation. The translation turns upper |
| 137 // case characters into lower case characters and inserts dashes to | 137 // case characters into lower case characters and inserts dashes to |
| 138 // separate words. | 138 // separate words. |
| 139 // | 139 // |
| 140 // Example: 'backgroundPositionY' -> 'background-position-y' | 140 // Example: 'backgroundPositionY' -> 'background-position-y' |
| 141 // | 141 // |
| 142 // Also, certain prefixes such as 'css-' are stripped. | 142 // Also, certain prefixes such as 'css-' are stripped. |
| 143 static CSSPropertyInfo* cssPropertyInfo(v8::Handle<v8::String> v8PropertyName, v
8::Isolate* isolate) | 143 static CSSPropertyInfo* cssPropertyInfo(v8::Local<v8::String> v8PropertyName, v8
::Isolate* isolate) |
| 144 { | 144 { |
| 145 String propertyName = toCoreString(v8PropertyName); | 145 String propertyName = toCoreString(v8PropertyName); |
| 146 typedef HashMap<String, CSSPropertyInfo*> CSSPropertyInfoMap; | 146 typedef HashMap<String, CSSPropertyInfo*> CSSPropertyInfoMap; |
| 147 DEFINE_STATIC_LOCAL(CSSPropertyInfoMap, map, ()); | 147 DEFINE_STATIC_LOCAL(CSSPropertyInfoMap, map, ()); |
| 148 CSSPropertyInfo* propInfo = map.get(propertyName); | 148 CSSPropertyInfo* propInfo = map.get(propertyName); |
| 149 if (!propInfo) { | 149 if (!propInfo) { |
| 150 propInfo = new CSSPropertyInfo(); | 150 propInfo = new CSSPropertyInfo(); |
| 151 propInfo->propID = cssResolvedPropertyID(propertyName, isolate); | 151 propInfo->propID = cssResolvedPropertyID(propertyName, isolate); |
| 152 map.add(propertyName, propInfo); | 152 map.add(propertyName, propInfo); |
| 153 } | 153 } |
| (...skipping 12 matching lines...) Expand all Loading... |
| 166 if (propertyNames.isEmpty()) { | 166 if (propertyNames.isEmpty()) { |
| 167 for (int id = firstCSSProperty; id <= lastCSSProperty; ++id) { | 167 for (int id = firstCSSProperty; id <= lastCSSProperty; ++id) { |
| 168 CSSPropertyID propertyId = static_cast<CSSPropertyID>(id); | 168 CSSPropertyID propertyId = static_cast<CSSPropertyID>(id); |
| 169 if (CSSPropertyMetadata::isEnabledProperty(propertyId)) | 169 if (CSSPropertyMetadata::isEnabledProperty(propertyId)) |
| 170 propertyNames.append(getJSPropertyName(propertyId)); | 170 propertyNames.append(getJSPropertyName(propertyId)); |
| 171 } | 171 } |
| 172 std::sort(propertyNames.begin(), propertyNames.end(), codePointCompareLe
ssThan); | 172 std::sort(propertyNames.begin(), propertyNames.end(), codePointCompareLe
ssThan); |
| 173 propertyNamesLength = propertyNames.size(); | 173 propertyNamesLength = propertyNames.size(); |
| 174 } | 174 } |
| 175 | 175 |
| 176 v8::Handle<v8::Array> properties = v8::Array::New(info.GetIsolate(), propert
yNamesLength); | 176 v8::Local<v8::Array> properties = v8::Array::New(info.GetIsolate(), property
NamesLength); |
| 177 for (unsigned i = 0; i < propertyNamesLength; ++i) { | 177 for (unsigned i = 0; i < propertyNamesLength; ++i) { |
| 178 String key = propertyNames.at(i); | 178 String key = propertyNames.at(i); |
| 179 ASSERT(!key.isNull()); | 179 ASSERT(!key.isNull()); |
| 180 properties->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.Ge
tIsolate(), key)); | 180 properties->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.Ge
tIsolate(), key)); |
| 181 } | 181 } |
| 182 | 182 |
| 183 v8SetReturnValue(info, properties); | 183 v8SetReturnValue(info, properties); |
| 184 } | 184 } |
| 185 | 185 |
| 186 void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::Name> v8Name,
const v8::PropertyCallbackInfo<v8::Integer>& info) | 186 void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::Name> v8Name,
const v8::PropertyCallbackInfo<v8::Integer>& info) |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 234 ExceptionState exceptionState(ExceptionState::SetterContext, getPropertyName
(static_cast<CSSPropertyID>(propInfo->propID)), "CSSStyleDeclaration", info.Hold
er(), info.GetIsolate()); | 234 ExceptionState exceptionState(ExceptionState::SetterContext, getPropertyName
(static_cast<CSSPropertyID>(propInfo->propID)), "CSSStyleDeclaration", info.Hold
er(), info.GetIsolate()); |
| 235 impl->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), prop
ertyValue, false, exceptionState); | 235 impl->setPropertyInternal(static_cast<CSSPropertyID>(propInfo->propID), prop
ertyValue, false, exceptionState); |
| 236 | 236 |
| 237 if (exceptionState.throwIfNeeded()) | 237 if (exceptionState.throwIfNeeded()) |
| 238 return; | 238 return; |
| 239 | 239 |
| 240 v8SetReturnValue(info, value); | 240 v8SetReturnValue(info, value); |
| 241 } | 241 } |
| 242 | 242 |
| 243 } // namespace blink | 243 } // namespace blink |
| OLD | NEW |