From c5134f1ff9c5db1064d6644f42868bd2323a0168 Mon Sep 17 00:00:00 2001 From: Michael Yoshitaka Erlewine Date: Mon, 7 Feb 2011 20:57:37 -0500 Subject: [PATCH] Bug 629189 - Rect.contains should be inclusive [r=ian, a=sdwilsh] --HG-- extra : rebase_source : f9c21f70c6991f8df3a904163f886561f30d78e1 --- browser/base/content/tabview/modules/utils.jsm | 12 ++++++------ browser/base/content/test/tabview/Makefile.in | 1 + .../test/tabview/browser_tabview_bug629189.js | 14 ++++++++++++++ 3 files changed, 21 insertions(+), 6 deletions(-) create mode 100644 browser/base/content/test/tabview/browser_tabview_bug629189.js diff --git a/browser/base/content/tabview/modules/utils.jsm b/browser/base/content/tabview/modules/utils.jsm index 4555192c80f..0650369d35b 100644 --- a/browser/base/content/tabview/modules/utils.jsm +++ b/browser/base/content/tabview/modules/utils.jsm @@ -156,16 +156,16 @@ Rect.prototype = { // ---------- // Function: contains - // Returns a boolean denoting if the is contained inside - // of the bounding rect. + // Returns a boolean denoting if the given is contained within + // the this rectangle. // // Paramaters // - A 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); }, // ---------- diff --git a/browser/base/content/test/tabview/Makefile.in b/browser/base/content/test/tabview/Makefile.in index cb76aae2bad..c1fe877fa88 100644 --- a/browser/base/content/test/tabview/Makefile.in +++ b/browser/base/content/test/tabview/Makefile.in @@ -105,6 +105,7 @@ _BROWSER_FILES = \ 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 \ diff --git a/browser/base/content/test/tabview/browser_tabview_bug629189.js b/browser/base/content/test/tabview/browser_tabview_bug629189.js new file mode 100644 index 00000000000..0b7504fd501 --- /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]"); +}