Add null checks in ImageDocument
<rdar://problem/245457>
Pull request: https://github.com/WebKit/WebKit/pull/4556
Committed 254715@main (4b51c19b1cdd): <https://commits.webkit.org/254715@main> Reviewed commits have been landed. Closing PR #4556 and removing active labels.