From: Ben Hutchings Date: Sat, 12 Apr 2008 16:10:53 +0000 (+0000) Subject: Added support for XULRunner/GRE 1.9: X-Git-Tag: 1.2.3~15 X-Git-Url: https://git.decadent.org.uk/gitweb/?a=commitdiff_plain;h=9d2e69a1cf5011f52ae8ec6f5a45c5ddc39ac112;p=videolink.git Added support for XULRunner/GRE 1.9: - Use XPCOM and GtkMozEmbed glue code - Do not set rpath in executable - Use not since the internal string API is not exported - Do not define MOZILLA_INTERNAL_API macro - Do not use nsACString::{Begin,End}Reading since they are not exported (bug?) - Do not add per-module directories to include search path, since they no longer exist - Add NSPR header directory to include search path, since mozilla-gtkmozembed-embedding.pc doesn't do that (bug) - Move use of nsPresContext to a separate source file since its header still requires MOZILLA_INTERNAL_API to be defined (bug?) --- diff --git a/ChangeLog b/ChangeLog index 9211033..e616abc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,9 @@ +videolink (1.2.3) unstable; urgency=low + + * Added support for XULRunner 1.9 + + -- Ben Hutchings Tue, 08 Apr 2008 01:22:08 +0100 + videolink (1.2.2) unstable; urgency=low * Fixed build failure with g++ 4.3 diff --git a/Makefile b/Makefile index 3226da6..bf15959 100644 --- a/Makefile +++ b/Makefile @@ -5,13 +5,25 @@ sharedir := $(prefix)/share docdir := $(sharedir)/doc mandir := $(sharedir)/man -# Prefer XULRunner to the old Mozilla -ifeq ($(shell pkg-config --exists xulrunner-gtkmozembed && echo yes),yes) +ifeq ($(shell pkg-config --atleast-version 1.9 mozilla-gtkmozembed-embedding && echo yes),yes) + moz_name := xulrunner-1.9 + moz_pc := mozilla-gtkmozembed-embedding + moz_cppflags_extra := $(shell pkg-config --cflags xulrunner-nspr) + moz_unstable_cppflags_extra := + moz_ldflags_extra := +else + ifeq ($(shell pkg-config --exists xulrunner-gtkmozembed && echo yes),yes) moz_name := xulrunner moz_pc := xulrunner-gtkmozembed -else + else moz_name := mozilla moz_pc := mozilla-gtkmozembed + endif + moz_unstable_cppflags_extra = \ + $(addprefix -I$(moz_include_dir)/, \ + content docshell dom gfx imglib2 layout locale necko uconv webshell widget) \ + -DMOZILLA_INTERNAL_API + moz_ldflags_extra = -Wl,-rpath,$(moz_lib_dir) endif moz_prefix := $(shell pkg-config --variable=prefix $(moz_pc)) @@ -27,7 +39,7 @@ CPPFLAGS := -D_REENTRANT CXXFLAGS := -ansi -Wall -Wunused LDFLAGS := -lpthread \ $(shell pkg-config --libs gtkmm-2.4 $(moz_pc)) \ - -Wl,-rpath -Wl,$(moz_lib_dir) -lexpat + $(moz_ldflags_extra) -lexpat ifdef NDEBUG CPPFLAGS += -DNDEBUG @@ -38,9 +50,10 @@ else endif cxxsources := \ - auto_proc.cpp browser_widget.cpp child_iterator.cpp generate_dvd.cpp \ - link_iterator.cpp null_prompt_service.cpp pixbufs.cpp style_sheets.cpp \ - temp_file.cpp video.cpp vob_list.cpp videolink.cpp warp_pointer.cpp \ + auto_proc.cpp browser_widget.cpp child_iterator.cpp \ + event_state_manager.cpp generate_dvd.cpp link_iterator.cpp \ + null_prompt_service.cpp pixbufs.cpp style_sheets.cpp temp_file.cpp \ + video.cpp vob_list.cpp videolink.cpp warp_pointer.cpp \ x_frame_buffer.cpp xml_utils.cpp xpcom_support.cpp csources := jquant2.c @@ -48,10 +61,12 @@ sources_using_gtkmm := \ browser_widget.cpp generate_dvd.cpp pixbufs.cpp temp_file.cpp \ vob_list.cpp videolink.cpp warp_pointer.cpp sources_using_moz := \ - browser_widget.cpp child_iterator.cpp link_iterator.cpp \ - null_prompt_service.cpp style_sheets.cpp videolink.cpp xpcom_support.cpp + browser_widget.cpp child_iterator.cpp event_state_manager.cpp \ + link_iterator.cpp null_prompt_service.cpp style_sheets.cpp \ + videolink.cpp xpcom_support.cpp sources_using_moz_unstable := \ - link_iterator.cpp null_prompt_service.cpp style_sheets.cpp videolink.cpp + browser_widget.cpp event_state_manager.cpp link_iterator.cpp \ + null_prompt_service.cpp style_sheets.cpp videolink.cpp videolink : $(cxxsources:%.cpp=.objs/%.o) $(csources:%.c=.objs/%.o) $(CXX) $^ $(LDFLAGS) -o $@ @@ -84,16 +99,13 @@ $(sources_using_gtkmm:%.cpp=.objs/%.o) \ : CPPFLAGS += $(shell pkg-config --cflags gtkmm-2.4) $(sources_using_moz:%.cpp=.objs/%.o) \ - : CPPFLAGS += $(shell pkg-config --cflags $(moz_pc)) + : CPPFLAGS += $(shell pkg-config --cflags $(moz_pc)) $(moz_cppflags_extra) # Non-virtual destructors are fine in XPCOM interface classes since # instances are only ever called by the Release function which is virtual. $(sources_using_moz:%.cpp=.objs/%.o) : CXXFLAGS += -Wno-non-virtual-dtor $(sources_using_moz_unstable:%.cpp=.objs/%.o) \ - : CPPFLAGS += $(addprefix -I$(moz_include_dir)/, \ - content docshell dom gfx imglib2 layout locale \ - necko uconv webshell widget) \ - -DMOZILLA_INTERNAL_API \ + : CPPFLAGS += $(moz_unstable_cppflags_extra) \ -DMOZ_VERSION_MAJOR=$(moz_version_major) \ -DMOZ_VERSION_MINOR=$(moz_version_minor) diff --git a/browser_widget.cpp b/browser_widget.cpp index 46d1fb5..07df0d0 100644 --- a/browser_widget.cpp +++ b/browser_widget.cpp @@ -1,11 +1,21 @@ -// Copyright 2005 Ben Hutchings . +// Copyright 2005-8 Ben Hutchings . // See the file "COPYING" for licence details. #include "browser_widget.hpp" #include +#include + +#include #include +#if MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR == 9 +#include +#endif + +#include "xpcom_support.hpp" + +using xpcom_support::check; browser_widget::browser_widget() : Gtk::Bin(GTK_BIN(gtk_moz_embed_new())) @@ -518,7 +528,26 @@ Glib::ObjectBase * browser_widget::wrap_new(GObject * gobject) browser_widget::initialiser::initialiser() { +#if MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR == 9 + static const GREVersionRange gre_versions = { + "1.9a", PR_TRUE, + "1.9.*", PR_TRUE + }; + char path[PATH_MAX]; + check(GRE_GetGREPathWithProperties(&gre_versions, 1, 0, 0, + path, sizeof(path))); + + check(XPCOMGlueStartup(path)); + check(GTKEmbedGlueStartup()); + + char * last_slash = std::strrchr(path, '/'); + if (last_slash != path) + *last_slash = '\0'; + gtk_moz_embed_set_path(path); +#else gtk_moz_embed_set_comp_path(MOZ_LIB_DIR); +#endif + gtk_moz_embed_push_startup(); wrap_register(gtk_moz_embed_get_type(), wrap_new); @@ -527,6 +556,10 @@ browser_widget::initialiser::initialiser() browser_widget::initialiser::~initialiser() { gtk_moz_embed_pop_startup(); + +#if MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR == 9 + XPCOMGlueShutdown(); +#endif } namespace Glib diff --git a/event_state_manager.cpp b/event_state_manager.cpp new file mode 100644 index 0000000..50b068a --- /dev/null +++ b/event_state_manager.cpp @@ -0,0 +1,20 @@ +// Copyright 2008 Ben Hutchings . +// See the file "COPYING" for licence details. + +#ifndef MOZILLA_INTERNAL_API +#define MOZILLA_INTERNAL_API +#endif +#include +#include + +#include "event_state_manager.hpp" +#include "xpcom_support.hpp" + +using xpcom_support::check; + +nsIEventStateManager * get_event_state_manager(nsIDocShell * doc_shell) +{ + nsCOMPtr pres_context; + check(doc_shell->GetPresContext(getter_AddRefs(pres_context))); + return pres_context->EventStateManager(); +} diff --git a/event_state_manager.hpp b/event_state_manager.hpp new file mode 100644 index 0000000..de06b15 --- /dev/null +++ b/event_state_manager.hpp @@ -0,0 +1,15 @@ +// Copyright 2008 Ben Hutchings . +// See the file "COPYING" for licence details. + +#ifndef INC_EVENT_STATE_MANAGER_HPP +#define INC_EVENT_STATE_MANAGER_HPP + +class nsIDocShell; +class nsIEventStateManager; + +// This function works with nsPresContext, defined in +// , which includes , which is mutually +// exclusive with including . What a mess. +nsIEventStateManager * get_event_state_manager(nsIDocShell * doc_shell); + +#endif // !INC_EVENT_STATE_MANAGER_HPP diff --git a/videolink.cpp b/videolink.cpp index 5867023..cec4ecc 100644 --- a/videolink.cpp +++ b/videolink.cpp @@ -1,4 +1,4 @@ -// Copyright 2005-6 Ben Hutchings . +// Copyright 2005-8 Ben Hutchings . // See the file "COPYING" for licence details. #include @@ -23,6 +23,11 @@ #include #include +#if MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR == 9 +#include +/* For some reason no longer defines this */ +typedef nsCOMPtr nsWeakPtr; +#endif #include #include #include @@ -42,16 +47,20 @@ #include // required before nsILink.h #include #include -#include #include #include #include #include +#ifdef MOZILLA_INTERNAL_API #include +#else +#include +#endif #include "browser_widget.hpp" #include "child_iterator.hpp" #include "dvd.hpp" +#include "event_state_manager.hpp" #include "generate_dvd.hpp" #include "geometry.hpp" #include "link_iterator.hpp" @@ -237,8 +246,7 @@ namespace bool process_links( page_state * state, nsIDOMDocument * basic_doc, - nsIPresShell * pres_shell, - nsPresContext * pres_context, + nsIDocShell * doc_shell, nsIDOMWindow * dom_window); std::string output_dir_; @@ -508,10 +516,6 @@ namespace nsCOMPtr browser(browser_widget_.get_browser()); nsCOMPtr doc_shell(do_GetInterface(browser)); assert(doc_shell); - nsCOMPtr pres_shell; - check(doc_shell->GetPresShell(getter_AddRefs(pres_shell))); - nsCOMPtr pres_context; - check(doc_shell->GetPresContext(getter_AddRefs(pres_context))); nsCOMPtr dom_window; check(browser->GetContentDOMWindow(getter_AddRefs(dom_window))); @@ -524,9 +528,7 @@ namespace new page_state( get_screenshot(), basic_doc, frame_params_.width, frame_params_.height)); - if (!process_links( - page_state_.get(), - basic_doc, pres_shell, pres_context, dom_window)) + if (!process_links(page_state_.get(), basic_doc, doc_shell, dom_window)) { // We've finished work on the links so generate the // menu VOB. @@ -569,8 +571,7 @@ namespace bool conversion_window::process_links( page_state * state, nsIDOMDocument * basic_doc, - nsIPresShell * pres_shell, - nsPresContext * pres_context, + nsIDocShell * doc_shell, nsIDOMWindow * dom_window) { Glib::RefPtr window(get_window()); @@ -578,8 +579,10 @@ namespace nsCOMPtr ns_doc(do_QueryInterface(basic_doc)); assert(ns_doc); + nsCOMPtr pres_shell; + check(doc_shell->GetPresShell(getter_AddRefs(pres_shell))); nsCOMPtr event_state_man( - pres_context->EventStateManager()); // does not AddRef + get_event_state_manager(doc_shell)); assert(event_state_man); nsCOMPtr event_factory( do_QueryInterface(basic_doc)); @@ -610,8 +613,9 @@ namespace { nsCString link_target_ns; check(uri_iface->GetSpec(link_target_ns)); - state->link_target.assign(link_target_ns.BeginReading(), - link_target_ns.EndReading()); + const char * str; + PRUint32 len = NS_CStringGetData(link_target_ns, &str); + state->link_target.assign(str, len); std::size_t hash_pos = state->link_target.find('#'); uri.assign(state->link_target, 0, hash_pos);