Refactor TextDocument out of TextBrowser