| 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 13 matching lines...) Expand all Loading... |
| 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | 24 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, |
| 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | 25 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY |
| 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | 26 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT |
| 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 27 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
| 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
| 29 */ | 29 */ |
| 30 | 30 |
| 31 #include "config.h" | 31 #include "config.h" |
| 32 #include "bindings/v8/DOMWrapperWorld.h" | 32 #include "bindings/v8/DOMWrapperWorld.h" |
| 33 | 33 |
| 34 #include "V8DOMWindow.h" | 34 #include "V8Window.h" |
| 35 #include "bindings/v8/DOMDataStore.h" | 35 #include "bindings/v8/DOMDataStore.h" |
| 36 #include "bindings/v8/V8Binding.h" | 36 #include "bindings/v8/V8Binding.h" |
| 37 #include "bindings/v8/V8DOMActivityLogger.h" | 37 #include "bindings/v8/V8DOMActivityLogger.h" |
| 38 #include "bindings/v8/V8DOMWrapper.h" | 38 #include "bindings/v8/V8DOMWrapper.h" |
| 39 #include "bindings/v8/WrapperTypeInfo.h" | 39 #include "bindings/v8/WrapperTypeInfo.h" |
| 40 #include "core/dom/ScriptExecutionContext.h" | 40 #include "core/dom/ScriptExecutionContext.h" |
| 41 #include "wtf/HashTraits.h" | 41 #include "wtf/HashTraits.h" |
| 42 #include "wtf/MainThread.h" | 42 #include "wtf/MainThread.h" |
| 43 #include "wtf/StdLibExtras.h" | 43 #include "wtf/StdLibExtras.h" |
| 44 | 44 |
| (...skipping 17 matching lines...) Expand all Loading... |
| 62 , m_extensionGroup(extensionGroup) | 62 , m_extensionGroup(extensionGroup) |
| 63 { | 63 { |
| 64 if (isIsolatedWorld()) | 64 if (isIsolatedWorld()) |
| 65 m_domDataStore = adoptPtr(new DOMDataStore(IsolatedWorld)); | 65 m_domDataStore = adoptPtr(new DOMDataStore(IsolatedWorld)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 DOMWrapperWorld* DOMWrapperWorld::current() | 68 DOMWrapperWorld* DOMWrapperWorld::current() |
| 69 { | 69 { |
| 70 ASSERT(v8::Context::InContext()); | 70 ASSERT(v8::Context::InContext()); |
| 71 v8::Handle<v8::Context> context = v8::Context::GetCurrent(); | 71 v8::Handle<v8::Context> context = v8::Context::GetCurrent(); |
| 72 if (!V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWindo
w::info)) | 72 if (!V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8Window::
info)) |
| 73 return 0; | 73 return 0; |
| 74 ASSERT(isMainThread()); | 74 ASSERT(isMainThread()); |
| 75 if (DOMWrapperWorld* world = isolatedWorld(context)) | 75 if (DOMWrapperWorld* world = isolatedWorld(context)) |
| 76 return world; | 76 return world; |
| 77 return mainThreadNormalWorld(); | 77 return mainThreadNormalWorld(); |
| 78 } | 78 } |
| 79 | 79 |
| 80 DOMWrapperWorld* mainThreadNormalWorld() | 80 DOMWrapperWorld* mainThreadNormalWorld() |
| 81 { | 81 { |
| 82 ASSERT(isMainThread()); | 82 ASSERT(isMainThread()); |
| 83 DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedNormalWorld, (DOMWrapperW
orld::createMainWorld())); | 83 DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, cachedNormalWorld, (DOMWrapperW
orld::createMainWorld())); |
| 84 return cachedNormalWorld.get(); | 84 return cachedNormalWorld.get(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 // FIXME: Remove this function. There is currently an issue with the inspector r
elated to the call to dispatchDidClearWindowObjectInWorld in ScriptController::w
indowShell. | 87 // FIXME: Remove this function. There is currently an issue with the inspector r
elated to the call to dispatchDidClearWindowObjectInWorld in ScriptController::w
indowShell. |
| 88 DOMWrapperWorld* existingWindowShellWorkaroundWorld() | 88 DOMWrapperWorld* existingWindowShellWorkaroundWorld() |
| 89 { | 89 { |
| 90 DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, world, (adoptRef(new DOMWrapper
World(DOMWrapperWorld::mainWorldId - 1, DOMWrapperWorld::mainWorldExtensionGroup
- 1)))); | 90 DEFINE_STATIC_LOCAL(RefPtr<DOMWrapperWorld>, world, (adoptRef(new DOMWrapper
World(DOMWrapperWorld::mainWorldId - 1, DOMWrapperWorld::mainWorldExtensionGroup
- 1)))); |
| 91 return world.get(); | 91 return world.get(); |
| 92 } | 92 } |
| 93 | 93 |
| 94 bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context
) | 94 bool DOMWrapperWorld::contextHasCorrectPrototype(v8::Handle<v8::Context> context
) |
| 95 { | 95 { |
| 96 ASSERT(isMainThread()); | 96 ASSERT(isMainThread()); |
| 97 if (initializingWindow) | 97 if (initializingWindow) |
| 98 return true; | 98 return true; |
| 99 return V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8DOMWin
dow::info); | 99 return V8DOMWrapper::isWrapperOfType(toInnerGlobalObject(context), &V8Window
::info); |
| 100 } | 100 } |
| 101 | 101 |
| 102 void DOMWrapperWorld::setIsolatedWorldField(v8::Handle<v8::Context> context) | 102 void DOMWrapperWorld::setIsolatedWorldField(v8::Handle<v8::Context> context) |
| 103 { | 103 { |
| 104 context->SetAlignedPointerInEmbedderData(v8ContextIsolatedWorld, isMainWorld
() ? 0 : this); | 104 context->SetAlignedPointerInEmbedderData(v8ContextIsolatedWorld, isMainWorld
() ? 0 : this); |
| 105 } | 105 } |
| 106 | 106 |
| 107 typedef HashMap<int, DOMWrapperWorld*> WorldMap; | 107 typedef HashMap<int, DOMWrapperWorld*> WorldMap; |
| 108 static WorldMap& isolatedWorldMap() | 108 static WorldMap& isolatedWorldMap() |
| 109 { | 109 { |
| (...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 237 } | 237 } |
| 238 | 238 |
| 239 V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId) | 239 V8DOMActivityLogger* DOMWrapperWorld::activityLogger(int worldId) |
| 240 { | 240 { |
| 241 DOMActivityLoggerMap& loggers = domActivityLoggers(); | 241 DOMActivityLoggerMap& loggers = domActivityLoggers(); |
| 242 DOMActivityLoggerMap::iterator it = loggers.find(worldId); | 242 DOMActivityLoggerMap::iterator it = loggers.find(worldId); |
| 243 return it == loggers.end() ? 0 : it->value.get(); | 243 return it == loggers.end() ? 0 : it->value.get(); |
| 244 } | 244 } |
| 245 | 245 |
| 246 } // namespace WebCore | 246 } // namespace WebCore |
| OLD | NEW |