| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2008, 2009, 2011 Google Inc. All rights reserved. | 2 * Copyright (C) 2008, 2009, 2011 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 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 64 #include "wtf/text/CString.h" | 64 #include "wtf/text/CString.h" |
| 65 #include <algorithm> | 65 #include <algorithm> |
| 66 #include <utility> | 66 #include <utility> |
| 67 #include <v8-debug.h> | 67 #include <v8-debug.h> |
| 68 #include <v8.h> | 68 #include <v8.h> |
| 69 | 69 |
| 70 namespace blink { | 70 namespace blink { |
| 71 | 71 |
| 72 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum
ent) | 72 static void checkDocumentWrapper(v8::Handle<v8::Object> wrapper, Document* docum
ent) |
| 73 { | 73 { |
| 74 ASSERT(V8Document::toNative(wrapper) == document); | 74 ASSERT(V8Document::toImpl(wrapper) == document); |
| 75 ASSERT(!document->isHTMLDocument() || (V8Document::toNative(v8::Handle<v8::O
bject>::Cast(wrapper->GetPrototype())) == document)); | 75 ASSERT(!document->isHTMLDocument() || (V8Document::toImpl(v8::Handle<v8::Obj
ect>::Cast(wrapper->GetPrototype())) == document)); |
| 76 } | 76 } |
| 77 | 77 |
| 78 PassOwnPtr<WindowProxy> WindowProxy::create(LocalFrame* frame, DOMWrapperWorld&
world, v8::Isolate* isolate) | 78 PassOwnPtr<WindowProxy> WindowProxy::create(LocalFrame* frame, DOMWrapperWorld&
world, v8::Isolate* isolate) |
| 79 { | 79 { |
| 80 return adoptPtr(new WindowProxy(frame, &world, isolate)); | 80 return adoptPtr(new WindowProxy(frame, &world, isolate)); |
| 81 } | 81 } |
| 82 | 82 |
| 83 WindowProxy::WindowProxy(LocalFrame* frame, PassRefPtr<DOMWrapperWorld> world, v
8::Isolate* isolate) | 83 WindowProxy::WindowProxy(LocalFrame* frame, PassRefPtr<DOMWrapperWorld> world, v
8::Isolate* isolate) |
| 84 : m_frame(frame) | 84 : m_frame(frame) |
| 85 , m_isolate(isolate) | 85 , m_isolate(isolate) |
| (...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 278 return v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype()); | 278 return v8::Handle<v8::Object>::Cast(context->Global()->GetPrototype()); |
| 279 } | 279 } |
| 280 | 280 |
| 281 bool WindowProxy::installDOMWindow() | 281 bool WindowProxy::installDOMWindow() |
| 282 { | 282 { |
| 283 LocalDOMWindow* window = m_frame->domWindow(); | 283 LocalDOMWindow* window = m_frame->domWindow(); |
| 284 v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(m_iso
late, m_scriptState->perContextData()->constructorForType(&V8Window::wrapperType
Info)); | 284 v8::Local<v8::Object> windowWrapper = V8ObjectConstructor::newInstance(m_iso
late, m_scriptState->perContextData()->constructorForType(&V8Window::wrapperType
Info)); |
| 285 if (windowWrapper.IsEmpty()) | 285 if (windowWrapper.IsEmpty()) |
| 286 return false; | 286 return false; |
| 287 | 287 |
| 288 V8DOMWrapper::setNativeInfoForHiddenWrapper(v8::Handle<v8::Object>::Cast(win
dowWrapper->GetPrototype()), &V8Window::wrapperTypeInfo, V8Window::toInternalPoi
nter(window)); | 288 V8DOMWrapper::setNativeInfoForHiddenWrapper(v8::Handle<v8::Object>::Cast(win
dowWrapper->GetPrototype()), &V8Window::wrapperTypeInfo, window->toScriptWrappab
leBase()); |
| 289 | 289 |
| 290 // Install the windowWrapper as the prototype of the innerGlobalObject. | 290 // Install the windowWrapper as the prototype of the innerGlobalObject. |
| 291 // The full structure of the global object is as follows: | 291 // The full structure of the global object is as follows: |
| 292 // | 292 // |
| 293 // outerGlobalObject (Empty object, remains after navigation) | 293 // outerGlobalObject (Empty object, remains after navigation) |
| 294 // -- has prototype --> innerGlobalObject (Holds global variables, changes
during navigation) | 294 // -- has prototype --> innerGlobalObject (Holds global variables, changes
during navigation) |
| 295 // -- has prototype --> LocalDOMWindow instance | 295 // -- has prototype --> LocalDOMWindow instance |
| 296 // -- has prototype --> Window.prototype | 296 // -- has prototype --> Window.prototype |
| 297 // -- has prototype --> Object.prototype | 297 // -- has prototype --> Object.prototype |
| 298 // | 298 // |
| 299 // Note: Much of this prototype structure is hidden from web content. The | 299 // Note: Much of this prototype structure is hidden from web content. The |
| 300 // outer, inner, and LocalDOMWindow instance all appear to be the same | 300 // outer, inner, and LocalDOMWindow instance all appear to be the same |
| 301 // JavaScript object. | 301 // JavaScript object. |
| 302 // | 302 // |
| 303 // Note: With Oilpan, the LocalDOMWindow object is garbage collected. | 303 // Note: With Oilpan, the LocalDOMWindow object is garbage collected. |
| 304 // Persistent references to this inner global object view of the Local
DOMWindow | 304 // Persistent references to this inner global object view of the Local
DOMWindow |
| 305 // aren't kept, as that would prevent the global object from ever bein
g released. | 305 // aren't kept, as that would prevent the global object from ever bein
g released. |
| 306 // It is safe not to do so, as the wrapper for the LocalDOMWindow bein
g installed here | 306 // It is safe not to do so, as the wrapper for the LocalDOMWindow bein
g installed here |
| 307 // already keeps a persistent reference, and it along with the inner g
lobal object | 307 // already keeps a persistent reference, and it along with the inner g
lobal object |
| 308 // views of the LocalDOMWindow will die together once that wrapper cle
ars the persistent | 308 // views of the LocalDOMWindow will die together once that wrapper cle
ars the persistent |
| 309 // reference. | 309 // reference. |
| 310 v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_scriptState
->context()); | 310 v8::Handle<v8::Object> innerGlobalObject = toInnerGlobalObject(m_scriptState
->context()); |
| 311 V8DOMWrapper::setNativeInfoForHiddenWrapper(innerGlobalObject, &V8Window::wr
apperTypeInfo, V8Window::toInternalPointer(window)); | 311 V8DOMWrapper::setNativeInfoForHiddenWrapper(innerGlobalObject, &V8Window::wr
apperTypeInfo, window->toScriptWrappableBase()); |
| 312 innerGlobalObject->SetPrototype(windowWrapper); | 312 innerGlobalObject->SetPrototype(windowWrapper); |
| 313 V8DOMWrapper::associateObjectWithWrapper<V8Window>(PassRefPtrWillBeRawPtr<Lo
calDOMWindow>(window), &V8Window::wrapperTypeInfo, windowWrapper, m_isolate); | 313 V8DOMWrapper::associateObjectWithWrapper<V8Window>(PassRefPtrWillBeRawPtr<Lo
calDOMWindow>(window), &V8Window::wrapperTypeInfo, windowWrapper, m_isolate); |
| 314 V8Window::installConditionallyEnabledProperties(windowWrapper, m_isolate); | 314 V8Window::installConditionallyEnabledProperties(windowWrapper, m_isolate); |
| 315 return true; | 315 return true; |
| 316 } | 316 } |
| 317 | 317 |
| 318 void WindowProxy::updateDocumentWrapper(v8::Handle<v8::Object> wrapper) | 318 void WindowProxy::updateDocumentWrapper(v8::Handle<v8::Object> wrapper) |
| 319 { | 319 { |
| 320 ASSERT(m_world->isMainWorld()); | 320 ASSERT(m_world->isMainWorld()); |
| 321 m_document.set(m_isolate, wrapper); | 321 m_document.set(m_isolate, wrapper); |
| (...skipping 108 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 430 return toV8(frame->domWindow(), creationContext, isolate); | 430 return toV8(frame->domWindow(), creationContext, isolate); |
| 431 return toV8(element, creationContext, isolate); | 431 return toV8(element, creationContext, isolate); |
| 432 } | 432 } |
| 433 return toV8(PassRefPtrWillBeRawPtr<HTMLCollection>(items.release()), creatio
nContext, isolate); | 433 return toV8(PassRefPtrWillBeRawPtr<HTMLCollection>(items.release()), creatio
nContext, isolate); |
| 434 } | 434 } |
| 435 | 435 |
| 436 static void getter(v8::Local<v8::String> property, const v8::PropertyCallbackInf
o<v8::Value>& info) | 436 static void getter(v8::Local<v8::String> property, const v8::PropertyCallbackInf
o<v8::Value>& info) |
| 437 { | 437 { |
| 438 // FIXME: Consider passing StringImpl directly. | 438 // FIXME: Consider passing StringImpl directly. |
| 439 AtomicString name = toCoreAtomicString(property); | 439 AtomicString name = toCoreAtomicString(property); |
| 440 HTMLDocument* htmlDocument = V8HTMLDocument::toNative(info.Holder()); | 440 HTMLDocument* htmlDocument = V8HTMLDocument::toImpl(info.Holder()); |
| 441 ASSERT(htmlDocument); | 441 ASSERT(htmlDocument); |
| 442 v8::Handle<v8::Value> result = getNamedProperty(htmlDocument, name, info.Hol
der(), info.GetIsolate()); | 442 v8::Handle<v8::Value> result = getNamedProperty(htmlDocument, name, info.Hol
der(), info.GetIsolate()); |
| 443 if (!result.IsEmpty()) { | 443 if (!result.IsEmpty()) { |
| 444 v8SetReturnValue(info, result); | 444 v8SetReturnValue(info, result); |
| 445 return; | 445 return; |
| 446 } | 446 } |
| 447 v8::Handle<v8::Value> prototype = info.Holder()->GetPrototype(); | 447 v8::Handle<v8::Value> prototype = info.Holder()->GetPrototype(); |
| 448 if (prototype->IsObject()) { | 448 if (prototype->IsObject()) { |
| 449 v8SetReturnValue(info, prototype.As<v8::Object>()->Get(property)); | 449 v8SetReturnValue(info, prototype.As<v8::Object>()->Get(property)); |
| 450 return; | 450 return; |
| (...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 484 | 484 |
| 485 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) | 485 void WindowProxy::updateSecurityOrigin(SecurityOrigin* origin) |
| 486 { | 486 { |
| 487 ASSERT(m_world->isMainWorld()); | 487 ASSERT(m_world->isMainWorld()); |
| 488 if (!isContextInitialized()) | 488 if (!isContextInitialized()) |
| 489 return; | 489 return; |
| 490 setSecurityToken(origin); | 490 setSecurityToken(origin); |
| 491 } | 491 } |
| 492 | 492 |
| 493 } // namespace blink | 493 } // namespace blink |
| OLD | NEW |