Skip to content

Commit

Permalink
Bug 622631 - JavaScript Warning: "Error in parsing value for 'width'/…
Browse files Browse the repository at this point in the history
…'height'. Declaration dropped." [r=ian, a=beltzner]
  • Loading branch information
mitcho committed Jan 12, 2011
1 parent 95441cb commit 42ee6c6
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 19 deletions.
25 changes: 19 additions & 6 deletions browser/base/content/tabview/groupitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -429,8 +429,7 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (!options)
options = {};

rect.width = Math.max(110, rect.width);
rect.height = Math.max(125, rect.height);
GroupItems.enforceMinSize(rect);

var titleHeight = this.$titlebar.height();

Expand Down Expand Up @@ -1212,14 +1211,14 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {

var self = this;
var children = [];
this._children.forEach(function(child) {
this._children.forEach(function GroupItem__stackArrange_order(child) {
if (child == self.topChild)
children.unshift(child);
else
children.push(child);
});

children.forEach(function(child, index) {
children.forEach(function GroupItem__stackArrange_apply(child, index) {
if (!child.locked.bounds) {
child.setZ(zIndex);
zIndex--;
Expand Down Expand Up @@ -1509,8 +1508,8 @@ GroupItem.prototype = Utils.extend(new Item(), new Subscribable(), {
// Function: setResizable
// Sets whether the groupItem is resizable and updates the UI accordingly.
setResizable: function GroupItem_setResizable(value, immediately) {
this.resizeOptions.minWidth = 110;
this.resizeOptions.minHeight = 125;
this.resizeOptions.minWidth = GroupItems.minGroupWidth;
this.resizeOptions.minHeight = GroupItems.minGroupHeight;

if (value) {
immediately ? this.$resizer.show() : this.$resizer.fadeIn();
Expand Down Expand Up @@ -1628,6 +1627,8 @@ let GroupItems = {
_arrangePaused: false,
_arrangesPending: [],
_removingHiddenGroups: false,
minGroupHeight: 110,
minGroupWidth: 125,

// ----------
// Function: init
Expand Down Expand Up @@ -2309,6 +2310,18 @@ let GroupItems = {
this._removingHiddenGroups = false;
},

// ----------
// Function: enforceMinSize
// Takes a <Rect> and modifies that <Rect> in case it is too small to be
// the bounds of a <GroupItem>.
//
// Parameters:
// bounds - (<Rect>) the target bounds of a <GroupItem>
enforceMinSize: function GroupItems_enforceMinSize(bounds) {
bounds.width = Math.max(bounds.width, this.minGroupWidth);
bounds.height = Math.max(bounds.height, this.minGroupHeight);
},

// ----------
// Function: getUnclosableGroupItemId
// If there's only one (non-hidden) group, and there are app tabs present,
Expand Down
1 change: 1 addition & 0 deletions browser/base/content/tabview/iq.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,6 +502,7 @@ iQClass.prototype = {
let elem = this[i];
for (let key in properties) {
let value = properties[key];

if (pixels[key] && typeof value != 'string')
value += 'px';

Expand Down
23 changes: 13 additions & 10 deletions browser/base/content/tabview/items.js
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Item.prototype = {
var itemsToPush = [this];
this.pushAwayData.generation = 0;

var pushOne = function(baseItem) {
var pushOne = function Item_pushAway_pushOne(baseItem) {
// the baseItem is an n-generation pushed item. (n could be 0)
var baseData = baseItem.pushAwayData;
var bb = new Rect(baseData.bounds);
Expand All @@ -357,7 +357,7 @@ Item.prototype = {
// bbc = center of the base's bounds
var bbc = bb.center();

items.forEach(function(item) {
items.forEach(function Item_pushAway_pushOne_pushEach(item) {
if (item == baseItem || item.locked.bounds)
return;

Expand Down Expand Up @@ -419,12 +419,12 @@ Item.prototype = {

// ___ Squish!
var pageBounds = Items.getSafeWindowBounds();
items.forEach(function(item) {
items.forEach(function Item_pushAway_squish(item) {
var data = item.pushAwayData;
if (data.generation == 0 || item.locked.bounds)
return;

function apply(item, posStep, posStep2, sizeStep) {
let apply = function Item_pushAway_squish_apply(item, posStep, posStep2, sizeStep) {
var data = item.pushAwayData;
if (data.generation == 0)
return;
Expand All @@ -434,8 +434,11 @@ Item.prototype = {
bounds.height -= sizeStep.y;
bounds.left += posStep.x;
bounds.top += posStep.y;

if (!item.isAGroupItem) {

if (item.isAGroupItem) {
GroupItems.enforceMinSize(bounds);
} else {
TabItems.enforceMinSize(bounds);
if (sizeStep.y > sizeStep.x) {
var newWidth = bounds.height * (TabItems.tabWidth / TabItems.tabHeight);
bounds.left += (bounds.width - newWidth) / 2;
Expand Down Expand Up @@ -463,7 +466,7 @@ Item.prototype = {
posStep.x = pageBounds.left - bounds.left;
sizeStep.x = posStep.x / data.generation;
posStep2.x = -sizeStep.x;
} else if (bounds.right > pageBounds.right) {
} else if (bounds.right > pageBounds.right) { // this may be less of a problem post-601534
posStep.x = pageBounds.right - bounds.right;
sizeStep.x = -posStep.x / data.generation;
posStep.x += sizeStep.x;
Expand All @@ -474,7 +477,7 @@ Item.prototype = {
posStep.y = pageBounds.top - bounds.top;
sizeStep.y = posStep.y / data.generation;
posStep2.y = -sizeStep.y;
} else if (bounds.bottom > pageBounds.bottom) {
} else if (bounds.bottom > pageBounds.bottom) { // this may be less of a problem post-601534
posStep.y = pageBounds.bottom - bounds.bottom;
sizeStep.y = -posStep.y / data.generation;
posStep.y += sizeStep.y;
Expand All @@ -487,7 +490,7 @@ Item.prototype = {

// ___ Unsquish
var pairs = [];
items.forEach(function(item) {
items.forEach(function Item_pushAway_setupUnsquish(item) {
var data = item.pushAwayData;
pairs.push({
item: item,
Expand All @@ -498,7 +501,7 @@ Item.prototype = {
Items.unsquish(pairs);

// ___ Apply changes
items.forEach(function(item) {
items.forEach(function Item_pushAway_setBounds(item) {
var data = item.pushAwayData;
var bounds = data.bounds;
if (!bounds.equals(data.startBounds)) {
Expand Down
21 changes: 18 additions & 3 deletions browser/base/content/tabview/tabitems.js
Original file line number Diff line number Diff line change
Expand Up @@ -394,6 +394,8 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
if (!options)
options = {};

TabItems.enforceMinSize(rect);

if (this._zoomPrep)
this.bounds.copy(rect);
else {
Expand Down Expand Up @@ -576,7 +578,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {

if (value) {
this.resizeOptions.minWidth = TabItems.minTabWidth;
this.resizeOptions.minHeight = TabItems.minTabWidth * (TabItems.tabHeight / TabItems.tabWidth);
this.resizeOptions.minHeight = TabItems.minTabHeight;
immediately ? $resizer.show() : $resizer.fadeIn();
this.resizable(true);
} else {
Expand Down Expand Up @@ -744,9 +746,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
let animateZoom = gPrefBranch.getBoolPref("animate_zoom");

var $div = iQ(this.container);
var data;

var box = this.getBounds();
if (value && animateZoom) {
this._zoomPrep = true;

Expand All @@ -763,6 +763,7 @@ TabItem.prototype = Utils.extend(new Item(), new Subscribable(), {
.addClass('front')
.css(this.getZoomRect(2));
} else {
let box = this.getBounds();
this._zoomPrep = false;
$div.removeClass('front');

Expand Down Expand Up @@ -799,6 +800,8 @@ let TabItems = {
init: function TabItems_init() {
Utils.assert(window.AllTabs, "AllTabs must be initialized first");
let self = this;

this.minTabHeight = this.minTabWidth * this.tabHeight / this.tabWidth;

let $canvas = iQ("<canvas>");
$canvas.appendTo(iQ("body"));
Expand Down Expand Up @@ -1191,6 +1194,18 @@ let TabItems = {
}

return sane;
},

// ----------
// Function: enforceMinSize
// Takes a <Rect> and modifies that <Rect> in case it is too small to be
// the bounds of a <TabItem>.
//
// Parameters:
// bounds - (<Rect>) the target bounds of a <TabItem>
enforceMinSize: function TabItems_enforceMinSize(bounds) {
bounds.width = Math.max(bounds.width, this.minTabWidth);
bounds.height = Math.max(bounds.height, this.minTabHeight);
}
};

Expand Down

0 comments on commit 42ee6c6

Please sign in to comment.