]> git.decadent.org.uk Git - videolink.git/blobdiff - webdvd.cpp
Replaced BrowserWidget::init with a class that ensures proper initialisation and...
[videolink.git] / webdvd.cpp
index ceefb7804d446614ce69676bb8e6bbc05982aca7..5eca6c87eafe5a43d865241cff4e83df9b6df3e8 100644 (file)
 #include <nsIInterfaceRequestorUtils.h>
 #include <nsIURI.h> // required before nsILink.h
 #include <nsILink.h>
+#include <nsIPrefBranch.h>
+#include <nsIPrefService.h>
 #include <nsIPresContext.h>
 #include <nsIPresShell.h>
+#include <nsIServiceManagerUtils.h>
 #include <nsIWebBrowser.h>
 #include <nsString.h>
 
@@ -975,6 +978,30 @@ namespace
                   " [--preview] menu-url [output-dir]\n");
     }
     
+    void set_browser_preferences()
+    {
+       // Disable IE-compatibility kluge that causes backgrounds to
+       // sometimes/usually be missing from snapshots.  This is only
+       // effective from Mozilla 1.8 onward.
+#      if MOZ_VERSION_MAJOR > 1                                 \
+           || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
+       nsCOMPtr<nsIPrefService> pref_service;
+       static const nsCID pref_service_cid = NS_PREFSERVICE_CID;
+       check(CallGetService<nsIPrefService>(pref_service_cid,
+                                            getter_AddRefs(pref_service)));
+       nsCOMPtr<nsIPrefBranch> pref_branch;
+       check(pref_service->GetDefaultBranch("layout",
+                                            getter_AddRefs(pref_branch)));
+       check(pref_branch->SetBoolPref(
+                 "fire_onload_after_image_background_loads",
+                 true));
+#      endif
+
+       // TODO: Set display resolution?  Unfortunately Mozilla doesn't
+       // support non-square pixels (and neither do fontconfig or Xft
+       // anyway).
+    }
+
 } // namespace
 
 int main(int argc, char ** argv)
@@ -1091,7 +1118,8 @@ int main(int argc, char ** argv)
            output_dir = argv[argi + 1];
 
        // Initialise Mozilla
-       BrowserWidget::init();
+       BrowserWidget::Initialiser browser_init;
+       set_browser_preferences();
 
        // Run the browser/converter
        WebDvdWindow window(frame_params, menu_url, output_dir);