Range update
authorMichael Yoshitaka Erlewine <mitcho@mitcho.com>
Sat, 19 Jun 2010 17:37:36 -0400
changeset 49468 851973ffcc6e291377ae262fada258d3eac458e0
parent 49467 e922e758caead42286612e6bac33b629194c3adf
child 49469 b38d070141234ff488674628a9b8abdc091c2f6b
push id1
push userroot
push dateTue, 26 Apr 2011 22:38:44 +0000
treeherdermozilla-beta@bfdb6e623a36 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
Range update
browser/base/content/tabview/modules/utils.jsm
--- a/browser/base/content/tabview/modules/utils.jsm
+++ b/browser/base/content/tabview/modules/utils.jsm
@@ -252,45 +252,61 @@ window.Rect.prototype = {
 
 // ##########  
 // Class: Range
 // A physical interval, with a min and max.
 //
 // Constructor: Range
 // Creates a Range with the given min and max
 window.Range = function(min, max) {
-	this.min = min;
-	this.max = max;
+	this.min = min || 0;
+	this.max = max || 0;
 };
 
 // ----------
 window.isRange = function(r) {
   return (r 
       && Utils.isNumber(r.min)
       && Utils.isNumber(r.max));
 };
 
 window.Range.prototype = {  
+	// Variable: extent
+	// Equivalent to max-min
+	get extent() {
+		return (this.max - this.min);
+	},
+
+	set extent(extent) {
+		this.max = extent - this.min;
+	},
+
   // ----------
   // Function: contains
   // Whether the <Range> contains the given value or not
   //
   // Paramaters
-  //  - a number
+  //  - a number or <Range>
   contains: function(value) {
-    return( value >= this.min && value <= this.max );
+  	if (Utils.isNumber(value))
+			return ( value >= this.min && value <= this.max );
+		else if (isRange(value))
+			return ( value.min >= this.min && value.max <= this.max );
   },
   // ----------
   // Function: containsWithin
   // Whether the <Range>'s interior contains the given value or not
   //
   // Paramaters
-  //  - a number
+  //  - a number or <Range>
   containsWithin: function(value) {
-    return( value > this.min && value < this.max );
+  	if (Utils.isNumber(value))
+			return ( value > this.min && value < this.max );
+		else if (isRange(value))
+			return ( value.min > this.min && value.max < this.max );
   },
   
 };
 
 // ##########
 // Class: Subscribable
 // A mix-in for allowing objects to collect subscribers for custom events. 
 // Currently supports only onClose.