Changeset 30391 in webkit
- Timestamp:
- Feb 18, 2008, 5:12:12 PM (17 years ago)
- Location:
- trunk/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified trunk/WebCore/ChangeLog ¶
r30389 r30391 1 2008-02-18 Darin Adler <darin@apple.com> 2 3 Reviewed by Sam. 4 5 * bindings/js/JSCSSStyleDeclarationCustom.cpp: 6 (WebCore::hasCSSPropertyNamePrefix): Added. 7 (WebCore::cssPropertyName): Reimplement to not use DeprecatedString. Also made faster 8 by using a Vector<UChar> and eliminating all the string operations. 9 1 10 2008-02-18 Stephanie Lewis <slewis@apple.com> 2 11 -
TabularUnified trunk/WebCore/bindings/js/JSCSSStyleDeclarationCustom.cpp ¶
r29663 r30391 1 1 /* 2 * Copyright (C) 2007 Apple Inc. All rights reserved.2 * Copyright (C) 2007, 2008 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 31 31 #include "CSSStyleDeclaration.h" 32 32 #include "CSSValue.h" 33 #include "DeprecatedString.h"34 33 #include "PlatformString.h" 35 34 #include <kjs/string_object.h> 35 #include <wtf/ASCIICType.h> 36 37 using namespace KJS; 38 using namespace WTF; 36 39 37 40 namespace WebCore { 38 41 39 using namespace KJS; 42 // Check for a CSS prefix. 43 // Passed prefix is all lowercase. 44 // First characters of property name may be upper or lowercase. 45 // Other characters in the prefix within the property name must be lowercase. 46 // The prefix within the property name must be followed by a capital letter. 47 static bool hasCSSPropertyNamePrefix(const Identifier& propertyName, const char* prefix) 48 { 49 #ifndef NDEBUG 50 ASSERT(*prefix); 51 for (const char* p = prefix; *p; ++p) 52 ASSERT(isASCIILower(*p)); 53 #endif 54 55 unsigned length = propertyName.size(); 56 ASSERT(length); 57 58 if (toASCIILower(propertyName.data()[0].unicode()) != prefix[0]) 59 return false; 60 61 for (unsigned i = 1; i < length; ++i) { 62 if (!prefix[i]) 63 return isASCIIUpper(propertyName.data()[i].unicode()); 64 if (propertyName.data()[0].unicode() != prefix[0]) 65 return false; 66 } 67 return false; 68 } 40 69 41 70 static String cssPropertyName(const Identifier& propertyName, bool* hadPixelOrPosPrefix = 0) 42 71 { 43 DeprecatedString prop = propertyName;44 45 int i = prop.length();46 47 if (!i)48 return prop;49 50 while (--i) {51 ::UChar c = prop[i].unicode();52 if (c >= 'A' && c <= 'Z')53 prop.insert(i, '-');54 }55 56 prop = prop.lower();57 58 72 if (hadPixelOrPosPrefix) 59 73 *hadPixelOrPosPrefix = false; 60 74 61 if (prop.startsWith("css-")) 62 prop = prop.mid(4); 63 else if (prop.startsWith("pixel-")) { 64 prop = prop.mid(6); 75 unsigned length = propertyName.size(); 76 if (!length) 77 return String(); 78 79 Vector< ::UChar> name; 80 name.reserveCapacity(length); 81 82 unsigned i = 0; 83 84 if (hasCSSPropertyNamePrefix(propertyName, "css")) 85 i += 3; 86 else if (hasCSSPropertyNamePrefix(propertyName, "pixel")) { 87 i += 5; 65 88 if (hadPixelOrPosPrefix) 66 89 *hadPixelOrPosPrefix = true; 67 } else if ( prop.startsWith("pos-")) {68 prop = prop.mid(4);90 } else if (hasCSSPropertyNamePrefix(propertyName, "pos")) { 91 i += 3; 69 92 if (hadPixelOrPosPrefix) 70 93 *hadPixelOrPosPrefix = true; 71 } else if (prop.startsWith("khtml-") || prop.startsWith("apple-") || prop.startsWith("webkit-")) 72 prop.insert(0, '-'); 94 } else if (hasCSSPropertyNamePrefix(propertyName, "webkit") 95 || hasCSSPropertyNamePrefix(propertyName, "khtml") 96 || hasCSSPropertyNamePrefix(propertyName, "apple")) 97 name.append('-'); 73 98 74 return prop; 99 name.append(toASCIILower(propertyName.data()[i++].unicode())); 100 101 for (; i < length; ++i) { 102 ::UChar c = propertyName.data()[i].unicode(); 103 if (!isASCIIUpper(c)) 104 name.append(c); 105 else { 106 name.append('-'); 107 name.append(toASCIILower(c)); 108 } 109 } 110 111 return String::adopt(name); 75 112 } 76 113 … … 85 122 } 86 123 87 JSValue* JSCSSStyleDeclaration::nameGetter(ExecState* exec, JSObject* originalObject, const Identifier& propertyName, const PropertySlot& slot) 124 // FIXME: You can get these properties, and set them (see customPut below), 125 // but you should also be able the enumerate them. 126 JSValue* JSCSSStyleDeclaration::nameGetter(ExecState* exec, JSObject* originalObject, 127 const Identifier& propertyName, const PropertySlot& slot) 88 128 { 89 129 JSCSSStyleDeclaration* thisObj = static_cast<JSCSSStyleDeclaration*>(slot.slotBase()); … … 108 148 // Make the SVG 'filter' attribute undetectable, to avoid confusion with the IE 'filter' attribute. 109 149 if (propertyName == "filter") 110 return new StringInstanceThatMasqueradesAsUndefined(exec->lexicalGlobalObject()->stringPrototype(), thisObj->impl()->getPropertyValue(prop)); 150 return new StringInstanceThatMasqueradesAsUndefined(exec->lexicalGlobalObject()->stringPrototype(), 151 thisObj->impl()->getPropertyValue(prop)); 111 152 112 153 return jsString(thisObj->impl()->getPropertyValue(prop));
Note:
See TracChangeset
for help on using the changeset viewer.