Detect document focus properly and allow null selection in model

The document is considered to be focused when it or its pasteTarget
has a native range. When it doesn't, the DM selection should be null.

Uses OO.ui.Element.onDOMEvent introduced in OOjs UI in 851fc18a.

(Second attempt after premature merge.)

Bug: 59868
Change-Id: I56ee6b1b00d22d2e68d4a4b032b4c9263599e730