diff options
author | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
---|---|---|
committer | Lorry Tar Creator <lorry-tar-importer@lorry> | 2017-06-27 06:07:23 +0000 |
commit | 1bf1084f2b10c3b47fd1a588d85d21ed0eb41d0c (patch) | |
tree | 46dcd36c86e7fbc6e5df36deb463b33e9967a6f7 /Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp | |
parent | 32761a6cee1d0dee366b885b7b9c777e67885688 (diff) | |
download | WebKitGtk-tarball-master.tar.gz |
webkitgtk-2.16.5HEADwebkitgtk-2.16.5master
Diffstat (limited to 'Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp')
-rw-r--r-- | Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp | 67 |
1 files changed, 27 insertions, 40 deletions
diff --git a/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp b/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp index 6ff6b9c05..b3cc70d73 100644 --- a/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp +++ b/Source/WebCore/bindings/js/JSDOMStringMapCustom.cpp @@ -1,5 +1,5 @@ /* - * Copyright (C) 2010 Apple Inc. All rights reserved. + * Copyright (C) 2010, 2014 Apple Inc. All rights reserved. * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -26,64 +26,51 @@ #include "config.h" #include "JSDOMStringMap.h" +#include "CustomElementReactionQueue.h" #include "DOMStringMap.h" -#include "Element.h" +#include "JSDOMConvert.h" #include "JSNode.h" +#include <runtime/IdentifierInlines.h> #include <wtf/text/AtomicString.h> using namespace JSC; namespace WebCore { -bool JSDOMStringMap::canGetItemsForName(ExecState*, DOMStringMap* impl, PropertyName propertyName) +bool JSDOMStringMap::deleteProperty(JSCell* cell, ExecState* state, PropertyName propertyName) { - return impl->contains(propertyNameToAtomicString(propertyName)); + CustomElementReactionStack customElementReactionStack; + if (propertyName.isSymbol()) + return Base::deleteProperty(cell, state, propertyName); + return jsCast<JSDOMStringMap*>(cell)->wrapped().deleteItem(propertyNameToString(propertyName)); } -EncodedJSValue JSDOMStringMap::nameGetter(ExecState* exec, EncodedJSValue slotBase, EncodedJSValue, PropertyName propertyName) +bool JSDOMStringMap::deletePropertyByIndex(JSCell* cell, ExecState* state, unsigned index) { - JSDOMStringMap* thisObj = jsCast<JSDOMStringMap*>(JSValue::decode(slotBase)); - return JSValue::encode(jsStringWithCache(exec, thisObj->impl().item(propertyNameToAtomicString(propertyName)))); + return deleteProperty(cell, state, Identifier::from(state, index)); } -void JSDOMStringMap::getOwnPropertyNames(JSObject* object, ExecState* exec, PropertyNameArray& propertyNames, EnumerationMode mode) +bool JSDOMStringMap::putDelegate(ExecState* state, PropertyName propertyName, JSValue value, PutPropertySlot&, bool& putResult) { - JSDOMStringMap* thisObject = jsCast<JSDOMStringMap*>(object); - Vector<String> names; - thisObject->m_impl->getNames(names); - size_t length = names.size(); - for (size_t i = 0; i < length; ++i) - propertyNames.add(Identifier(exec, names[i])); + VM& vm = state->vm(); + auto scope = DECLARE_THROW_SCOPE(vm); - Base::getOwnPropertyNames(thisObject, exec, propertyNames, mode); -} - -bool JSDOMStringMap::deleteProperty(JSCell* cell, ExecState* exec, PropertyName propertyName) -{ - JSDOMStringMap* thisObject = jsCast<JSDOMStringMap*>(cell); - AtomicString stringName = propertyNameToAtomicString(propertyName); - if (!thisObject->m_impl->contains(stringName)) + if (propertyName.isSymbol()) return false; - ExceptionCode ec = 0; - thisObject->m_impl->deleteItem(stringName, ec); - setDOMException(exec, ec); - return !ec; -} -bool JSDOMStringMap::deletePropertyByIndex(JSCell* cell, ExecState* exec, unsigned index) -{ - return deleteProperty(cell, exec, Identifier::from(exec, index)); -} + CustomElementReactionStack customElementReactionStack; -bool JSDOMStringMap::putDelegate(ExecState* exec, PropertyName propertyName, JSValue value, PutPropertySlot&) -{ - String stringValue = value.toString(exec)->value(exec); - if (exec->hadException()) - return false; - ExceptionCode ec = 0; - impl().setItem(propertyNameToString(propertyName), stringValue, ec); - setDOMException(exec, ec); - return !ec; + String stringValue = value.toWTFString(state); + RETURN_IF_EXCEPTION(scope, true); + + auto result = wrapped().setItem(propertyNameToString(propertyName), WTFMove(stringValue)); + if (result.hasException()) { + propagateException(*state, scope, result.releaseException()); + return true; + } + + putResult = true; + return true; } } // namespace WebCore |