зеркало из https://github.com/mozilla/pjs.git
Fix for bug 373219 (ASSERTION: Fault in cycle collector: null XPCOM pointer returned (ptr: 0)). r/sr=dbaron.
This commit is contained in:
Родитель
f581a0f0e6
Коммит
9ed7625526
|
@ -1,389 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Stephen Lamm <slamm@netscape.com>
|
||||
* Robert John Churchill <rjc@netscape.com>
|
||||
* David Hyatt <hyatt@mozilla.org>
|
||||
* Christopher A. Aillon <christopher@aillon.com>
|
||||
* Myk Melez <myk@mozilla.org>
|
||||
* Pamela Greene <pamg.bugs@gmail.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
/*
|
||||
* No magic constructor behaviour, as is de rigeur for XPCOM.
|
||||
* If you must perform some initialization, and it could possibly fail (even
|
||||
* due to an out-of-memory condition), you should use an Init method, which
|
||||
* can convey failure appropriately (thrown exception in JS,
|
||||
* NS_FAILED(nsresult) return in C++).
|
||||
*
|
||||
* In JS, you can actually cheat, because a thrown exception will cause the
|
||||
* CreateInstance call to fail in turn, but not all languages are so lucky.
|
||||
* (Though ANSI C++ provides exceptions, they are verboten in Mozilla code
|
||||
* for portability reasons -- and even when you're building completely
|
||||
* platform-specific code, you can't throw across an XPCOM method boundary.)
|
||||
*/
|
||||
|
||||
const DEBUG = false; /* set to false to suppress debug messages */
|
||||
|
||||
const SIDEBAR_CONTRACTID = "@mozilla.org/sidebar;1";
|
||||
const SIDEBAR_CID = Components.ID("{22117140-9c6e-11d3-aaf1-00805f8a4905}");
|
||||
const nsISupports = Components.interfaces.nsISupports;
|
||||
const nsIFactory = Components.interfaces.nsIFactory;
|
||||
const nsISidebar = Components.interfaces.nsISidebar;
|
||||
const nsISidebarExternal = Components.interfaces.nsISidebarExternal;
|
||||
const nsIClassInfo = Components.interfaces.nsIClassInfo;
|
||||
|
||||
// File extension for Sherlock search plugin description files
|
||||
const SHERLOCK_FILE_EXT_REGEXP = /\.src$/i;
|
||||
|
||||
function nsSidebar()
|
||||
{
|
||||
const PROMPTSERVICE_CONTRACTID = "@mozilla.org/embedcomp/prompt-service;1";
|
||||
const nsIPromptService = Components.interfaces.nsIPromptService;
|
||||
this.promptService =
|
||||
Components.classes[PROMPTSERVICE_CONTRACTID].getService(nsIPromptService);
|
||||
|
||||
const SEARCHSERVICE_CONTRACTID = "@mozilla.org/browser/search-service;1";
|
||||
const nsIBrowserSearchService = Components.interfaces.nsIBrowserSearchService;
|
||||
this.searchService =
|
||||
Components.classes[SEARCHSERVICE_CONTRACTID].getService(nsIBrowserSearchService);
|
||||
}
|
||||
|
||||
nsSidebar.prototype.nc = "http://home.netscape.com/NC-rdf#";
|
||||
|
||||
function sidebarURLSecurityCheck(url)
|
||||
{
|
||||
if (!/^(https?:|ftp:)/i.test(url)) {
|
||||
Components.utils.reportError("Invalid argument passed to window.sidebar.addPanel: Unsupported panel URL." );
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
/* decorate prototype to provide ``class'' methods and property accessors */
|
||||
nsSidebar.prototype.addPanel =
|
||||
function (aTitle, aContentURL, aCustomizeURL)
|
||||
{
|
||||
debug("addPanel(" + aTitle + ", " + aContentURL + ", " +
|
||||
aCustomizeURL + ")");
|
||||
|
||||
return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL, false);
|
||||
}
|
||||
|
||||
nsSidebar.prototype.addPersistentPanel =
|
||||
function(aTitle, aContentURL, aCustomizeURL)
|
||||
{
|
||||
debug("addPersistentPanel(" + aTitle + ", " + aContentURL + ", " +
|
||||
aCustomizeURL + ")\n");
|
||||
|
||||
return this.addPanelInternal(aTitle, aContentURL, aCustomizeURL, true);
|
||||
}
|
||||
|
||||
nsSidebar.prototype.addPanelInternal =
|
||||
function (aTitle, aContentURL, aCustomizeURL, aPersist)
|
||||
{
|
||||
var WINMEDSVC = Components.classes['@mozilla.org/appshell/window-mediator;1']
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
var win = WINMEDSVC.getMostRecentWindow( "navigator:browser" );
|
||||
|
||||
if (!sidebarURLSecurityCheck(aContentURL))
|
||||
return;
|
||||
|
||||
#ifdef MOZ_PLACES_BOOKMARKS
|
||||
var uri = null;
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"]
|
||||
.getService(Components.interfaces.nsIIOService);
|
||||
try {
|
||||
uri = ioService.newURI(aContentURL, null, null);
|
||||
}
|
||||
catch(ex) { return; }
|
||||
|
||||
win.PlacesUtils.showAddBookmarkUI(uri, aTitle, null, true, true);
|
||||
#else
|
||||
var dialogArgs = {
|
||||
name: aTitle,
|
||||
url: aContentURL,
|
||||
bWebPanel: true
|
||||
}
|
||||
#ifdef XP_MACOSX
|
||||
var features = "chrome,dialog,resizable,modal";
|
||||
#else
|
||||
var features = "centerscreen,chrome,dialog,resizable,dependent";
|
||||
#endif
|
||||
win.openDialog("chrome://browser/content/bookmarks/addBookmark2.xul", "",
|
||||
features, dialogArgs);
|
||||
#endif
|
||||
}
|
||||
|
||||
nsSidebar.prototype.validateSearchEngine =
|
||||
function (engineURL, iconURL)
|
||||
{
|
||||
try
|
||||
{
|
||||
// Make sure we're using HTTP, HTTPS, or FTP.
|
||||
if (! /^(https?|ftp):\/\//i.test(engineURL))
|
||||
throw "Unsupported search engine URL";
|
||||
|
||||
// Make sure we're using HTTP, HTTPS, or FTP and refering to a
|
||||
// .gif/.jpg/.jpeg/.png/.ico file for the icon.
|
||||
if (iconURL &&
|
||||
! /^(https?|ftp):\/\/.+\.(gif|jpg|jpeg|png|ico)$/i.test(iconURL))
|
||||
throw "Unsupported search icon URL.";
|
||||
}
|
||||
catch(ex)
|
||||
{
|
||||
debug(ex);
|
||||
Components.utils.reportError("Invalid argument passed to window.sidebar.addSearchEngine: " + ex);
|
||||
|
||||
var searchBundle = srGetStrBundle("chrome://browser/locale/search.properties");
|
||||
var brandBundle = srGetStrBundle("chrome://branding/locale/brand.properties");
|
||||
var brandName = brandBundle.GetStringFromName("brandShortName");
|
||||
var title = searchBundle.GetStringFromName("error_invalid_engine_title");
|
||||
var msg = searchBundle.formatStringFromName("error_invalid_engine_msg",
|
||||
[brandName], 1);
|
||||
var ww = Components.classes["@mozilla.org/embedcomp/window-watcher;1"].
|
||||
getService(Components.interfaces.nsIWindowWatcher);
|
||||
ww.getNewPrompter(null).alert(title, msg);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
// The suggestedTitle and suggestedCategory parameters are ignored, but remain
|
||||
// for backward compatibility.
|
||||
nsSidebar.prototype.addSearchEngine =
|
||||
function (engineURL, iconURL, suggestedTitle, suggestedCategory)
|
||||
{
|
||||
debug("addSearchEngine(" + engineURL + ", " + iconURL + ", " +
|
||||
suggestedCategory + ", " + suggestedTitle + ")");
|
||||
|
||||
if (!this.validateSearchEngine(engineURL, iconURL))
|
||||
return;
|
||||
|
||||
// OpenSearch files will likely be far more common than Sherlock files, and
|
||||
// have less consistent suffixes, so we assume that ".src" is a Sherlock
|
||||
// (text) file, and anything else is OpenSearch (XML).
|
||||
var dataType;
|
||||
if (SHERLOCK_FILE_EXT_REGEXP.test(engineURL))
|
||||
dataType = Components.interfaces.nsISearchEngine.DATA_TEXT;
|
||||
else
|
||||
dataType = Components.interfaces.nsISearchEngine.DATA_XML;
|
||||
|
||||
this.searchService.addEngine(engineURL, dataType, iconURL, true);
|
||||
}
|
||||
|
||||
// This function exists largely to implement window.external.AddSearchProvider(),
|
||||
// to match other browsers' APIs. The capitalization, although nonstandard here,
|
||||
// is therefore important.
|
||||
nsSidebar.prototype.AddSearchProvider =
|
||||
function (aDescriptionURL)
|
||||
{
|
||||
// Get the favicon URL for the current page, or our best guess at the current
|
||||
// page since we don't have easy access to the active document. Most search
|
||||
// engines will override this with an icon specified in the OpenSearch
|
||||
// description anyway.
|
||||
var WINMEDSVC = Components.classes['@mozilla.org/appshell/window-mediator;1']
|
||||
.getService(Components.interfaces.nsIWindowMediator);
|
||||
var win = WINMEDSVC.getMostRecentWindow("navigator:browser");
|
||||
var browser = win.document.getElementById("content");
|
||||
var iconURL = "";
|
||||
if (browser.shouldLoadFavIcon(browser.selectedBrowser.currentURI))
|
||||
iconURL = win.gProxyFavIcon.getAttribute("src");
|
||||
|
||||
if (!this.validateSearchEngine(aDescriptionURL, iconURL))
|
||||
return;
|
||||
|
||||
const typeXML = Components.interfaces.nsISearchEngine.DATA_XML;
|
||||
this.searchService.addEngine(aDescriptionURL, typeXML, iconURL, true);
|
||||
}
|
||||
|
||||
// This function exists to implement window.external.IsSearchProviderInstalled(),
|
||||
// for compatibility with other browsers. It will return an integer value
|
||||
// indicating whether the given engine is installed for the current user.
|
||||
// However, it is currently stubbed out due to security/privacy concerns
|
||||
// stemming from difficulties in determining what domain issued the request.
|
||||
// See bug 340604 and
|
||||
// http://msdn.microsoft.com/workshop/author/dhtml/reference/methods/issearchproviderinstalled.asp .
|
||||
// XXX Implement this!
|
||||
nsSidebar.prototype.IsSearchProviderInstalled =
|
||||
function (aSearchURL)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
nsSidebar.prototype.addMicrosummaryGenerator =
|
||||
function (generatorURL)
|
||||
{
|
||||
debug("addMicrosummaryGenerator(" + generatorURL + ")");
|
||||
|
||||
var stringBundle = srGetStrBundle("chrome://browser/locale/sidebar/sidebar.properties");
|
||||
var titleMessage = stringBundle.GetStringFromName("addMicsumGenConfirmTitle");
|
||||
var dialogMessage = stringBundle.formatStringFromName("addMicsumGenConfirmText", [generatorURL], 1);
|
||||
|
||||
if (!this.promptService.confirm(null, titleMessage, dialogMessage))
|
||||
return;
|
||||
|
||||
var ioService = Components.classes["@mozilla.org/network/io-service;1"].
|
||||
getService(Components.interfaces.nsIIOService);
|
||||
var generatorURI = ioService.newURI(generatorURL, null, null);
|
||||
|
||||
var microsummaryService = Components.classes["@mozilla.org/microsummary/service;1"].
|
||||
getService(Components.interfaces.nsIMicrosummaryService);
|
||||
if (microsummaryService)
|
||||
microsummaryService.addGenerator(generatorURI);
|
||||
}
|
||||
|
||||
// property of nsIClassInfo
|
||||
nsSidebar.prototype.flags = nsIClassInfo.DOM_OBJECT;
|
||||
|
||||
// property of nsIClassInfo
|
||||
nsSidebar.prototype.classDescription = "Sidebar";
|
||||
|
||||
// method of nsIClassInfo
|
||||
nsSidebar.prototype.getInterfaces = function(count) {
|
||||
var interfaceList = [nsISidebar, nsISidebarExternal, nsIClassInfo];
|
||||
count.value = interfaceList.length;
|
||||
return interfaceList;
|
||||
}
|
||||
|
||||
// method of nsIClassInfo
|
||||
nsSidebar.prototype.getHelperForLanguage = function(count) {return null;}
|
||||
|
||||
nsSidebar.prototype.QueryInterface =
|
||||
function (iid) {
|
||||
if (!iid.equals(nsISidebar) &&
|
||||
!iid.equals(nsISidebarExternal) &&
|
||||
!iid.equals(nsIClassInfo) &&
|
||||
!iid.equals(nsISupports))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
return this;
|
||||
}
|
||||
|
||||
var sidebarModule = new Object();
|
||||
|
||||
sidebarModule.registerSelf =
|
||||
function (compMgr, fileSpec, location, type)
|
||||
{
|
||||
debug("registering (all right -- a JavaScript module!)");
|
||||
compMgr = compMgr.QueryInterface(Components.interfaces.nsIComponentRegistrar);
|
||||
|
||||
compMgr.registerFactoryLocation(SIDEBAR_CID,
|
||||
"Sidebar JS Component",
|
||||
SIDEBAR_CONTRACTID,
|
||||
fileSpec,
|
||||
location,
|
||||
type);
|
||||
const CATMAN_CONTRACTID = "@mozilla.org/categorymanager;1";
|
||||
const nsICategoryManager = Components.interfaces.nsICategoryManager;
|
||||
var catman = Components.classes[CATMAN_CONTRACTID].
|
||||
getService(nsICategoryManager);
|
||||
|
||||
const JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY = "JavaScript global property";
|
||||
catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
|
||||
"sidebar",
|
||||
SIDEBAR_CONTRACTID,
|
||||
true,
|
||||
true);
|
||||
|
||||
catman.addCategoryEntry(JAVASCRIPT_GLOBAL_PROPERTY_CATEGORY,
|
||||
"external",
|
||||
SIDEBAR_CONTRACTID,
|
||||
true,
|
||||
true);
|
||||
}
|
||||
|
||||
sidebarModule.getClassObject =
|
||||
function (compMgr, cid, iid) {
|
||||
if (!cid.equals(SIDEBAR_CID))
|
||||
throw Components.results.NS_ERROR_NO_INTERFACE;
|
||||
|
||||
if (!iid.equals(Components.interfaces.nsIFactory))
|
||||
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
|
||||
|
||||
return sidebarFactory;
|
||||
}
|
||||
|
||||
sidebarModule.canUnload =
|
||||
function(compMgr)
|
||||
{
|
||||
debug("Unloading component.");
|
||||
return true;
|
||||
}
|
||||
|
||||
/* factory object */
|
||||
var sidebarFactory = new Object();
|
||||
|
||||
sidebarFactory.createInstance =
|
||||
function (outer, iid) {
|
||||
debug("CI: " + iid);
|
||||
if (outer != null)
|
||||
throw Components.results.NS_ERROR_NO_AGGREGATION;
|
||||
|
||||
return (new nsSidebar()).QueryInterface(iid);
|
||||
}
|
||||
|
||||
/* entrypoint */
|
||||
function NSGetModule(compMgr, fileSpec) {
|
||||
return sidebarModule;
|
||||
}
|
||||
|
||||
/* static functions */
|
||||
if (DEBUG)
|
||||
debug = function (s) { dump("-*- sidebar component: " + s + "\n"); }
|
||||
else
|
||||
debug = function (s) {}
|
||||
|
||||
var strBundleService = null;
|
||||
function srGetStrBundle(path)
|
||||
{
|
||||
var strBundle = null;
|
||||
if (!strBundleService) {
|
||||
try {
|
||||
strBundleService =
|
||||
Components.classes["@mozilla.org/intl/stringbundle;1"].getService();
|
||||
strBundleService =
|
||||
strBundleService.QueryInterface(Components.interfaces.nsIStringBundleService);
|
||||
} catch (ex) {
|
||||
dump("\n--** strBundleService failed: " + ex + "\n");
|
||||
return null;
|
||||
}
|
||||
}
|
||||
strBundle = strBundleService.createBundle(path);
|
||||
if (!strBundle) {
|
||||
dump("\n--** strBundle createInstance failed **--\n");
|
||||
}
|
||||
return strBundle;
|
||||
}
|
|
@ -831,8 +831,7 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIContent, NS_ICONTENT_IID)
|
|||
nsISupports *preservedWrapper = nsnull; \
|
||||
if (tmp->GetOwnerDoc()) \
|
||||
preservedWrapper = tmp->GetOwnerDoc()->GetReference(tmp); \
|
||||
if (preservedWrapper) \
|
||||
cb.NoteXPCOMChild(preservedWrapper); \
|
||||
cb.NoteXPCOMChild(preservedWrapper); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_UNLINK_LISTENERMANAGER \
|
||||
|
|
|
@ -103,8 +103,7 @@ TraverseMapEntry(nsAttrHashKey::KeyType aKey, nsCOMPtr<nsIDOMNode>& aData, void*
|
|||
nsCycleCollectionTraversalCallback *cb =
|
||||
NS_STATIC_CAST(nsCycleCollectionTraversalCallback*, aUserArg);
|
||||
|
||||
if (aData.get())
|
||||
cb->NoteXPCOMChild(aData.get());
|
||||
cb->NoteXPCOMChild(aData.get());
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
|
|
@ -949,10 +949,7 @@ SubDocTraverser(PLDHashTable *table, PLDHashEntryHdr *hdr, PRUint32 number,
|
|||
NS_STATIC_CAST(nsCycleCollectionTraversalCallback*, arg);
|
||||
|
||||
cb->NoteXPCOMChild(entry->mKey);
|
||||
nsISupports *doc = entry->mSubDocument;
|
||||
if (doc) {
|
||||
cb->NoteXPCOMChild(doc);
|
||||
}
|
||||
cb->NoteXPCOMChild(entry->mSubDocument);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
}
|
||||
|
@ -964,10 +961,7 @@ RadioGroupsTraverser(nsHashKey *aKey, void *aData, void* aClosure)
|
|||
nsCycleCollectionTraversalCallback *cb =
|
||||
NS_STATIC_CAST(nsCycleCollectionTraversalCallback*, aClosure);
|
||||
|
||||
nsISupports *radioButton = entry->mSelectedRadioButton;
|
||||
if (radioButton) {
|
||||
cb->NoteXPCOMChild(radioButton);
|
||||
}
|
||||
cb->NoteXPCOMChild(entry->mSelectedRadioButton);
|
||||
|
||||
nsSmallVoidArray &radioButtons = entry->mRadioButtons;
|
||||
PRUint32 i, count = radioButtons.Count();
|
||||
|
@ -1054,11 +1048,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsDocument)
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(mVisitednessChangedURIs)
|
||||
|
||||
// Traverse any associated preserved wrapper.
|
||||
{
|
||||
nsISupports *preservedWrapper = tmp->GetReference(tmp);
|
||||
if (preservedWrapper)
|
||||
cb.NoteXPCOMChild(preservedWrapper);
|
||||
}
|
||||
cb.NoteXPCOMChild(tmp->GetReference(tmp));
|
||||
|
||||
if (tmp->mSubDocuments && tmp->mSubDocuments->ops) {
|
||||
PL_DHashTableEnumerate(tmp->mSubDocuments, SubDocTraverser, &cb);
|
||||
|
|
|
@ -3016,14 +3016,10 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGenericElement)
|
|||
nsISupports* property =
|
||||
NS_STATIC_CAST(nsISupports*,
|
||||
tmp->GetProperty(nsGkAtoms::contextmenulistener));
|
||||
if (property) {
|
||||
cb.NoteXPCOMChild(property);
|
||||
}
|
||||
cb.NoteXPCOMChild(property);
|
||||
property = NS_STATIC_CAST(nsISupports*,
|
||||
tmp->GetProperty(nsGkAtoms::popuplistener));
|
||||
if (property) {
|
||||
cb.NoteXPCOMChild(property);
|
||||
}
|
||||
cb.NoteXPCOMChild(property);
|
||||
}
|
||||
|
||||
// Traverse child content.
|
||||
|
@ -3038,10 +3034,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGenericElement)
|
|||
{
|
||||
nsDOMSlots *slots = tmp->GetExistingDOMSlots();
|
||||
if (slots) {
|
||||
if (slots->mAttributeMap.get())
|
||||
cb.NoteXPCOMChild(slots->mAttributeMap.get());
|
||||
if (slots->mControllers)
|
||||
cb.NoteXPCOMChild(slots->mControllers);
|
||||
cb.NoteXPCOMChild(slots->mAttributeMap.get());
|
||||
cb.NoteXPCOMChild(slots->mControllers);
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
|
|
@ -1031,9 +1031,7 @@ nsObjectLoadingContent::RemovedFromDocument()
|
|||
void
|
||||
nsObjectLoadingContent::Traverse(nsCycleCollectionTraversalCallback &cb)
|
||||
{
|
||||
if (mFrameLoader) {
|
||||
cb.NoteXPCOMChild(mFrameLoader);
|
||||
}
|
||||
cb.NoteXPCOMChild(mFrameLoader);
|
||||
}
|
||||
|
||||
// <private>
|
||||
|
|
|
@ -400,7 +400,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsEventListenerManager)
|
|||
nsListenerStruct *ls;
|
||||
for (i = 0; i < count; i++) {
|
||||
ls = NS_STATIC_CAST(nsListenerStruct*, tmp->mListeners.ElementAt(i));
|
||||
if (ls && ls->mListener.get()) {
|
||||
if (ls) {
|
||||
cb.NoteXPCOMChild(ls->mListener.get());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -353,7 +353,7 @@ IdAndNameMapEntryTraverse(PLDHashTable *table, PLDHashEntryHdr *hdr,
|
|||
NS_STATIC_CAST(nsCycleCollectionTraversalCallback*, arg);
|
||||
IdAndNameMapEntry *entry = NS_STATIC_CAST(IdAndNameMapEntry*, hdr);
|
||||
|
||||
if (entry->mNameContentList && entry->mNameContentList != NAME_NOT_VALID)
|
||||
if (entry->mNameContentList != NAME_NOT_VALID)
|
||||
cb->NoteXPCOMChild(entry->mNameContentList);
|
||||
|
||||
return PL_DHASH_NEXT;
|
||||
|
|
|
@ -284,7 +284,7 @@ nsXBLPrototypeBinding::Traverse(nsCycleCollectionTraversalCallback &cb) const
|
|||
{
|
||||
cb.NoteXPCOMChild(mBinding);
|
||||
// XXX mInsertionPointTable!
|
||||
if (mResources && mResources->mLoader)
|
||||
if (mResources)
|
||||
cb.NoteXPCOMChild(mResources->mLoader);
|
||||
}
|
||||
|
||||
|
|
|
@ -623,12 +623,9 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsXULPDGlobalObject)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsXULPDGlobalObject)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULPDGlobalObject)
|
||||
{
|
||||
PRUint32 lang_id;
|
||||
NS_STID_FOR_ID(lang_id) {
|
||||
nsISupports *context = tmp->mScriptContexts[NS_STID_INDEX(lang_id)];
|
||||
if (context) {
|
||||
cb.NoteXPCOMChild(context);
|
||||
}
|
||||
PRUint32 lang_index;
|
||||
NS_STID_FOR_INDEX(lang_index) {
|
||||
cb.NoteXPCOMChild(tmp->mScriptContexts[lang_index]);
|
||||
}
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
|
|
@ -227,12 +227,8 @@ public:
|
|||
|
||||
void Traverse(nsCycleCollectionTraversalCallback &cb) const
|
||||
{
|
||||
if (mRuleNode) {
|
||||
cb.NoteXPCOMChild(mRuleNode);
|
||||
}
|
||||
if (mAction) {
|
||||
cb.NoteXPCOMChild(mAction);
|
||||
}
|
||||
cb.NoteXPCOMChild(mRuleNode);
|
||||
cb.NoteXPCOMChild(mAction);
|
||||
}
|
||||
|
||||
protected:
|
||||
|
|
|
@ -94,12 +94,8 @@ struct nsSortState
|
|||
}
|
||||
void Traverse(nsCycleCollectionTraversalCallback &cb) const
|
||||
{
|
||||
if (processor) {
|
||||
cb.NoteXPCOMChild(processor);
|
||||
}
|
||||
if (lastContainer) {
|
||||
cb.NoteXPCOMChild(lastContainer);
|
||||
}
|
||||
cb.NoteXPCOMChild(processor);
|
||||
cb.NoteXPCOMChild(lastContainer);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -239,12 +239,8 @@ TraverseMatchList(nsISupports* aKey, nsTemplateMatch* aMatch, void* aContext)
|
|||
cb->NoteXPCOMChild(aKey);
|
||||
nsTemplateMatch* match = aMatch;
|
||||
while (match) {
|
||||
nsISupports *container = match->GetContainer();
|
||||
if (container)
|
||||
cb->NoteXPCOMChild(container);
|
||||
nsISupports *result = match->mResult;
|
||||
if (result)
|
||||
cb->NoteXPCOMChild(result);
|
||||
cb->NoteXPCOMChild(match->GetContainer());
|
||||
cb->NoteXPCOMChild(match->mResult);
|
||||
match = match->mNext;
|
||||
}
|
||||
|
||||
|
@ -265,9 +261,7 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsXULTemplateBuilder)
|
|||
for (i = 0; i < count; ++i) {
|
||||
nsTemplateQuerySet *set = tmp->mQuerySets[i];
|
||||
cb.NoteXPCOMChild(set->mQueryNode);
|
||||
if (set->mCompiledQuery) {
|
||||
cb.NoteXPCOMChild(set->mCompiledQuery);
|
||||
}
|
||||
cb.NoteXPCOMChild(set->mCompiledQuery);
|
||||
PRUint16 j, rulesCount = set->RuleCount();
|
||||
for (j = 0; j < rulesCount; ++j) {
|
||||
set->GetRuleAt(j)->Traverse(cb);
|
||||
|
|
|
@ -727,11 +727,8 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsGlobalWindow)
|
|||
|
||||
// Traverse any associated preserved wrappers.
|
||||
{
|
||||
nsISupports *preservedWrapper = nsnull;
|
||||
if (tmp->mDoc) {
|
||||
preservedWrapper = tmp->mDoc->GetReference(tmp);
|
||||
if (preservedWrapper)
|
||||
cb.NoteXPCOMChild(preservedWrapper);
|
||||
cb.NoteXPCOMChild(tmp->mDoc->GetReference(tmp));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1023,10 +1023,7 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(nsJSContext)
|
|||
NS_IMPL_CYCLE_COLLECTION_UNLINK_0(nsJSContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsJSContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mGlobalWrapperRef)
|
||||
JSObject *globalObject = ::JS_GetGlobalObject(tmp->mContext);
|
||||
if (globalObject) {
|
||||
cb.NoteScriptChild(JAVASCRIPT, globalObject);
|
||||
}
|
||||
cb.NoteScriptChild(JAVASCRIPT, ::JS_GetGlobalObject(tmp->mContext));
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsJSContext)
|
||||
|
|
|
@ -118,8 +118,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(nsJSScriptTimeoutHandler)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mArgv)
|
||||
if (tmp->mFunObj)
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, tmp->mFunObj);
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, tmp->mFunObj);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsJSScriptTimeoutHandler)
|
||||
|
|
|
@ -656,29 +656,20 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
|
|||
else if(clazz->flags & JSCLASS_HAS_PRIVATE &&
|
||||
clazz->flags & JSCLASS_PRIVATE_IS_NSISUPPORTS)
|
||||
{
|
||||
void *v = JS_GetPrivate(cx, obj);
|
||||
if (v)
|
||||
cb.NoteXPCOMChild(NS_STATIC_CAST(nsISupports*, v));
|
||||
cb.NoteXPCOMChild(NS_STATIC_CAST(nsISupports*, JS_GetPrivate(cx, obj)));
|
||||
}
|
||||
|
||||
JSObject *parent = OBJ_GET_PARENT(cx, obj);
|
||||
if(parent)
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, parent);
|
||||
|
||||
JSObject *proto = OBJ_GET_PROTO(cx, obj);
|
||||
if(proto)
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, proto);
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
OBJ_GET_PARENT(cx, obj));
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
OBJ_GET_PROTO(cx, obj));
|
||||
|
||||
for(uint32 i = JSSLOT_START(clazz); i < STOBJ_NSLOTS(obj); ++i)
|
||||
{
|
||||
jsval val = STOBJ_GET_SLOT(obj, i);
|
||||
if (!JSVAL_IS_NULL(val)
|
||||
&& JSVAL_IS_OBJECT(val))
|
||||
{
|
||||
JSObject *child = JSVAL_TO_OBJECT(val);
|
||||
if (child)
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, child);
|
||||
}
|
||||
if (JSVAL_IS_OBJECT(val))
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
JSVAL_TO_OBJECT(val));
|
||||
}
|
||||
|
||||
#ifndef XPCONNECT_STANDALONE
|
||||
|
@ -686,8 +677,7 @@ nsXPConnect::Traverse(void *p, nsCycleCollectionTraversalCallback &cb)
|
|||
{
|
||||
nsISupports *principal = nsnull;
|
||||
mObjRefcounts->mScopes.Get(obj, &principal);
|
||||
if(principal)
|
||||
cb.NoteXPCOMChild(principal);
|
||||
cb.NoteXPCOMChild(principal);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -3101,7 +3101,8 @@ sandbox_finalize(JSContext *cx, JSObject *obj)
|
|||
}
|
||||
|
||||
static JSClass SandboxClass = {
|
||||
"Sandbox", JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
|
||||
"Sandbox",
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_GLOBAL_FLAGS,
|
||||
JS_PropertyStub, JS_PropertyStub, JS_PropertyStub, JS_PropertyStub,
|
||||
sandbox_enumerate, sandbox_resolve, JS_ConvertStub, sandbox_finalize,
|
||||
JSCLASS_NO_OPTIONAL_MEMBERS
|
||||
|
|
|
@ -140,7 +140,7 @@ SafeFinalize(JSContext* cx, JSObject* obj)
|
|||
static JSClass global_class = {
|
||||
"global_for_XPCJSContextStack_SafeJSContext",
|
||||
#ifndef XPCONNECT_STANDALONE
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS,
|
||||
JSCLASS_HAS_PRIVATE | JSCLASS_PRIVATE_IS_NSISUPPORTS | JSCLASS_GLOBAL_FLAGS,
|
||||
#else
|
||||
0,
|
||||
#endif
|
||||
|
|
|
@ -102,17 +102,11 @@ NS_CYCLE_COLLECTION_CLASSNAME(nsXPCWrappedJS)::Traverse
|
|||
|
||||
nsXPCWrappedJS* root = tmp->GetRootWrapper();
|
||||
if(root == tmp)
|
||||
{
|
||||
// The root wrapper keeps the aggregated native object alive.
|
||||
nsISupports* outer = tmp->GetAggregatedNativeObject();
|
||||
if (outer)
|
||||
cb.NoteXPCOMChild(outer);
|
||||
}
|
||||
cb.NoteXPCOMChild(tmp->GetAggregatedNativeObject());
|
||||
else
|
||||
{
|
||||
// Non-root wrappers keep their root alive.
|
||||
cb.NoteXPCOMChild(NS_STATIC_CAST(nsIXPConnectWrappedJS*, root));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -85,9 +85,8 @@ NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::Traverse(nsISupports *s,
|
|||
|
||||
JSObject *obj = nsnull;
|
||||
nsresult rv = tmp->GetJSObject(&obj);
|
||||
if (NS_SUCCEEDED(rv) && obj) {
|
||||
if (NS_SUCCEEDED(rv))
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, obj);
|
||||
}
|
||||
}
|
||||
|
||||
// XXX If there is a scriptable helper we will not be able to find out what
|
||||
|
@ -103,17 +102,14 @@ NS_CYCLE_COLLECTION_CLASSNAME(XPCWrappedNative)::Traverse(nsISupports *s,
|
|||
tmp->GetProto()->GetJSProtoObject());
|
||||
|
||||
// XPCWrappedNative marks its mNativeWrapper (see MarkBeforeJSFinalize).
|
||||
if(tmp->mNativeWrapper)
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
tmp->mNativeWrapper);
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, tmp->mNativeWrapper);
|
||||
|
||||
// XPCWrappedNative marks its scope.
|
||||
tmp->GetScope()->Traverse(cb);
|
||||
|
||||
// XPCWrappedNative keeps its native object alive.
|
||||
if (tmp->GetIdentityObject()) {
|
||||
cb.NoteXPCOMChild(tmp->GetIdentityObject());
|
||||
}
|
||||
cb.NoteXPCOMChild(tmp->GetIdentityObject());
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
|
|
@ -798,12 +798,9 @@ XPCWrappedNativeScope::Traverse(nsCycleCollectionTraversalCallback &cb)
|
|||
{
|
||||
// See MarkScopeJSObjects.
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, mGlobalJSObject);
|
||||
JSObject *obj = mPrototypeJSObject;
|
||||
if(obj)
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, obj);
|
||||
obj = mPrototypeJSFunction;
|
||||
if(obj)
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, obj);
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT, mPrototypeJSObject);
|
||||
cb.NoteScriptChild(nsIProgrammingLanguage::JAVASCRIPT,
|
||||
mPrototypeJSFunction);
|
||||
}
|
||||
|
||||
#ifndef XPCONNECT_STANDALONE
|
||||
|
|
|
@ -218,23 +218,19 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsCycleCollectionParticipant,
|
|||
NS_CYCLE_COLLECTION_CLASSNAME(_base_class)::Traverse(s, cb);
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_RAWPTR(_field) \
|
||||
if (tmp->_field) { cb.NoteXPCOMChild(tmp->_field); }
|
||||
cb.NoteXPCOMChild(tmp->_field);
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(_field) \
|
||||
if (tmp->_field) { cb.NoteXPCOMChild(tmp->_field.get()); }
|
||||
cb.NoteXPCOMChild(tmp->_field.get());
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(_field, _base) \
|
||||
{ \
|
||||
nsISupports *f = NS_ISUPPORTS_CAST(_base*, tmp->_field); \
|
||||
if (f) { cb.NoteXPCOMChild(f); } \
|
||||
}
|
||||
cb.NoteXPCOMChild(NS_ISUPPORTS_CAST(_base*, tmp->_field));
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMARRAY(_field) \
|
||||
{ \
|
||||
PRInt32 i; \
|
||||
for (i = 0; i < tmp->_field.Count(); ++i) \
|
||||
if (tmp->_field[i]) \
|
||||
cb.NoteXPCOMChild(tmp->_field[i]); \
|
||||
PRInt32 i; \
|
||||
for (i = 0; i < tmp->_field.Count(); ++i) \
|
||||
cb.NoteXPCOMChild(tmp->_field[i]); \
|
||||
}
|
||||
|
||||
#define NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END \
|
||||
|
|
|
@ -636,7 +636,7 @@ void
|
|||
GraphWalker::NoteXPCOMChild(nsISupports *child)
|
||||
{
|
||||
if (!child)
|
||||
Fault("null XPCOM pointer returned");
|
||||
return;
|
||||
|
||||
child = canonicalize(child);
|
||||
|
||||
|
@ -655,7 +655,7 @@ void
|
|||
GraphWalker::NoteScriptChild(PRUint32 langID, void *child)
|
||||
{
|
||||
if (!child)
|
||||
Fault("null script language pointer returned");
|
||||
return;
|
||||
|
||||
if (!mRuntimes[langID])
|
||||
Fault("traversing pointer for unregistered language", child);
|
||||
|
@ -1532,7 +1532,7 @@ nsCycleCollector::Suspect(nsISupports *n)
|
|||
if (!NS_IsMainThread())
|
||||
Fault("trying to suspect from non-main thread");
|
||||
|
||||
if (!nsCycleCollector_isScanSafe(n))
|
||||
if (!n || !nsCycleCollector_isScanSafe(n))
|
||||
Fault("suspected a non-scansafe pointer", n);
|
||||
|
||||
if (nsCycleCollector_shouldSuppress(n))
|
||||
|
@ -1764,9 +1764,6 @@ nsCycleCollector_isScanSafe(nsISupports *s)
|
|||
{
|
||||
nsresult rv;
|
||||
|
||||
if (!s)
|
||||
return PR_FALSE;
|
||||
|
||||
nsCOMPtr<nsCycleCollectionParticipant> cp = do_QueryInterface(s, &rv);
|
||||
if (NS_FAILED(rv)) {
|
||||
sCollector.mStats.mFailedQI++;
|
||||
|
|
|
@ -1666,9 +1666,7 @@ nsVariant::Traverse(const nsDiscriminatedUnion& data,
|
|||
{
|
||||
case nsIDataType::VTYPE_INTERFACE:
|
||||
case nsIDataType::VTYPE_INTERFACE_IS:
|
||||
if (data.u.iface.mInterfaceValue) {
|
||||
cb.NoteXPCOMChild(data.u.iface.mInterfaceValue);
|
||||
}
|
||||
cb.NoteXPCOMChild(data.u.iface.mInterfaceValue);
|
||||
break;
|
||||
case nsIDataType::VTYPE_ARRAY:
|
||||
switch(data.u.array.mArrayType) {
|
||||
|
@ -1677,8 +1675,7 @@ nsVariant::Traverse(const nsDiscriminatedUnion& data,
|
|||
{
|
||||
nsISupports** p = (nsISupports**) data.u.array.mArrayValue;
|
||||
for(PRUint32 i = data.u.array.mArrayCount; i > 0; p++, i--)
|
||||
if(*p)
|
||||
cb.NoteXPCOMChild(*p);
|
||||
cb.NoteXPCOMChild(*p);
|
||||
}
|
||||
default:
|
||||
break;
|
||||
|
|
Загрузка…
Ссылка в новой задаче