Skip to content

Commit

Permalink
Issue 82: YSLOW does not work in Firebug 1.12beta
Browse files Browse the repository at this point in the history
  • Loading branch information
janodvarko committed Aug 21, 2013
1 parent 9ff0c71 commit 91bc85d
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 18 deletions.
59 changes: 48 additions & 11 deletions src/common/view.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,16 @@ YSLOW.view = function (panel, yscontext) {
this.yscontext = yscontext;

YSLOW.util.addEventListener(this.panelNode, 'click', function (e) {
var help, helplink, x, y, parent,
toolbar = panel.document.ysview.getElementByTagNameAndId(panel.panelNode, "div", "toolbarDiv");
var help, helplink, x, y, parent;
var doc = FBL.getContentView(panel.document);
var toolbar = doc.ysview.getElementByTagNameAndId(panel.panelNode, "div", "toolbarDiv");

// In order to support YSlow running on mutli-tab,
// we need to look up helpDiv using panelNode.
// panel_doc.getElementById('helpDiv') will always find
// helpDiv of YSlow running on the first browser tab.
if (toolbar) {
helplink = panel.document.ysview.getElementByTagNameAndId(toolbar, "li", "helpLink");
helplink = doc.ysview.getElementByTagNameAndId(toolbar, "li", "helpLink");
if (helplink) {
x = helplink.offsetLeft;
y = helplink.offsetTop;
Expand All @@ -84,15 +85,16 @@ YSLOW.view = function (panel, yscontext) {
return;
}
}
help = panel.document.ysview.getElementByTagNameAndId(toolbar, "div", "helpDiv");
help = doc.ysview.getElementByTagNameAndId(toolbar, "div", "helpDiv");
}
if (help && help.style.visibility === "visible") {
help.style.visibility = "hidden";
}
});

YSLOW.util.addEventListener(this.panelNode, 'scroll', function (e) {
var overlay = panel.document.ysview.modaldlg;
var doc = FBL.getContentView(panel.document);
var overlay = doc.ysview.modaldlg;

if (overlay && overlay.style.display === "block") {
overlay.style.top = panel.panelNode.scrollTop + 'px';
Expand All @@ -107,19 +109,22 @@ YSLOW.view = function (panel, yscontext) {
if (e.target.nodeName === "LABEL" && e.target.className === "rules") {
if (e.target.firstChild && e.target.firstChild.nodeName === "INPUT" && e.target.firstChild.type === "checkbox") {
rule = YSLOW.controller.getRule(e.target.firstChild.value);
panel.document.ysview.tooltip.show('<b>' + rule.name + '</b><br><br>' + rule.info, e.target);
var doc = FBL.getContentView(panel.document);
doc.ysview.tooltip.show('<b>' + rule.name + '</b><br><br>' + rule.info, e.target);
}
}
}
});

YSLOW.util.addEventListener(this.panelNode, 'mouseout', function (e) {
panel.document.ysview.tooltip.hide();
var doc = FBL.getContentView(panel.document);
doc.ysview.tooltip.hide();
});

YSLOW.util.addEventListener(this.panel_doc.defaultView ||
this.panel_doc.parentWindow, 'resize', function (e) {
var overlay = panel.document.ysview.modaldlg;
this.panel_doc.parentWindow, 'resize', function (e) {
var doc = FBL.getContentView(panel.document);
var overlay = doc.ysview.modaldlg;

if (overlay && overlay.style.display === "block") {
overlay.style.display = "none";
Expand Down Expand Up @@ -459,7 +464,8 @@ YSLOW.view.prototype = {
sText = this.getRulesetListSource(rulesets),

onchangeFunc = function (event) {
this.ownerDocument.ysview.onChangeRuleset(event);
var doc = FBL.getContentView(this.ownerDocument);
doc.ysview.onChangeRuleset(event);
};

for (i = 0; i < selects.length; i += 1) {
Expand Down Expand Up @@ -1443,8 +1449,39 @@ YSLOW.view.prototype = {
}
}
}
}
},

// exposed for access from content scope (Firebug UI, panel.html)
// See: https://blog.mozilla.org/addons/2012/08/20/exposing-objects-to-content-safely/
__exposedProps__: {
"openLink": "rw",
"showComponentHeaders": "rw",
"smushIt": "rw",
"saveRuleset": "rw",
"regenComponentsTable": "rw",
"expandCollapseComponentType": "rw",
"expandAll": "rw",
"updateFilterSelection": "rw",
"openPopup": "rw",
"runTool": "rw",
"onclickRuleset": "rw",
"createRuleset": "rw",
"addCDN": "rw",
"closeDialog": "rw",
"setAutorun": "rw",
"setAntiIframe": "rw",
"runTest": "rw",
"onChangeRuleset": "rw",
"showRuleSettings": "rw",
"openPrintableDialog": "rw",
"showHideHelp": "rw",
"setSplashView": "rw",
"onclickToolbarMenu": "rw",
"showPerformance": "rw",
"showComponents": "rw",
"showStats": "rw",
"showTools": "rw",
},
};

YSLOW.view.Tooltip = function (panel_doc, parentNode) {
Expand Down
18 changes: 12 additions & 6 deletions src/firefox/chrome/content/yslow-firebug.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ YSLOW.FBYSlow = {
*/
Firebug.YSlow = FBL.extend(Firebug.Module, {
initialize: function (prefDomain, prefNames) {
// nasty hack to workaround FB iinit issues
// nasty hack to workaround FB init issues
YSLOW.FBModInitialized = true;

YSLOW.net.registerNative(YSLOW.FBYSlow.net);
Expand Down Expand Up @@ -60,7 +60,9 @@ YSLOW.FBYSlow = {
panel = fbCtx.getPanel('YSlow');
panel.document.yslow_panel = panel;
panel.document.yslowContext = fbCtx.yslowContext;
panel.document.ysview = panel.ysview;

var doc = FBL.getContentView(panel.document);
doc.ysview = panel.ysview;
// update the document object we store in ysview
panel.ysview.setDocument(panel.document);
// reload all css.
Expand All @@ -80,7 +82,7 @@ YSLOW.FBYSlow = {

showPanel: function (browser, panel) {
var isYSlow = panel && panel.name === "YSlow",
YSlowButtons = browser.chrome.$("fbYSlowButtons");
YSlowButtons = Firebug.chrome.$("fbYSlowButtons");

FBL.collapse(YSlowButtons, !isYSlow);
},
Expand Down Expand Up @@ -259,7 +261,7 @@ YSLOW.FBYSlow = {
editable: false,

initialize: function (context, doc) {
// nasty hack to workaround FB iinit issues
// nasty hack to workaround FB init issues
if (!YSLOW.FBModInitialized) {
Firebug.YSlow.initialize();
}
Expand All @@ -284,7 +286,9 @@ YSLOW.FBYSlow = {

this.ysview = new YSLOW.view(this, this.context.yslowContext);
YSLOW.ysview = this.ysview;
this.document.ysview = this.ysview;

var doc = FBL.getContentView(this.document);
doc.ysview = this.ysview;

this.ysview.setSplashView();
},
Expand All @@ -298,7 +302,9 @@ YSLOW.FBYSlow = {
// There is only ONE DOCUMENT shared by all browser tabs. So if the user opens two
// browser tabs, we have to restore the appropriate yslowContext when switching between tabs.
this.document.yslowContext = fbCtx.yslowContext;
this.document.ysview = this.ysview;

var doc = FBL.getContentView(this.document);
doc.ysview = this.ysview;
},

createProgressBar: function () {
Expand Down
4 changes: 3 additions & 1 deletion src/firefox/chrome/content/yslow-firefox.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,9 @@ YSLOW.firefox.Panel.prototype = {

this.ysview = new YSLOW.view(this, this.document.yslowContext);
YSLOW.ysview = this.ysview;
this.document.ysview = this.ysview;

var doc = FBL.getContentView(this.document);
doc.ysview = this.ysview;

this.ysview.setSplashView();

Expand Down

0 comments on commit 91bc85d

Please sign in to comment.