Removed support for Mozilla 1.7.
authorBen Hutchings <ben@decadent.org.uk>
Sat, 2 Dec 2006 19:50:00 +0000 (19:50 +0000)
committerBen Hutchings <ben@decadent.org.uk>
Sun, 2 Nov 2008 23:58:13 +0000 (23:58 +0000)
null_prompt_service.cpp
style_sheets.cpp
style_sheets.hpp
videolink.cpp

index 28156d5..2548512 100644 (file)
 #include <nsICharsetConverterManager.h>
 #include <nsIComponentManager.h>
 #include <nsIFactory.h>
-#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-#   include <nsIComponentRegistrar.h>
-#   include <nsServiceManagerUtils.h>
-#else
-#   include <nsIServiceManagerUtils.h>
-#endif
+#include <nsIComponentRegistrar.h>
+#include <nsServiceManagerUtils.h>
 #include <nsIUnicodeEncoder.h>
 
 #include "null_prompt_service.hpp"
@@ -198,21 +194,11 @@ void null_prompt_service::install()
        {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0}
     };
     nsCOMPtr<nsIFactory> prompt_factory(new null_prompt_service_factory);
-#   if MOZ_VERSION_MAJOR > 1                              \
-    || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-        nsCOMPtr<nsIComponentRegistrar> comp_registrar;
-        check(NS_GetComponentRegistrar(getter_AddRefs(comp_registrar)));
-       check(comp_registrar->RegisterFactory(
-                 prompt_service_cid,
-                 "Prompt Service",
-                 "@mozilla.org/embedcomp/prompt-service;1",
-                 prompt_factory));       
-#   else
-       check(nsComponentManager::RegisterFactory(
-                 prompt_service_cid,
-                 "Prompt Service",
-                 "@mozilla.org/embedcomp/prompt-service;1",
-                 prompt_factory,
-                 PR_TRUE)); // replace existing
-#   endif
+    nsCOMPtr<nsIComponentRegistrar> comp_registrar;
+    check(NS_GetComponentRegistrar(getter_AddRefs(comp_registrar)));
+    check(comp_registrar->RegisterFactory(
+             prompt_service_cid,
+             "Prompt Service",
+             "@mozilla.org/embedcomp/prompt-service;1",
+             prompt_factory));   
 }
index 1f66810..9cd6273 100644 (file)
@@ -1,18 +1,12 @@
-// Copyright 2005 Ben Hutchings <ben@decadent.org.uk>.
+// Copyright 2005-6 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
 #include "style_sheets.hpp"
 
+#include <nsCOMPtr.h>
 #include <nsContentCID.h>
-#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-#   include <nsIStyleSheetService.h>
-#   include <nsServiceManagerUtils.h>
-#else
-#   include <nsICSSLoader.h>
-#   include <nsICSSStyleSheet.h>
-#   include <nsIPresShell.h>
-#   include <nsIServiceManagerUtils.h>
-#endif
+#include <nsIStyleSheetService.h>
+#include <nsServiceManagerUtils.h>
 #include <nsIURI.h>
 #include <nsNetUtil.h>
 
 
 using xpcom_support::check;
 
-#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-
 // We just have to load and register a style-sheet as a user
 // style-sheet.  There is no need to do anything for each page.
 
-agent_style_sheet_holder init_agent_style_sheet(const char * uri)
+void init_agent_style_sheet(const char * uri)
 {
     nsCOMPtr<nsIURI> style_sheet_uri;
     check(NS_NewURI(getter_AddRefs(style_sheet_uri), nsCString(uri)));
@@ -41,42 +33,4 @@ agent_style_sheet_holder init_agent_style_sheet(const char * uri)
              style_sheet_service_cid, getter_AddRefs(style_sheet_service)));
     check(style_sheet_service->LoadAndRegisterSheet(
              style_sheet_uri, nsIStyleSheetService::USER_SHEET));
-
-    return agent_style_sheet_holder();
-}
-
-#else // Mozilla version < 1.8
-
-already_AddRefed<nsIStyleSheet> init_agent_style_sheet(const char * uri)
-{
-    nsCOMPtr<nsICSSLoader> css_loader;
-    static const nsCID css_loader_cid = NS_CSS_LOADER_CID;
-    check(CallGetService<nsICSSLoader>(css_loader_cid,
-                                      getter_AddRefs(css_loader)));
-
-    nsCOMPtr<nsIURI> style_sheet_uri;
-    check(NS_NewURI(getter_AddRefs(style_sheet_uri), nsCString(uri)));
-
-    nsICSSStyleSheet * style_sheet;
-    check(css_loader->LoadAgentSheet(style_sheet_uri, &style_sheet));
-    return style_sheet;
-}
-
-// Apply a style-sheet to a given presentation shell as the top-priority
-// agent style-sheet and disable the preferences-derived style rules.
-void apply_agent_style_sheet(nsIStyleSheet * style_sheet,
-                            nsIPresShell * pres_shell)
-{
-    nsCOMArray<nsIStyleSheet> style_sheets;
-    check(pres_shell->GetAgentStyleSheets(style_sheets));
-    check(style_sheets.InsertObjectAt(style_sheet, 0));
-    check(pres_shell->SetAgentStyleSheets(style_sheets));
-
-    check(pres_shell->EnablePrefStyleRules(false));
-
-    // Update the display
-    check(pres_shell->ReconstructStyleData());
-    check(pres_shell->FlushPendingNotifications(true));
 }
-
-#endif // Mozilla version >=/< 1.8
index ef4aef3..66670e6 100644 (file)
@@ -1,37 +1,10 @@
-// Copyright 2005 Ben Hutchings <ben@decadent.org.uk>.
+// Copyright 2005-6 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
 #ifndef INC_STYLESHEETS_HPP
 #define INC_STYLESHEETS_HPP
 
-#include <nsCOMPtr.h>
-#include <nsIStyleSheet.h>
-
-class nsIPresShell;
-
-// These functions load and apply a style-sheet as necessary,
-// overriding the built-in "preferences".
-
-// init_agent_style_sheet() must be called once during startup
-// apply_agent_style_sheet() must be called for each page
-
-#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-
-struct agent_style_sheet_holder {};
-
-// Load agent style sheet from an (absolute) URI, and register it if
-// possible.
-agent_style_sheet_holder init_agent_style_sheet(const char * uri);
-inline void apply_agent_style_sheet(agent_style_sheet_holder, nsIPresShell *)
-{}
-
-#else
-
-typedef nsCOMPtr<nsIStyleSheet> agent_style_sheet_holder;
-already_AddRefed<nsIStyleSheet> init_agent_style_sheet(const char * uri);
-void apply_agent_style_sheet(nsIStyleSheet *, nsIPresShell *);
-
-#endif
-
+// Load agent style sheet from an (absolute) URI and register it.
+void init_agent_style_sheet(const char * uri);
 
 #endif // !INC_STYLESHEETS_HPP
index a5792bb..74b8a21 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 <nsPresContext.h>
 #include <nsIPrefService.h>
 #include <nsIPresShell.h>
-#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-#   include <nsServiceManagerUtils.h>
-#else
-#   include <nsIServiceManagerUtils.h>
-#endif
+#include <nsServiceManagerUtils.h>
 #include <nsIWebBrowser.h>
 #include <nsString.h>
 
@@ -187,7 +178,6 @@ namespace
        video::frame_params frame_params_;
        std::string output_dir_;
        browser_widget browser_widget_;
-       agent_style_sheet_holder main_style_sheet_, frame_style_sheet_;
 
        dvd_generator generator_;
        typedef std::map<std::string, dvd_generator::pgc_ref>
@@ -210,15 +200,6 @@ namespace
        dvd_generator::mpeg_encoder encoder)
            : frame_params_(frame_params),
              output_dir_(output_dir),
-             main_style_sheet_(
-                 init_agent_style_sheet(
-                     "file://" VIDEOLINK_SHARE_DIR "/videolink.css")),
-             frame_style_sheet_(
-                 init_agent_style_sheet(
-                     std::string("file://" VIDEOLINK_SHARE_DIR "/")
-                     .append(frame_params.common_name)
-                     .append(".css")
-                     .c_str())),
              generator_(frame_params, encoder),
              pending_window_update_(false),
              pending_req_count_(0),
@@ -456,13 +437,9 @@ namespace
        nsCOMPtr<nsIDOMWindow> dom_window;
        check(browser->GetContentDOMWindow(getter_AddRefs(dom_window)));
 
-       // If we haven't done so already, apply the stylesheet and
-       // disable scrollbars.
+       // If we haven't done so already, disable scrollbars.
        if (!have_tweaked_page_)
        {
-           apply_agent_style_sheet(main_style_sheet_, pres_shell);
-           apply_agent_style_sheet(frame_style_sheet_, pres_shell);
-
            // This actually only needs to be done once.
            nsCOMPtr<nsIDOMBarProp> dom_bar_prop;
            check(dom_window->GetScrollbars(getter_AddRefs(dom_bar_prop)));
@@ -668,12 +645,7 @@ namespace
                check(event_state_man->SetContentState(content,
                                                       NS_EVENT_STATE_HOVER));
 
-#              if MOZ_VERSION_MAJOR > 1                                   \
-                    || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-                   pres_shell->FlushPendingNotifications(Flush_Display);
-#              else
-                   pres_shell->FlushPendingNotifications(true);
-#              endif
+               pres_shell->FlushPendingNotifications(Flush_Display);
 
                // We may have to exit and wait for image loading
                // to complete, at which point we will be called
@@ -749,15 +721,12 @@ namespace
        nsCOMPtr<nsIPrefBranch> pref_branch;
        check(pref_service->GetBranch("", getter_AddRefs(pref_branch)));
 
-#      if MOZ_VERSION_MAJOR > 1                                 \
-           || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8)
-           // 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
+       // 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));
 
        // Set display resolution.  With standard-definition video we
        // will be fitting ~600 pixels across a screen typically
@@ -778,7 +747,7 @@ namespace
        // 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
+#      if 0
            check(pref_branch->SetIntPref("browser.display.screen_resolution",
                                          40));
 #      endif
@@ -945,6 +914,10 @@ int main(int argc, char ** argv)
        // Initialise Mozilla
        browser_widget::initialiser browser_init;
        set_browser_preferences();
+       init_agent_style_sheet("file://" VIDEOLINK_SHARE_DIR "/videolink.css");
+       init_agent_style_sheet(std::string("file://" VIDEOLINK_SHARE_DIR "/")
+                              .append(frame_params.common_name).append(".css")
+                              .c_str());
        if (!preview_mode)
            null_prompt_service::install();