]> git.decadent.org.uk Git - videolink.git/blobdiff - videolink.cpp
Added support for XULRunner/GRE 1.9:
[videolink.git] / videolink.cpp
index 5867023ae9aa0b0e8d0511b8dbe6017d096ea4b5..cec4eccad2e8dfe5d11e3ddfe1cc5cdbcf8c7937 100644 (file)
@@ -1,4 +1,4 @@
-// Copyright 2005-6 Ben Hutchings <ben@decadent.org.uk>.
+// Copyright 2005-8 Ben Hutchings <ben@decadent.org.uk>.
 // See the file "COPYING" for licence details.
 
 #include <cassert>
 #include <gtkmm/window.h>
 
 #include <ImageErrors.h>
+#if MOZ_VERSION_MAJOR == 1 && MOZ_VERSION_MINOR == 9
+#include <nsWeakPtr.h>
+/* For some reason <nsWeakPtr.h> no longer defines this */
+typedef nsCOMPtr<nsIWeakReference> nsWeakPtr;
+#endif
 #include <nsGUIEvent.h>
 #include <nsIBoxObject.h>
 #include <nsIContent.h>
 #include <nsIURI.h> // required before nsILink.h
 #include <nsILink.h>
 #include <nsIPrefBranch.h>
-#include <nsPresContext.h>
 #include <nsIPrefService.h>
 #include <nsIPresShell.h>
 #include <nsServiceManagerUtils.h>
 #include <nsIWebBrowser.h>
+#ifdef MOZILLA_INTERNAL_API
 #include <nsString.h>
+#else
+#include <nsStringAPI.h>
+#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<nsIWebBrowser> browser(browser_widget_.get_browser());
        nsCOMPtr<nsIDocShell> doc_shell(do_GetInterface(browser));
        assert(doc_shell);
-       nsCOMPtr<nsIPresShell> pres_shell;
-       check(doc_shell->GetPresShell(getter_AddRefs(pres_shell)));
-       nsCOMPtr<nsPresContext> pres_context;
-       check(doc_shell->GetPresContext(getter_AddRefs(pres_context)));
        nsCOMPtr<nsIDOMWindow> 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<Gdk::Window> window(get_window());
@@ -578,8 +579,10 @@ namespace
 
        nsCOMPtr<nsIDOMNSDocument> ns_doc(do_QueryInterface(basic_doc));
        assert(ns_doc);
+       nsCOMPtr<nsIPresShell> pres_shell;
+       check(doc_shell->GetPresShell(getter_AddRefs(pres_shell)));
        nsCOMPtr<nsIEventStateManager> event_state_man(
-           pres_context->EventStateManager()); // does not AddRef
+           get_event_state_manager(doc_shell));
        assert(event_state_man);
        nsCOMPtr<nsIDOMDocumentEvent> 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);