diff options
Diffstat (limited to 'embed/mozilla/EphyWrapper.cpp')
-rw-r--r-- | embed/mozilla/EphyWrapper.cpp | 51 |
1 files changed, 36 insertions, 15 deletions
diff --git a/embed/mozilla/EphyWrapper.cpp b/embed/mozilla/EphyWrapper.cpp index 605c3183a..5cb399201 100644 --- a/embed/mozilla/EphyWrapper.cpp +++ b/embed/mozilla/EphyWrapper.cpp @@ -24,7 +24,6 @@ #include "EphyWrapper.h" #include "GlobalHistory.h" -//#include "ProgressListener.h" #include "ephy-embed.h" #include "ephy-string.h" @@ -74,6 +73,7 @@ #include "nsIPresContext.h" #include "nsIAtom.h" #include "nsIDocumentCharsetInfo.h" +#include "nsPromiseFlatString.h" #include "ContentHandler.h" #include "EphyEventListener.h" @@ -590,8 +590,13 @@ nsresult EphyWrapper::GetMainDocumentUrl (nsCString &url) nsCOMPtr<nsIDocument> doc = do_QueryInterface(DOMDocument); if(!doc) return NS_ERROR_FAILURE; +#if MOZILLA_SNAPSHOT > 11 + nsIURI *uri; + uri = doc->GetDocumentURL (); +#else nsCOMPtr<nsIURI> uri; doc->GetDocumentURL(getter_AddRefs(uri)); +#endif return uri->GetSpec (url); } @@ -608,8 +613,13 @@ nsresult EphyWrapper::GetDocumentUrl (nsCString &url) nsCOMPtr<nsIDocument> doc = do_QueryInterface(DOMDocument); if(!doc) return NS_ERROR_FAILURE; +#if MOZILLA_SNAPSHOT > 11 + nsIURI *uri; + uri = doc->GetDocumentURL (); +#else nsCOMPtr<nsIURI> uri; doc->GetDocumentURL(getter_AddRefs(uri)); +#endif uri->GetSpec (url); @@ -773,23 +783,13 @@ nsresult EphyWrapper::GetEncodingInfo (EphyEncodingInfo **infoptr) info = g_new0 (EphyEncodingInfo, 1); *infoptr = info; -#if MOZILLA_SNAPSHOT >= 10 - nsCAutoString enc; - result = doc->GetDocumentCharacterSet (enc); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - - info->encoding = g_strdup (enc.get()); -#else - nsAutoString enc; - result = doc->GetDocumentCharacterSet (enc); - if (NS_FAILED (result)) return NS_ERROR_FAILURE; - - info->encoding = g_strdup (NS_ConvertUCS2toUTF8(enc).get()); -#endif - PRInt32 source; +#if MOZILLA_SNAPSHOT > 11 + source = doc->GetDocumentCharacterSetSource (); +#else result = doc->GetDocumentCharacterSetSource (&source); if (NS_FAILED (result)) return NS_ERROR_FAILURE; +#endif info->encoding_source = (EphyEncodingSource) source; nsCOMPtr<nsIDocShell> ds; @@ -831,7 +831,28 @@ nsresult EphyWrapper::GetEncodingInfo (EphyEncodingInfo **infoptr) &result); if (NS_FAILED(result) || !mdv) return NS_ERROR_FAILURE; +#if MOZILLA_SNAPSHOT > 11 + const nsACString& charsetEnc = doc->GetDocumentCharacterSet (); + if (charsetEnc.IsEmpty()) return NS_ERROR_FAILURE; + + info->encoding = g_strdup (PromiseFlatCString(charsetEnc).get()); +#elif MOZILLA_SNAPSHOT >= 10 + nsCAutoString charsetEnc; + result = doc->GetDocumentCharacterSet (charsetEnc); + if (NS_FAILED (result)) return NS_ERROR_FAILURE; + + info->encoding = g_strdup (charsetEnc.get()); +#else + nsAutoString charsetEnc; + result = doc->GetDocumentCharacterSet (charsetEnc); + if (NS_FAILED (result)) return NS_ERROR_FAILURE; + + info->encoding = g_strdup (NS_ConvertUCS2toUTF8(charsetEnc).get()); +#endif + #if MOZILLA_SNAPSHOT >= 10 + nsCAutoString enc; + result = mdv->GetDefaultCharacterSet (enc); if (NS_FAILED (result)) return NS_ERROR_FAILURE; info->default_encoding = g_strdup (enc.get()); |