From 4398f99eeab163c9a6fec72486a7fd7e2d30ceb6 Mon Sep 17 00:00:00 2001 From: "db48x@yahoo.com" Date: Mon, 6 Aug 2007 09:13:05 -0700 Subject: [PATCH] =?UTF-8?q?Bug=20388504=20-=20It=20should=20be=20possible?= =?UTF-8?q?=20for=20an=20extension=20to=20reload=20Page=20Info=20on=20a=20?= =?UTF-8?q?different=20document=20patch=20by=20Florian=20Qu=C3=A8ze=20,=20r=3Ddb48x,=20sr=3Dneil?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- browser/base/content/pageinfo/feeds.js | 3 +- browser/base/content/pageinfo/pageInfo.js | 84 +++++++++++++++----- browser/base/content/pageinfo/permissions.js | 4 +- browser/base/content/pageinfo/security.js | 12 ++- 4 files changed, 75 insertions(+), 28 deletions(-) diff --git a/browser/base/content/pageinfo/feeds.js b/browser/base/content/pageinfo/feeds.js index e865f5d936ce..e0d5dd28eabf 100644 --- a/browser/base/content/pageinfo/feeds.js +++ b/browser/base/content/pageinfo/feeds.js @@ -62,8 +62,7 @@ function initFeedTab() } var feedListbox = document.getElementById("feedListbox"); - if (feedListbox.getRowCount() > 0) - document.getElementById("feedTab").hidden = false; + document.getElementById("feedTab").hidden = feedListbox.getRowCount() == 0; } function onSubscribeFeed() diff --git a/browser/base/content/pageinfo/pageInfo.js b/browser/base/content/pageinfo/pageInfo.js index 76fc3beff264..6d2bf6fdd24d 100644 --- a/browser/base/content/pageinfo/pageInfo.js +++ b/browser/base/content/pageinfo/pageInfo.js @@ -243,9 +243,16 @@ const XHTMLre = RegExp(XHTMLNSre + "|" + XHTML2NSre, ""); * invoked as "XXXLoadFunc();" */ -// These functions are called once when the Page Info window is opened. +// These functions are called to build the data displayed in the Page +// Info window. The global variables gDocument and gWindow are set. var onLoadRegistry = [ ]; +// These functions are called to remove old data still displayed in +// the window when the document whose information is displayed +// changes. For example, at this time, the list of images of the Media +// tab is cleared. +var onResetRegistry = [ ]; + // These are called once for each subframe of the target document and // the target document itself. The frame is passed as an argument. var onProcessFrame = [ ]; @@ -294,27 +301,12 @@ function onLoadPageInfo() gDocument = gWindow.document; } - var titleFormat = gWindow != gWindow.top ? "pageInfo.frame.title" - : "pageInfo.page.title"; - document.title = gBundle.getFormattedString(titleFormat, [gDocument.location]); - - document.getElementById("main-window").setAttribute("relatedUrl", gDocument.location); - - // do the easy stuff first - makeGeneralTab(); - // init media view var imageTree = document.getElementById("imagetree"); imageTree.view = gImageView; - // and then the hard stuff - makeTabs(gDocument, gWindow); - - initFeedTab(); - onLoadPermission(); - - /* Call registered overlay init functions */ - onLoadRegistry.map(function(func) { func(); }); + // build the content + loadPageInfo(); /* Select the requested tab, if the name is specified */ var initialTab = "general"; @@ -328,6 +320,55 @@ function onLoadPageInfo() radioGroup.focus(); } +function loadPageInfo() +{ + var titleFormat = gWindow != gWindow.top ? "pageInfo.frame.title" + : "pageInfo.page.title"; + document.title = gBundle.getFormattedString(titleFormat, [gDocument.location]); + + document.getElementById("main-window").setAttribute("relatedUrl", gDocument.location); + + // do the easy stuff first + makeGeneralTab(); + + // and then the hard stuff + makeTabs(gDocument, gWindow); + + initFeedTab(); + onLoadPermission(); + + /* Call registered overlay init functions */ + onLoadRegistry.map(function(func) { func(); }); +} + +function resetPageInfo() +{ + /* Reset Meta tags part */ + gMetaView.clear(); + + /* Reset Media tab */ + var mediaTab = document.getElementById("mediaTab"); + if (!mediaTab.hidden) { + var os = Components.classes["@mozilla.org/observer-service;1"] + .getService(Components.interfaces.nsIObserverService); + os.removeObserver(imagePermissionObserver, "perm-changed"); + mediaTab.hidden = true; + } + gImageView.clear(); + gImageHash = {}; + + /* Reset Feeds Tab */ + var feedListbox = document.getElementById("feedListbox"); + while (feedListbox.firstChild) + feedListbox.removeChild(feedListbox.firstChild); + + /* Call registered overlay reset functions */ + onResetRegistry.map(function(func) { func(); }); + + /* And let's rebuild the data */ + loadPageInfo(); +} + function onUnloadPageInfo() { if (!document.getElementById("mediaTab").hidden) { @@ -410,10 +451,9 @@ function makeGeneralTab() var metaNodes = gDocument.getElementsByTagName("meta"); var length = metaNodes.length; - if (!length) { - var metaGroup = document.getElementById("metaTags"); + var metaGroup = document.getElementById("metaTags"); + if (!length) metaGroup.collapsed = true; - } else { var metaTagsCaption = document.getElementById("metaTagsCaption"); if (length == 1) @@ -425,6 +465,8 @@ function makeGeneralTab() for (var i = 0; i < length; i++) gMetaView.addRow([metaNodes[i].name || metaNodes[i].httpEquiv, metaNodes[i].content]); + + metaGroup.collapsed = false; } // get the date of last modification diff --git a/browser/base/content/pageinfo/permissions.js b/browser/base/content/pageinfo/permissions.js index a5f46efed273..bf730df9a637 100644 --- a/browser/base/content/pageinfo/permissions.js +++ b/browser/base/content/pageinfo/permissions.js @@ -86,6 +86,7 @@ function onLoadPermission() .getService(Components.interfaces.nsIPrefBranch2); var uri = gDocument.documentURIObject; + var permTab = document.getElementById("permTab"); if(/^https?/.test(uri.scheme)) { gPermURI = uri; var hostText = document.getElementById("hostText"); @@ -97,9 +98,10 @@ function onLoadPermission() .getService(Components.interfaces.nsIObserverService); os.addObserver(permissionObserver, "perm-changed", false); onUnloadRegistry.push(onUnloadPermission); + permTab.hidden = false; } else - document.getElementById("permTab").hidden = true; + permTab.hidden = true; } function onUnloadPermission() diff --git a/browser/base/content/pageinfo/security.js b/browser/base/content/pageinfo/security.js index 35ff75380963..99c0f816da9a 100644 --- a/browser/base/content/pageinfo/security.js +++ b/browser/base/content/pageinfo/security.js @@ -162,10 +162,14 @@ function securityOnLoad() { var info = security._getSecurityInfo(); if (!info) { - document.getElementById("securityTab").setAttribute("hidden", true); + document.getElementById("securityTab").hidden = true; document.getElementById("securityBox").collapsed = true; return; } + else { + document.getElementById("securityTab").hidden = false; + document.getElementById("securityBox").collapsed = false; + } /* Set Identity section text */ setText("security-identity-domain-value", info.hostName); @@ -198,15 +202,15 @@ function securityOnLoad() { setText("general-security-identity", generalPageIdentityString); /* Manage the View Cert button*/ + var viewCert = document.getElementById("security-view-cert"); if (info.cert) { var viewText = pageInfoBundle.getString("securityCertText"); setText("security-view-text", viewText); security._cert = info.cert; + viewCert.collapsed = false; } - else { - var viewCert = document.getElementById("security-view-cert"); + else viewCert.collapsed = true; - } /* Set Privacy & History section text */ var yesStr = pageInfoBundle.getString("yes");