Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(113)

Side by Side Diff: third_party/WebKit/Source/bindings/core/v8/WindowProxy.cpp

Issue 2617733004: binding: Changes the association among global-proxy/global/window-instance. (Closed)
Patch Set: Fixed Document.defaultView Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
197 // object is NOT observable from user JavaScript code. All other 197 // object is NOT observable from user JavaScript code. All other
198 // prototype chains are observable. Global proxy object and global object 198 // prototype chains are observable. Global proxy object and global object
199 // together appear to be the same single JavaScript object. See also: 199 // together appear to be the same single JavaScript object. See also:
200 // https://wiki.mozilla.org/Gecko:SplitWindow 200 // https://wiki.mozilla.org/Gecko:SplitWindow
201 // global object (= window wrapper object) provides most of Window's DOM 201 // global object (= window wrapper object) provides most of Window's DOM
202 // attributes and operations. Also global variables defined by user 202 // attributes and operations. Also global variables defined by user
203 // JavaScript are placed on this object. When navigated, a new global 203 // JavaScript are placed on this object. When navigated, a new global
204 // object is created together with a new v8::Context, but the global proxy 204 // object is created together with a new v8::Context, but the global proxy
205 // object doesn't change. 205 // object doesn't change.
206 // [3] WindowProperties is a named properties object of Window interface. 206 // [3] WindowProperties is a named properties object of Window interface.
207 //
208 // Note that the wrapper object of a DOMWindow is the global proxy object, not
209 // the global object, although both of them have the internal field which
210 // points to the DOMWindow. Since the global proxy object remains the same
211 // while navigations, the management of the wrapper association for DOMWindow
212 // is special compared to other objects. See DOMWindow::~DOMWindow for the
213 // need of dissociation of the wrappers from DOMWindow instance.
214 //
215 // global proxy object <====> DOMWindow instance
216 // ^
217 // |
218 // global object --------+
207 219
208 DOMWindow* window = m_frame->domWindow(); 220 DOMWindow* window = m_frame->domWindow();
209 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); 221 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo();
210 v8::Local<v8::Context> context = m_scriptState->context(); 222 v8::Local<v8::Context> context = m_scriptState->context();
211 223
212 // The global proxy object. Note this is not the global object. 224 // The global proxy object. Note this is not the global object.
213 v8::Local<v8::Object> globalProxy = context->Global(); 225 v8::Local<v8::Object> globalProxy = context->Global();
214 CHECK(m_globalProxy == globalProxy); 226 CHECK(m_globalProxy == globalProxy);
215 V8DOMWrapper::setNativeInfo(m_isolate, globalProxy, wrapperTypeInfo, window); 227 v8::Local<v8::Object> associatedWrapper =
228 V8DOMWrapper::associateObjectWithWrapper(
229 m_isolate, window, wrapperTypeInfo, globalProxy);
230 CHECK(globalProxy == associatedWrapper);
216 // Mark the handle to be traced by Oilpan, since the global proxy has a 231 // Mark the handle to be traced by Oilpan, since the global proxy has a
217 // reference to the DOMWindow. 232 // reference to the DOMWindow.
218 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId); 233 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId);
219 234
220 // The global object, aka window wrapper object. 235 // The global object, aka window wrapper object.
221 v8::Local<v8::Object> windowWrapper = 236 v8::Local<v8::Object> windowWrapper =
222 globalProxy->GetPrototype().As<v8::Object>(); 237 globalProxy->GetPrototype().As<v8::Object>();
223 windowWrapper = V8DOMWrapper::associateObjectWithWrapper( 238 V8DOMWrapper::setNativeInfo(m_isolate, windowWrapper, wrapperTypeInfo,
224 m_isolate, window, wrapperTypeInfo, windowWrapper); 239 window);
225 240
226 // The prototype object of Window interface. 241 // The prototype object of Window interface.
227 v8::Local<v8::Object> windowPrototype = 242 v8::Local<v8::Object> windowPrototype =
228 windowWrapper->GetPrototype().As<v8::Object>(); 243 windowWrapper->GetPrototype().As<v8::Object>();
229 CHECK(!windowPrototype.IsEmpty()); 244 CHECK(!windowPrototype.IsEmpty());
230 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo, 245 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo,
231 window); 246 window);
232 247
233 // The named properties object of Window interface. 248 // The named properties object of Window interface.
234 v8::Local<v8::Object> windowProperties = 249 v8::Local<v8::Object> windowProperties =
235 windowPrototype->GetPrototype().As<v8::Object>(); 250 windowPrototype->GetPrototype().As<v8::Object>();
236 CHECK(!windowProperties.IsEmpty()); 251 CHECK(!windowProperties.IsEmpty());
237 V8DOMWrapper::setNativeInfo(m_isolate, windowProperties, wrapperTypeInfo, 252 V8DOMWrapper::setNativeInfo(m_isolate, windowProperties, wrapperTypeInfo,
238 window); 253 window);
239 254
240 // TODO(keishi): Remove installPagePopupController and implement 255 // TODO(keishi): Remove installPagePopupController and implement
241 // PagePopupController in another way. 256 // PagePopupController in another way.
242 V8PagePopupControllerBinding::installPagePopupController(context, 257 V8PagePopupControllerBinding::installPagePopupController(context,
243 windowWrapper); 258 windowWrapper);
244 } 259 }
245 260
246 } // namespace blink 261 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698