Bug 629189 - Rect.contains should be inclusive [r=ian, a=sdwilsh]
authorMichael Yoshitaka Erlewine <mitcho@mitcho.com>
Mon, 07 Feb 2011 20:57:37 -0500
changeset 62156 6f4c4e84943d63d7eaf3a1d0e8a56eb50da2c4aa
parent 62155 d265cdc8c02c3c69335ec3506d057f30c53ebf5f
child 62157 18b96505628988dcaacdc095e648240b958884f1
push idunknown
push userunknown
push dateunknown
reviewersian, sdwilsh
bugs629189
milestone2.0b12pre
Bug 629189 - Rect.contains should be inclusive [r=ian, a=sdwilsh]
browser/base/content/tabview/modules/utils.jsm
browser/base/content/test/tabview/Makefile.in
browser/base/content/test/tabview/browser_tabview_bug629189.js
--- a/browser/base/content/tabview/modules/utils.jsm
+++ b/browser/base/content/tabview/modules/utils.jsm
@@ -151,26 +151,26 @@ Rect.prototype = {
     if (box.width > 0 && box.height > 0)
       return box;
 
     return null;
   },
 
   // ----------
   // Function: contains
-  // Returns a boolean denoting if the <Rect> is contained inside
-  // of the bounding rect.
+  // Returns a boolean denoting if the given <Rect> is contained within
+  // the this rectangle.
   //
   // Paramaters
   //  - A <Rect>
   contains: function Rect_contains(rect) {
-    return (rect.left > this.left &&
-            rect.right < this.right &&
-            rect.top > this.top &&
-            rect.bottom < this.bottom);
+    return (rect.left >= this.left &&
+            rect.right <= this.right &&
+            rect.top >= this.top &&
+            rect.bottom <= this.bottom);
   },
 
   // ----------
   // Function: center
   // Returns a new <Point> with the center location of this rectangle.
   center: function Rect_center() {
     return new Point(this.left + (this.width / 2), this.top + (this.height / 2));
   },
--- a/browser/base/content/test/tabview/Makefile.in
+++ b/browser/base/content/test/tabview/Makefile.in
@@ -100,16 +100,17 @@ include $(topsrcdir)/config/rules.mk
                  browser_tabview_bug625269.js \
                  browser_tabview_bug625424.js \
                  browser_tabview_bug626368.js \
                  browser_tabview_bug626525.js \
                  browser_tabview_bug627288.js \
                  browser_tabview_bug627736.js \
                  browser_tabview_bug628165.js \
                  browser_tabview_bug628270.js \
+                 browser_tabview_bug629189.js \
                  browser_tabview_bug629195.js \
                  browser_tabview_bug630102.js \
                  browser_tabview_bug630157.js \
                  browser_tabview_bug631662.js \
                  browser_tabview_dragdrop.js \
                  browser_tabview_exit_button.js \
                  browser_tabview_expander.js \
                  browser_tabview_group.js \
new file mode 100644
--- /dev/null
+++ b/browser/base/content/test/tabview/browser_tabview_bug629189.js
@@ -0,0 +1,14 @@
+/* Any copyright is dedicated to the Public Domain.
+   http://creativecommons.org/publicdomain/zero/1.0/ */
+
+function test() {
+  let {Rect} = Components.utils.import("resource:///modules/tabview/utils.jsm", {});
+  
+  let referenceRect = new Rect(50,50,150,150);
+  let rect = new Rect(100,100,100,100);
+  
+  ok(referenceRect.contains(referenceRect), "A rect contains itself");
+  ok(referenceRect.contains(rect), "[50,50,150,150] contains [100,100,99,99]");
+  rect.inset(-1,-1);
+  ok(!referenceRect.contains(rect), "Now it grew and [50,50,150,150] doesn't contain [99,99,102,102]");
+}