Bug 377724: Don't crash when calling into layout on a detached document.