as per last commit, local messaging listener not needed anymore

This commit is contained in:
gorhill 2015-06-29 11:02:54 -04:00
parent aeba71790f
commit 8305b8990a
1 changed files with 52 additions and 79 deletions

View File

@ -435,16 +435,8 @@ var currentTabId = function() {
/******************************************************************************/
var cancelPollTimer = function() {
if ( pollTimer !== null ) {
clearTimeout(pollTimer);
pollTimer = null;
}
};
/******************************************************************************/
var onDOMFetched = function(response) {
var fetchDOMAsync = (function() {
var onFetched = function(response) {
if ( !response || currentTabId() !== inspectedTabId ) {
shutdownInspector();
injectInspectorAsync(250);
@ -473,9 +465,8 @@ var onDOMFetched = function(response) {
fetchDOMAsync();
};
/******************************************************************************/
var fetchDOM = function() {
var onTimeout = function() {
pollTimer = null;
messager.sendTo(
{
what: 'domLayout',
@ -483,21 +474,17 @@ var fetchDOM = function() {
},
inspectedTabId,
'dom-inspector.js',
onDOMFetched
onFetched
);
};
/******************************************************************************/
var fetchDOMAsync = function(delay) {
if ( pollTimer !== null ) {
return;
// Poll for DOM layout data every ~2 seconds at most
return function(delay) {
if ( pollTimer === null ) {
pollTimer = vAPI.setTimeout(onTimeout, delay || 2003);
}
pollTimer = vAPI.setTimeout(function() {
pollTimer = null;
fetchDOM();
}, delay || 2003);
};
})();
/******************************************************************************/
@ -540,7 +527,10 @@ var shutdownInspector = function() {
messager.sendTo({ what: 'shutdown' }, inspectedTabId, 'dom-inspector.js');
}
logger.removeAllChildren(domTree);
cancelPollTimer();
if ( pollTimer !== null ) {
clearTimeout(pollTimer);
pollTimer = null;
}
inspectedTabId = '';
};
@ -581,20 +571,6 @@ var revert = function() {
/******************************************************************************/
var onMessage = function(request) {
switch ( request.what ) {
case 'domLayout':
cancelPollTimer();
onDOMFetched(request);
break;
default:
break;
}
};
/******************************************************************************/
var toggleOn = function() {
window.addEventListener('beforeunload', toggleOff);
tabSelector.addEventListener('change', onTabIdChanged);
@ -604,7 +580,6 @@ var toggleOn = function() {
uDom.nodeFromSelector('#domInspector .permatoolbar .revert').addEventListener('click', revert);
uDom.nodeFromSelector('#domInspector .permatoolbar .commit').addEventListener('click', startDialog);
inspector.classList.add('enabled');
messager.addListener(onMessage);
injectInspector();
// Adjust tree view for toolbar height
domTree.style.setProperty(
@ -616,8 +591,6 @@ var toggleOn = function() {
/******************************************************************************/
var toggleOff = function() {
messager.removeListener(onMessage);
cancelPollTimer();
shutdownInspector();
window.removeEventListener('beforeunload', toggleOff);
tabSelector.removeEventListener('change', onTabIdChanged);