Backout 34d187fac5f7 (bug 777176) for possibly causing bug 782901 on a CLOSED TREE

This commit is contained in:
Ed Morley 2012-08-15 10:48:13 +01:00
parent 97def80127
commit c099eff7e1
5 changed files with 55 additions and 81 deletions

View File

@ -282,14 +282,6 @@ var SocialToolbar = {
updateButtonHiddenState: function SocialToolbar_updateButtonHiddenState() {
this.button.hidden = !Social.uiVisible;
if (!Social.provider.profile || !Social.provider.profile.userName) {
["social-notification-box",
"social-status-iconbox"].forEach(function removeChildren(parentId) {
let parent = document.getElementById(parentId);
while(parent.hasChildNodes())
parent.removeChild(parent.firstChild);
});
}
},
updateProfile: function SocialToolbar_updateProfile() {
@ -314,67 +306,42 @@ var SocialToolbar = {
updateButton: function SocialToolbar_updateButton() {
this.updateButtonHiddenState();
let provider = Social.provider;
// if there are no ambient icons, we collapse them in the following loop
let iconNames = Object.keys(provider.ambientNotificationIcons);
let iconBox = document.getElementById("social-status-iconbox");
let notifBox = document.getElementById("social-notification-box");
let notifBrowsers = document.createDocumentFragment();
let iconContainers = document.createDocumentFragment();
for each(let name in iconNames) {
let icon = provider.ambientNotificationIcons[name];
let notifBrowserId = "social-status-" + icon.name;
let notifBrowser = document.getElementById(notifBrowserId);
if (!notifBrowser) {
notifBrowser = document.createElement("iframe");
notifBrowser.setAttribute("type", "content");
notifBrowser.setAttribute("id", notifBrowserId);
notifBrowsers.appendChild(notifBrowser);
for (var i = 0; i < iconBox.childNodes.length; i++) {
let iconContainer = iconBox.childNodes[i];
if (i > iconNames.length - 1) {
iconContainer.collapsed = true;
continue;
}
notifBrowser.setAttribute("origin", provider.origin);
if (notifBrowser.getAttribute("src") != icon.contentPanel)
notifBrowser.setAttribute("src", icon.contentPanel);
let iconId = "social-notification-icon-" + icon.name;
let iconContainer = document.getElementById(iconId);
let iconImage, iconCounter;
if (iconContainer) {
iconImage = iconContainer.getElementsByClassName("social-notification-icon-image")[0];
iconCounter = iconContainer.getElementsByClassName("social-notification-icon-counter")[0];
iconContainer.collapsed = false;
let icon = provider.ambientNotificationIcons[iconNames[i]];
let iconImage = iconContainer.firstChild;
let iconCounter = iconImage.nextSibling;
iconImage.setAttribute("contentPanel", icon.contentPanel);
iconImage.setAttribute("src", icon.iconURL);
if (iconCounter.firstChild)
iconCounter.removeChild(iconCounter.firstChild);
if (icon.counter) {
iconCounter.appendChild(document.createTextNode(icon.counter));
iconCounter.collapsed = false;
} else {
iconContainer = document.createElement("box");
iconContainer.setAttribute("id", iconId);
iconContainer.classList.add("social-notification-icon-container");
iconContainer.addEventListener("click", function (e) { SocialToolbar.showAmbientPopup(iconContainer); }, false);
iconImage = document.createElement("image");
iconImage.classList.add("social-notification-icon-image");
iconImage = iconContainer.appendChild(iconImage);
iconCounter = document.createElement("box");
iconCounter.classList.add("social-notification-icon-counter");
iconCounter.appendChild(document.createTextNode(""));
iconCounter = iconContainer.appendChild(iconCounter);
iconContainers.appendChild(iconContainer);
iconCounter.collapsed = true;
}
if (iconImage.getAttribute("src") != icon.iconURL)
iconImage.setAttribute("src", icon.iconURL);
iconImage.setAttribute("notifBrowserId", notifBrowserId);
iconCounter.collapsed = !icon.counter;
iconCounter.firstChild.textContent = icon.counter || "";
}
notifBox.appendChild(notifBrowsers);
iconBox.appendChild(iconContainers);
},
showAmbientPopup: function SocialToolbar_showAmbientPopup(iconContainer) {
let iconImage = iconContainer.firstChild;
let panel = document.getElementById("social-notification-panel");
let notifBox = document.getElementById("social-notification-box");
let notifBrowser = document.getElementById(iconImage.getAttribute("notifBrowserId"));
let notifBrowser = document.getElementById("social-notification-browser");
panel.hidden = false;
@ -382,36 +349,30 @@ var SocialToolbar = {
// FIXME: bug 764787: Maybe we can use nsIDOMWindowUtils.getRootBounds() here?
// Need to handle dynamic sizing
let doc = notifBrowser.contentDocument;
if (!doc) {
return;
}
// "notif" is an implementation detail that we should get rid of
// eventually
let body = doc.getElementById("notif") || doc.body;
if (!body || !body.firstChild) {
let body = doc.getElementById("notif") || (doc.body && doc.body.firstChild);
if (!body)
return;
}
// Clear dimensions on all browsers so the panel size will
// only use the selected browser.
let browserIter = notifBox.firstElementChild;
while (browserIter) {
browserIter.hidden = (browserIter != notifBrowser);
browserIter = browserIter.nextElementSibling;
}
let [height, width] = [body.firstChild.offsetHeight || 300, 330];
notifBrowser.style.width = width + "px";
notifBrowser.style.height = height + "px";
let h = body.scrollHeight > 0 ? body.scrollHeight : 300;
notifBrowser.style.width = body.scrollWidth + "px";
notifBrowser.style.height = h + "px";
}
sizePanelToContent();
notifBrowser.addEventListener("DOMContentLoaded", function onload() {
notifBrowser.removeEventListener("DOMContentLoaded", onload);
sizePanelToContent();
});
panel.addEventListener("popuphiding", function onpopuphiding() {
panel.removeEventListener("popuphiding", onpopuphiding);
// unload the panel
SocialToolbar.button.removeAttribute("open");
notifBrowser.setAttribute("src", "about:blank");
});
notifBrowser.setAttribute("origin", Social.provider.origin);
notifBrowser.setAttribute("src", iconImage.getAttribute("contentPanel"));
this.button.setAttribute("open", "true");
panel.openPopup(iconImage, "bottomcenter topleft", 0, 0, false, false);
}

View File

@ -269,7 +269,7 @@
</panel>
<panel id="social-notification-panel" type="arrow" hidden="true" noautofocus="true">
<box id="social-notification-box" flex="1"></box>
<browser id="social-notification-browser" type="content" flex="1"/>
</panel>
<menupopup id="inspector-node-popup">
@ -685,6 +685,21 @@
</menupopup>
</button>
<hbox id="social-status-iconbox" flex="1">
<box class="social-notification-icon-container" collapsed="true"
onclick="SocialToolbar.showAmbientPopup(this);">
<image class="social-notification-icon-image"/>
<box class="social-notification-icon-counter" collapsed="true"/>
</box>
<box class="social-notification-icon-container" collapsed="true"
onclick="SocialToolbar.showAmbientPopup(this);">
<image class="social-notification-icon-image"/>
<box class="social-notification-icon-counter" collapsed="true"/>
</box>
<box class="social-notification-icon-container" collapsed="true"
onclick="SocialToolbar.showAmbientPopup(this);">
<image class="social-notification-icon-image"/>
<box class="social-notification-icon-counter" collapsed="true"/>
</box>
</hbox>
</hbox>
</toolbaritem>

View File

@ -64,9 +64,6 @@ endif
# browser_pageInfo.js + feed_tab.html is disabled for leaking (bug 767896)
# browser_social_shareButton.js is disabled for not properly
# tearing down the social providers (bug 780010).
_BROWSER_FILES = \
head.js \
browser_typeAheadFind.js \
@ -159,6 +156,7 @@ _BROWSER_FILES = \
browser_bug749738.js \
browser_bug763468.js \
browser_bug767836.js \
browser_social_shareButton.js \
browser_canonizeURL.js \
browser_customize.js \
browser_findbarClose.js \

View File

@ -29,7 +29,7 @@ var tests = {
function triggerIconPanel() {
let statusIcons = document.getElementById("social-status-iconbox");
ok(!statusIcons.firstChild.hidden, "status icon is visible");
ok(!statusIcons.firstChild.collapsed, "status icon is visible");
// Click the button to trigger its contentPanel
let panel = document.getElementById("social-notification-panel");
EventUtils.synthesizeMouseAtCenter(statusIcons.firstChild, {});

View File

@ -62,7 +62,7 @@ var tests = {
ok(userButton.hidden, "username is not visible");
let ambience = document.getElementById("social-status-iconbox").firstChild;
while (ambience) {
ok(ambience.collapsed, "ambient icon (" + ambience.id + ") is collapsed");
ok(ambience.collapsed, "ambient icon is collapsed");
ambience = ambience.nextSibling;
}