ick...ick ick ick. Try to fix preferences.

This commit is contained in:
blakeross%telocity.com 2003-08-24 01:01:46 +00:00
Родитель 87562f5b7a
Коммит ad2c14ebc1
8 изменённых файлов: 48 добавлений и 52 удалений

Просмотреть файл

@ -65,9 +65,8 @@ function GetFields()
return dataObject; return dataObject;
} }
function SetFields() function SetFields(dataObject)
{ {
var dataObject = window.opener.top.hPrefWindow.wsm.dataManager.pageData[window.location.href];
if ('cookies' in dataObject) if ('cookies' in dataObject)
cookies = dataObject.cookies; cookies = dataObject.cookies;
@ -129,7 +128,7 @@ function loadCookies() {
if (!cookiesTree) if (!cookiesTree)
cookiesTree = document.getElementById("cookiesTree"); cookiesTree = document.getElementById("cookiesTree");
var dataObject = window.opener.top.hPrefWindow.wsm.dataManager.pageData[window.location.href]; var dataObject = window.opener.top.hPrefWindow.wsm.dataManager.pageData[window.location.href].userData;
if (!('cookies' in dataObject)) { if (!('cookies' in dataObject)) {
// load cookies into a table // load cookies into a table
var enumerator = cookiemanager.enumerator; var enumerator = cookiemanager.enumerator;

Просмотреть файл

@ -187,13 +187,11 @@ nsPrefWindow.prototype =
for( var pageTag in this.wsm.dataManager.pageData ) for( var pageTag in this.wsm.dataManager.pageData )
{ {
var pageData = this.wsm.dataManager.getPageData( pageTag ); var pageData = this.wsm.dataManager.getPageData( pageTag );
if ("initialized" in pageData && pageData.initialized) if ("initialized" in pageData && pageData.initialized && "elementIDs" in pageData)
{ {
for( var elementID in pageData ) for( var elementID in pageData.elementIDs )
{ {
if (elementID == "initialized") continue; var itemObject = pageData.elementIDs[elementID];
var itemObject = pageData[elementID];
if (typeof(itemObject) != "object") break;
if ( "prefstring" in itemObject && itemObject.prefstring ) if ( "prefstring" in itemObject && itemObject.prefstring )
{ {
var elt = itemObject.localname; var elt = itemObject.localname;
@ -308,10 +306,11 @@ nsPrefWindow.prototype =
aWindow.document.documentElement.getAttribute("headertitle")); aWindow.document.documentElement.getAttribute("headertitle"));
} }
if( !(aPageTag in this.wsm.dataManager.pageData) ) var pageData = this.wsm.dataManager.getPageData(aPageTag);
if(!('initialized' in pageData))
{ {
var prefElements = aWindow.document.getElementsByAttribute( "prefstring", "*" ); var prefElements = aWindow.document.getElementsByAttribute( "prefstring", "*" );
this.wsm.dataManager.pageData[aPageTag] = [];
for( var i = 0; i < prefElements.length; i++ ) for( var i = 0; i < prefElements.length; i++ )
{ {
var prefstring = prefElements[i].getAttribute( "prefstring" ); var prefstring = prefElements[i].getAttribute( "prefstring" );
@ -350,12 +349,11 @@ nsPrefWindow.prototype =
} }
} }
this.wsm.setPageData( aPageTag, aWindow ); // do not set extra elements, accept hard coded defaults this.wsm.setPageData( aPageTag, aWindow ); // do not set extra elements, accept hard coded defaults
if( 'Startup' in aWindow) if( 'Startup' in aWindow)
{ {
aWindow.Startup(); aWindow.Startup();
} }
this.wsm.dataManager.pageData[aPageTag].initialized=true; this.wsm.dataManager.pageData[aPageTag].initialized = true;
} }
}; };

Просмотреть файл

@ -39,7 +39,7 @@ function GetFields()
return dataObject; return dataObject;
} }
function SetFields() function SetFields(data)
{ {
var win; var win;
if ('opener' in window && window.opener) if ('opener' in window && window.opener)
@ -47,14 +47,11 @@ function SetFields()
else else
win = window.top; win = window.top;
var dataObject = win.hPrefWindow.wsm.dataManager.pageData[window.location.href]; if ('permissions' in data)
if ('permissions' in dataObject) permissions = data.permissions;
permissions = dataObject.permissions;
if ('deletedPermissions' in dataObject) if ('deletedPermissions' in data)
deletedPermissions = dataObject.deletedPermissions; deletedPermissions = data.deletedPermissions;
return true;
} }
var permissionsTreeView = { var permissionsTreeView = {
@ -137,7 +134,7 @@ function loadPermissions() {
else else
win = window.top; win = window.top;
var dataObject = win.hPrefWindow.wsm.dataManager.pageData[window.location.href]; var dataObject = win.hPrefWindow.wsm.dataManager.pageData[window.location.href].userData;
// load permissions into a table // load permissions into a table
if (!('permissions' in dataObject)) { if (!('permissions' in dataObject)) {

Просмотреть файл

@ -121,7 +121,7 @@ function showFontsAndColors()
function saveFontPrefs() function saveFontPrefs()
{ {
var dataObject = top.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-fonts.xul"]; var dataObject = top.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-fonts.xul"].userData;
var pref = top.hPrefWindow.pref; var pref = top.hPrefWindow.pref;
for (var language in dataObject.languageData) { for (var language in dataObject.languageData) {
for (var type in dataObject.languageData[language].types) { for (var type in dataObject.languageData[language].types) {
@ -188,7 +188,7 @@ function saveFontPrefs()
} }
items = ["browserUseSystemColors", "browserUnderlineAnchors"]; items = ["browserUseSystemColors", "browserUnderlineAnchors"];
prefs = ["browser.display.use_system_colors", "browser.underline_anchors"]; prefs = ["browser.display.use_system_colors", "browser.underline_anchors"];
for (var i = 0; i < items.length; ++i) { for (i = 0; i < items.length; ++i) {
prefvalue = dataObject.dataEls[items[i]].checked; prefvalue = dataObject.dataEls[items[i]].checked;
pref.SetBoolPref(prefs[i], prefvalue) pref.SetBoolPref(prefs[i], prefvalue)
} }
@ -199,7 +199,7 @@ function onPopupPrefsOK()
var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService(); var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService();
permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager); permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager);
var dataObject = parent.hPrefWindow.wsm.dataManager.pageData[window.location.href]; var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-features.xul"].userData;
if ('deletedPermissions' in dataObject) { if ('deletedPermissions' in dataObject) {
for (var p = 0; p < dataObject.deletedPermissions.length; ++p) { for (var p = 0; p < dataObject.deletedPermissions.length; ++p) {
permissionmanager.remove(dataObject.deletedPermissions[p].host, dataObject.deletedPermissions[p].type); permissionmanager.remove(dataObject.deletedPermissions[p].host, dataObject.deletedPermissions[p].type);
@ -223,7 +223,7 @@ function onImagePrefsOK()
var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService(); var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService();
permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager); permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager);
var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-features-images.xul"]; var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-features-images.xul"].userData;
if ('deletedPermissions' in dataObject) { if ('deletedPermissions' in dataObject) {
for (var p = 0; p < dataObject.deletedPermissions.length; ++p) { for (var p = 0; p < dataObject.deletedPermissions.length; ++p) {
permissionmanager.remove(dataObject.deletedPermissions[p].host, dataObject.deletedPermissions[p].type); permissionmanager.remove(dataObject.deletedPermissions[p].host, dataObject.deletedPermissions[p].type);

Просмотреть файл

@ -95,7 +95,7 @@ function GetFields()
} }
// manual data setting function for PrefWindow // manual data setting function for PrefWindow
function SetFields( aDataObject ) function SetFields(aDataObject)
{ {
languageData = "languageData" in aDataObject ? aDataObject.languageData : languageData ; languageData = "languageData" in aDataObject ? aDataObject.languageData : languageData ;
currentLanguage = "currentLanguage" in aDataObject ? aDataObject.currentLanguage : null ; currentLanguage = "currentLanguage" in aDataObject ? aDataObject.currentLanguage : null ;
@ -479,7 +479,7 @@ function selectLanguage()
} }
// and set the font sizes // and set the font sizes
var dataObject = gPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-fonts.xul"]; var dataObject = gPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-fonts.xul"].userData;
var langData = null; var langData = null;
try try
{ {

Просмотреть файл

@ -110,7 +110,7 @@ function unload()
function cookieViewerOnPrefsOK() function cookieViewerOnPrefsOK()
{ {
var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/cookieviewer/CookieViewer.xul"]; var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/cookieviewer/CookieViewer.xul"].userData;
if ('deletedCookies' in dataObject) { if ('deletedCookies' in dataObject) {
var cookiemanager = Components.classes["@mozilla.org/cookiemanager;1"].getService(); var cookiemanager = Components.classes["@mozilla.org/cookiemanager;1"].getService();
cookiemanager = cookiemanager.QueryInterface(Components.interfaces.nsICookieManager); cookiemanager = cookiemanager.QueryInterface(Components.interfaces.nsICookieManager);
@ -326,7 +326,7 @@ function onPrefsOK()
var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService(); var permissionmanager = Components.classes["@mozilla.org/permissionmanager;1"].getService();
permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager); permissionmanager = permissionmanager.QueryInterface(Components.interfaces.nsIPermissionManager);
var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/cookieviewer/CookieExceptions.xul"]; var dataObject = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/cookieviewer/CookieExceptions.xul"].userData;
if ('deletedPermissions' in dataObject) { if ('deletedPermissions' in dataObject) {
for (var p = 0; p < dataObject.deletedPermissions.length; ++p) { for (var p = 0; p < dataObject.deletedPermissions.length; ++p) {
permissionmanager.remove(dataObject.deletedPermissions[p].host, dataObject.deletedPermissions[p].type); permissionmanager.remove(dataObject.deletedPermissions[p].host, dataObject.deletedPermissions[p].type);

Просмотреть файл

@ -51,7 +51,7 @@ catch(e) {}
function Startup() function Startup()
{ {
gData = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-themes.xul"]; gData = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-themes.xul"].userData;
var list = document.getElementById( "skinsList" ); var list = document.getElementById( "skinsList" );
if ("loaded" in gData && "themeIndex" in gData) { if ("loaded" in gData && "themeIndex" in gData) {
list.selectedIndex = gData.themeIndex; list.selectedIndex = gData.themeIndex;
@ -93,7 +93,7 @@ function Startup()
function applyTheme() function applyTheme()
{ {
var data = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-themes.xul"]; var data = parent.hPrefWindow.wsm.dataManager.pageData["chrome://browser/content/pref/pref-themes.xul"].userData;
if (data.name == null) if (data.name == null)
return; return;

Просмотреть файл

@ -51,6 +51,13 @@ function nsWidgetStateManager (aFrameID)
{ {
if (!(aPageTag in this.pageData)) if (!(aPageTag in this.pageData))
this.pageData[aPageTag] = { }; this.pageData[aPageTag] = { };
if (!('elementIDs' in this.pageData[aPageTag]))
this.pageData[aPageTag].elementIDs = new Object();
if (!('userData' in this.pageData[aPageTag]))
this.pageData[aPageTag].userData = new Object();
return this.pageData[aPageTag]; return this.pageData[aPageTag];
}, },
@ -58,14 +65,15 @@ function nsWidgetStateManager (aFrameID)
{ {
if (!(aPageTag in this.pageData)) if (!(aPageTag in this.pageData))
this.pageData[aPageTag] = new Object(); this.pageData[aPageTag] = new Object();
this.pageData[aPageTag][aItemID] = aDataObject;
this.pageData[aPageTag].elementIDs[aItemID] = aDataObject;
}, },
getItemData: function (aPageTag, aItemID) getItemData: function (aPageTag, aItemID)
{ {
if (!(aItemID in this.pageData[aPageTag])) if (!(aItemID in this.pageData[aPageTag].elementIDs))
this.pageData[aPageTag][aItemID] = new Object(); this.pageData[aPageTag].elementIDs[aItemID] = new Object();
return this.pageData[aPageTag][aItemID]; return this.pageData[aPageTag].elementIDs[aItemID];
} }
} }
@ -115,8 +123,8 @@ nsWidgetStateManager.prototype =
if ("GetFields" in gCurrentWindow) { if ("GetFields" in gCurrentWindow) {
// save page data based on user supplied function in content area // save page data based on user supplied function in content area
var dataObject = gCurrentWindow.GetFields(); var dataObject = gCurrentWindow.GetFields();
if (dataObject) if (dataObject)
this.dataManager.setPageData(aPageTag, dataObject); this.dataManager.pageData[aPageTag].userData = dataObject;
} }
// Automatic element retrieval. This is done in two ways. // Automatic element retrieval. This is done in two ways.
@ -145,11 +153,7 @@ nsWidgetStateManager.prototype =
for (var ii = 0; ii < elements.length; ii++) { for (var ii = 0; ii < elements.length; ii++) {
var elementID = elements[ii].id; var elementID = elements[ii].id;
var elementType = elements[ii].localName; var elementType = elements[ii].localName;
if (!(aPageTag in this.dataManager.pageData) )
this.dataManager.pageData[aPageTag] = new Object();
this.dataManager.pageData[aPageTag][elementID] = new Object();
// persist attributes // persist attributes
var get_Func = (elementType in this.handlers) ? var get_Func = (elementType in this.handlers) ?
this.handlers[elementType].get : this.handlers[elementType].get :
@ -163,22 +167,20 @@ nsWidgetStateManager.prototype =
gCurrentWindow = aWindow || this.contentArea; gCurrentWindow = aWindow || this.contentArea;
var pageData = this.dataManager.getPageData(aPageTag); var pageData = this.dataManager.getPageData(aPageTag);
if ("SetFields" in gCurrentWindow) { if ("SetFields" in gCurrentWindow)
if (!gCurrentWindow.SetFields(pageData)) { gCurrentWindow.SetFields(pageData.userData)
// If the function returns false (or null/undefined) then it
// doesn't want *us* to process the page data.
return;
}
}
for (var elementID in pageData) { if (!('elementIDs' in pageData))
return;
for (var elementID in pageData.elementIDs) {
var element = gCurrentWindow.document.getElementById(elementID); var element = gCurrentWindow.document.getElementById(elementID);
if (element) { if (element) {
var elementType = element.localName; var elementType = element.localName;
var set_Func = (elementType in this.handlers) ? var set_Func = (elementType in this.handlers) ?
this.handlers[elementType].set : this.handlers[elementType].set :
this.handlers.default_handler.set; this.handlers.default_handler.set;
set_Func(elementID, pageData[elementID]); set_Func(elementID, pageData.elementIDs[elementID]);
} }
} }
}, },
@ -376,4 +378,4 @@ nsWidgetStateManager.prototype =
# there is no way out of here # there is no way out of here
# [The Master is] not dead as you know it. He is with us always.. # [The Master is] not dead as you know it. He is with us always..
# My name is Torgo, I take care of the place while the Master is away. # My name is Torgo, I take care of the place while the Master is away.
# The car won't start