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

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

Issue 53092: Fix window.history GC issue. Since the history object is not part of... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years, 9 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 | « webkit/port/bindings/v8/v8_custom.h ('k') | webkit/tools/layout_tests/test_expectations.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1805 matching lines...) Expand 10 before | Expand all | Expand 10 after
1816 case V8ClassIndex::DOMWINDOW: { 1816 case V8ClassIndex::DOMWINDOW: {
1817 v8::Local<v8::Signature> default_signature = v8::Signature::New(desc); 1817 v8::Local<v8::Signature> default_signature = v8::Signature::New(desc);
1818 1818
1819 desc->PrototypeTemplate()->SetNamedPropertyHandler( 1819 desc->PrototypeTemplate()->SetNamedPropertyHandler(
1820 USE_NAMED_PROPERTY_GETTER(DOMWindow)); 1820 USE_NAMED_PROPERTY_GETTER(DOMWindow));
1821 desc->PrototypeTemplate()->SetIndexedPropertyHandler( 1821 desc->PrototypeTemplate()->SetIndexedPropertyHandler(
1822 USE_INDEXED_PROPERTY_GETTER(DOMWindow)); 1822 USE_INDEXED_PROPERTY_GETTER(DOMWindow));
1823 1823
1824 desc->SetHiddenPrototype(true); 1824 desc->SetHiddenPrototype(true);
1825 1825
1826 // Reserve spaces for references to location and navigator objects. 1826 // Reserve spaces for references to location, history and
1827 // navigator objects.
1827 v8::Local<v8::ObjectTemplate> instance_template = 1828 v8::Local<v8::ObjectTemplate> instance_template =
1828 desc->InstanceTemplate(); 1829 desc->InstanceTemplate();
1829 instance_template->SetInternalFieldCount( 1830 instance_template->SetInternalFieldCount(
1830 V8Custom::kDOMWindowInternalFieldCount); 1831 V8Custom::kDOMWindowInternalFieldCount);
1831 1832
1832 // Set access check callbacks, but turned off initially. 1833 // Set access check callbacks, but turned off initially.
1833 // When a context is detached from a frame, turn on the access check. 1834 // When a context is detached from a frame, turn on the access check.
1834 // Turning on checks also invalidates inline caches of the object. 1835 // Turning on checks also invalidates inline caches of the object.
1835 instance_template->SetAccessCheckCallbacks( 1836 instance_template->SetAccessCheckCallbacks(
1836 V8Custom::v8DOMWindowNamedSecurityCheck, 1837 V8Custom::v8DOMWindowNamedSecurityCheck,
(...skipping 809 matching lines...) Expand 10 before | Expand all | Expand 10 after
2646 #undef MAKE_CASE 2647 #undef MAKE_CASE
2647 default: 2648 default:
2648 ASSERT(false); 2649 ASSERT(false);
2649 } 2650 }
2650 result = v8::Persistent<v8::Object>::New(v8obj); 2651 result = v8::Persistent<v8::Object>::New(v8obj);
2651 if (is_active_dom_object) 2652 if (is_active_dom_object)
2652 SetJSWrapperForActiveDOMObject(imp, result); 2653 SetJSWrapperForActiveDOMObject(imp, result);
2653 else 2654 else
2654 SetJSWrapperForDOMObject(imp, result); 2655 SetJSWrapperForDOMObject(imp, result);
2655 2656
2656 // Special case for Location and Navigator. Both Safari and FF let 2657 // Special case for non-node objects History, Location and
2657 // Location and Navigator JS wrappers survive GC. To mimic their 2658 // Navigator. Both Safari and FF let Location and Navigator JS
2658 // behaviors, V8 creates hidden references from the DOMWindow to 2659 // wrappers survive GC. To mimic their behaviors, V8 creates
2659 // location and navigator objects. These references get cleared 2660 // hidden references from the DOMWindow to these wrapper
2660 // when the DOMWindow is reused by a new page. 2661 // objects. These references get cleared when the DOMWindow is
2661 if (type == V8ClassIndex::LOCATION) { 2662 // reused by a new page.
2662 SetHiddenWindowReference(static_cast<Location*>(imp)->frame(), 2663 switch (type) {
2663 V8Custom::kDOMWindowLocationIndex, result); 2664 case V8ClassIndex::HISTORY:
2664 } else if (type == V8ClassIndex::NAVIGATOR) { 2665 SetHiddenWindowReference(static_cast<History*>(imp)->frame(),
2665 SetHiddenWindowReference(static_cast<Navigator*>(imp)->frame(), 2666 V8Custom::kDOMWindowHistoryIndex, result);
2666 V8Custom::kDOMWindowNavigatorIndex, result); 2667 break;
2668 case V8ClassIndex::NAVIGATOR:
2669 SetHiddenWindowReference(static_cast<Navigator*>(imp)->frame(),
2670 V8Custom::kDOMWindowNavigatorIndex, result);
2671 break;
2672 case V8ClassIndex::LOCATION:
2673 SetHiddenWindowReference(static_cast<Location*>(imp)->frame(),
2674 V8Custom::kDOMWindowLocationIndex, result);
2675 break;
2676 default:
2677 break;
2667 } 2678 }
2668 } 2679 }
2669 } 2680 }
2670 return result; 2681 return result;
2671 } 2682 }
2672 2683
2673 2684
2674 void V8Proxy::SetHiddenWindowReference(Frame* frame, 2685 void V8Proxy::SetHiddenWindowReference(Frame* frame,
2675 const int internal_index, 2686 const int internal_index,
2676 v8::Handle<v8::Object> jsobj) 2687 v8::Handle<v8::Object> jsobj)
(...skipping 934 matching lines...) Expand 10 before | Expand all | Expand 10 after
3611 } 3622 }
3612 3623
3613 void V8Proxy::RegisterExtension(v8::Extension* extension, 3624 void V8Proxy::RegisterExtension(v8::Extension* extension,
3614 const String& schemeRestriction) { 3625 const String& schemeRestriction) {
3615 v8::RegisterExtension(extension); 3626 v8::RegisterExtension(extension);
3616 V8ExtensionInfo info = {schemeRestriction, extension}; 3627 V8ExtensionInfo info = {schemeRestriction, extension};
3617 m_extensions.push_back(info); 3628 m_extensions.push_back(info);
3618 } 3629 }
3619 3630
3620 } // namespace WebCore 3631 } // namespace WebCore
OLDNEW
« no previous file with comments | « webkit/port/bindings/v8/v8_custom.h ('k') | webkit/tools/layout_tests/test_expectations.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698