[kazehakase-svn] [3343] * module/embed/gecko/kz-mozwrapper.{cpp,h}: removing MozillaPrivate dependency.

Back to archive index

svnno****@sourc***** svnno****@sourc*****
Sat Jan 5 16:05:22 JST 2008


Revision: 3343
          http://svn.sourceforge.jp/cgi-bin/viewcvs.cgi?root=kazehakase&view=rev&rev=3343
Author:   kous
Date:     2008-01-05 16:05:21 +0900 (Sat, 05 Jan 2008)

Log Message:
-----------
* module/embed/gecko/kz-mozwrapper.{cpp,h}: removing MozillaPrivate dependency.
* macros/gecko.m4: checked nsIPrintOptions::AvailablePrinters availability.

Modified Paths:
--------------
    kazehakase/trunk/ChangeLog
    kazehakase/trunk/macros/gecko.m4
    kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.cpp
    kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.h
    kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp
    kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h

Modified: kazehakase/trunk/ChangeLog
===================================================================
--- kazehakase/trunk/ChangeLog	2008-01-05 06:49:48 UTC (rev 3342)
+++ kazehakase/trunk/ChangeLog	2008-01-05 07:05:21 UTC (rev 3343)
@@ -1,5 +1,11 @@
 2008-01-05  Kouhei Sutou  <kou****@cozmi*****>
 
+	* module/embed/gecko/kz-mozwrapper.{cpp,h}: removing MozillaPrivate
+	dependency.
+
+	* macros/gecko.m4: checked nsIPrintOptions::AvailablePrinters
+	availability.
+
 	* module/embed/gecko/kz-mozwrapper.cpp: defined MOZILLA_CLIENT.
 
 	* macros/gecko.m4: checked nsIPrintSettings::SetPapserSize availability.

Modified: kazehakase/trunk/macros/gecko.m4
===================================================================
--- kazehakase/trunk/macros/gecko.m4	2008-01-05 06:49:48 UTC (rev 3342)
+++ kazehakase/trunk/macros/gecko.m4	2008-01-05 07:05:21 UTC (rev 3343)
@@ -186,6 +186,22 @@
 
 AC_MSG_RESULT([$result])
 
+AC_MSG_CHECKING([whether nsIPrintOptions has AvailablePrinters method])
+
+AC_COMPILE_IFELSE(
+	[AC_LANG_PROGRAM(
+		[[#include <nsIPrintOptions.h>]],
+		[[nsIPrintOptions *printOptions;
+		  printOptions->AvailablePrinters;]]
+	)],
+	[AC_DEFINE([HAVE_NSIPRINTOPTIONS_AVAILABLEPRINTERS],[1],
+                   [Define if nsIPrintOptions has AvailablePrinters method])
+         result=yes],
+	[result=no])
+
+AC_MSG_RESULT([$result])
+
+
 AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/content/nsICanvasRenderingContextInternal.h],
 	[AC_DEFINE([HAVE_NSICANVASRENDERINGCONTEXTINTERNAL_H],[1],[Define if nsICanvasRenderingContextInternal.h exists])])
 

Modified: kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.cpp
===================================================================
--- kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.cpp	2008-01-05 06:49:48 UTC (rev 3342)
+++ kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.cpp	2008-01-05 07:05:21 UTC (rev 3343)
@@ -125,99 +125,6 @@
 }
 
 gboolean
-MozillaPrivate::GetRootRange (nsIDOMDocument *domDoc, nsIDOMRange *range)
-{
-	nsCOMPtr<nsIContent> rootContent;
-	nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
-	if (htmlDoc)
-	{
-		nsCOMPtr<nsIDOMHTMLElement> bodyElement;
-		htmlDoc->GetBody(getter_AddRefs(bodyElement));
-		rootContent = do_QueryInterface(bodyElement);
-	}
-
-        // to avoid segfault with DetailedPreference, 
-        // return if rootContent is NULL.
-	if (!rootContent)
-		return FALSE;
-
-	nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootContent));
-
-	PRUint32 childcount;
-	childcount = rootContent->GetChildCount();
-	
-	range->SetStart(rootNode,0);
-	range->SetEnd(rootNode,childcount);
-
-	return TRUE;
-}
-
-gboolean
-MozillaPrivate::GetSelectedRange (nsIDOMDocument *domDoc,
-				  nsIDOMRange *range,
-				  nsISelection *selection,
-				  gboolean backward)
-{
-	nsCOMPtr<nsIContent> rootContent;
-	nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
-	if (htmlDoc)
-	{
-		nsCOMPtr<nsIDOMHTMLElement> bodyElement;
-		htmlDoc->GetBody(getter_AddRefs(bodyElement));
-		rootContent = do_QueryInterface(bodyElement);
-	}
-
-        // to avoid segfault with DetailedPreference, 
-        // return if rootContent is NULL.
-	if (!rootContent)
-		return FALSE;
-
-	// Get root content node
-	nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootContent));
-
-	PRUint32 childcount;
-	childcount = rootContent->GetChildCount();
-	
-	if (backward)
-	{
-		if (selection)
-		{
-			nsCOMPtr<nsIDOMNode> endNode;
-			PRInt32 endOffset;
-			selection->CollapseToStart();
-			selection->GetAnchorNode(getter_AddRefs(endNode));
-			selection->GetAnchorOffset(&endOffset);
-	
-			range->SetEnd(endNode, endOffset);
-		}
-		else
-		{
-			range->SetEnd(rootNode, childcount);
-		}
-		range->SetStart(rootNode, 0);
-	}
-	else
-	{
-		if (selection)
-		{
-			nsCOMPtr<nsIDOMNode> endNode;
-			PRInt32 endOffset;
-			selection->GetAnchorNode(getter_AddRefs(endNode));
-			selection->GetAnchorOffset(&endOffset);
-	
-			range->SetStart(endNode, endOffset + 1);
-		}
-		else
-		{
-			range->SetStart(rootNode, 0);
-		}
-		range->SetEnd(rootNode, childcount);
-	}
-
-	return TRUE;
-}
-
-gboolean
 MozillaPrivate::SetZoomOnDocShell (float aZoom, nsIDocShell *DocShell)
 {
 #ifdef HAVE_NSIPRESCONTEXT_H
@@ -290,28 +197,6 @@
   	return TRUE;
 }
 
-gchar *
-MozillaPrivate::GetURIForDOMWindow(nsIDOMWindow* aDOMWindow)
-{
-	if (!aDOMWindow)
-		return NULL;
-
-	nsCOMPtr<nsIDOMDocument> domDoc;
-	aDOMWindow->GetDocument(getter_AddRefs(domDoc));
-	nsCOMPtr<nsIDocument> doc = do_QueryInterface(domDoc);
-
-	if (!doc)
-		return NULL;
-
-	nsCOMPtr<nsIURI> uri;
-	uri = doc->GetDocumentURI();
-
-	nsCAutoString str;
-	uri->GetHost(str);
-
-	return g_strdup(str.get());
-}
-
 const char *
 MozillaPrivate::Unescape(const char *text)
 {

Modified: kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.h
===================================================================
--- kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.h	2008-01-05 06:49:48 UTC (rev 3342)
+++ kazehakase/trunk/module/embed/gecko/gtkmozembed/MozillaPrivate.h	2008-01-05 07:05:21 UTC (rev 3343)
@@ -46,13 +46,9 @@
 {
 	GList    *GetPrinterList      ();
 	gboolean  CreatePrintSettings (nsIPrintSettings **options);
-	gboolean  GetRootRange        (nsIDOMDocument *domDoc, nsIDOMRange *range);
-	gboolean  GetSelectedRange    (nsIDOMDocument *domDoc, nsIDOMRange *range,
-				       nsISelection *selection, gboolean backward);
-	gboolean  SetZoomOnDocShell   (float aZoom, nsIDocShell *DocShell);
+        gboolean  SetZoomOnDocShell   (float aZoom, nsIDocShell *DocShell);
 	GdkWindow *GetGdkWindow       (nsIBaseWindow *window);
 	gboolean  GetEventReceiver    (nsIDOMWindow *domWindow, nsIDOMEventReceiver **receiver);
-	gchar    *GetURIForDOMWindow  (nsIDOMWindow *aDOMWindow);
 	const char *Unescape          (const char *text);	
 #ifdef MOZ_NSICANVASRENDERINGCONTEXTINTERNAL_HAVE_GETINPUTSTREAM_
 	gboolean  CreateThumbnail     (nsIDOMWindow *domWindow,

Modified: kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp
===================================================================
--- kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp	2008-01-05 06:49:48 UTC (rev 3342)
+++ kazehakase/trunk/module/embed/gecko/kz-mozwrapper.cpp	2008-01-05 07:05:21 UTC (rev 3343)
@@ -59,6 +59,7 @@
 #define MOZILLA_STRICT_API
 #include <nsEmbedString.h>
 #undef MOZILLA_STRICT_API
+#include <nsIDOMEventTarget.h>
 #include <nsIDOMElement.h>
 #include <nsIDOMDocumentType.h>
 #include <nsIURI.h>
@@ -80,13 +81,13 @@
 #include <nsIWebBrowserPrint.h>
 #include <nsIPrintSettingsService.h>
 #include <nsIPrintSettings.h>
+#include <nsIPrintOptions.h>
 #include <nsISupportsPrimitives.h>
 #include <nsIDOM3Document.h>
 #include <nsIDocCharset.h>
 #include "kz-mozprogresslistener.h"
 #include "kz-mozutils.h"
 #include "utils.h"
-#include "MozillaPrivate.h"
 #include "kz-bookmark.h"
 
 # include <nsISSLStatus.h>
@@ -417,7 +418,7 @@
 	if (!range)
 		return NS_ERROR_FAILURE;
 
-	MozillaPrivate::GetRootRange(domDoc, range);
+	GetRootRange(domDoc, range);
 	range->ToString(string);
 
 	return NS_OK;
@@ -445,7 +446,7 @@
 
 	mDOMWindow->GetSelection(getter_AddRefs(selection));
 
-	MozillaPrivate::GetSelectedRange(domDoc, range, selection, backward);
+	GetSelectedRange(domDoc, range, selection, backward);
 
 	range->ToString(string);
 
@@ -1406,7 +1407,46 @@
 nsresult
 KzMozWrapper::GetPrinterList (GList **list)
 {
-	*list = MozillaPrivate::GetPrinterList();
+	GList *printers = NULL;
+	nsresult rv = NS_OK;
+
+#ifndef HAVE_NSIPRINTOPTIONS_AVAILABLEPRINTERS
+	*list = NULL;
+#else
+	nsCOMPtr<nsIPrintSettingsService> pss =
+		do_GetService("@mozilla.org/gfx/printsettings-service;1", &rv);
+	NS_ENSURE_SUCCESS(rv, nsnull);
+
+	nsCOMPtr<nsIPrintOptions> po = do_QueryInterface(pss, &rv);
+	NS_ENSURE_SUCCESS(rv, nsnull);
+
+	nsCOMPtr<nsISimpleEnumerator> avPrinters;
+	rv = po->AvailablePrinters(getter_AddRefs(avPrinters));
+	NS_ENSURE_SUCCESS(rv, nsnull);
+
+	PRBool more = PR_FALSE;
+
+	for (avPrinters->HasMoreElements(&more);
+	     more == PR_TRUE;
+	     avPrinters->HasMoreElements(&more))
+	{
+		nsCOMPtr<nsISupports> i;
+		rv = avPrinters->GetNext(getter_AddRefs(i));
+		NS_ENSURE_SUCCESS(rv, nsnull);
+
+		nsCOMPtr<nsISupportsString> printer = do_QueryInterface(i, &rv);
+		NS_ENSURE_SUCCESS(rv, nsnull);
+
+		nsAutoString data;
+		rv = printer->GetData(data);
+		NS_ENSURE_SUCCESS(rv, nsnull);
+
+		printers = g_list_prepend (printers, g_strdup (NS_ConvertUCS2toUTF8 (data).get()));
+	}
+
+	*list = g_list_reverse (printers);
+#endif
+
 	return NS_OK;
 }
 
@@ -2039,3 +2079,96 @@
 	return NS_OK;
 }
 #endif
+
+gboolean
+KzMozWrapper::GetRootRange (nsIDOMDocument *domDoc, nsIDOMRange *range)
+{
+	nsCOMPtr<nsIContent> rootContent;
+	nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
+	if (htmlDoc)
+	{
+		nsCOMPtr<nsIDOMHTMLElement> bodyElement;
+		htmlDoc->GetBody(getter_AddRefs(bodyElement));
+		rootContent = do_QueryInterface(bodyElement);
+	}
+
+        // to avoid segfault with DetailedPreference, 
+        // return if rootContent is NULL.
+	if (!rootContent)
+		return FALSE;
+
+	nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootContent));
+
+	PRUint32 childcount;
+	childcount = rootContent->GetChildCount();
+	
+	range->SetStart(rootNode,0);
+	range->SetEnd(rootNode,childcount);
+
+	return TRUE;
+}
+
+gboolean
+KzMozWrapper::GetSelectedRange (nsIDOMDocument *domDoc,
+				nsIDOMRange *range,
+				nsISelection *selection,
+				gboolean backward)
+{
+	nsCOMPtr<nsIContent> rootContent;
+	nsCOMPtr<nsIDOMHTMLDocument> htmlDoc = do_QueryInterface(domDoc);
+	if (htmlDoc)
+	{
+		nsCOMPtr<nsIDOMHTMLElement> bodyElement;
+		htmlDoc->GetBody(getter_AddRefs(bodyElement));
+		rootContent = do_QueryInterface(bodyElement);
+	}
+
+        // to avoid segfault with DetailedPreference, 
+        // return if rootContent is NULL.
+	if (!rootContent)
+		return FALSE;
+
+	// Get root content node
+	nsCOMPtr<nsIDOMNode> rootNode(do_QueryInterface(rootContent));
+
+	PRUint32 childcount;
+	childcount = rootContent->GetChildCount();
+	
+	if (backward)
+	{
+		if (selection)
+		{
+			nsCOMPtr<nsIDOMNode> endNode;
+			PRInt32 endOffset;
+			selection->CollapseToStart();
+			selection->GetAnchorNode(getter_AddRefs(endNode));
+			selection->GetAnchorOffset(&endOffset);
+	
+			range->SetEnd(endNode, endOffset);
+		}
+		else
+		{
+			range->SetEnd(rootNode, childcount);
+		}
+		range->SetStart(rootNode, 0);
+	}
+	else
+	{
+		if (selection)
+		{
+			nsCOMPtr<nsIDOMNode> endNode;
+			PRInt32 endOffset;
+			selection->GetAnchorNode(getter_AddRefs(endNode));
+			selection->GetAnchorOffset(&endOffset);
+	
+			range->SetStart(endNode, endOffset + 1);
+		}
+		else
+		{
+			range->SetStart(rootNode, 0);
+		}
+		range->SetEnd(rootNode, childcount);
+	}
+
+	return TRUE;
+}

Modified: kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h
===================================================================
--- kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h	2008-01-05 06:49:48 UTC (rev 3342)
+++ kazehakase/trunk/module/embed/gecko/kz-mozwrapper.h	2008-01-05 07:05:21 UTC (rev 3343)
@@ -198,4 +198,9 @@
 				     const gchar *type,
 				     nsAString &LocalFile);
 	nsresult  GetSSLStatus      (nsISSLStatus **aSSLStatus);
+
+private:
+	gboolean  GetRootRange      (nsIDOMDocument *domDoc, nsIDOMRange *range);
+	gboolean  GetSelectedRange  (nsIDOMDocument *domDoc, nsIDOMRange *range,
+				     nsISelection *selection, gboolean backward);
 };




More information about the Kazehakase-cvs mailing list
Back to archive index