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

Side by Side Diff: webkit/port/bindings/v8/v8_proxy.cpp

Issue 17053: Ensure that constructor functions are created in the context of the... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 11 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
OLDNEW
1 // Copyright (c) 2008, Google Inc. 1 // Copyright (c) 2008, Google Inc.
2 // All rights reserved. 2 // 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 1442 matching lines...) Expand 10 before | Expand all | Expand 10 after
1453 { 1453 {
1454 ASSERT(ContextInitialized()); 1454 ASSERT(ContextInitialized());
1455 v8::Local<v8::Value> cached = 1455 v8::Local<v8::Value> cached =
1456 m_dom_constructor_cache->Get(v8::Integer::New(V8ClassIndex::ToInt(t))); 1456 m_dom_constructor_cache->Get(v8::Integer::New(V8ClassIndex::ToInt(t)));
1457 if (cached->IsFunction()) { 1457 if (cached->IsFunction()) {
1458 return v8::Local<v8::Function>::Cast(cached); 1458 return v8::Local<v8::Function>::Cast(cached);
1459 } 1459 }
1460 1460
1461 // Not in cache. 1461 // Not in cache.
1462 { 1462 {
1463 // Enter the context of the proxy to make sure that the
1464 // function is constructed in the context corresponding to
1465 // this proxy.
1466 v8::Context::Scope scope(m_context);
1463 v8::Handle<v8::FunctionTemplate> templ = GetTemplate(t); 1467 v8::Handle<v8::FunctionTemplate> templ = GetTemplate(t);
1468 // Getting the function might fail if we're running out of
1469 // stack or memory.
1464 v8::TryCatch try_catch; 1470 v8::TryCatch try_catch;
1465 // This might fail if we're running out of stack or memory.
1466 v8::Local<v8::Function> value = templ->GetFunction(); 1471 v8::Local<v8::Function> value = templ->GetFunction();
1467 if (value.IsEmpty()) 1472 if (value.IsEmpty())
1468 return v8::Local<v8::Function>(); 1473 return v8::Local<v8::Function>();
1469 m_dom_constructor_cache->Set(v8::Integer::New(t), value); 1474 m_dom_constructor_cache->Set(v8::Integer::New(t), value);
1470 // Hotmail fix, see comments in v8_proxy.h above 1475 // Hotmail fix, see comments in v8_proxy.h above
1471 // m_dom_constructor_cache. 1476 // m_dom_constructor_cache.
1472 value->Set(v8::String::New("__proto__"), m_object_prototype); 1477 value->Set(v8::String::New("__proto__"), m_object_prototype);
1473 return value; 1478 return value;
1474 } 1479 }
1475 } 1480 }
(...skipping 293 matching lines...) Expand 10 before | Expand all | Expand 10 after
1769 // JS world, but we setup the constructor function lazily in 1774 // JS world, but we setup the constructor function lazily in
1770 // WindowNamedPropertyHandler::get. 1775 // WindowNamedPropertyHandler::get.
1771 case V8ClassIndex::DOMPARSER: 1776 case V8ClassIndex::DOMPARSER:
1772 desc->SetCallHandler(USE_CALLBACK(DOMParserConstructor)); 1777 desc->SetCallHandler(USE_CALLBACK(DOMParserConstructor));
1773 break; 1778 break;
1774 case V8ClassIndex::XMLSERIALIZER: 1779 case V8ClassIndex::XMLSERIALIZER:
1775 desc->SetCallHandler(USE_CALLBACK(XMLSerializerConstructor)); 1780 desc->SetCallHandler(USE_CALLBACK(XMLSerializerConstructor));
1776 break; 1781 break;
1777 case V8ClassIndex::XMLHTTPREQUEST: { 1782 case V8ClassIndex::XMLHTTPREQUEST: {
1778 // Reserve one more internal field for keeping event listeners. 1783 // Reserve one more internal field for keeping event listeners.
1779 v8::Local<v8::ObjectTemplate> instance_template = 1784 v8::Local<v8::ObjectTemplate> instance_template =
1780 desc->InstanceTemplate(); 1785 desc->InstanceTemplate();
1781 instance_template->SetInternalFieldCount( 1786 instance_template->SetInternalFieldCount(
1782 V8Custom::kXMLHttpRequestInternalFieldCount); 1787 V8Custom::kXMLHttpRequestInternalFieldCount);
1783 desc->SetCallHandler(USE_CALLBACK(XMLHttpRequestConstructor)); 1788 desc->SetCallHandler(USE_CALLBACK(XMLHttpRequestConstructor));
1784 break; 1789 break;
1785 } 1790 }
1786 case V8ClassIndex::XMLHTTPREQUESTUPLOAD: { 1791 case V8ClassIndex::XMLHTTPREQUESTUPLOAD: {
1787 // Reserve one more internal field for keeping event listeners. 1792 // Reserve one more internal field for keeping event listeners.
1788 v8::Local<v8::ObjectTemplate> instance_template = 1793 v8::Local<v8::ObjectTemplate> instance_template =
1789 desc->InstanceTemplate(); 1794 desc->InstanceTemplate();
1790 instance_template->SetInternalFieldCount( 1795 instance_template->SetInternalFieldCount(
1791 V8Custom::kXMLHttpRequestInternalFieldCount); 1796 V8Custom::kXMLHttpRequestInternalFieldCount);
1792 break; 1797 break;
1793 } 1798 }
1794 case V8ClassIndex::XPATHEVALUATOR: 1799 case V8ClassIndex::XPATHEVALUATOR:
(...skipping 1663 matching lines...) Expand 10 before | Expand all | Expand 10 after
3458 v8::Handle<v8::Function> frame_source_name; 3463 v8::Handle<v8::Function> frame_source_name;
3459 frame_source_name = v8::Local<v8::Function>::Cast( 3464 frame_source_name = v8::Local<v8::Function>::Cast(
3460 utility_context->Global()->Get(v8::String::New("frame_source_name"))); 3465 utility_context->Global()->Get(v8::String::New("frame_source_name")));
3461 if (frame_source_name.IsEmpty()) { 3466 if (frame_source_name.IsEmpty()) {
3462 return String(); 3467 return String();
3463 } 3468 }
3464 return ToWebCoreString(v8::Debug::Call(frame_source_name)); 3469 return ToWebCoreString(v8::Debug::Call(frame_source_name));
3465 } 3470 }
3466 3471
3467 } // namespace WebCore 3472 } // namespace WebCore
OLDNEW
« no previous file with comments | « webkit/port/bindings/scripts/CodeGeneratorV8.pm ('k') | webkit/tools/layout_tests/test_lists/tests_fixable.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698