зеркало из https://github.com/mozilla/pjs.git
Remove content dependency on the RDF-ness of bookmarks (since in general, they
need not be RDF-enabled at all). Remove bizarre dependency of an interface we really want to expose to embeddors on nsIParser. Bug 101995 followup, r=bsmedberg, sr=alecf
This commit is contained in:
Родитель
32494d1aa2
Коммит
9042fd7a93
|
@ -161,8 +161,6 @@ MatchElementId(nsIContent *aContent, const nsACString& aUTF8Id, const nsAString&
|
|||
|
||||
static NS_DEFINE_CID(kCParserCID, NS_PARSER_CID);
|
||||
|
||||
nsIRDFService* nsHTMLDocument::gRDF;
|
||||
nsrefcnt nsHTMLDocument::gRefCntRDFService = 0;
|
||||
PRUint32 nsHTMLDocument::gWyciwygSessionCnt = 0;
|
||||
|
||||
static int PR_CALLBACK
|
||||
|
@ -288,20 +286,11 @@ nsHTMLDocument::nsHTMLDocument()
|
|||
// NOTE! nsDocument::operator new() zeroes out all members, so don't
|
||||
// bother initializing members to 0.
|
||||
|
||||
if (gRefCntRDFService++ == 0)
|
||||
{
|
||||
CallGetService(kRDFServiceCID, &gRDF);
|
||||
}
|
||||
|
||||
mDefaultElementType = kNameSpaceID_XHTML;
|
||||
}
|
||||
|
||||
nsHTMLDocument::~nsHTMLDocument()
|
||||
{
|
||||
if (--gRefCntRDFService == 0) {
|
||||
NS_IF_RELEASE(gRDF);
|
||||
}
|
||||
|
||||
if (mIdAndNameHashTable.ops) {
|
||||
PL_DHashTableFinish(&mIdAndNameHashTable);
|
||||
}
|
||||
|
@ -516,35 +505,29 @@ nsHTMLDocument::TryBookmarkCharset(nsIDocShell* aDocShell,
|
|||
return PR_TRUE;
|
||||
}
|
||||
|
||||
if (!gRDF) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIRDFDataSource> datasource;
|
||||
nsresult rv = gRDF->GetDataSource("rdf:bookmarks",
|
||||
getter_AddRefs(datasource));
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
if (!aChannel) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsICharsetResolver> bookmarksResolver =
|
||||
do_QueryInterface(datasource);
|
||||
|
||||
if (bookmarksResolver && aDocShell && aChannel) {
|
||||
do_GetService("@mozilla.org/embeddor.implemented/bookmark-charset-resolver;1");
|
||||
|
||||
PRBool wantCharset; // ignored for now
|
||||
nsCAutoString charset;
|
||||
rv = bookmarksResolver->RequestCharset(aDocShell,
|
||||
aChannel,
|
||||
&aCharsetSource,
|
||||
&wantCharset,
|
||||
nsnull,
|
||||
charset);
|
||||
if (NS_SUCCEEDED(rv) && !charset.IsEmpty()) {
|
||||
aCharset = charset;
|
||||
return PR_TRUE;
|
||||
}
|
||||
if (!bookmarksResolver) {
|
||||
return PR_FALSE;
|
||||
}
|
||||
|
||||
PRBool wantCharset; // ignored for now
|
||||
nsCAutoString charset;
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(aDocShell));
|
||||
nsresult rv = bookmarksResolver->RequestCharset(webNav,
|
||||
aChannel,
|
||||
&wantCharset,
|
||||
nsnull,
|
||||
charset);
|
||||
if (NS_SUCCEEDED(rv) && !charset.IsEmpty()) {
|
||||
aCharset = charset;
|
||||
aCharsetSource = kCharsetFromBookmarks;
|
||||
return PR_TRUE;
|
||||
}
|
||||
|
||||
return PR_FALSE;
|
||||
|
|
|
@ -281,8 +281,6 @@ protected:
|
|||
// ahmed 12-2
|
||||
PRInt32 mTexttype;
|
||||
|
||||
static nsrefcnt gRefCntRDFService;
|
||||
static nsIRDFService* gRDF;
|
||||
static PRUint32 gWyciwygSessionCnt;
|
||||
|
||||
static PRBool TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
|
||||
|
|
|
@ -38,37 +38,38 @@
|
|||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
interface nsIDocShell;
|
||||
interface nsIWebNavigation;
|
||||
interface nsIChannel;
|
||||
|
||||
[scriptable, uuid(d143a084-b626-4614-845f-41f3ca43a674)]
|
||||
interface nsICharsetResolver : nsISupports
|
||||
{
|
||||
/**
|
||||
* requestCharset
|
||||
* called to resolve the charset of an existing docshell.
|
||||
* If the charset cannot be resolved, but the implementation is
|
||||
* still curious what the final charset turned out to be, it can
|
||||
* set wantCharset to true.
|
||||
* If so, notifyResovedCharset will be called with the resulting
|
||||
* closure
|
||||
* Called to resolve the charset that should be used for parsing the
|
||||
* document being loaded from aChannel.
|
||||
*
|
||||
* If the charset cannot be resolved, but the implementation of
|
||||
* nsICharsetResolver wants to be notified of the final resolved charset
|
||||
* when one is available, it can set wantCharset to true. If this is done,
|
||||
* the caller of requestCharset is responsible for calling
|
||||
* notifyResovedCharset and passing it the final resolved charset and the
|
||||
* closure that requestCharset set.
|
||||
*
|
||||
* @param docShell the docshell the document is being loaded in
|
||||
* @param channel the channel the document is coming in from
|
||||
* @param charsetSource a unique number which can be stored by the
|
||||
* caller to remember which resolver actually
|
||||
* resolved the charset.
|
||||
* @param wantCharset gets set to true if notifyResolvedCharset should be
|
||||
* called with the given closure object
|
||||
* @param closure a resulting object which should be passed
|
||||
* to notifyResolvedCharset
|
||||
* @returns the resolved charset, or the empty string if no
|
||||
* charset could be determined
|
||||
* @param aWebNavigation the nsIWebNavigation the document is being loaded
|
||||
* in. May be null.
|
||||
* @param aChannel the channel the document is coming in from.
|
||||
* @param aWantCharset gets set to true if notifyResolvedCharset should be
|
||||
* called with the given closure object.
|
||||
* @param aClosure a resulting object which should be passed
|
||||
* to notifyResolvedCharset if wantCharset is set to
|
||||
* true.
|
||||
* @returns the resolved charset, or the empty string if no
|
||||
* charset could be determined.
|
||||
*/
|
||||
ACString requestCharset(in nsIDocShell docShell, in nsIChannel channel,
|
||||
out long charsetSource,
|
||||
out boolean wantCharset,
|
||||
out nsISupports closure);
|
||||
ACString requestCharset(in nsIWebNavigation aWebNavigation,
|
||||
in nsIChannel aChannel,
|
||||
out boolean aWantCharset,
|
||||
out nsISupports aClosure);
|
||||
|
||||
/**
|
||||
* notifyResolvedCharset
|
||||
|
|
|
@ -95,7 +95,7 @@ enum eParserDocType {
|
|||
|
||||
|
||||
// define Charset source constants
|
||||
// note: the value order define the priority
|
||||
// note: the value order defines the priority; higher numbers take priority
|
||||
#define kCharsetUninitialized 0
|
||||
#define kCharsetFromWeakDocTypeDefault 1
|
||||
#define kCharsetFromUserDefault 2
|
||||
|
|
|
@ -62,6 +62,7 @@ REQUIRES = xpcom \
|
|||
chardet \
|
||||
htmlparser \
|
||||
locale \
|
||||
docshell \
|
||||
$(NULL)
|
||||
|
||||
CPPSRCS = nsBookmarksService.cpp
|
||||
|
|
|
@ -87,7 +87,7 @@
|
|||
#include "nsIPrefBranch.h"
|
||||
#include "nsIPrefBranch2.h"
|
||||
|
||||
#include "nsIParser.h" // for kCharsetFromBookmarks
|
||||
#include "nsIWebNavigation.h"
|
||||
|
||||
// for sorting
|
||||
#include "nsCollationCID.h"
|
||||
|
@ -98,9 +98,6 @@
|
|||
#include "nsAutoBuffer.h"
|
||||
|
||||
|
||||
#include "nsIParser.h" // for kCharsetFromBookmarks
|
||||
|
||||
|
||||
#ifdef XP_WIN
|
||||
#include <shlobj.h>
|
||||
#include <intshcut.h>
|
||||
|
@ -3352,9 +3349,8 @@ nsBookmarksService::IsBookmarked(const char* aURL, PRBool* aIsBookmarked)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsBookmarksService::RequestCharset(nsIDocShell* aDocShell,
|
||||
nsBookmarksService::RequestCharset(nsIWebNavigation* aWebNavigation,
|
||||
nsIChannel* aChannel,
|
||||
PRInt32* aCharsetSource,
|
||||
PRBool* aWantCharset,
|
||||
nsISupports** aClosure,
|
||||
nsACString& aResult)
|
||||
|
@ -3402,7 +3398,6 @@ nsBookmarksService::RequestCharset(nsIDocShell* aDocShell,
|
|||
const PRUnichar* charset;
|
||||
charsetLiteral->GetValueConst(&charset);
|
||||
LossyCopyUTF16toASCII(charset, aResult);
|
||||
*aCharsetSource = kCharsetFromBookmarks;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
@ -3418,6 +3413,7 @@ NS_IMETHODIMP
|
|||
nsBookmarksService::NotifyResolvedCharset(const nsACString& aCharset,
|
||||
nsISupports* aClosure)
|
||||
{
|
||||
NS_ERROR("Unexpected call to NotifyResolvedCharset -- we never set aWantCharset to true!");
|
||||
return NS_ERROR_NOT_IMPLEMENTED;
|
||||
}
|
||||
|
||||
|
|
|
@ -178,6 +178,9 @@ static const nsModuleComponentInfo components[] = {
|
|||
#if !defined(MOZ_PHOENIX) && !defined(MOZ_XULRUNNER)
|
||||
{ "Bookmarks", NS_BOOKMARKS_SERVICE_CID, NS_BOOKMARKS_SERVICE_CONTRACTID,
|
||||
nsBookmarksServiceConstructor },
|
||||
{ "Bookmarks", NS_BOOKMARKS_SERVICE_CID,
|
||||
"@mozilla.org/embeddor.implemented/bookmark-charset-resolver;1",
|
||||
nsBookmarksServiceConstructor },
|
||||
{ "Bookmarks", NS_BOOKMARKS_SERVICE_CID, NS_BOOKMARKS_DATASOURCE_CONTRACTID,
|
||||
nsBookmarksServiceConstructor },
|
||||
{ "Download Manager", NS_DOWNLOADMANAGER_CID, NS_DOWNLOADMANAGER_CONTRACTID,
|
||||
|
|
Загрузка…
Ссылка в новой задаче