]> git.decadent.org.uk Git - videolink.git/blobdiff - videolink.cpp
Stopped setting assumed screen resolution in Mozilla/XULRunner 1.8 since the browser...
[videolink.git] / videolink.cpp
index 3d2daebd0176644a008444e729c76e86ebd85be3..bda78ce113c51bca35894e3db3e14795eb7455b6 100644 (file)
 #include <nsIURI.h> // required before nsILink.h
 #include <nsILink.h>
 #include <nsIPrefBranch.h>
+#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
+#   include <nsPresContext.h>
+#else
+#   include <nsIPresContext.h>
+    typedef nsIPresContext nsPresContext; // ugh
+#endif
 #include <nsIPrefService.h>
-#include <nsIPresContext.h>
 #include <nsIPresShell.h>
-#include <nsIServiceManagerUtils.h>
+#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
+#   include <nsServiceManagerUtils.h>
+#else
+#   include <nsIServiceManagerUtils.h>
+#endif
 #include <nsIWebBrowser.h>
 #include <nsString.h>
 
@@ -178,14 +187,14 @@ namespace
        bool process_page();
        void save_screenshot();
        void process_links(nsIPresShell * pres_shell,
-                          nsIPresContext * pres_context,
+                          nsPresContext * pres_context,
                           nsIDOMWindow * dom_window);
 
        video::frame_params frame_params_;
        std::string output_dir_;
        mpeg_encoder encoder_;
        browser_widget browser_widget_;
-       nsCOMPtr<nsIStyleSheet> stylesheet_;
+       agent_style_sheet_holder style_sheet_;
 
        dvd_contents contents_;
        typedef std::map<std::string, dvd_contents::pgc_ref> resource_map_type;
@@ -210,7 +219,8 @@ namespace
            : frame_params_(frame_params),
              output_dir_(output_dir),
              encoder_(encoder),
-             stylesheet_(load_css("file://" VIDEOLINK_LIB_DIR "/videolink.css")),
+             style_sheet_(init_agent_style_sheet(
+                              "file://"VIDEOLINK_SHARE_DIR"/videolink.css")),
              pending_window_update_(false),
              pending_req_count_(0),
              have_tweaked_page_(false),
@@ -422,7 +432,7 @@ namespace
        assert(doc_shell);
        nsCOMPtr<nsIPresShell> pres_shell;
        check(doc_shell->GetPresShell(getter_AddRefs(pres_shell)));
-       nsCOMPtr<nsIPresContext> pres_context;
+       nsCOMPtr<nsPresContext> pres_context;
        check(doc_shell->GetPresContext(getter_AddRefs(pres_context)));
        nsCOMPtr<nsIDOMWindow> dom_window;
        check(browser->GetContentDOMWindow(getter_AddRefs(dom_window)));
@@ -431,7 +441,7 @@ namespace
        // disable scrollbars.
        if (!have_tweaked_page_)
        {
-           apply_style_sheet(stylesheet_, pres_shell);
+           apply_agent_style_sheet(style_sheet_, pres_shell);
 
            // This actually only needs to be done once.
            nsCOMPtr<nsIDOMBarProp> dom_bar_prop;
@@ -526,7 +536,7 @@ namespace
     };
 
     void videolink_window::process_links(nsIPresShell * pres_shell,
-                                    nsIPresContext * pres_context,
+                                    nsPresContext * pres_context,
                                     nsIDOMWindow * dom_window)
     {
        Glib::RefPtr<Gdk::Window> window(get_window());
@@ -703,7 +713,12 @@ namespace
                check(event_state_man->SetContentState(content,
                                                       NS_EVENT_STATE_HOVER));
 
-               pres_shell->FlushPendingNotifications(true);
+#              if MOZ_VERSION_MAJOR > 1                                   \
+                    || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
+                   pres_shell->FlushPendingNotifications(Flush_Display);
+#              else
+                   pres_shell->FlushPendingNotifications(true);
+#              endif
 
                // We may have to exit and wait for image loading
                // to complete, at which point we will be called
@@ -850,17 +865,16 @@ namespace
        check(CallGetService<nsIPrefService>(pref_service_cid,
                                             getter_AddRefs(pref_service)));
        nsCOMPtr<nsIPrefBranch> pref_branch;
+       check(pref_service->GetBranch("", getter_AddRefs(pref_branch)));
 
-       // 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)
-       check(pref_service->GetDefaultBranch("layout",
-                                            getter_AddRefs(pref_branch)));
-       check(pref_branch->SetBoolPref(
-                 "fire_onload_after_image_background_loads",
-                 true));
+           // Disable IE-compatibility kluge that causes backgrounds to
+           // sometimes/usually be missing from snapshots.  This is only
+           // effective from Mozilla 1.8 onward.
+           check(pref_branch->SetBoolPref(
+                     "layout.fire_onload_after_image_background_loads",
+                     true));
 #      endif
 
        // Set display resolution.  With standard-definition video we
@@ -871,9 +885,21 @@ namespace
        // slightly different but unfortunately Mozilla doesn't
        // support non-square pixels (and neither do fontconfig or Xft
        // anyway).
-       check(pref_service->GetDefaultBranch("browser.display",
-                                            getter_AddRefs(pref_branch)));
-       check(pref_branch->SetIntPref("screen_resolution", 40));
+
+       // The browser.display.screen_resolution preference sets the
+       // the nominal resolution for dimensions expressed in pixels.
+       // (They may be scaled!)  In Mozilla 1.7 it also sets the
+       // assumed resolution of the display - hence pixel sizes are
+       // respected on-screen - but this is no longer the case in
+       // 1.8.  Therefore it was renamed to layout.css.dpi in 1.8.1.
+       // In 1.8 we need to set the assumed screen resolution
+       // separately, but don't know how yet.  Setting one to 40
+       // but not the other is *bad*, so currently we set neither.
+
+#      if MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR < 8
+           check(pref_branch->SetIntPref("browser.display.screen_resolution",
+                                         40));
+#      endif
     }
 
 } // namespace