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 } // namespace WebCore | 84 } // namespace WebCore |
OLD | NEW |