Safer way of getting rtl environment. Fixes #520

This is a workaround for a Firefox bug, where `window.getComputedStyle()` returns null in an iframe with display:none.

Please let me know if you want style changes or a restructuring of the logic.