Changeset 151978 in webkit
- Timestamp:
- Jun 25, 2013 8:48:12 PM (11 years ago)
- Location:
- trunk/Source
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r151923 r151978 1 2013-06-25 Ryosuke Niwa <rniwa@webkit.org> 2 3 JSString should remember AtomicString 4 https://bugs.webkit.org/show_bug.cgi?id=117386 5 6 Reviewed by Geoffrey Garen. 7 8 Added JSValue::toAtomicString and JSString::atomicString. These two functions allow WebCore to update 9 JSString's m_value to set isAtomic flag and avoid the AtomicStringTable lookups in subsequent attempts 10 to obtain the AtomicString of the same value. 11 12 * runtime/JSCJSValue.h: 13 * runtime/JSString.h: 14 (JSC::JSString::atomicString): 15 (JSC::JSValue::toAtomicString): 16 1 17 2013-06-24 Roger Fong <roger_fong@apple.com> 2 18 -
trunk/Source/JavaScriptCore/runtime/JSCJSValue.h
r149673 r151978 221 221 double toNumber(ExecState*) const; 222 222 JSString* toString(ExecState*) const; 223 AtomicString toAtomicString(ExecState*) const; 223 224 WTF::String toWTFString(ExecState*) const; 224 225 WTF::String toWTFStringInline(ExecState*) const; -
trunk/Source/JavaScriptCore/runtime/JSString.h
r148696 r151978 140 140 const String& tryGetValue() const; 141 141 unsigned length() { return m_length; } 142 AtomicString atomicString(ExecState*) const; 142 143 143 144 JSValue toPrimitive(ExecState*, PreferredPrimitiveType) const; … … 370 371 static_cast<const JSRopeString*>(this)->resolveRope(exec); 371 372 return m_value; 373 } 374 375 inline AtomicString JSString::atomicString(ExecState* exec) const 376 { 377 if (isRope()) { 378 static_cast<const JSRopeString*>(this)->resolveRope(exec); 379 if (exec->hadException()) 380 return nullAtom; 381 } 382 const AtomicString atomicValue(m_value); 383 if (atomicValue.impl() != m_value.impl()) 384 m_value = atomicValue; 385 return atomicValue; 372 386 } 373 387 … … 515 529 return jsCast<JSString*>(asCell()); 516 530 return toStringSlowCase(exec); 531 } 532 533 inline AtomicString JSValue::toAtomicString(ExecState* exec) const 534 { 535 if (isString()) 536 return jsCast<JSString*>(asCell())->atomicString(exec); 537 return toStringSlowCase(exec)->value(exec); 517 538 } 518 539 -
trunk/Source/WebCore/ChangeLog
r151975 r151978 1 2013-06-25 Ryosuke Niwa <rniwa@webkit.org> 2 3 JSString should remember AtomicString 4 https://bugs.webkit.org/show_bug.cgi?id=117386 5 6 Reviewed by Geoffrey Garen. 7 8 Added "Atomic" attribute as a WebKit extension to WebIDL, and deployed it in Element.idl and Node.idl so that 9 the binding code can use newly added JSValue::toAtomic to update JSString's m_value. 10 11 * bindings/js/JSDOMBinding.cpp: 12 (WebCore::valueToAtomicStringWithNullCheck): Added. 13 (WebCore::valueToAtomicStringWithUndefinedOrNullCheck): Added. 14 15 * bindings/js/JSDOMBinding.h: 16 17 * bindings/scripts/CodeGeneratorJS.pm: 18 (GetNativeTypeFromSignature): Return const AtomicString& when either Atomic attribute is specified or the type is 19 Reflect. Note that setAttribute and getAttribute both use AtomicString for all arguments. 20 (JSValueToNative): Use AtomicString equivalents when possible when converting DOMString to a WebCore object. 21 22 * bindings/scripts/IDLAttributes.txt: Added "Atomic" attribute. 23 24 * bindings/scripts/test/JS/JSTestObj.cpp: Baselined test cases. 25 (WebCore::setJSTestObjReflectedStringAttr): 26 (WebCore::setJSTestObjReflectedURLAttr): 27 (WebCore::setJSTestObjReflectedCustomURLAttr): 28 29 * dom/Document.idl: 30 * dom/Element.idl: 31 * dom/Node.idl: 32 1 33 2013-06-25 Kangil Han <kangil.han@samsung.com> 2 34 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.cpp
r151907 r151978 110 110 } 111 111 112 AtomicString valueToAtomicStringWithNullCheck(ExecState* exec, JSValue value) 113 { 114 if (value.isNull()) 115 return nullAtom; 116 return value.toAtomicString(exec); 117 } 118 112 119 String valueToStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value) 113 120 { … … 115 122 return String(); 116 123 return value.toString(exec)->value(exec); 124 } 125 126 AtomicString valueToAtomicStringWithUndefinedOrNullCheck(ExecState* exec, JSValue value) 127 { 128 if (value.isUndefinedOrNull()) 129 return nullAtom; 130 return value.toAtomicString(exec); 117 131 } 118 132 -
trunk/Source/WebCore/bindings/js/JSDOMBinding.h
r151563 r151978 250 250 251 251 String valueToStringWithNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null 252 AtomicString valueToAtomicStringWithNullCheck(JSC::ExecState*, JSC::JSValue); 253 252 254 String valueToStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); // null if the value is null or undefined 255 AtomicString valueToAtomicStringWithUndefinedOrNullCheck(JSC::ExecState*, JSC::JSValue); 253 256 254 257 inline int32_t finiteInt32Value(JSC::JSValue value, JSC::ExecState* exec, bool& okay) -
trunk/Source/WebCore/bindings/scripts/CodeGeneratorJS.pm
r151832 r151978 3363 3363 } 3364 3364 3365 # FIXME: GetNativeType should support Atomic extension. 3366 if ($type eq "DOMString" and ($signature->extendedAttributes->{"Atomic"} or $signature->extendedAttributes->{"Reflect"})) { 3367 return "const AtomicString&"; 3368 } 3369 3365 3370 return GetNativeType($type); 3366 3371 } … … 3502 3507 # FIXME: This implements [TreatNullAs=NullString] and [TreatUndefinedAs=NullString], 3503 3508 # but the Web IDL spec requires [TreatNullAs=EmptyString] and [TreatUndefinedAs=EmptyString]. 3504 if (($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") and ($signature->extendedAttributes->{"TreatUndefinedAs"} and $signature->extendedAttributes->{"TreatUndefinedAs"} eq "NullString")) { 3505 return "valueToStringWithUndefinedOrNullCheck(exec, $value)" 3506 } 3507 if (($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") or $signature->extendedAttributes->{"Reflect"}) { 3508 return "valueToStringWithNullCheck(exec, $value)" 3509 if (($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") 3510 and ($signature->extendedAttributes->{"TreatUndefinedAs"} and $signature->extendedAttributes->{"TreatUndefinedAs"} eq "NullString")) { 3511 if ($signature->extendedAttributes->{"Atomic"}) { 3512 return "valueToStringWithUndefinedOrNullCheck(exec, $value)"; 3513 } else { 3514 return "valueToAtomicStringWithUndefinedOrNullCheck(exec, $value)"; 3515 } 3516 } 3517 if ($signature->extendedAttributes->{"Reflect"}) { 3518 return "valueToAtomicStringWithNullCheck(exec, $value)"; 3519 } 3520 if ($signature->extendedAttributes->{"TreatNullAs"} and $signature->extendedAttributes->{"TreatNullAs"} eq "NullString") { 3521 return "valueToStringWithNullCheck(exec, $value)"; 3522 } 3523 if ($signature->extendedAttributes->{"Atomic"}) { 3524 return "$value.isEmpty() ? nullAtom : $value.toAtomicString(exec)"; 3509 3525 } 3510 3526 # FIXME: Add the case for 'if ($signature->extendedAttributes->{"TreatUndefinedAs"} and $signature->extendedAttributes->{"TreatUndefinedAs"} eq "NullString"))'. -
trunk/Source/WebCore/bindings/scripts/IDLAttributes.txt
r151832 r151978 20 20 21 21 ActiveDOMObject 22 Atomic 22 23 CPPPureInterface 23 24 CachedAttribute -
trunk/Source/WebCore/bindings/scripts/test/JS/JSTestObj.cpp
r151832 r151978 1279 1279 JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); 1280 1280 TestObj* impl = static_cast<TestObj*>(castedThis->impl()); 1281 const String& nativeValue(valueToStringWithNullCheck(exec, value));1281 const AtomicString& nativeValue(valueToAtomicStringWithNullCheck(exec, value)); 1282 1282 if (exec->hadException()) 1283 1283 return; … … 1327 1327 JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); 1328 1328 TestObj* impl = static_cast<TestObj*>(castedThis->impl()); 1329 const String& nativeValue(valueToStringWithNullCheck(exec, value));1329 const AtomicString& nativeValue(valueToAtomicStringWithNullCheck(exec, value)); 1330 1330 if (exec->hadException()) 1331 1331 return; … … 1339 1339 JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); 1340 1340 TestObj* impl = static_cast<TestObj*>(castedThis->impl()); 1341 const String& nativeValue(valueToStringWithNullCheck(exec, value));1341 const AtomicString& nativeValue(valueToAtomicStringWithNullCheck(exec, value)); 1342 1342 if (exec->hadException()) 1343 1343 return; … … 1375 1375 JSTestObj* castedThis = jsCast<JSTestObj*>(thisObject); 1376 1376 TestObj* impl = static_cast<TestObj*>(castedThis->impl()); 1377 const String& nativeValue(valueToStringWithNullCheck(exec, value));1377 const AtomicString& nativeValue(valueToAtomicStringWithNullCheck(exec, value)); 1378 1378 if (exec->hadException()) 1379 1379 return; -
trunk/Source/WebCore/dom/Document.idl
r151951 r151978 30 30 readonly attribute Element documentElement; 31 31 32 [ReturnNewObject, RaisesException] Element createElement([TreatNullAs=NullString,Default=Undefined ] optional DOMString tagName);32 [ReturnNewObject, RaisesException] Element createElement([TreatNullAs=NullString,Default=Undefined,Atomic] optional DOMString tagName); 33 33 DocumentFragment createDocumentFragment(); 34 34 [ReturnNewObject] Text createTextNode([Default=Undefined] optional DOMString data); … … 39 39 [ReturnNewObject, RaisesException] Attr createAttribute([Default=Undefined] optional DOMString name); 40 40 [ReturnNewObject, RaisesException] EntityReference createEntityReference([Default=Undefined] optional DOMString name); 41 NodeList getElementsByTagName([Default=Undefined ] optional DOMString tagname);41 NodeList getElementsByTagName([Default=Undefined, Atomic] optional DOMString tagname); 42 42 43 43 // Introduced in DOM Level 2: … … 49 49 [ObjCLegacyUnnamedParameters, ReturnNewObject, RaisesException] Attr createAttributeNS([TreatNullAs=NullString,Default=Undefined] optional DOMString namespaceURI, 50 50 [TreatNullAs=NullString,Default=Undefined] optional DOMString qualifiedName); 51 [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined ] optional DOMString namespaceURI,52 [Default=Undefined ] optional DOMString localName);53 Element getElementById([Default=Undefined ] optional DOMString elementId);51 [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString,Default=Undefined,Atomic] optional DOMString namespaceURI, 52 [Default=Undefined,Atomic] optional DOMString localName); 53 Element getElementById([Default=Undefined,Atomic] optional DOMString elementId); 54 54 55 55 // DOM Level 3 Core … … 217 217 218 218 // NodeSelector - Selector API 219 [RaisesException] Element querySelector( DOMString selectors);220 [RaisesException] NodeList querySelectorAll( DOMString selectors);219 [RaisesException] Element querySelector([Atomic] DOMString selectors); 220 [RaisesException] NodeList querySelectorAll([Atomic] DOMString selectors); 221 221 222 222 #if defined(ENABLE_FULLSCREEN_API) && ENABLE_FULLSCREEN_API … … 339 339 #if defined(ENABLE_CUSTOM_ELEMENTS) && ENABLE_CUSTOM_ELEMENTS 340 340 [Conditional=CUSTOM_ELEMENTS, ImplementedAs=registerElement, CallWith=ScriptState, RaisesException] CustomElementConstructor webkitRegister(DOMString name, optional Dictionary options); 341 [ReturnNewObject, RaisesException] Element createElement( DOMString localName, [TreatNullAs=NullString] DOMString typeExtension);342 [ReturnNewObject, RaisesException] Element createElementNS([TreatNullAs=NullString ] DOMString namespaceURI, DOMString qualifiedName,343 [TreatNullAs=NullString ] DOMString typeExtension);341 [ReturnNewObject, RaisesException] Element createElement([Atomic] DOMString localName, [TreatNullAs=NullString, Atomic] DOMString typeExtension); 342 [ReturnNewObject, RaisesException] Element createElementNS([TreatNullAs=NullString, Atomic] DOMString namespaceURI, DOMString qualifiedName, 343 [TreatNullAs=NullString, Atomic] DOMString typeExtension); 344 344 #endif 345 345 -
trunk/Source/WebCore/dom/Element.idl
r151896 r151978 28 28 [TreatReturnedNullStringAs=Null] readonly attribute DOMString tagName; 29 29 30 [TreatReturnedNullStringAs=Null] DOMString getAttribute([Default=Undefined ] optional DOMString name);31 [ObjCLegacyUnnamedParameters, RaisesException] void setAttribute([Default=Undefined ] optional DOMString name,32 [Default=Undefined ] optional DOMString value);33 void removeAttribute([Default=Undefined ] optional DOMString name);34 Attr getAttributeNode([Default=Undefined ] optional DOMString name);30 [TreatReturnedNullStringAs=Null] DOMString getAttribute([Default=Undefined, Atomic] optional DOMString name); 31 [ObjCLegacyUnnamedParameters, RaisesException] void setAttribute([Default=Undefined, Atomic] optional DOMString name, 32 [Default=Undefined, Atomic] optional DOMString value); 33 void removeAttribute([Default=Undefined, Atomic] optional DOMString name); 34 Attr getAttributeNode([Default=Undefined, Atomic] optional DOMString name); 35 35 [RaisesException] Attr setAttributeNode([Default=Undefined] optional Attr newAttr); 36 36 [RaisesException] Attr removeAttributeNode([Default=Undefined] optional Attr oldAttr); 37 NodeList getElementsByTagName([Default=Undefined ] optional DOMString name);37 NodeList getElementsByTagName([Default=Undefined, Atomic] optional DOMString name); 38 38 39 39 #if !defined(LANGUAGE_OBJECTIVE_C) … … 45 45 // DOM Level 2 Core 46 46 47 [ObjCLegacyUnnamedParameters] DOMString getAttributeNS([TreatNullAs=NullString, Default=Undefined] optional DOMString namespaceURI,48 [Default=Undefined ] optional DOMString localName);49 [ObjCLegacyUnnamedParameters, RaisesException] void setAttributeNS([TreatNullAs=NullString, Default=Undefined] optional DOMString namespaceURI,50 [Default=Undefined ] optional DOMString qualifiedName,51 [Default=Undefined ] optional DOMString value);52 [ObjCLegacyUnnamedParameters] void removeAttributeNS([TreatNullAs=NullString ] DOMString namespaceURI,53 DOMString localName);54 [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString, Default=Undefined] optional DOMString namespaceURI,55 [Default=Undefined ] optional DOMString localName);56 [ObjCLegacyUnnamedParameters] Attr getAttributeNodeNS([TreatNullAs=NullString, Default=Undefined] optional DOMString namespaceURI,57 [Default=Undefined ] optional DOMString localName);47 [ObjCLegacyUnnamedParameters] DOMString getAttributeNS([TreatNullAs=NullString, Default=Undefined, Atomic] optional DOMString namespaceURI, 48 [Default=Undefined, Atomic] optional DOMString localName); 49 [ObjCLegacyUnnamedParameters, RaisesException] void setAttributeNS([TreatNullAs=NullString, Default=Undefined, Atomic] optional DOMString namespaceURI, 50 [Default=Undefined, Atomic] optional DOMString qualifiedName, 51 [Default=Undefined, Atomic] optional DOMString value); 52 [ObjCLegacyUnnamedParameters] void removeAttributeNS([TreatNullAs=NullString, Atomic] DOMString namespaceURI, 53 [Atomic] DOMString localName); 54 [ObjCLegacyUnnamedParameters] NodeList getElementsByTagNameNS([TreatNullAs=NullString, Default=Undefined, Atomic] optional DOMString namespaceURI, 55 [Default=Undefined, Atomic] optional DOMString localName); 56 [ObjCLegacyUnnamedParameters] Attr getAttributeNodeNS([TreatNullAs=NullString, Default=Undefined, Atomic] optional DOMString namespaceURI, 57 [Default=Undefined, Atomic] optional DOMString localName); 58 58 [RaisesException] Attr setAttributeNodeNS([Default=Undefined] optional Attr newAttr); 59 59 boolean hasAttribute(DOMString name); 60 [ObjCLegacyUnnamedParameters] boolean hasAttributeNS([TreatNullAs=NullString, Default=Undefined] optional DOMString namespaceURI,61 [Default=Undefined ] optional DOMString localName);60 [ObjCLegacyUnnamedParameters] boolean hasAttributeNS([TreatNullAs=NullString, Default=Undefined, Atomic] optional DOMString namespaceURI, 61 [Default=Undefined, Atomic] optional DOMString localName); 62 62 63 63 readonly attribute CSSStyleDeclaration style; … … 100 100 101 101 // NodeSelector - Selector API 102 [RaisesException] Element querySelector( DOMString selectors);103 [RaisesException] NodeList querySelectorAll( DOMString selectors);102 [RaisesException] Element querySelector([Atomic] DOMString selectors); 103 [RaisesException] NodeList querySelectorAll([Atomic] DOMString selectors); 104 104 105 105 // WebKit extension, pending specification. -
trunk/Source/WebCore/dom/Node.idl
r151714 r151978 127 127 #if !defined(LANGUAGE_CPP) || !LANGUAGE_CPP 128 128 #if !defined(LANGUAGE_OBJECTIVE_C) || !LANGUAGE_OBJECTIVE_C 129 void addEventListener( DOMString type,129 void addEventListener([Atomic] DOMString type, 130 130 EventListener listener, 131 131 optional boolean useCapture); 132 void removeEventListener( DOMString type,132 void removeEventListener([Atomic] DOMString type, 133 133 EventListener listener, 134 134 optional boolean useCapture);
Note: See TracChangeset
for help on using the changeset viewer.