зеркало из https://github.com/mozilla/pjs.git
Bug 629189 - Rect.contains should be inclusive [r=ian, a=sdwilsh]
--HG-- extra : rebase_source : f9c21f70c6991f8df3a904163f886561f30d78e1
This commit is contained in:
Родитель
31806d79b3
Коммит
c5134f1ff9
|
@ -156,16 +156,16 @@ Rect.prototype = {
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
// Function: contains
|
// Function: contains
|
||||||
// Returns a boolean denoting if the <Rect> is contained inside
|
// Returns a boolean denoting if the given <Rect> is contained within
|
||||||
// of the bounding rect.
|
// the this rectangle.
|
||||||
//
|
//
|
||||||
// Paramaters
|
// Paramaters
|
||||||
// - A <Rect>
|
// - A <Rect>
|
||||||
contains: function Rect_contains(rect) {
|
contains: function Rect_contains(rect) {
|
||||||
return (rect.left > this.left &&
|
return (rect.left >= this.left &&
|
||||||
rect.right < this.right &&
|
rect.right <= this.right &&
|
||||||
rect.top > this.top &&
|
rect.top >= this.top &&
|
||||||
rect.bottom < this.bottom);
|
rect.bottom <= this.bottom);
|
||||||
},
|
},
|
||||||
|
|
||||||
// ----------
|
// ----------
|
||||||
|
|
|
@ -105,6 +105,7 @@ _BROWSER_FILES = \
|
||||||
browser_tabview_bug627736.js \
|
browser_tabview_bug627736.js \
|
||||||
browser_tabview_bug628165.js \
|
browser_tabview_bug628165.js \
|
||||||
browser_tabview_bug628270.js \
|
browser_tabview_bug628270.js \
|
||||||
|
browser_tabview_bug629189.js \
|
||||||
browser_tabview_bug629195.js \
|
browser_tabview_bug629195.js \
|
||||||
browser_tabview_bug630102.js \
|
browser_tabview_bug630102.js \
|
||||||
browser_tabview_bug630157.js \
|
browser_tabview_bug630157.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]");
|
||||||
|
}
|
Загрузка…
Ссылка в новой задаче