From fcc6457245904ddccbeef52a3fc38c18efedf8ac Mon Sep 17 00:00:00 2001 From: Ben Hutchings Date: Sat, 2 Dec 2006 19:50:00 +0000 Subject: [PATCH] Removed support for Mozilla 1.7. --- null_prompt_service.cpp | 32 +++++++---------------- style_sheets.cpp | 56 ++++------------------------------------ style_sheets.hpp | 33 +++--------------------- videolink.cpp | 57 +++++++++++------------------------------ 4 files changed, 32 insertions(+), 146 deletions(-) diff --git a/null_prompt_service.cpp b/null_prompt_service.cpp index 28156d5..2548512 100644 --- a/null_prompt_service.cpp +++ b/null_prompt_service.cpp @@ -10,12 +10,8 @@ #include #include #include -#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8) -# include -# include -#else -# include -#endif +#include +#include #include #include "null_prompt_service.hpp" @@ -198,21 +194,11 @@ void null_prompt_service::install() {0xb4, 0x6a, 0x25, 0xc0, 0xb3, 0x8, 0xcb, 0xd0} }; nsCOMPtr prompt_factory(new null_prompt_service_factory); -# if MOZ_VERSION_MAJOR > 1 \ - || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8) - nsCOMPtr 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 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)); } diff --git a/style_sheets.cpp b/style_sheets.cpp index 1f66810..9cd6273 100644 --- a/style_sheets.cpp +++ b/style_sheets.cpp @@ -1,18 +1,12 @@ -// Copyright 2005 Ben Hutchings . +// Copyright 2005-6 Ben Hutchings . // See the file "COPYING" for licence details. #include "style_sheets.hpp" +#include #include -#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8) -# include -# include -#else -# include -# include -# include -# include -#endif +#include +#include #include #include @@ -20,12 +14,10 @@ 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 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 init_agent_style_sheet(const char * uri) -{ - nsCOMPtr css_loader; - static const nsCID css_loader_cid = NS_CSS_LOADER_CID; - check(CallGetService(css_loader_cid, - getter_AddRefs(css_loader))); - - nsCOMPtr 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 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 diff --git a/style_sheets.hpp b/style_sheets.hpp index ef4aef3..66670e6 100644 --- a/style_sheets.hpp +++ b/style_sheets.hpp @@ -1,37 +1,10 @@ -// Copyright 2005 Ben Hutchings . +// Copyright 2005-6 Ben Hutchings . // See the file "COPYING" for licence details. #ifndef INC_STYLESHEETS_HPP #define INC_STYLESHEETS_HPP -#include -#include - -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 agent_style_sheet_holder; -already_AddRefed 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 diff --git a/videolink.cpp b/videolink.cpp index a5792bb..74b8a21 100644 --- a/videolink.cpp +++ b/videolink.cpp @@ -41,19 +41,10 @@ #include // required before nsILink.h #include #include -#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8) -# include -#else -# include - typedef nsIPresContext nsPresContext; // ugh -#endif +#include #include #include -#if MOZ_VERSION_MAJOR > 1 || (MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR >= 8) -# include -#else -# include -#endif +#include #include #include @@ -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 @@ -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 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 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 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(); -- 2.39.5