Use next edge when preferred edge rect would be out of bounds

This fixes a bug where defaulting to the preferred edge when the popover's proposed rect isn't contained in the screen's visible frame, causes the popover to display incorrectly.

Before:

![popover-edge-bug](https://cloud.githubusercontent.com/assets/24247/2635858/00eec702-be8a-11e3-97e9-737146650ec6.gif)

After:
![popover-edge-bug-fix](https://cloud.githubusercontent.com/assets/24247/2635860/0746cf0a-be8a-11e3-9ab2-ed22c30450fa.gif)

Also fixes a bug where a zero anchor point doesn't render the arrow on the edge.

Before:

![arrow-edge-bug](https://cloud.githubusercontent.com/assets/24247/2635963/7127d09e-be8b-11e3-9e68-fbe766caf50b.gif)

After:
![arrow-edge-bug-fix](https://cloud.githubusercontent.com/assets/24247/2635967/7585b692-be8b-11e3-8134-6f17114c7c85.gif)