| 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 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 144 CSSPropertyIDMap::iterator iter = map.find(propertyName); | 144 CSSPropertyIDMap::iterator iter = map.find(propertyName); |
| 145 if (iter != map.end()) | 145 if (iter != map.end()) |
| 146 return iter->value; | 146 return iter->value; |
| 147 | 147 |
| 148 CSSPropertyID unresolvedProperty = parseCSSPropertyID(isolate, propertyName)
; | 148 CSSPropertyID unresolvedProperty = parseCSSPropertyID(isolate, propertyName)
; |
| 149 map.add(propertyName, unresolvedProperty); | 149 map.add(propertyName, unresolvedProperty); |
| 150 ASSERT(!unresolvedProperty || CSSPropertyMetadata::isEnabledProperty(unresol
vedProperty)); | 150 ASSERT(!unresolvedProperty || CSSPropertyMetadata::isEnabledProperty(unresol
vedProperty)); |
| 151 return unresolvedProperty; | 151 return unresolvedProperty; |
| 152 } | 152 } |
| 153 | 153 |
| 154 void V8CSSStyleDeclaration::namedPropertyEnumeratorCustom(const v8::PropertyCall
backInfo<v8::Array>& info) | |
| 155 { | |
| 156 typedef Vector<String, numCSSProperties - 1> PreAllocatedPropertyVector; | |
| 157 DEFINE_STATIC_LOCAL(PreAllocatedPropertyVector, propertyNames, ()); | |
| 158 static unsigned propertyNamesLength = 0; | |
| 159 | |
| 160 if (propertyNames.isEmpty()) { | |
| 161 for (int id = firstCSSProperty; id <= lastCSSProperty; ++id) { | |
| 162 CSSPropertyID propertyId = static_cast<CSSPropertyID>(id); | |
| 163 if (CSSPropertyMetadata::isEnabledProperty(propertyId)) | |
| 164 propertyNames.append(getJSPropertyName(propertyId)); | |
| 165 } | |
| 166 std::sort(propertyNames.begin(), propertyNames.end(), codePointCompareLe
ssThan); | |
| 167 propertyNamesLength = propertyNames.size(); | |
| 168 } | |
| 169 | |
| 170 v8::Local<v8::Array> properties = v8::Array::New(info.GetIsolate(), property
NamesLength); | |
| 171 for (unsigned i = 0; i < propertyNamesLength; ++i) { | |
| 172 String key = propertyNames.at(i); | |
| 173 ASSERT(!key.isNull()); | |
| 174 properties->Set(v8::Integer::New(info.GetIsolate(), i), v8String(info.Ge
tIsolate(), key)); | |
| 175 } | |
| 176 | |
| 177 v8SetReturnValue(info, properties); | |
| 178 } | |
| 179 | |
| 180 void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::Name> v8Name,
const v8::PropertyCallbackInfo<v8::Integer>& info) | 154 void V8CSSStyleDeclaration::namedPropertyQueryCustom(v8::Local<v8::Name> v8Name,
const v8::PropertyCallbackInfo<v8::Integer>& info) |
| 181 { | 155 { |
| 182 if (!v8Name->IsString()) | 156 if (!v8Name->IsString()) |
| 183 return; | 157 return; |
| 184 // NOTE: cssPropertyInfo lookups incur several mallocs. | 158 // NOTE: cssPropertyInfo lookups incur several mallocs. |
| 185 // Successful lookups have the same cost the first time, but are cached. | 159 // Successful lookups have the same cost the first time, but are cached. |
| 186 if (cssPropertyInfo(v8Name.As<v8::String>(), info.GetIsolate())) { | 160 if (cssPropertyInfo(v8Name.As<v8::String>(), info.GetIsolate())) { |
| 187 v8SetReturnValueInt(info, 0); | 161 v8SetReturnValueInt(info, 0); |
| 188 return; | 162 return; |
| 189 } | 163 } |
| (...skipping 14 matching lines...) Expand all Loading... |
| 204 if (cssValue) { | 178 if (cssValue) { |
| 205 v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate(
)); | 179 v8SetReturnValueStringOrNull(info, cssValue->cssText(), info.GetIsolate(
)); |
| 206 return; | 180 return; |
| 207 } | 181 } |
| 208 | 182 |
| 209 String result = impl->getPropertyValueInternal(resolvedProperty); | 183 String result = impl->getPropertyValueInternal(resolvedProperty); |
| 210 v8SetReturnValueString(info, result, info.GetIsolate()); | 184 v8SetReturnValueString(info, result, info.GetIsolate()); |
| 211 } | 185 } |
| 212 | 186 |
| 213 } // namespace blink | 187 } // namespace blink |
| OLD | NEW |