This code sets things up so that we can edit (or make a thumbnail of, etc.) one page of a book. This is tricky because we have to satisfy several constraints: - We need to make this page content the 'src' of an iframe in a browser. So it has to be locatable by url. - It needs to appear to the browser to be a document in the book's folder. This allows local hrefs (e.g., src of images) that are normally relative to the whole-book file to locate the images. (We previously did this by making a file elsewhere and setting the 'base' for interpreting urls. But this fails for internal hrefs (starting with #)). - We don't want to risk leaving junk page files in the real book folder if anything goes wrong. - There may be several of these simulated pages around at the same time (e.g., when the thumbnailer is working on several threads). - The simulated files need to hang around for an unpredictable time (until the browser is done with them). The solution we have adopted is to make this server simulate files in the book folder. That is, the src for the page iframe is set to a localhost: url which maps to a file in the book folder. This means that any local hrefs (e.g., to images) will become server requests for the right file in the right folder. However, the page file never exists as a real file system file; instead, a request for the page file itself will be intercepted, and this server simply returns the content it has remembered. To manage the lifetime of the page data, we use a SimulatedPageFile object, which the Browser disposes of when it is no longer looking at that URL. Its dispose method tells this class to discard the simulated page data. To handle the need for multiple simulated page files and quickly check whether a particular url is one of them, we have a dictionary in which the urls are keys. A marker is inserted into the generated urls if the input HtmlDom wants to use original images.