| 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 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 | 55 |
| 56 // Check for a CSS prefix. | 56 // Check for a CSS prefix. |
| 57 // Passed prefix is all lowercase. | 57 // Passed prefix is all lowercase. |
| 58 // First character of the prefix within the property name may be upper or | 58 // First character of the prefix within the property name may be upper or |
| 59 // lowercase. | 59 // lowercase. |
| 60 // Other characters in the prefix within the property name must be lowercase. | 60 // Other characters in the prefix within the property name must be lowercase. |
| 61 // The prefix within the property name must be followed by a capital letter. | 61 // The prefix within the property name must be followed by a capital letter. |
| 62 static bool HasCSSPropertyNamePrefix(const String& property_name, | 62 static bool HasCSSPropertyNamePrefix(const String& property_name, |
| 63 const char* prefix) { | 63 const char* prefix) { |
| 64 #if DCHECK_IS_ON() | 64 #if DCHECK_IS_ON() |
| 65 ASSERT(*prefix); | 65 DCHECK(*prefix); |
| 66 for (const char* p = prefix; *p; ++p) | 66 for (const char* p = prefix; *p; ++p) |
| 67 ASSERT(IsASCIILower(*p)); | 67 DCHECK(IsASCIILower(*p)); |
| 68 ASSERT(property_name.length()); | 68 DCHECK(property_name.length()); |
| 69 #endif | 69 #endif |
| 70 | 70 |
| 71 if (ToASCIILower(property_name[0]) != prefix[0]) | 71 if (ToASCIILower(property_name[0]) != prefix[0]) |
| 72 return false; | 72 return false; |
| 73 | 73 |
| 74 unsigned length = property_name.length(); | 74 unsigned length = property_name.length(); |
| 75 for (unsigned i = 1; i < length; ++i) { | 75 for (unsigned i = 1; i < length; ++i) { |
| 76 if (!prefix[i]) | 76 if (!prefix[i]) |
| 77 return IsASCIIUpper(property_name[i]); | 77 return IsASCIIUpper(property_name[i]); |
| 78 if (property_name[i] != prefix[i]) | 78 if (property_name[i] != prefix[i]) |
| (...skipping 57 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 136 typedef HashMap<String, CSSPropertyID> CSSPropertyIDMap; | 136 typedef HashMap<String, CSSPropertyID> CSSPropertyIDMap; |
| 137 DEFINE_STATIC_LOCAL(CSSPropertyIDMap, map, ()); | 137 DEFINE_STATIC_LOCAL(CSSPropertyIDMap, map, ()); |
| 138 CSSPropertyIDMap::iterator iter = map.Find(name); | 138 CSSPropertyIDMap::iterator iter = map.Find(name); |
| 139 if (iter != map.end()) | 139 if (iter != map.end()) |
| 140 return iter->value; | 140 return iter->value; |
| 141 | 141 |
| 142 CSSPropertyID unresolved_property = ParseCSSPropertyID(name); | 142 CSSPropertyID unresolved_property = ParseCSSPropertyID(name); |
| 143 if (unresolved_property == CSSPropertyVariable) | 143 if (unresolved_property == CSSPropertyVariable) |
| 144 unresolved_property = CSSPropertyInvalid; | 144 unresolved_property = CSSPropertyInvalid; |
| 145 map.insert(name, unresolved_property); | 145 map.insert(name, unresolved_property); |
| 146 ASSERT(!unresolved_property || | 146 DCHECK(!unresolved_property || |
| 147 CSSPropertyMetadata::IsEnabledProperty(unresolved_property)); | 147 CSSPropertyMetadata::IsEnabledProperty(unresolved_property)); |
| 148 return unresolved_property; | 148 return unresolved_property; |
| 149 } | 149 } |
| 150 | 150 |
| 151 void V8CSSStyleDeclaration::namedPropertyEnumeratorCustom( | 151 void V8CSSStyleDeclaration::namedPropertyEnumeratorCustom( |
| 152 const v8::PropertyCallbackInfo<v8::Array>& info) { | 152 const v8::PropertyCallbackInfo<v8::Array>& info) { |
| 153 typedef Vector<String, numCSSProperties - 1> PreAllocatedPropertyVector; | 153 typedef Vector<String, numCSSProperties - 1> PreAllocatedPropertyVector; |
| 154 DEFINE_STATIC_LOCAL(PreAllocatedPropertyVector, property_names, ()); | 154 DEFINE_STATIC_LOCAL(PreAllocatedPropertyVector, property_names, ()); |
| 155 static unsigned property_names_length = 0; | 155 static unsigned property_names_length = 0; |
| 156 | 156 |
| 157 if (property_names.IsEmpty()) { | 157 if (property_names.IsEmpty()) { |
| 158 for (int id = firstCSSProperty; id <= lastCSSProperty; ++id) { | 158 for (int id = firstCSSProperty; id <= lastCSSProperty; ++id) { |
| 159 CSSPropertyID property_id = static_cast<CSSPropertyID>(id); | 159 CSSPropertyID property_id = static_cast<CSSPropertyID>(id); |
| 160 if (CSSPropertyMetadata::IsEnabledProperty(property_id)) | 160 if (CSSPropertyMetadata::IsEnabledProperty(property_id)) |
| 161 property_names.push_back(getJSPropertyName(property_id)); | 161 property_names.push_back(getJSPropertyName(property_id)); |
| 162 } | 162 } |
| 163 std::sort(property_names.begin(), property_names.end(), | 163 std::sort(property_names.begin(), property_names.end(), |
| 164 CodePointCompareLessThan); | 164 CodePointCompareLessThan); |
| 165 property_names_length = property_names.size(); | 165 property_names_length = property_names.size(); |
| 166 } | 166 } |
| 167 | 167 |
| 168 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); | 168 v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext(); |
| 169 v8::Local<v8::Array> properties = | 169 v8::Local<v8::Array> properties = |
| 170 v8::Array::New(info.GetIsolate(), property_names_length); | 170 v8::Array::New(info.GetIsolate(), property_names_length); |
| 171 for (unsigned i = 0; i < property_names_length; ++i) { | 171 for (unsigned i = 0; i < property_names_length; ++i) { |
| 172 String key = property_names.at(i); | 172 String key = property_names.at(i); |
| 173 ASSERT(!key.IsNull()); | 173 DCHECK(!key.IsNull()); |
| 174 if (!V8CallBoolean(properties->CreateDataProperty( | 174 if (!V8CallBoolean(properties->CreateDataProperty( |
| 175 context, i, V8String(info.GetIsolate(), key)))) | 175 context, i, V8String(info.GetIsolate(), key)))) |
| 176 return; | 176 return; |
| 177 } | 177 } |
| 178 | 178 |
| 179 V8SetReturnValue(info, properties); | 179 V8SetReturnValue(info, properties); |
| 180 } | 180 } |
| 181 | 181 |
| 182 void V8CSSStyleDeclaration::namedPropertyQueryCustom( | 182 void V8CSSStyleDeclaration::namedPropertyQueryCustom( |
| 183 const AtomicString& name, | 183 const AtomicString& name, |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 229 ExceptionState exception_state( | 229 ExceptionState exception_state( |
| 230 info.GetIsolate(), ExceptionState::kSetterContext, "CSSStyleDeclaration", | 230 info.GetIsolate(), ExceptionState::kSetterContext, "CSSStyleDeclaration", |
| 231 getPropertyName(resolveCSSPropertyID(unresolved_property))); | 231 getPropertyName(resolveCSSPropertyID(unresolved_property))); |
| 232 impl->SetPropertyInternal(unresolved_property, String(), property_value, | 232 impl->SetPropertyInternal(unresolved_property, String(), property_value, |
| 233 false, exception_state); | 233 false, exception_state); |
| 234 | 234 |
| 235 V8SetReturnValue(info, value); | 235 V8SetReturnValue(info, value); |
| 236 } | 236 } |
| 237 | 237 |
| 238 } // namespace blink | 238 } // namespace blink |
| OLD | NEW |