| 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 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 | 51 |
| 52 static DOMDataStore& current(v8::Isolate*); | 52 static DOMDataStore& current(v8::Isolate*); |
| 53 | 53 |
| 54 // We can use a wrapper stored in a ScriptWrappable when we're in the main w
orld. | 54 // We can use a wrapper stored in a ScriptWrappable when we're in the main w
orld. |
| 55 // This method does the fast check if we're in the main world. If this metho
d returns true, | 55 // This method does the fast check if we're in the main world. If this metho
d returns true, |
| 56 // it is guaranteed that we're in the main world. On the other hand, if this
method returns | 56 // it is guaranteed that we're in the main world. On the other hand, if this
method returns |
| 57 // false, nothing is guaranteed (we might be in the main world). | 57 // false, nothing is guaranteed (we might be in the main world). |
| 58 template<typename T> | 58 template<typename T> |
| 59 static bool canUseScriptWrappable(T* object) | 59 static bool canUseScriptWrappable(T* object) |
| 60 { | 60 { |
| 61 return !DOMWrapperWorld::isolatedWorldsExist() | 61 return ScriptWrappable::wrapperCanBeStoredInObject(object); |
| 62 && ScriptWrappable::wrapperCanBeStoredInObject(object); | |
| 63 } | 62 } |
| 64 | 63 |
| 65 static bool canUseScriptWrappableNonTemplate(Node* object) | 64 static bool canUseScriptWrappableNonTemplate(Node* object) |
| 66 { | 65 { |
| 67 return !DOMWrapperWorld::isolatedWorldsExist(); | 66 return true; |
| 68 } | 67 } |
| 69 | 68 |
| 70 template<typename V8T, typename T, typename Wrappable> | 69 template<typename V8T, typename T, typename Wrappable> |
| 71 static bool setReturnValueFromWrapperFast(v8::ReturnValue<v8::Value> returnV
alue, T* object, v8::Local<v8::Object> holder, Wrappable* wrappable) | 70 static bool setReturnValueFromWrapperFast(v8::ReturnValue<v8::Value> returnV
alue, T* object, v8::Local<v8::Object> holder, Wrappable* wrappable) |
| 72 { | 71 { |
| 73 if (canUseScriptWrappable(object)) { | 72 if (canUseScriptWrappable(object)) { |
| 74 ScriptWrappable::assertWrapperSanity<V8T, T>(object, object); | 73 ScriptWrappable::assertWrapperSanity<V8T, T>(object, object); |
| 75 return ScriptWrappable::fromObject(object)->setReturnValue(returnVal
ue); | 74 return ScriptWrappable::fromObject(object)->setReturnValue(returnVal
ue); |
| 76 } | 75 } |
| 77 // The second fastest way to check if we're in the main world is to chec
k if | 76 // The second fastest way to check if we're in the main world is to chec
k if |
| (...skipping 228 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 306 v8::UniquePersistent<v8::Object> value, | 305 v8::UniquePersistent<v8::Object> value, |
| 307 ScriptWrappableBase* key) | 306 ScriptWrappableBase* key) |
| 308 { | 307 { |
| 309 RELEASE_ASSERT(!value.IsEmpty()); // See crbug.com/368095. | 308 RELEASE_ASSERT(!value.IsEmpty()); // See crbug.com/368095. |
| 310 releaseObject(v8::Local<v8::Object>::New(isolate, value)); | 309 releaseObject(v8::Local<v8::Object>::New(isolate, value)); |
| 311 } | 310 } |
| 312 | 311 |
| 313 } // namespace blink | 312 } // namespace blink |
| 314 | 313 |
| 315 #endif // SKY_ENGINE_BINDINGS_CORE_V8_DOMDATASTORE_H_ | 314 #endif // SKY_ENGINE_BINDINGS_CORE_V8_DOMDATASTORE_H_ |
| OLD | NEW |