Handle cases when there's no viewport. Also make clientWidth/Height not use viewport dimensions in iframes. https://www.w3.org/Bugs/Public/show_bug.cgi?id=16380&list_id=10990 https://www.w3.org/Bugs/Public/show_bug.cgi?id=22063