We switch the open state storage to the element rather than the frame,
to be able to preserve it across reframes.
The code is loosely based on nsHideViewer in nsSubDocument.cpp, but it's
simpler because we don't need to do restoration shenanigans.
Differential Revision: https://phabricator.services.mozilla.com/D138689