+ bool WebDvdWindow::process_page()
+ {
+ assert(!page_queue_.empty());
+
+ nsCOMPtr<nsIWebBrowser> browser(browser_widget_.get_browser());
+ nsCOMPtr<nsIDocShell> doc_shell(do_GetInterface(browser));
+ assert(doc_shell);
+ nsCOMPtr<nsIPresShell> pres_shell;
+ check(doc_shell->GetPresShell(getter_AddRefs(pres_shell)));
+ nsCOMPtr<nsIPresContext> pres_context;
+ check(doc_shell->GetPresContext(getter_AddRefs(pres_context)));
+ nsCOMPtr<nsIDOMWindow> dom_window;
+ check(browser->GetContentDOMWindow(getter_AddRefs(dom_window)));
+
+ if (output_dir_.empty())
+ {
+ // In preview mode, just apply the stylesheet and let the
+ // user select links.
+ apply_style_sheet(stylesheet_, pres_shell);
+ }
+ else
+ {
+ // If we haven't already started work on this page, apply
+ // the stylesheet and save a screenshot of its normal
+ // appearance.
+ if (!page_state_.get())
+ {
+ apply_style_sheet(stylesheet_, pres_shell);
+ save_screenshot();
+ }
+
+ // Start or continue processing links.
+ process_links(pres_shell, pres_context, dom_window);
+
+ // If we've finished work on the links, move on to the
+ // next page, if any, or else generate the DVD filesystem.
+ if (!page_state_.get())
+ {
+ page_queue_.pop();
+ if (page_queue_.empty())
+ {
+ generate_dvd();
+ return false;
+ }
+ else
+ {
+ load_next_page();
+ }
+ }
+ }
+
+ return true;
+ }
+