| 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 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 static bool setReturnValueFast(v8::ReturnValue<v8::Value> returnValue, Node*
node, v8::Local<v8::Object> holder, const ScriptWrappable* wrappable) | 89 static bool setReturnValueFast(v8::ReturnValue<v8::Value> returnValue, Node*
node, v8::Local<v8::Object> holder, const ScriptWrappable* wrappable) |
| 90 { | 90 { |
| 91 if (canUseScriptWrappable(node) | 91 if (canUseScriptWrappable(node) |
| 92 // The second fastest way to check if we're in the main world is to | 92 // The second fastest way to check if we're in the main world is to |
| 93 // check if the wrappable's wrapper is the same as the holder. | 93 // check if the wrappable's wrapper is the same as the holder. |
| 94 || holderContainsWrapper(holder, wrappable)) | 94 || holderContainsWrapper(holder, wrappable)) |
| 95 return ScriptWrappable::fromNode(node)->setReturnValue(returnValue); | 95 return ScriptWrappable::fromNode(node)->setReturnValue(returnValue); |
| 96 return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue,
ScriptWrappable::fromNode(node)); | 96 return current(returnValue.GetIsolate()).setReturnValueFrom(returnValue,
ScriptWrappable::fromNode(node)); |
| 97 } | 97 } |
| 98 | 98 |
| 99 static v8::Handle<v8::Object> getWrapper(ScriptWrappable* object, v8::Isolat
e* isolate) | 99 static v8::Local<v8::Object> getWrapper(ScriptWrappable* object, v8::Isolate
* isolate) |
| 100 { | 100 { |
| 101 return current(isolate).get(object, isolate); | 101 return current(isolate).get(object, isolate); |
| 102 } | 102 } |
| 103 | 103 |
| 104 static v8::Handle<v8::Object> getWrapper(Node* node, v8::Isolate* isolate) | 104 static v8::Local<v8::Object> getWrapper(Node* node, v8::Isolate* isolate) |
| 105 { | 105 { |
| 106 if (canUseScriptWrappable(node)) | 106 if (canUseScriptWrappable(node)) |
| 107 return ScriptWrappable::fromNode(node)->newLocalWrapper(isolate); | 107 return ScriptWrappable::fromNode(node)->newLocalWrapper(isolate); |
| 108 return current(isolate).get(ScriptWrappable::fromNode(node), isolate); | 108 return current(isolate).get(ScriptWrappable::fromNode(node), isolate); |
| 109 } | 109 } |
| 110 | 110 |
| 111 static void setWrapperReference(const v8::Persistent<v8::Object>& parent, Sc
riptWrappable* child, v8::Isolate* isolate) | 111 static void setWrapperReference(const v8::Persistent<v8::Object>& parent, Sc
riptWrappable* child, v8::Isolate* isolate) |
| 112 { | 112 { |
| 113 current(isolate).setReference(parent, child, isolate); | 113 current(isolate).setReference(parent, child, isolate); |
| 114 } | 114 } |
| 115 | 115 |
| 116 static void setWrapperReference(const v8::Persistent<v8::Object>& parent, No
de* child, v8::Isolate* isolate) | 116 static void setWrapperReference(const v8::Persistent<v8::Object>& parent, No
de* child, v8::Isolate* isolate) |
| 117 { | 117 { |
| 118 if (canUseScriptWrappable(child)) { | 118 if (canUseScriptWrappable(child)) { |
| 119 ScriptWrappable::fromNode(child)->setReference(parent, isolate); | 119 ScriptWrappable::fromNode(child)->setReference(parent, isolate); |
| 120 return; | 120 return; |
| 121 } | 121 } |
| 122 current(isolate).setReference(parent, ScriptWrappable::fromNode(child),
isolate); | 122 current(isolate).setReference(parent, ScriptWrappable::fromNode(child),
isolate); |
| 123 } | 123 } |
| 124 | 124 |
| 125 static void setWrapper(ScriptWrappable* object, v8::Handle<v8::Object> wrapp
er, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo) | 125 static void setWrapper(ScriptWrappable* object, v8::Local<v8::Object> wrappe
r, v8::Isolate* isolate, const WrapperTypeInfo* wrapperTypeInfo) |
| 126 { | 126 { |
| 127 return current(isolate).set(object, wrapper, isolate, wrapperTypeInfo); | 127 return current(isolate).set(object, wrapper, isolate, wrapperTypeInfo); |
| 128 } | 128 } |
| 129 | 129 |
| 130 static void setWrapper(Node* node, v8::Handle<v8::Object> wrapper, v8::Isola
te* isolate, const WrapperTypeInfo* wrapperTypeInfo) | 130 static void setWrapper(Node* node, v8::Local<v8::Object> wrapper, v8::Isolat
e* isolate, const WrapperTypeInfo* wrapperTypeInfo) |
| 131 { | 131 { |
| 132 if (canUseScriptWrappable(node)) { | 132 if (canUseScriptWrappable(node)) { |
| 133 ScriptWrappable::fromNode(node)->setWrapper(wrapper, isolate, wrappe
rTypeInfo); | 133 ScriptWrappable::fromNode(node)->setWrapper(wrapper, isolate, wrappe
rTypeInfo); |
| 134 return; | 134 return; |
| 135 } | 135 } |
| 136 return current(isolate).set(ScriptWrappable::fromNode(node), wrapper, is
olate, wrapperTypeInfo); | 136 return current(isolate).set(ScriptWrappable::fromNode(node), wrapper, is
olate, wrapperTypeInfo); |
| 137 } | 137 } |
| 138 | 138 |
| 139 static bool containsWrapper(ScriptWrappable* object, v8::Isolate* isolate) | 139 static bool containsWrapper(ScriptWrappable* object, v8::Isolate* isolate) |
| 140 { | 140 { |
| 141 return current(isolate).containsWrapper(object); | 141 return current(isolate).containsWrapper(object); |
| 142 } | 142 } |
| 143 | 143 |
| 144 v8::Handle<v8::Object> get(ScriptWrappable* object, v8::Isolate* isolate) | 144 v8::Local<v8::Object> get(ScriptWrappable* object, v8::Isolate* isolate) |
| 145 { | 145 { |
| 146 if (m_isMainWorld) | 146 if (m_isMainWorld) |
| 147 return object->newLocalWrapper(isolate); | 147 return object->newLocalWrapper(isolate); |
| 148 return m_wrapperMap->newLocal(object, isolate); | 148 return m_wrapperMap->newLocal(object, isolate); |
| 149 } | 149 } |
| 150 | 150 |
| 151 void setReference(const v8::Persistent<v8::Object>& parent, ScriptWrappable*
child, v8::Isolate* isolate) | 151 void setReference(const v8::Persistent<v8::Object>& parent, ScriptWrappable*
child, v8::Isolate* isolate) |
| 152 { | 152 { |
| 153 if (m_isMainWorld) { | 153 if (m_isMainWorld) { |
| 154 child->setReference(parent, isolate); | 154 child->setReference(parent, isolate); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 165 } | 165 } |
| 166 | 166 |
| 167 bool containsWrapper(ScriptWrappable* object) | 167 bool containsWrapper(ScriptWrappable* object) |
| 168 { | 168 { |
| 169 if (m_isMainWorld) | 169 if (m_isMainWorld) |
| 170 return object->containsWrapper(); | 170 return object->containsWrapper(); |
| 171 return m_wrapperMap->containsKey(object); | 171 return m_wrapperMap->containsKey(object); |
| 172 } | 172 } |
| 173 | 173 |
| 174 private: | 174 private: |
| 175 void set(ScriptWrappable* object, v8::Handle<v8::Object> wrapper, v8::Isolat
e* isolate, const WrapperTypeInfo* wrapperTypeInfo) | 175 void set(ScriptWrappable* object, v8::Local<v8::Object> wrapper, v8::Isolate
* isolate, const WrapperTypeInfo* wrapperTypeInfo) |
| 176 { | 176 { |
| 177 ASSERT(object); | 177 ASSERT(object); |
| 178 ASSERT(!wrapper.IsEmpty()); | 178 ASSERT(!wrapper.IsEmpty()); |
| 179 if (m_isMainWorld) { | 179 if (m_isMainWorld) { |
| 180 object->setWrapper(wrapper, isolate, wrapperTypeInfo); | 180 object->setWrapper(wrapper, isolate, wrapperTypeInfo); |
| 181 return; | 181 return; |
| 182 } | 182 } |
| 183 m_wrapperMap->set(object, wrapper, wrapperTypeInfo); | 183 m_wrapperMap->set(object, wrapper, wrapperTypeInfo); |
| 184 } | 184 } |
| 185 | 185 |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 217 v8::UniquePersistent<v8::Object> value, | 217 v8::UniquePersistent<v8::Object> value, |
| 218 ScriptWrappable* key) | 218 ScriptWrappable* key) |
| 219 { | 219 { |
| 220 RELEASE_ASSERT(!value.IsEmpty()); // See crbug.com/368095. | 220 RELEASE_ASSERT(!value.IsEmpty()); // See crbug.com/368095. |
| 221 releaseObject(v8::Local<v8::Object>::New(isolate, value)); | 221 releaseObject(v8::Local<v8::Object>::New(isolate, value)); |
| 222 } | 222 } |
| 223 | 223 |
| 224 } // namespace blink | 224 } // namespace blink |
| 225 | 225 |
| 226 #endif // DOMDataStore_h | 226 #endif // DOMDataStore_h |
| OLD | NEW |