Skip to content
This repository has been archived by the owner on Nov 3, 2021. It is now read-only.

Commit

Permalink
Merge pull request #7348 from vingtetun/827137
Browse files Browse the repository at this point in the history
Bug 827137 - Cost control running with foreground priority when not visi...
  • Loading branch information
vingtetun committed Jan 8, 2013
2 parents 66221e0 + 36609a3 commit df13e23
Showing 1 changed file with 30 additions and 33 deletions.
63 changes: 30 additions & 33 deletions apps/system/js/cost_control.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,48 +13,45 @@

var widgetFrame;
function _ensureWidget() {
if (!Applications.ready)
return;

if (Applications.ready) {
// Check widget is there
widgetFrame = widgetContainer.querySelector('iframe');
if (widgetFrame && !widgetFrame.dataset.killed)
return;

// Check widget is there
widgetFrame = widgetContainer.querySelector('iframe');
if (widgetFrame && !widgetFrame.dataset.killed)
return;

// Create the widget
if (!widgetFrame) {
widgetFrame = document.createElement('iframe');
widgetFrame.addEventListener('mozbrowsererror',
function ccdriver_onError(e) {
e.target.dataset.killed = true;
}
);
}
// Create the widget
if (!widgetFrame) {
widgetFrame = document.createElement('iframe');
widgetFrame.addEventListener('mozbrowsererror',
function ccdriver_onError(e) {
e.target.dataset.killed = true;
}
);
}

widgetFrame.dataset.frameType = 'widget';
widgetFrame.dataset.frameOrigin = origin;
delete widgetFrame.dataset.killed;
widgetFrame.dataset.frameType = 'widget';
widgetFrame.dataset.frameOrigin = origin;
delete widgetFrame.dataset.killed;

widgetFrame.setAttribute('mozbrowser', true);
widgetFrame.setAttribute('remote', 'true');
widgetFrame.setAttribute('mozapp', origin + '/manifest.webapp');
widgetFrame.setAttribute('mozbrowser', true);
widgetFrame.setAttribute('remote', 'true');
widgetFrame.setAttribute('mozapp', origin + '/manifest.webapp');

widgetFrame.src = origin + '/widget.html';
widgetContainer.appendChild(widgetFrame);
widgetFrame.src = origin + '/widget.html';
widgetContainer.appendChild(widgetFrame);

// TODO: Remove this when weird bug #809031 (Bugzilla) is solved
// See cost_control.css as well to remove the last rule
var offsetY = document.getElementById('notification-bar').clientHeight;
offsetY +=
document.getElementById('notifications-container').clientHeight;
widgetFrame.style.transform = 'translate(0, ' + offsetY + 'px)';
}
// TODO: Remove this when weird bug #809031 (Bugzilla) is solved
// See cost_control.css as well to remove the last rule
var offsetY = document.getElementById('notification-bar').clientHeight;
offsetY +=
document.getElementById('notifications-container').clientHeight;
widgetFrame.style.transform = 'translate(0, ' + offsetY + 'px)';
}

function _showWidget() {
if (!widgetFrame) {
_ensureWidget();
}
_ensureWidget();
widgetFrame.setVisible(true);
}

Expand Down

0 comments on commit df13e23

Please sign in to comment.