function rectContains(a, b) {
    // check for empty first
    return a.left < a.right && a.top < a.bottom
        // now check for containment
        && a.left <= b.left && a.top <= b.top && a.right >= b.right && a.bottom >= b.bottom;
}
Returns true iff the specified rectangle b is inside or equal to
rectangle b. An empty rectangle never contains another rectangle.

@param {DOMRect} a The rectangle being tested whether rectangle b is inside this or not.
@param {DOMRect} b The rectangle being tested for containment.
@returns {boolean} returns true iff the specified rectangle r is inside or equal to this rectangle