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 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
48 #include "wtf/text/StringBuilder.h" | 48 #include "wtf/text/StringBuilder.h" |
49 #include "wtf/text/StringConcatenate.h" | 49 #include "wtf/text/StringConcatenate.h" |
50 #include <algorithm> | 50 #include <algorithm> |
51 | 51 |
52 using namespace WTF; | 52 using namespace WTF; |
53 | 53 |
54 namespace blink { | 54 namespace blink { |
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 lowerc
ase. | 58 // First character of the prefix within the property name may be upper or |
| 59 // lowercase. |
59 // 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. |
60 // 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. |
61 static bool hasCSSPropertyNamePrefix(const String& propertyName, | 62 static bool hasCSSPropertyNamePrefix(const String& propertyName, |
62 const char* prefix) { | 63 const char* prefix) { |
63 #if ENABLE(ASSERT) | 64 #if ENABLE(ASSERT) |
64 ASSERT(*prefix); | 65 ASSERT(*prefix); |
65 for (const char* p = prefix; *p; ++p) | 66 for (const char* p = prefix; *p; ++p) |
66 ASSERT(isASCIILower(*p)); | 67 ASSERT(isASCIILower(*p)); |
67 ASSERT(propertyName.length()); | 68 ASSERT(propertyName.length()); |
68 #endif | 69 #endif |
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
106 if (c == '-') | 107 if (c == '-') |
107 hasSeenDash = true; | 108 hasSeenDash = true; |
108 builder.append(c); | 109 builder.append(c); |
109 } else { | 110 } else { |
110 hasSeenUpper = true; | 111 hasSeenUpper = true; |
111 builder.append('-'); | 112 builder.append('-'); |
112 builder.append(toASCIILower(c)); | 113 builder.append(toASCIILower(c)); |
113 } | 114 } |
114 } | 115 } |
115 | 116 |
116 // Reject names containing both dashes and upper-case characters, such as "bor
der-rightColor". | 117 // Reject names containing both dashes and upper-case characters, such as |
| 118 // "border-rightColor". |
117 if (hasSeenDash && hasSeenUpper) | 119 if (hasSeenDash && hasSeenUpper) |
118 return CSSPropertyInvalid; | 120 return CSSPropertyInvalid; |
119 | 121 |
120 String propName = builder.toString(); | 122 String propName = builder.toString(); |
121 return unresolvedCSSPropertyID(propName); | 123 return unresolvedCSSPropertyID(propName); |
122 } | 124 } |
123 | 125 |
124 // When getting properties on CSSStyleDeclarations, the name used from | 126 // When getting properties on CSSStyleDeclarations, the name used from |
125 // Javascript and the actual name of the property are not the same, so | 127 // Javascript and the actual name of the property are not the same, so |
126 // we have to do the following translation. The translation turns upper | 128 // we have to do the following translation. The translation turns upper |
(...skipping 100 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
227 ExceptionState::SetterContext, | 229 ExceptionState::SetterContext, |
228 getPropertyName(resolveCSSPropertyID(unresolvedProperty)), | 230 getPropertyName(resolveCSSPropertyID(unresolvedProperty)), |
229 "CSSStyleDeclaration", info.Holder(), info.GetIsolate()); | 231 "CSSStyleDeclaration", info.Holder(), info.GetIsolate()); |
230 impl->setPropertyInternal(unresolvedProperty, String(), propertyValue, false, | 232 impl->setPropertyInternal(unresolvedProperty, String(), propertyValue, false, |
231 exceptionState); | 233 exceptionState); |
232 | 234 |
233 v8SetReturnValue(info, value); | 235 v8SetReturnValue(info, value); |
234 } | 236 } |
235 | 237 |
236 } // namespace blink | 238 } // namespace blink |
OLD | NEW |