mirror of
https://github.com/mozilla/gecko-dev.git
synced 2025-01-13 15:34:01 +00:00
Bug 530835 - Flash: Chrome UI shows up on background of flash videos [r=gavin.sharp]
This commit is contained in:
parent
17da625f90
commit
82fe8b26eb
@ -176,11 +176,15 @@ let Util = {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* Cache of commonly used elements.
|
||||
*/
|
||||
let Elements = {};
|
||||
|
||||
[
|
||||
["browserBundle", "bundle_browser"],
|
||||
["contentShowing", "bcast_contentShowing"],
|
||||
["stack", "stack"],
|
||||
].forEach(function (elementGlobal) {
|
||||
let [name, id] = elementGlobal;
|
||||
Elements.__defineGetter__(name, function () {
|
||||
@ -314,7 +318,7 @@ Rect.prototype = {
|
||||
return this;
|
||||
},
|
||||
|
||||
setBounds: function(t, l, b, r) {
|
||||
setBounds: function(l, t, r, b) {
|
||||
this.top = t;
|
||||
this.left = l;
|
||||
this.bottom = b;
|
||||
@ -452,8 +456,35 @@ Rect.prototype = {
|
||||
translateInside: function translateInside(other) {
|
||||
let offsetX = (this.left < other.left ? other.left - this.left :
|
||||
(this.right > other.right ? this.right - other.right : 0));
|
||||
let offsetY = (this.top < other.top ? other.top - this.top :
|
||||
let offsetY = (this.top < other.top ? other.top - this.top :
|
||||
(this.bottom > other.bottom ? this.bottom - other.bottom : 0));
|
||||
return this.translate(offsetX, offsetY);
|
||||
}
|
||||
},
|
||||
|
||||
/** Subtract other area from this. Returns array of rects whose union is this-other. */
|
||||
subtract: function subtract(other) {
|
||||
let r = new Rect(0, 0, 0, 0);
|
||||
let result = [];
|
||||
other = other.intersect(this);
|
||||
if (other.isEmpty())
|
||||
return [this.clone()];
|
||||
|
||||
// left strip
|
||||
r.setBounds(this.left, this.top, other.left, this.bottom);
|
||||
if (!r.isEmpty())
|
||||
result.push(r.clone());
|
||||
// inside strip
|
||||
r.setBounds(other.left, this.top, other.right, other.top);
|
||||
if (!r.isEmpty())
|
||||
result.push(r.clone());
|
||||
r.setBounds(other.left, other.bottom, other.right, this.bottom);
|
||||
if (!r.isEmpty())
|
||||
result.push(r.clone());
|
||||
// right strip
|
||||
r.setBounds(other.right, this.top, this.right, this.bottom);
|
||||
if (!r.isEmpty())
|
||||
result.push(r.clone());
|
||||
|
||||
return result;
|
||||
},
|
||||
};
|
||||
|
@ -69,5 +69,34 @@ let tests = {
|
||||
let r2 = new Rect(0, 0, 0, 0);
|
||||
r1.expandToContain(r2);
|
||||
ok(r1.isEmpty(), "expandToContain of empty and empty is empty");
|
||||
}
|
||||
},
|
||||
|
||||
testSubtract: function testSubtract() {
|
||||
function equals(rects1, rects2) {
|
||||
return rects1.length == rects2.length && rects1.every(function(r, i) {
|
||||
return r.equals(rects2[i]);
|
||||
});
|
||||
}
|
||||
|
||||
let r1 = new Rect(0, 0, 100, 100);
|
||||
let r2 = new Rect(500, 500, 100, 100);
|
||||
ok(equals(r1.subtract(r2), [r1]), "subtract area outside of region yields same region");
|
||||
|
||||
let r1 = new Rect(0, 0, 100, 100);
|
||||
let r2 = new Rect(-10, -10, 50, 120);
|
||||
ok(equals(r1.subtract(r2), [new Rect(40, 0, 60, 100)]), "subtracting vertical bar from edge leaves one rect");
|
||||
|
||||
let r1 = new Rect(0, 0, 100, 100);
|
||||
let r2 = new Rect(-10, -10, 120, 50);
|
||||
ok(equals(r1.subtract(r2), [new Rect(0, 40, 100, 60)]), "subtracting horizontal bar from edge leaves one rect");
|
||||
|
||||
let r1 = new Rect(0, 0, 100, 100);
|
||||
let r2 = new Rect(40, 40, 20, 20);
|
||||
ok(equals(r1.subtract(r2), [
|
||||
new Rect(0, 0, 40, 100),
|
||||
new Rect(40, 0, 20, 40),
|
||||
new Rect(40, 60, 20, 40),
|
||||
new Rect(60, 0, 40, 100)]),
|
||||
"subtracting rect in middle leaves union of rects");
|
||||
},
|
||||
};
|
||||
|
Loading…
x
Reference in New Issue
Block a user