Fix bounding-box checks due to off-by-one errors on Firefox

"I got 98.999999999999 problems..."

Due to rounding errors, sometimes bounds checks would fail in FF.
Solution: use Math.floor() and Math.ceil() to account for sub-pixel
errors.

Close #477.
Close #305 (no more test failures in FF!).