galeon r8979 - in trunk: . mozilla



Author: philipl
Date: Fri Sep  5 02:39:20 2008
New Revision: 8979
URL: http://svn.gnome.org/viewvc/galeon?rev=8979&view=rev

Log:
2008-09-04  Philip Langdale  <philipl alumni utexas net>

	* configure.in
	* mozilla/GaleonWrapper.cpp
	* mozilla/MozillaPrivate.h
	* mozilla/GaleonWrapper.h
	* mozilla/mozilla-embed.cpp
	* mozilla/MozillaPrivate.cpp: Initial reimplementation
	of user stylesheet support. The new Mozilla API is global
	rather than per-page, so the functionality is currently
	mismatched. Frankly, I probably won't clean that up until
	Gecko 1.8 support is dropped.



Modified:
   trunk/ChangeLog
   trunk/configure.in
   trunk/mozilla/GaleonWrapper.cpp
   trunk/mozilla/GaleonWrapper.h
   trunk/mozilla/MozillaPrivate.cpp
   trunk/mozilla/MozillaPrivate.h
   trunk/mozilla/mozilla-embed.cpp

Modified: trunk/configure.in
==============================================================================
--- trunk/configure.in	(original)
+++ trunk/configure.in	Fri Sep  5 02:39:20 2008
@@ -781,6 +781,14 @@
 	[AC_DEFINE([HAVE_NSIPROMPTSERVICE2_H],[1],
 	[Define if nsIPromptService2.h exists])])
 
+dnl nsIStyleSheetService to set override stylesheets in 1.9
+AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/nsIStyleSheetService.h],
+	[AC_DEFINE([HAVE_NSISTYLESHEETSERVICE_H],[1],
+	[Define if nsIPromptService2.h exists])])
+AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/layout/nsIStyleSheetService.h],
+	[AC_DEFINE([HAVE_NSISTYLESHEETSERVICE_H],[1],
+	[Define if nsIStyleSheetService.h exists])])
+
 dnl nsIXULAppInfo is needed for 1.9
 AC_CHECK_FILE([$MOZILLA_INCLUDE_ROOT/nsIXULAppInfo.h],
 	[AC_DEFINE([HAVE_NSIXULAPPINFO_H],[1],

Modified: trunk/mozilla/GaleonWrapper.cpp
==============================================================================
--- trunk/mozilla/GaleonWrapper.cpp	(original)
+++ trunk/mozilla/GaleonWrapper.cpp	Fri Sep  5 02:39:20 2008
@@ -849,6 +849,21 @@
 	return MozillaPrivate::LoadOverrideStyleSheet (docShell, uri, aStyleSheet);
 }
 
+#ifdef HAVE_NSISTYLESHEETSERVICE_H
+nsresult GaleonWrapper::RemoveOverrideStyleSheet(char *css)
+{
+	nsresult rv;
+
+	nsCOMPtr<nsIURI> uri;
+	rv = GaleonUtils::NewURI(getter_AddRefs(uri), GulCString (css));
+	NS_ENSURE_SUCCESS (rv, rv);
+
+	nsCOMPtr<nsIDocShell> docShell = do_GetInterface (mWebBrowser);
+	NS_ENSURE_TRUE (docShell, NS_ERROR_FAILURE);
+
+	return MozillaPrivate::RemoveOverrideStyleSheet (docShell, uri);
+}
+#else
 nsresult GaleonWrapper::RemoveOverrideStyleSheet(nsIStyleSheet *remove)
 {
 	nsCOMPtr<nsIDocShell> docShell = do_GetInterface (mWebBrowser);
@@ -856,6 +871,7 @@
 
 	return MozillaPrivate::RemoveOverrideStyleSheet (docShell, remove);
 }
+#endif
 
 nsresult GaleonWrapper::GetLinkInterfaceItems (GList **list)
 {

Modified: trunk/mozilla/GaleonWrapper.h
==============================================================================
--- trunk/mozilla/GaleonWrapper.h	(original)
+++ trunk/mozilla/GaleonWrapper.h	Fri Sep  5 02:39:20 2008
@@ -165,7 +165,11 @@
 
 	nsresult LoadOverrideStyleSheet (char *css,
 					 nsIStyleSheet **return_sheet);
+#ifdef HAVE_NSISTYLESHEETSERVICE_H
+	nsresult RemoveOverrideStyleSheet (char *css);
+#else
 	nsresult RemoveOverrideStyleSheet (nsIStyleSheet *remove);
+#endif
 
 	nsresult GetLinkInterfaceItems (GList **list);
 

Modified: trunk/mozilla/MozillaPrivate.cpp
==============================================================================
--- trunk/mozilla/MozillaPrivate.cpp	(original)
+++ trunk/mozilla/MozillaPrivate.cpp	Fri Sep  5 02:39:20 2008
@@ -56,6 +56,9 @@
 #include <nsIDOMWindow.h>
 #include <nsIDOMNSDocument.h>
 #include <nsCOMPtr.h>
+#ifdef HAVE_NSISTYLESHEETSERVICE_H
+#include <nsIStyleSheetService.h>
+#endif
 
 #include "GaleonUtils.h"
 
@@ -155,6 +158,27 @@
 {
 	nsresult rv;
 
+#ifdef HAVE_NSISTYLESHEETSERVICE_H
+	nsCOMPtr<nsIStyleSheetService> service
+			(do_GetService ("@mozilla.org/content/style-sheet-service;1", &rv));
+	NS_ENSURE_SUCCESS (rv, rv);
+
+	PRBool isRegistered = PR_FALSE;
+	rv = service->SheetRegistered (aUri, nsIStyleSheetService::USER_SHEET,
+				       &isRegistered);
+	if (NS_SUCCEEDED (rv) && isRegistered)
+	{
+		rv = service->UnregisterSheet (aUri, nsIStyleSheetService::USER_SHEET);
+	}
+
+	rv = service->LoadAndRegisterSheet (aUri, nsIStyleSheetService::AGENT_SHEET);
+	if (NS_FAILED (rv))
+	{
+		g_warning ("Registering the user stylesheet failed (rv=%x)!\n", rv);
+	}
+
+	return rv;
+#else
 	nsCOMPtr<nsIPresShell> presShell;
 	aDocShell->GetPresShell (getter_AddRefs(presShell));
 	NS_ENSURE_TRUE (presShell, NS_ERROR_FAILURE);
@@ -165,7 +189,6 @@
 	nsICSSLoader *loader = doc->CSSLoader();
 	NS_ENSURE_TRUE (loader, NS_ERROR_FAILURE);
 
-#ifdef HAVE_NSSTRING_INTERNAL
 	/* load sheet */
 	nsCOMPtr<nsICSSStyleSheet> sheet;
 #ifdef HAVE_NSICSSLOADER_LOADSHEETSYNC
@@ -194,15 +217,38 @@
 	NS_ADDREF(*aStyleSheet = styleSheet);
 	
 	return NS_OK;
-#else
-	return NS_ERROR_FAILURE;
 #endif
 }
 
 nsresult
 MozillaPrivate::RemoveOverrideStyleSheet (nsIDocShell *aDocShell,
+#if HAVE_NSISTYLESHEETSERVICE_H
+					  nsIURI *aUri)
+#else
 					  nsIStyleSheet* aStyleSheet)
+#endif
 {
+#if HAVE_NSISTYLESHEETSERVICE_H
+	nsresult rv;
+
+	nsCOMPtr<nsIStyleSheetService> service
+			(do_GetService ("@mozilla.org/content/style-sheet-service;1", &rv));
+	NS_ENSURE_SUCCESS (rv, rv);
+
+	PRBool isRegistered = PR_FALSE;
+	rv = service->SheetRegistered (aUri, nsIStyleSheetService::AGENT_SHEET,
+				       &isRegistered);
+	if (NS_SUCCEEDED (rv) && isRegistered)
+	{
+		rv = service->UnregisterSheet (aUri, nsIStyleSheetService::AGENT_SHEET);
+	}
+	if (NS_FAILED (rv))
+	{
+		g_warning ("Unregistering the user stylesheet failed (rv=%x)!\n", rv);
+	}
+
+	return rv;
+#else
 	nsCOMPtr<nsIPresShell> ps;
 	aDocShell->GetPresShell (getter_AddRefs(ps));
 	NS_ENSURE_TRUE (ps, NS_ERROR_FAILURE);
@@ -212,6 +258,7 @@
 	aStyleSheet->SetEnabled(PR_FALSE);
 
 	return NS_OK;
+#endif
 }
 
 

Modified: trunk/mozilla/MozillaPrivate.h
==============================================================================
--- trunk/mozilla/MozillaPrivate.h	(original)
+++ trunk/mozilla/MozillaPrivate.h	Fri Sep  5 02:39:20 2008
@@ -39,7 +39,11 @@
 					 nsIStyleSheet**aStyleSheet);
 
 	nsresult RemoveOverrideStyleSheet (nsIDocShell *aDocShell,
+#ifdef HAVE_NSISTYLESHEETSERVICE_H
+					   nsIURI *aUri);
+#else
 					   nsIStyleSheet*aStyleSheet);
+#endif
 
 	nsresult EvaluateJS (nsIDOMWindow *aWindow, const nsAString& aScript,
 			     nsAString &aResult, PRBool *isUndefined);

Modified: trunk/mozilla/mozilla-embed.cpp
==============================================================================
--- trunk/mozilla/mozilla-embed.cpp	(original)
+++ trunk/mozilla/mozilla-embed.cpp	Fri Sep  5 02:39:20 2008
@@ -1813,7 +1813,17 @@
 
         GaleonWrapper *wrapper = MOZILLA_EMBED(embed)->priv->wrapper;
 
+#ifdef HAVE_NSISTYLESHEETSERVICE_H
+	gchar *path = galeon_embed_utils_get_user_sheet_path(sheet->name);
+
+	gchar *tmp = g_strconcat("file://", path, NULL);
+	g_free(path);
+
+	wrapper->RemoveOverrideStyleSheet(tmp);
+	g_free(tmp);
+#else
 	wrapper->RemoveOverrideStyleSheet(mess->style);
+#endif
 }
 
 EmbedStyleSheet *



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]