| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2009 Google Inc. All rights reserved. | 2 * Copyright (C) 2009 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 63 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 74 return v8::Handle<v8::Integer>(); | 74 return v8::Handle<v8::Integer>(); |
| 75 ExceptionCode ec = 0; | 75 ExceptionCode ec = 0; |
| 76 bool found = storage->contains(name, ec); | 76 bool found = storage->contains(name, ec); |
| 77 if (ec) | 77 if (ec) |
| 78 return setDOMException<v8::Integer>(ec, info); | 78 return setDOMException<v8::Integer>(ec, info); |
| 79 if (!found) | 79 if (!found) |
| 80 return v8::Handle<v8::Integer>(); | 80 return v8::Handle<v8::Integer>(); |
| 81 return v8Integer(0, info.GetIsolate()); | 81 return v8Integer(0, info.GetIsolate()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 static v8::Handle<v8::Value> storageSetter(v8::Local<v8::String> v8Name, v8::Loc
al<v8::Value> v8Value, const v8::AccessorInfo& info) | |
| 85 { | |
| 86 Storage* storage = V8Storage::toNative(info.Holder()); | |
| 87 String name = toWebCoreString(v8Name); | |
| 88 String value = toWebCoreString(v8Value); | |
| 89 | |
| 90 // Silently ignore length (rather than letting the bindings raise an excepti
on). | |
| 91 if (name == "length") | |
| 92 return v8Value; | |
| 93 | |
| 94 if (!info.Holder()->GetRealNamedPropertyInPrototypeChain(v8Name).IsEmpty()) | |
| 95 return v8Undefined(); | |
| 96 | |
| 97 ExceptionCode ec = 0; | |
| 98 storage->setItem(name, value, ec); | |
| 99 if (ec) | |
| 100 return setDOMException(ec, info.GetIsolate()); | |
| 101 | |
| 102 return v8Value; | |
| 103 } | |
| 104 | |
| 105 v8::Handle<v8::Value> V8Storage::indexedPropertySetter(uint32_t index, v8::Local
<v8::Value> value, const v8::AccessorInfo& info) | |
| 106 { | |
| 107 v8::Handle<v8::Integer> indexV8 = v8Integer(index, info.GetIsolate()); | |
| 108 return storageSetter(indexV8->ToString(), value, info); | |
| 109 } | |
| 110 | |
| 111 static v8::Handle<v8::Boolean> storageDeleter(v8::Local<v8::String> v8Name, cons
t v8::AccessorInfo& info) | 84 static v8::Handle<v8::Boolean> storageDeleter(v8::Local<v8::String> v8Name, cons
t v8::AccessorInfo& info) |
| 112 { | 85 { |
| 113 Storage* storage = V8Storage::toNative(info.Holder()); | 86 Storage* storage = V8Storage::toNative(info.Holder()); |
| 114 String name = toWebCoreString(v8Name); | 87 String name = toWebCoreString(v8Name); |
| 115 | 88 |
| 116 ExceptionCode ec = 0; | 89 ExceptionCode ec = 0; |
| 117 bool found = storage->contains(name, ec); | 90 bool found = storage->contains(name, ec); |
| 118 if (ec) | 91 if (ec) |
| 119 return setDOMException<v8::Boolean>(ec, info); | 92 return setDOMException<v8::Boolean>(ec, info); |
| 120 if (!found) | 93 if (!found) |
| 121 return v8::Handle<v8::Boolean>(); | 94 return v8::Handle<v8::Boolean>(); |
| 122 storage->removeItem(name, ec); | 95 storage->removeItem(name, ec); |
| 123 if (ec) | 96 if (ec) |
| 124 return setDOMException<v8::Boolean>(ec, info); | 97 return setDOMException<v8::Boolean>(ec, info); |
| 125 return v8Boolean(true, info.GetIsolate()); | 98 return v8Boolean(true, info.GetIsolate()); |
| 126 } | 99 } |
| 127 | 100 |
| 128 v8::Handle<v8::Boolean> V8Storage::indexedPropertyDeleter(uint32_t index, const
v8::AccessorInfo& info) | 101 v8::Handle<v8::Boolean> V8Storage::indexedPropertyDeleter(uint32_t index, const
v8::AccessorInfo& info) |
| 129 { | 102 { |
| 130 v8::Handle<v8::Integer> indexV8 = v8Integer(index, info.GetIsolate()); | 103 v8::Handle<v8::Integer> indexV8 = v8Integer(index, info.GetIsolate()); |
| 131 return storageDeleter(indexV8->ToString(), info); | 104 return storageDeleter(indexV8->ToString(), info); |
| 132 } | 105 } |
| 133 | 106 |
| 134 v8::Handle<v8::Boolean> V8Storage::namedPropertyDeleter(v8::Local<v8::String> na
me, const v8::AccessorInfo& info) | 107 v8::Handle<v8::Boolean> V8Storage::namedPropertyDeleter(v8::Local<v8::String> na
me, const v8::AccessorInfo& info) |
| 135 { | 108 { |
| 136 return storageDeleter(name, info); | 109 return storageDeleter(name, info); |
| 137 } | 110 } |
| 138 | 111 |
| 139 } // namespace WebCore | 112 } // namespace WebCore |
| OLD | NEW |