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

Side by Side Diff: Source/bindings/v8/V8Binding.cpp

Issue 14297007: Make DOMWrapperWorlds easier to use (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 8 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 | Annotate | Revision Log
« no previous file with comments | « Source/bindings/v8/DOMWrapperWorld.cpp ('k') | Source/bindings/v8/V8MutationCallback.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 /* 1 /*
2 * Copyright (C) 2006, 2007, 2008, 2009 Google Inc. All rights reserved. 2 * Copyright (C) 2006, 2007, 2008, 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 327 matching lines...) Expand 10 before | Expand all | Expand 10 after
338 } else if (context->isWorkerContext()) { 338 } else if (context->isWorkerContext()) {
339 if (WorkerScriptController* script = static_cast<WorkerContext*>(context )->script()) 339 if (WorkerScriptController* script = static_cast<WorkerContext*>(context )->script())
340 return script->context(); 340 return script->context();
341 } 341 }
342 return v8::Local<v8::Context>(); 342 return v8::Local<v8::Context>();
343 } 343 }
344 344
345 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, DOMWrapperWo rld* world) 345 v8::Local<v8::Context> toV8Context(ScriptExecutionContext* context, DOMWrapperWo rld* world)
346 { 346 {
347 if (context->isDocument()) { 347 if (context->isDocument()) {
348 if (Frame* frame = toDocument(context)->frame()) { 348 ASSERT(world);
349 // FIXME: Store the DOMWrapperWorld for the main world in the v8::Co ntext so callers 349 if (Frame* frame = toDocument(context)->frame())
350 // that are looking up their world with DOMWrapperWorld::isolatedWor ld(v8::Context::GetCurrent())
351 // won't end up passing null here when later trying to get their v8: :Context back.
352 if (!world)
353 return frame->script()->mainWorldContext();
354 return v8::Local<v8::Context>::New(frame->script()->windowShell(worl d)->context()); 350 return v8::Local<v8::Context>::New(frame->script()->windowShell(worl d)->context());
355 }
356 } else if (context->isWorkerContext()) { 351 } else if (context->isWorkerContext()) {
352 ASSERT(!world);
357 if (WorkerScriptController* script = static_cast<WorkerContext*>(context )->script()) 353 if (WorkerScriptController* script = static_cast<WorkerContext*>(context )->script())
358 return script->context(); 354 return script->context();
359 } 355 }
360 return v8::Local<v8::Context>(); 356 return v8::Local<v8::Context>();
361 } 357 }
362 358
363 bool handleOutOfMemory() 359 bool handleOutOfMemory()
364 { 360 {
365 v8::Local<v8::Context> context = v8::Context::GetCurrent(); 361 v8::Local<v8::Context> context = v8::Context::GetCurrent();
366 362
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
409 if (!DOMWrapperWorld::isolatedWorldsExist()) 405 if (!DOMWrapperWorld::isolatedWorldsExist())
410 return MainWorld; 406 return MainWorld;
411 ASSERT(!v8::Context::GetEntered().IsEmpty()); 407 ASSERT(!v8::Context::GetEntered().IsEmpty());
412 DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolatedWorld(v8::Context: :GetEntered()); 408 DOMWrapperWorld* isolatedWorld = DOMWrapperWorld::isolatedWorld(v8::Context: :GetEntered());
413 if (isolatedWorld) 409 if (isolatedWorld)
414 return IsolatedWorld; 410 return IsolatedWorld;
415 return MainWorld; 411 return MainWorld;
416 } 412 }
417 413
418 } // namespace WebCore 414 } // namespace WebCore
OLDNEW
« no previous file with comments | « Source/bindings/v8/DOMWrapperWorld.cpp ('k') | Source/bindings/v8/V8MutationCallback.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698