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

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

Issue 2690943002: Revert of binding: Changes the association among global-proxy/global/window-instance. (Closed)
Patch Set: 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 --------+
219 207
220 DOMWindow* window = m_frame->domWindow(); 208 DOMWindow* window = m_frame->domWindow();
221 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo(); 209 const WrapperTypeInfo* wrapperTypeInfo = window->wrapperTypeInfo();
222 v8::Local<v8::Context> context = m_scriptState->context(); 210 v8::Local<v8::Context> context = m_scriptState->context();
223 211
224 // The global proxy object. Note this is not the global object. 212 // The global proxy object. Note this is not the global object.
225 v8::Local<v8::Object> globalProxy = context->Global(); 213 v8::Local<v8::Object> globalProxy = context->Global();
226 CHECK(m_globalProxy == globalProxy); 214 CHECK(m_globalProxy == globalProxy);
227 v8::Local<v8::Object> associatedWrapper = 215 V8DOMWrapper::setNativeInfo(m_isolate, globalProxy, wrapperTypeInfo, window);
228 V8DOMWrapper::associateObjectWithWrapper(
229 m_isolate, window, wrapperTypeInfo, globalProxy);
230 CHECK(globalProxy == associatedWrapper);
231 // Mark the handle to be traced by Oilpan, since the global proxy has a 216 // Mark the handle to be traced by Oilpan, since the global proxy has a
232 // reference to the DOMWindow. 217 // reference to the DOMWindow.
233 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId); 218 m_globalProxy.get().SetWrapperClassId(wrapperTypeInfo->wrapperClassId);
234 219
235 // The global object, aka window wrapper object. 220 // The global object, aka window wrapper object.
236 v8::Local<v8::Object> windowWrapper = 221 v8::Local<v8::Object> windowWrapper =
237 globalProxy->GetPrototype().As<v8::Object>(); 222 globalProxy->GetPrototype().As<v8::Object>();
238 V8DOMWrapper::setNativeInfo(m_isolate, windowWrapper, wrapperTypeInfo, 223 windowWrapper = V8DOMWrapper::associateObjectWithWrapper(
239 window); 224 m_isolate, window, wrapperTypeInfo, windowWrapper);
240 225
241 // The prototype object of Window interface. 226 // The prototype object of Window interface.
242 v8::Local<v8::Object> windowPrototype = 227 v8::Local<v8::Object> windowPrototype =
243 windowWrapper->GetPrototype().As<v8::Object>(); 228 windowWrapper->GetPrototype().As<v8::Object>();
244 CHECK(!windowPrototype.IsEmpty()); 229 CHECK(!windowPrototype.IsEmpty());
245 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo, 230 V8DOMWrapper::setNativeInfo(m_isolate, windowPrototype, wrapperTypeInfo,
246 window); 231 window);
247 232
248 // The named properties object of Window interface. 233 // The named properties object of Window interface.
249 v8::Local<v8::Object> windowProperties = 234 v8::Local<v8::Object> windowProperties =
250 windowPrototype->GetPrototype().As<v8::Object>(); 235 windowPrototype->GetPrototype().As<v8::Object>();
251 CHECK(!windowProperties.IsEmpty()); 236 CHECK(!windowProperties.IsEmpty());
252 V8DOMWrapper::setNativeInfo(m_isolate, windowProperties, wrapperTypeInfo, 237 V8DOMWrapper::setNativeInfo(m_isolate, windowProperties, wrapperTypeInfo,
253 window); 238 window);
254 239
255 // TODO(keishi): Remove installPagePopupController and implement 240 // TODO(keishi): Remove installPagePopupController and implement
256 // PagePopupController in another way. 241 // PagePopupController in another way.
257 V8PagePopupControllerBinding::installPagePopupController(context, 242 V8PagePopupControllerBinding::installPagePopupController(context,
258 windowWrapper); 243 windowWrapper);
259 } 244 }
260 245
261 } // namespace blink 246 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698