зеркало из https://github.com/mozilla/gecko-dev.git
Merge last green changeset from mozilla-inbound to mozilla-central
This commit is contained in:
Коммит
7a066fff8d
|
@ -5973,12 +5973,12 @@ function MultiplexHandler(event)
|
|||
var name = node.getAttribute('name');
|
||||
|
||||
if (name == 'detectorGroup') {
|
||||
SetForcedDetector(true);
|
||||
BrowserCharsetReload();
|
||||
SelectDetector(event, false);
|
||||
} else if (name == 'charsetGroup') {
|
||||
var charset = node.getAttribute('id');
|
||||
charset = charset.substring('charset.'.length, charset.length)
|
||||
SetForcedCharset(charset);
|
||||
BrowserSetForcedCharacterSet(charset);
|
||||
} else if (name == 'charsetCustomize') {
|
||||
//do nothing - please remove this else statement, once the charset prefs moves to the pref window
|
||||
} else {
|
||||
|
@ -6009,30 +6009,17 @@ function SelectDetector(event, doReload)
|
|||
}
|
||||
}
|
||||
|
||||
function SetForcedDetector(doReload)
|
||||
{
|
||||
BrowserSetForcedDetector(doReload);
|
||||
}
|
||||
|
||||
function SetForcedCharset(charset)
|
||||
{
|
||||
BrowserSetForcedCharacterSet(charset);
|
||||
}
|
||||
|
||||
function BrowserSetForcedCharacterSet(aCharset)
|
||||
{
|
||||
var docCharset = gBrowser.docShell.QueryInterface(Ci.nsIDocCharset);
|
||||
docCharset.charset = aCharset;
|
||||
gBrowser.docShell.charset = aCharset;
|
||||
// Save the forced character-set
|
||||
PlacesUtils.history.setCharsetForURI(getWebNavigation().currentURI, aCharset);
|
||||
BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
||||
BrowserCharsetReload();
|
||||
}
|
||||
|
||||
function BrowserSetForcedDetector(doReload)
|
||||
function BrowserCharsetReload()
|
||||
{
|
||||
gBrowser.documentCharsetInfo.forcedDetector = true;
|
||||
if (doReload)
|
||||
BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
||||
BrowserReloadWithFlags(nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
||||
}
|
||||
|
||||
function charsetMenuGetElement(parent, id) {
|
||||
|
|
|
@ -2375,10 +2375,6 @@
|
|||
onget="return this.mCurrentBrowser.contentViewerFile;"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="documentCharsetInfo"
|
||||
onget="return this.mCurrentBrowser.documentCharsetInfo;"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="contentDocument"
|
||||
onget="return this.mCurrentBrowser.contentDocument;"
|
||||
readonly="true"/>
|
||||
|
|
|
@ -1600,6 +1600,8 @@ public:
|
|||
void WarnOnceAbout(DeprecatedOperations aOperation);
|
||||
|
||||
virtual void PostVisibilityUpdateEvent() = 0;
|
||||
|
||||
bool IsSyntheticDocument() { return mIsSyntheticDocument; }
|
||||
|
||||
void SetNeedLayoutFlush() {
|
||||
mNeedLayoutFlush = true;
|
||||
|
|
|
@ -5436,8 +5436,9 @@ public:
|
|||
}
|
||||
NS_IMETHOD_(void) NoteScriptChild(PRUint32 langID, void* child)
|
||||
{
|
||||
if (langID == nsIProgrammingLanguage::JAVASCRIPT) {
|
||||
mFound = child == mWrapper;
|
||||
if (langID == nsIProgrammingLanguage::JAVASCRIPT &&
|
||||
child == mWrapper) {
|
||||
mFound = true;
|
||||
}
|
||||
}
|
||||
NS_IMETHOD_(void) NoteXPCOMChild(nsISupports *child)
|
||||
|
|
|
@ -2516,7 +2516,7 @@ nsEventStateManager::DoScrollZoom(nsIFrame *aTargetFrame,
|
|||
// positive adjustment to decrease zoom, negative to increase
|
||||
PRInt32 change = (adjustment > 0) ? -1 : 1;
|
||||
|
||||
if (Preferences::GetBool("browser.zoom.full")) {
|
||||
if (Preferences::GetBool("browser.zoom.full") || content->GetCurrentDoc()->IsSyntheticDocument()) {
|
||||
ChangeFullZoom(change);
|
||||
} else {
|
||||
ChangeTextSize(change);
|
||||
|
|
|
@ -49,7 +49,6 @@
|
|||
#include "nsIMarkupDocumentViewer.h"
|
||||
#include "nsIDocShell.h"
|
||||
#include "nsIParser.h" // kCharsetFrom* macro definition
|
||||
#include "nsIDocumentCharsetInfo.h"
|
||||
#include "nsNodeInfoManager.h"
|
||||
#include "nsContentUtils.h"
|
||||
|
||||
|
@ -185,7 +184,7 @@ MediaDocument::StartDocumentLoad(const char* aCommand,
|
|||
// the charset of the referring document. On the other hand, if the
|
||||
// document is opened in a new window, it is |defaultCharacterSet| of |muCV|
|
||||
// where the charset of our interest is stored. In case of openining
|
||||
// in a new tab, we get the charset from |documentCharsetInfo|. Note that we
|
||||
// in a new tab, we get the charset from the docShell. Note that we
|
||||
// exclude UTF-8 as 'invalid' because UTF-8 is likely to be the charset
|
||||
// of a chrome document that has nothing to do with the actual content
|
||||
// whose charset we want to know. Even if "the actual content" is indeed
|
||||
|
@ -197,16 +196,12 @@ MediaDocument::StartDocumentLoad(const char* aCommand,
|
|||
// not being able to set the charset is not critical.
|
||||
NS_ENSURE_TRUE(docShell, NS_OK);
|
||||
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
|
||||
nsCAutoString charset;
|
||||
|
||||
docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
if (dcInfo) {
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
dcInfo->GetParentCharset(getter_AddRefs(csAtom));
|
||||
if (csAtom) { // opening in a new tab
|
||||
csAtom->ToUTF8String(charset);
|
||||
}
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
docShell->GetParentCharset(getter_AddRefs(csAtom));
|
||||
if (csAtom) { // opening in a new tab
|
||||
csAtom->ToUTF8String(charset);
|
||||
}
|
||||
|
||||
if (charset.IsEmpty() || charset.Equals("UTF-8")) {
|
||||
|
|
|
@ -105,7 +105,6 @@
|
|||
#include "nsICharsetAlias.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsJSUtils.h"
|
||||
#include "nsIDocumentCharsetInfo.h"
|
||||
#include "nsIDocumentEncoder.h" //for outputting selection
|
||||
#include "nsICachingChannel.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
|
@ -383,7 +382,7 @@ nsHTMLDocument::TryHintCharset(nsIMarkupDocumentViewer* aMarkupDV,
|
|||
|
||||
bool
|
||||
nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
|
||||
nsIDocumentCharsetInfo* aDocInfo,
|
||||
nsIDocShell* aDocShell,
|
||||
PRInt32& aCharsetSource,
|
||||
nsACString& aCharset)
|
||||
{
|
||||
|
@ -401,13 +400,13 @@ nsHTMLDocument::TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
|
|||
aCharset = forceCharsetFromDocShell;
|
||||
//TODO: we should define appropriate constant for force charset
|
||||
aCharsetSource = kCharsetFromUserForced;
|
||||
} else if (aDocInfo) {
|
||||
} else if (aDocShell) {
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
aDocInfo->GetForcedCharset(getter_AddRefs(csAtom));
|
||||
aDocShell->GetForcedCharset(getter_AddRefs(csAtom));
|
||||
if (csAtom) {
|
||||
csAtom->ToUTF8String(aCharset);
|
||||
aCharsetSource = kCharsetFromUserForced;
|
||||
aDocInfo->SetForcedCharset(nsnull);
|
||||
aDocShell->SetForcedCharset(nsnull);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -453,16 +452,16 @@ CheckSameOrigin(nsINode* aNode1, nsINode* aNode2)
|
|||
}
|
||||
|
||||
bool
|
||||
nsHTMLDocument::TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
|
||||
nsHTMLDocument::TryParentCharset(nsIDocShell* aDocShell,
|
||||
nsIDocument* aParentDocument,
|
||||
PRInt32& aCharsetSource,
|
||||
nsACString& aCharset)
|
||||
{
|
||||
if (aDocInfo) {
|
||||
if (aDocShell) {
|
||||
PRInt32 source;
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
PRInt32 parentSource;
|
||||
aDocInfo->GetParentCharsetSource(&parentSource);
|
||||
aDocShell->GetParentCharsetSource(&parentSource);
|
||||
if (kCharsetFromParentForced <= parentSource)
|
||||
source = kCharsetFromParentForced;
|
||||
else if (kCharsetFromHintPrevDoc == parentSource) {
|
||||
|
@ -489,7 +488,7 @@ nsHTMLDocument::TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
|
|||
if (source < aCharsetSource)
|
||||
return true;
|
||||
|
||||
aDocInfo->GetParentCharset(getter_AddRefs(csAtom));
|
||||
aDocShell->GetParentCharset(getter_AddRefs(csAtom));
|
||||
if (csAtom) {
|
||||
csAtom->ToUTF8String(aCharset);
|
||||
aCharsetSource = source;
|
||||
|
@ -744,9 +743,6 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
parserCharset = charset;
|
||||
} else {
|
||||
NS_ASSERTION(docShell && docShellAsItem, "Unexpected null value");
|
||||
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
|
||||
docShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
|
||||
charsetSource = kCharsetUninitialized;
|
||||
wyciwygChannel = do_QueryInterface(aChannel);
|
||||
|
@ -757,9 +753,9 @@ nsHTMLDocument::StartDocumentLoad(const char* aCommand,
|
|||
// describes. Some try call might change charset source to
|
||||
// multiple values, like TryHintCharset and TryParentCharset. It
|
||||
// should be always safe to try more sources.
|
||||
if (!TryUserForcedCharset(muCV, dcInfo, charsetSource, charset)) {
|
||||
if (!TryUserForcedCharset(muCV, docShell, charsetSource, charset)) {
|
||||
TryHintCharset(muCV, charsetSource, charset);
|
||||
TryParentCharset(dcInfo, parentDocument, charsetSource, charset);
|
||||
TryParentCharset(docShell, parentDocument, charsetSource, charset);
|
||||
|
||||
// Don't actually get the charset from the channel if this is a
|
||||
// wyciwyg channel; it'll always be UTF-16
|
||||
|
|
|
@ -63,7 +63,7 @@ class nsIEditorDocShell;
|
|||
class nsIParser;
|
||||
class nsIURI;
|
||||
class nsIMarkupDocumentViewer;
|
||||
class nsIDocumentCharsetInfo;
|
||||
class nsIDocShell;
|
||||
class nsICachingChannel;
|
||||
|
||||
class nsHTMLDocument : public nsDocument,
|
||||
|
@ -253,14 +253,14 @@ protected:
|
|||
PRInt32& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
static bool TryUserForcedCharset(nsIMarkupDocumentViewer* aMarkupDV,
|
||||
nsIDocumentCharsetInfo* aDocInfo,
|
||||
nsIDocShell* aDocShell,
|
||||
PRInt32& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
static bool TryCacheCharset(nsICachingChannel* aCachingChannel,
|
||||
PRInt32& aCharsetSource,
|
||||
nsACString& aCharset);
|
||||
// aParentDocument could be null.
|
||||
bool TryParentCharset(nsIDocumentCharsetInfo* aDocInfo,
|
||||
bool TryParentCharset(nsIDocShell* aDocShell,
|
||||
nsIDocument* aParentDocument,
|
||||
PRInt32& charsetSource, nsACString& aCharset);
|
||||
static bool UseWeakDocTypeDefault(PRInt32& aCharsetSource,
|
||||
|
|
|
@ -69,6 +69,7 @@ XPIDLSRCS = \
|
|||
nsIMarkupDocumentViewer.idl \
|
||||
nsIScrollable.idl \
|
||||
nsITextScroll.idl \
|
||||
nsIDocCharset.idl \
|
||||
nsIWebNavigation.idl \
|
||||
nsIWebNavigationInfo.idl \
|
||||
nsIContentViewer.idl \
|
||||
|
|
|
@ -90,7 +90,6 @@
|
|||
#include "nsIScriptSecurityManager.h"
|
||||
#include "nsIJSContextStack.h"
|
||||
#include "nsIScriptObjectPrincipal.h"
|
||||
#include "nsDocumentCharsetInfoCID.h"
|
||||
#include "nsIScrollableFrame.h"
|
||||
#include "nsContentPolicyUtils.h" // NS_CheckContentLoadPolicy(...)
|
||||
#include "nsICategoryManager.h"
|
||||
|
@ -756,10 +755,11 @@ nsDocShell::nsDocShell():
|
|||
mIsBeingDestroyed(false),
|
||||
mIsExecutingOnLoadHandler(false),
|
||||
mIsPrintingOrPP(false),
|
||||
mSavingOldViewer(false)
|
||||
mSavingOldViewer(false),
|
||||
#ifdef DEBUG
|
||||
, mInEnsureScriptEnv(false)
|
||||
mInEnsureScriptEnv(false),
|
||||
#endif
|
||||
mParentCharsetSource(0)
|
||||
{
|
||||
mHistoryID = ++gDocshellIDCounter;
|
||||
if (gDocShellCount++ == 0) {
|
||||
|
@ -1877,41 +1877,48 @@ nsDocShell::SetCharset(const char* aCharset)
|
|||
}
|
||||
|
||||
// set the charset override
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo;
|
||||
GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
if (dcInfo) {
|
||||
nsCOMPtr<nsIAtom> csAtom;
|
||||
csAtom = do_GetAtom(aCharset);
|
||||
dcInfo->SetForcedCharset(csAtom);
|
||||
}
|
||||
nsCOMPtr<nsIAtom> csAtom = do_GetAtom(aCharset);
|
||||
SetForcedCharset(csAtom);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::GetDocumentCharsetInfo(nsIDocumentCharsetInfo **
|
||||
aDocumentCharsetInfo)
|
||||
NS_IMETHODIMP nsDocShell::SetForcedCharset(nsIAtom * aCharset)
|
||||
{
|
||||
NS_ENSURE_ARG_POINTER(aDocumentCharsetInfo);
|
||||
|
||||
// if the mDocumentCharsetInfo does not exist already, we create it now
|
||||
if (!mDocumentCharsetInfo) {
|
||||
mDocumentCharsetInfo = do_CreateInstance(NS_DOCUMENTCHARSETINFO_CONTRACTID);
|
||||
if (!mDocumentCharsetInfo)
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
*aDocumentCharsetInfo = mDocumentCharsetInfo;
|
||||
NS_IF_ADDREF(*aDocumentCharsetInfo);
|
||||
return NS_OK;
|
||||
mForcedCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDocShell::SetDocumentCharsetInfo(nsIDocumentCharsetInfo *
|
||||
aDocumentCharsetInfo)
|
||||
NS_IMETHODIMP nsDocShell::GetForcedCharset(nsIAtom ** aResult)
|
||||
{
|
||||
mDocumentCharsetInfo = aDocumentCharsetInfo;
|
||||
return NS_OK;
|
||||
*aResult = mForcedCharset;
|
||||
if (mForcedCharset) NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::SetParentCharset(nsIAtom * aCharset)
|
||||
{
|
||||
mParentCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetParentCharset(nsIAtom ** aResult)
|
||||
{
|
||||
*aResult = mParentCharset;
|
||||
if (mParentCharset) NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::SetParentCharsetSource(PRInt32 aCharsetSource)
|
||||
{
|
||||
mParentCharsetSource = aCharsetSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocShell::GetParentCharsetSource(PRInt32 * aParentCharsetSource)
|
||||
{
|
||||
*aParentCharsetSource = mParentCharsetSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -3184,9 +3191,9 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
|
|||
|
||||
// charset, style-disabling, and zoom will be inherited in SetupNewViewer()
|
||||
|
||||
// Now take this document's charset and set the parentCharset field of the
|
||||
// child's DocumentCharsetInfo to it. We'll later use that field, in the
|
||||
// loading process, for the charset choosing algorithm.
|
||||
// Now take this document's charset and set the child's parentCharset field
|
||||
// to it. We'll later use that field, in the loading process, for the
|
||||
// charset choosing algorithm.
|
||||
// If we fail, at any point, we just return NS_OK.
|
||||
// This code has some performance impact. But this will be reduced when
|
||||
// the current charset will finally be stored as an Atom, avoiding the
|
||||
|
@ -3196,12 +3203,6 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
|
|||
if (mItemType == nsIDocShellTreeItem::typeChrome)
|
||||
return NS_OK;
|
||||
|
||||
// get the child's docCSInfo object
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> dcInfo = NULL;
|
||||
res = childAsDocShell->GetDocumentCharsetInfo(getter_AddRefs(dcInfo));
|
||||
if (NS_FAILED(res) || (!dcInfo))
|
||||
return NS_OK;
|
||||
|
||||
// get the parent's current charset
|
||||
if (!mContentViewer)
|
||||
return NS_OK;
|
||||
|
@ -3225,14 +3226,14 @@ nsDocShell::AddChild(nsIDocShellTreeItem * aChild)
|
|||
|
||||
// set the child's parentCharset
|
||||
nsCOMPtr<nsIAtom> parentCSAtom(do_GetAtom(parentCS));
|
||||
res = dcInfo->SetParentCharset(parentCSAtom);
|
||||
res = childAsDocShell->SetParentCharset(parentCSAtom);
|
||||
if (NS_FAILED(res))
|
||||
return NS_OK;
|
||||
|
||||
PRInt32 charsetSource = doc->GetDocumentCharacterSetSource();
|
||||
|
||||
// set the child's parentCharset
|
||||
res = dcInfo->SetParentCharsetSource(charsetSource);
|
||||
res = childAsDocShell->SetParentCharsetSource(charsetSource);
|
||||
if (NS_FAILED(res))
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -78,7 +78,6 @@
|
|||
#define REFRESH_REDIRECT_TIMER 15000
|
||||
|
||||
// Interfaces Needed
|
||||
#include "nsIDocumentCharsetInfo.h"
|
||||
#include "nsIDocCharset.h"
|
||||
#include "nsIGlobalHistory2.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
|
@ -710,7 +709,6 @@ protected:
|
|||
nsCOMPtr<nsISupportsArray> mSavedRefreshURIList;
|
||||
nsRefPtr<nsDSURIContentListener> mContentListener;
|
||||
nsCOMPtr<nsIContentViewer> mContentViewer;
|
||||
nsCOMPtr<nsIDocumentCharsetInfo> mDocumentCharsetInfo;
|
||||
nsCOMPtr<nsIWidget> mParentWidget;
|
||||
|
||||
// mCurrentURI should be marked immutable on set if possible.
|
||||
|
@ -841,8 +839,12 @@ protected:
|
|||
|
||||
nsRefPtr<nsDOMNavigationTiming> mTiming;
|
||||
|
||||
#ifdef DEBUG
|
||||
private:
|
||||
nsCOMPtr<nsIAtom> mForcedCharset;
|
||||
nsCOMPtr<nsIAtom> mParentCharset;
|
||||
PRInt32 mParentCharsetSource;
|
||||
|
||||
#ifdef DEBUG
|
||||
// We're counting the number of |nsDocShells| to help find leaks
|
||||
static unsigned long gNumberOfDocShells;
|
||||
#endif /* DEBUG */
|
||||
|
|
|
@ -0,0 +1,19 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* The functionality of the nsIDocCharset interface has been incorporated into
|
||||
* nsIDocShell.
|
||||
*
|
||||
* This is an empty interface for backwards compatibility that will go away at
|
||||
* some point in the future
|
||||
*
|
||||
*/
|
||||
|
||||
[scriptable, uuid(c3faaf6e-40f0-11e1-95fc-6c626d69675c)]
|
||||
interface nsIDocCharset : nsISupports
|
||||
{};
|
|
@ -39,6 +39,7 @@
|
|||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
#include "nsIAtom.idl"
|
||||
|
||||
%{ C++
|
||||
class nsPresContext;
|
||||
|
@ -59,7 +60,6 @@ interface nsIContentViewer;
|
|||
interface nsIURIContentListener;
|
||||
interface nsIDOMEventTarget;
|
||||
interface nsIDocShellLoadInfo;
|
||||
interface nsIDocumentCharsetInfo;
|
||||
interface nsIWebNavigation;
|
||||
interface nsISimpleEnumerator;
|
||||
interface nsIInputStream;
|
||||
|
@ -72,7 +72,7 @@ interface nsIPrincipal;
|
|||
interface nsIWebBrowserPrint;
|
||||
interface nsIVariant;
|
||||
|
||||
[scriptable, uuid(0666adf8-8738-4ca7-a917-0348f47d2f40)]
|
||||
[scriptable, uuid(0615d1a6-313f-11e1-a043-6c626d69675c)]
|
||||
interface nsIDocShell : nsISupports
|
||||
{
|
||||
/**
|
||||
|
@ -236,12 +236,6 @@ interface nsIDocShell : nsISupports
|
|||
*/
|
||||
attribute nsIDOMEventTarget chromeEventHandler;
|
||||
|
||||
/**
|
||||
* The document charset info. This is used by a load to determine priorities
|
||||
* for charset detection etc.
|
||||
*/
|
||||
attribute nsIDocumentCharsetInfo documentCharsetInfo;
|
||||
|
||||
/**
|
||||
* Whether to allow plugin execution
|
||||
*/
|
||||
|
@ -553,4 +547,59 @@ interface nsIDocShell : nsISupports
|
|||
* @param aPrincipal the principal to use for the new document.
|
||||
*/
|
||||
void createAboutBlankContentViewer(in nsIPrincipal aPrincipal);
|
||||
|
||||
/**
|
||||
* The charset attribute allows the user to view, hint, and set which
|
||||
* converter is used to read the document's data.
|
||||
*
|
||||
* <P>Inside Mozilla all text is encoded as Unicode. By standardizing
|
||||
* on Unicode every piece of code that handles characters no longer
|
||||
* needs to:
|
||||
*
|
||||
* Have access to a character encoding parameter.
|
||||
* Ask is the data stateful?
|
||||
* Ask is the data single byte?
|
||||
* Ask is the data multi-byte?
|
||||
* If multi-byte: have access to a routine that can
|
||||
* determine how many bytes in the current character.
|
||||
*
|
||||
* When the document is read in a converter is used to convert
|
||||
* the document's data to Unicode.
|
||||
*
|
||||
* The charset attribute provides the ability to:
|
||||
*
|
||||
* See what converter was used when inputting the documents
|
||||
* data.
|
||||
*
|
||||
* Override the character set for documents where the specified
|
||||
* fallback, or auto-detected character set is incorrect
|
||||
*
|
||||
* Get/sets the encoding (converter) used to read the
|
||||
* document. Get returns the encoding used. Set forces
|
||||
* (overrides) the encoding. After forcing the charset the
|
||||
* embedding application will need to cause the data to be
|
||||
* reparsed in order to update the DOM / display.
|
||||
*
|
||||
* A force also sets the fallback encoding for this frame.
|
||||
*/
|
||||
attribute string charset;
|
||||
|
||||
/**
|
||||
* The charset forced by the user. When the charset attribute is set this
|
||||
* attribute is set to the same value.
|
||||
*
|
||||
* XXX Could this be replaced by a boolean?
|
||||
*/
|
||||
attribute nsIAtom forcedCharset;
|
||||
|
||||
/**
|
||||
* In a child docshell, this is the charset of the parent docshell
|
||||
*/
|
||||
attribute nsIAtom parentCharset;
|
||||
|
||||
/*
|
||||
* In a child docshell, this is the source of parentCharset
|
||||
* @see nsIParser
|
||||
*/
|
||||
attribute PRInt32 parentCharsetSource;
|
||||
};
|
||||
|
|
|
@ -125,6 +125,7 @@ _TEST_FILES = \
|
|||
test_bug691547.html \
|
||||
bug691547_frame.html \
|
||||
test_bug694612.html \
|
||||
test_bug713825.html \
|
||||
$(NULL)
|
||||
|
||||
ifeq ($(MOZ_WIDGET_TOOLKIT),cocoa)
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<!--
|
||||
https://bugzilla.mozilla.org/show_bug.cgi?id=713825
|
||||
-->
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>Test for Bug 713825</title>
|
||||
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
||||
</head>
|
||||
<body>
|
||||
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=713825">Mozilla Bug 713825</a>
|
||||
<p id="display"></p>
|
||||
<div id="content" style="display: none">
|
||||
|
||||
</div>
|
||||
<pre id="test">
|
||||
<script type="application/javascript">
|
||||
|
||||
/**
|
||||
* Test for Bug 713825
|
||||
* test that nsIDocCharset still works backward compatibly
|
||||
*/
|
||||
netscape.security.PrivilegeManager.enablePrivilege('UniversalXPConnect');
|
||||
var Ci = Components.interfaces;
|
||||
var docShell = window.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIWebNavigation).
|
||||
QueryInterface(Ci.nsIDocShell);
|
||||
|
||||
var charset1 = docShell.charset;
|
||||
var charset2 = docShell.QueryInterface(Ci.nsIDocCharset).charset;
|
||||
var charset3 = window.QueryInterface(Ci.nsIInterfaceRequestor).
|
||||
getInterface(Ci.nsIDocCharset).charset;
|
||||
|
||||
/* if we get here without throwing and the three charsets are equal, all is OK */
|
||||
is(charset1, charset2, "QI'd nsIDocCharset.charset should equal nsIDocShell.charset");
|
||||
is(charset1, charset3, "getInterface'd nsIDocCharset.charset should equal nsIDocShell.charset");
|
||||
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
</html>
|
|
@ -0,0 +1,82 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "DOMError.h"
|
||||
|
||||
#include "mozilla/Util.h"
|
||||
#include "nsDOMClassInfo.h"
|
||||
|
||||
using mozilla::ArrayLength;
|
||||
using mozilla::dom::DOMError;
|
||||
|
||||
namespace {
|
||||
|
||||
struct NameMap
|
||||
{
|
||||
PRUint16 code;
|
||||
const char* name;
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIDOMDOMError>
|
||||
DOMError::CreateForDOMExceptionCode(PRUint16 aDOMExceptionCode)
|
||||
{
|
||||
// All of these codes (and yes, some are skipped) come from the spec.
|
||||
static const NameMap kNames[] = {
|
||||
{ 1, "IndexSizeError" },
|
||||
{ 3, "HierarchyRequestError" },
|
||||
{ 4, "WrongDocumentError" },
|
||||
{ 5, "InvalidCharacterError" },
|
||||
{ 7, "NoModificationAllowedError" },
|
||||
{ 8, "NotFoundError" },
|
||||
{ 9, "NotSupportedError" },
|
||||
{ 11, "InvalidStateError" },
|
||||
{ 12, "SyntaxError" },
|
||||
{ 13, "InvalidModificationError" },
|
||||
{ 14, "NamespaceError" },
|
||||
{ 15, "InvalidAccessError" },
|
||||
{ 17, "TypeMismatchError" },
|
||||
{ 18, "SecurityError" },
|
||||
{ 19, "NetworkError" },
|
||||
{ 20, "AbortError" },
|
||||
{ 21, "URLMismatchError" },
|
||||
{ 22, "QuotaExceededError" },
|
||||
{ 23, "TimeoutError" },
|
||||
{ 24, "InvalidNodeTypeError" },
|
||||
{ 25, "DataCloneError" }
|
||||
};
|
||||
|
||||
for (size_t index = 0; index < ArrayLength(kNames); index++) {
|
||||
if (kNames[index].code == aDOMExceptionCode) {
|
||||
nsString name;
|
||||
name.AssignASCII(kNames[index].name);
|
||||
return CreateWithName(name);
|
||||
}
|
||||
}
|
||||
|
||||
NS_NOTREACHED("Unknown DOMException code!");
|
||||
return nsnull;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(DOMError)
|
||||
NS_IMPL_RELEASE(DOMError)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(DOMError)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(DOMError)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMDOMError)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
DOMCI_DATA(DOMError, DOMError)
|
||||
|
||||
NS_IMETHODIMP
|
||||
DOMError::GetName(nsAString& aName)
|
||||
{
|
||||
aName = mName;
|
||||
return NS_OK;
|
||||
}
|
|
@ -0,0 +1,48 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_domerror_h__
|
||||
#define mozilla_dom_domerror_h__
|
||||
|
||||
#include "nsIDOMDOMError.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsStringGlue.h"
|
||||
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
|
||||
class DOMError : public nsIDOMDOMError
|
||||
{
|
||||
nsString mName;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMDOMERROR
|
||||
|
||||
static already_AddRefed<nsIDOMDOMError>
|
||||
CreateForDOMExceptionCode(PRUint16 aDOMExceptionCode);
|
||||
|
||||
static already_AddRefed<nsIDOMDOMError>
|
||||
CreateWithName(const nsAString& aName)
|
||||
{
|
||||
nsCOMPtr<nsIDOMDOMError> error = new DOMError(aName);
|
||||
return error.forget();
|
||||
}
|
||||
|
||||
protected:
|
||||
DOMError(const nsAString& aName)
|
||||
: mName(aName)
|
||||
{ }
|
||||
|
||||
virtual ~DOMError()
|
||||
{ }
|
||||
};
|
||||
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
#endif // mozilla_dom_domerror_h__
|
|
@ -66,6 +66,7 @@ EXTRA_JS_MODULES += Webapps.jsm \
|
|||
endif
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIDOMDOMError.idl \
|
||||
nsIEntropyCollector.idl \
|
||||
nsIScriptChannel.idl \
|
||||
$(NULL)
|
||||
|
@ -103,6 +104,7 @@ EXPORTS = \
|
|||
|
||||
EXPORTS_NAMESPACES = mozilla/dom
|
||||
EXPORTS_mozilla/dom = \
|
||||
DOMError.h \
|
||||
StructuredCloneTags.h \
|
||||
$(NULL)
|
||||
|
||||
|
@ -132,6 +134,7 @@ CPPSRCS = \
|
|||
nsDOMNavigationTiming.cpp \
|
||||
nsPerformance.cpp \
|
||||
nsDOMMemoryReporter.cpp \
|
||||
DOMError.cpp \
|
||||
Navigator.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -490,6 +490,7 @@
|
|||
#include "DOMSVGPointList.h"
|
||||
#include "DOMSVGTransformList.h"
|
||||
|
||||
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
||||
#include "mozilla/dom/indexedDB/IDBFactory.h"
|
||||
#include "mozilla/dom/indexedDB/IDBRequest.h"
|
||||
#include "mozilla/dom/indexedDB/IDBDatabase.h"
|
||||
|
@ -501,6 +502,8 @@
|
|||
#include "mozilla/dom/indexedDB/IDBIndex.h"
|
||||
#include "nsIIDBDatabaseException.h"
|
||||
|
||||
using mozilla::dom::indexedDB::IDBWrapperCache;
|
||||
|
||||
#include "nsIDOMMediaQueryList.h"
|
||||
|
||||
#include "nsDOMTouchEvent.h"
|
||||
|
@ -527,6 +530,8 @@
|
|||
#include "CallEvent.h"
|
||||
#endif
|
||||
|
||||
#include "DOMError.h"
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
|
@ -593,6 +598,9 @@ static const char kDOMStringBundleURL[] =
|
|||
(DOM_DEFAULT_SCRIPTABLE_FLAGS | \
|
||||
nsIXPCScriptable::WANT_ADDPROPERTY)
|
||||
|
||||
#define IDBEVENTTARGET_SCRIPTABLE_FLAGS \
|
||||
(EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
|
||||
#define DOMCLASSINFO_STANDARD_FLAGS \
|
||||
(nsIClassInfo::MAIN_THREAD_ONLY | nsIClassInfo::DOM_OBJECT)
|
||||
|
||||
|
@ -654,6 +662,34 @@ DOMCI_DATA(DOMConstructor, void)
|
|||
NS_DEFINE_CHROME_ONLY_CLASSINFO_DATA_WITH_NAME(_class, _class, _helper, \
|
||||
_flags)
|
||||
|
||||
namespace {
|
||||
|
||||
class IDBEventTargetSH : public nsEventTargetSH
|
||||
{
|
||||
protected:
|
||||
IDBEventTargetSH(nsDOMClassInfoData* aData) : nsEventTargetSH(aData)
|
||||
{ }
|
||||
|
||||
virtual ~IDBEventTargetSH()
|
||||
{ }
|
||||
|
||||
public:
|
||||
NS_IMETHOD PreCreate(nsISupports *aNativeObj, JSContext *aCx,
|
||||
JSObject *aGlobalObj, JSObject **aParentObj);
|
||||
|
||||
NS_IMETHOD AddProperty(nsIXPConnectWrappedNative *aWrapper, JSContext *aCx,
|
||||
JSObject *aObj, jsid aId, jsval *aVp, bool *aRetval);
|
||||
|
||||
virtual void PreserveWrapper(nsISupports *aNative);
|
||||
|
||||
static nsIClassInfo *doCreate(nsDOMClassInfoData *aData)
|
||||
{
|
||||
return new IDBEventTargetSH(aData);
|
||||
}
|
||||
};
|
||||
|
||||
} // anonymous namespace
|
||||
|
||||
// This list of NS_DEFINE_CLASSINFO_DATA macros is what gives the DOM
|
||||
// classes their correct behavior when used through XPConnect. The
|
||||
// arguments that are passed to NS_DEFINE_CLASSINFO_DATA are
|
||||
|
@ -1537,14 +1573,14 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBFactory, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBRequest, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBDatabase, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBRequest, IDBEventTargetSH,
|
||||
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBDatabase, IDBEventTargetSH,
|
||||
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBObjectStore, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBTransaction, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBTransaction, IDBEventTargetSH,
|
||||
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBCursor, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBCursorWithValue, nsDOMGenericSH,
|
||||
|
@ -1555,8 +1591,8 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBVersionChangeEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBOpenDBRequest, IDBEventTargetSH,
|
||||
IDBEVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(IDBDatabaseException, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
|
||||
|
@ -1585,6 +1621,9 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
NS_DEFINE_CLASSINFO_DATA(CallEvent, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
#endif
|
||||
|
||||
NS_DEFINE_CLASSINFO_DATA(DOMError, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
};
|
||||
|
||||
// Objects that should be constructable through |new Name();|
|
||||
|
@ -4318,6 +4357,10 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_END
|
||||
#endif
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(DOMError, nsIDOMDOMError)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMDOMError)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
#ifdef NS_DEBUG
|
||||
{
|
||||
PRUint32 i = ArrayLength(sClassInfoData);
|
||||
|
@ -7612,6 +7655,36 @@ nsEventTargetSH::PreserveWrapper(nsISupports *aNative)
|
|||
nsContentUtils::PreserveWrapper(aNative, target);
|
||||
}
|
||||
|
||||
// IDBEventTarget helper
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBEventTargetSH::PreCreate(nsISupports *aNativeObj, JSContext *aCx,
|
||||
JSObject *aGlobalObj, JSObject **aParentObj)
|
||||
{
|
||||
IDBWrapperCache *target = IDBWrapperCache::FromSupports(aNativeObj);
|
||||
JSObject *parent = target->GetParentObject();
|
||||
*aParentObj = parent ? parent : aGlobalObj;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBEventTargetSH::AddProperty(nsIXPConnectWrappedNative *aWrapper,
|
||||
JSContext *aCx, JSObject *aObj, jsid aId,
|
||||
jsval *aVp, bool *aRetval)
|
||||
{
|
||||
if (aId != sAddEventListener_id) {
|
||||
IDBEventTargetSH::PreserveWrapper(GetNative(aWrapper, aObj));
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
void
|
||||
IDBEventTargetSH::PreserveWrapper(nsISupports *aNative)
|
||||
{
|
||||
IDBWrapperCache *target = IDBWrapperCache::FromSupports(aNative);
|
||||
nsContentUtils::PreserveWrapper(aNative, target);
|
||||
}
|
||||
|
||||
// Element helper
|
||||
|
||||
|
|
|
@ -537,3 +537,5 @@ DOMCI_CLASS(Telephony)
|
|||
DOMCI_CLASS(TelephonyCall)
|
||||
DOMCI_CLASS(CallEvent)
|
||||
#endif
|
||||
|
||||
DOMCI_CLASS(DOMError)
|
||||
|
|
|
@ -8318,6 +8318,7 @@ nsGlobalWindow::GetInterface(const nsIID & aIID, void **aSink)
|
|||
if (mDocShell) {
|
||||
nsCOMPtr<nsIDocCharset> docCharset(do_QueryInterface(mDocShell));
|
||||
if (docCharset) {
|
||||
NS_WARNING("Using deprecated nsIDocCharset: use nsIDocShell.GetCharset() instead ");
|
||||
*aSink = docCharset;
|
||||
NS_ADDREF(((nsISupports *) *aSink));
|
||||
}
|
||||
|
|
|
@ -0,0 +1,13 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
[scriptable, builtinclass, uuid(e4e28307-d409-4cf7-93cd-6ea8e889f87a)]
|
||||
interface nsIDOMDOMError : nsISupports
|
||||
{
|
||||
readonly attribute DOMString name;
|
||||
};
|
|
@ -146,18 +146,11 @@ HelperBase::WrapNative(JSContext* aCx,
|
|||
NS_ASSERTION(aResult, "Null pointer!");
|
||||
NS_ASSERTION(mRequest, "Null request!");
|
||||
|
||||
JSObject* obj;
|
||||
if (mRequest->ScriptContext()) {
|
||||
obj = mRequest->ScriptContext()->GetNativeGlobal();
|
||||
}
|
||||
else {
|
||||
obj = mRequest->GetWrapper();
|
||||
}
|
||||
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
JSObject* global = mRequest->GetParentObject();
|
||||
NS_ASSERTION(global, "This should never be null!");
|
||||
|
||||
nsresult rv =
|
||||
nsContentUtils::WrapNative(aCx, obj, aNative, aResult);
|
||||
nsContentUtils::WrapNative(aCx, global, aNative, aResult);
|
||||
NS_ENSURE_SUCCESS(rv, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
return NS_OK;
|
||||
|
@ -288,7 +281,7 @@ AsyncConnectionHelper::Run()
|
|||
if (NS_SUCCEEDED(rv)) {
|
||||
bool hasSavepoint = false;
|
||||
if (mDatabase) {
|
||||
IndexedDatabaseManager::SetCurrentWindow(mDatabase->Owner());
|
||||
IndexedDatabaseManager::SetCurrentWindow(mDatabase->GetOwner());
|
||||
|
||||
// Make the first savepoint.
|
||||
if (mTransaction) {
|
||||
|
|
|
@ -64,8 +64,7 @@ GenerateRequest(IDBCursor* aCursor)
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
IDBDatabase* database = aCursor->Transaction()->Database();
|
||||
return IDBRequest::Create(aCursor, database->ScriptContext(),
|
||||
database->Owner(), aCursor->Transaction());
|
||||
return IDBRequest::Create(aCursor, database, aCursor->Transaction());
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -262,11 +261,14 @@ IDBCursor::CreateCommon(IDBRequest* aRequest,
|
|||
|
||||
nsRefPtr<IDBCursor> cursor = new IDBCursor();
|
||||
|
||||
IDBDatabase* database = aTransaction->Database();
|
||||
cursor->mScriptContext = database->GetScriptContext();
|
||||
cursor->mOwner = database->GetOwner();
|
||||
cursor->mScriptOwner = database->GetScriptOwner();
|
||||
|
||||
cursor->mRequest = aRequest;
|
||||
cursor->mTransaction = aTransaction;
|
||||
cursor->mObjectStore = aObjectStore;
|
||||
cursor->mScriptContext = aTransaction->Database()->ScriptContext();
|
||||
cursor->mOwner = aTransaction->Database()->Owner();
|
||||
cursor->mDirection = aDirection;
|
||||
cursor->mContinueQuery = aContinueQuery;
|
||||
cursor->mContinueToQuery = aContinueToQuery;
|
||||
|
@ -276,7 +278,8 @@ IDBCursor::CreateCommon(IDBRequest* aRequest,
|
|||
}
|
||||
|
||||
IDBCursor::IDBCursor()
|
||||
: mType(OBJECTSTORE),
|
||||
: mScriptOwner(nsnull),
|
||||
mType(OBJECTSTORE),
|
||||
mDirection(nsIIDBCursor::NEXT),
|
||||
mCachedKey(JSVAL_VOID),
|
||||
mCachedPrimaryKey(JSVAL_VOID),
|
||||
|
@ -377,6 +380,10 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBCursor)
|
|||
"Should have a cached primary key");
|
||||
NS_ASSERTION(tmp->mHaveCachedValue || JSVAL_IS_VOID(tmp->mCachedValue),
|
||||
"Should have a cached value");
|
||||
if (tmp->mScriptOwner) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mScriptOwner,
|
||||
"mScriptOwner")
|
||||
}
|
||||
if (JSVAL_IS_GCTHING(tmp->mCachedKey)) {
|
||||
void *gcThing = JSVAL_TO_GCTHING(tmp->mCachedKey);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(gcThing, "mCachedKey")
|
||||
|
@ -395,6 +402,7 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBCursor)
|
|||
// Don't unlink mObjectStore, mIndex, or mTransaction!
|
||||
if (tmp->mRooted) {
|
||||
NS_DROP_JS_OBJECTS(tmp, IDBCursor);
|
||||
tmp->mScriptOwner = nsnull;
|
||||
tmp->mCachedKey = JSVAL_VOID;
|
||||
tmp->mCachedPrimaryKey = JSVAL_VOID;
|
||||
tmp->mCachedValue = JSVAL_VOID;
|
||||
|
|
|
@ -154,6 +154,7 @@ protected:
|
|||
|
||||
nsCOMPtr<nsIScriptContext> mScriptContext;
|
||||
nsCOMPtr<nsPIDOMWindow> mOwner;
|
||||
JSObject* mScriptOwner;
|
||||
|
||||
Type mType;
|
||||
PRUint16 mDirection;
|
||||
|
|
|
@ -148,8 +148,7 @@ private:
|
|||
|
||||
// static
|
||||
already_AddRefed<IDBDatabase>
|
||||
IDBDatabase::Create(nsIScriptContext* aScriptContext,
|
||||
nsPIDOMWindow* aOwner,
|
||||
IDBDatabase::Create(IDBWrapperCache* aOwnerCache,
|
||||
already_AddRefed<DatabaseInfo> aDatabaseInfo,
|
||||
const nsACString& aASCIIOrigin,
|
||||
FileManager* aFileManager)
|
||||
|
@ -162,8 +161,9 @@ IDBDatabase::Create(nsIScriptContext* aScriptContext,
|
|||
|
||||
nsRefPtr<IDBDatabase> db(new IDBDatabase());
|
||||
|
||||
db->mScriptContext = aScriptContext;
|
||||
db->mOwner = aOwner;
|
||||
db->mScriptContext = aOwnerCache->GetScriptContext();
|
||||
db->mOwner = aOwnerCache->GetOwner();
|
||||
db->mScriptOwner = aOwnerCache->GetScriptOwner();
|
||||
|
||||
db->mDatabaseId = databaseInfo->id;
|
||||
db->mName = databaseInfo->name;
|
||||
|
@ -205,6 +205,8 @@ IDBDatabase::~IDBDatabase()
|
|||
mgr->UnregisterDatabase(this);
|
||||
}
|
||||
}
|
||||
|
||||
nsContentUtils::ReleaseWrapper(static_cast<nsIDOMEventTarget*>(this), this);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -218,7 +220,7 @@ IDBDatabase::Invalidate()
|
|||
// When the IndexedDatabaseManager needs to invalidate databases, all it has
|
||||
// is an origin, so we call back into the manager to cancel any prompts for
|
||||
// our owner.
|
||||
IndexedDatabaseManager::CancelPromptsForWindow(Owner());
|
||||
IndexedDatabaseManager::CancelPromptsForWindow(GetOwner());
|
||||
|
||||
mInvalidated = true;
|
||||
}
|
||||
|
@ -280,7 +282,8 @@ void
|
|||
IDBDatabase::OnUnlink()
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!mOwner, "Should have been cleared already!");
|
||||
NS_ASSERTION(!GetOwner() && !GetScriptOwner(),
|
||||
"Should have been cleared already!");
|
||||
|
||||
// We've been unlinked, at the very least we should be able to prevent further
|
||||
// transactions from starting and unblock any other SetVersion callers.
|
||||
|
@ -298,18 +301,16 @@ IDBDatabase::OnUnlink()
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBDatabase)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnAbortListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnVersionChangeListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(abort)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(error)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(versionchange)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnAbortListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnVersionChangeListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(abort)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(error)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(versionchange)
|
||||
|
||||
// Do some cleanup.
|
||||
tmp->OnUnlink();
|
||||
|
@ -318,13 +319,17 @@ NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
|||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBDatabase)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIDBDatabase)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBDatabase)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBDatabase, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBDatabase, nsDOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
|
||||
DOMCI_DATA(IDBDatabase, IDBDatabase)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(IDBDatabase, abort);
|
||||
NS_IMPL_EVENT_HANDLER(IDBDatabase, error);
|
||||
NS_IMPL_EVENT_HANDLER(IDBDatabase, versionchange);
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::GetName(nsAString& aName)
|
||||
{
|
||||
|
@ -668,47 +673,6 @@ IDBDatabase::Close()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::SetOnabort(nsIDOMEventListener* aAbortListener)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(ABORT_EVT_STR),
|
||||
mOnAbortListener, aAbortListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::GetOnabort(nsIDOMEventListener** aAbortListener)
|
||||
{
|
||||
return GetInnerEventListener(mOnAbortListener, aAbortListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::SetOnerror(nsIDOMEventListener* aErrorListener)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(ERROR_EVT_STR),
|
||||
mOnErrorListener, aErrorListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::GetOnerror(nsIDOMEventListener** aErrorListener)
|
||||
{
|
||||
return GetInnerEventListener(mOnErrorListener, aErrorListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::SetOnversionchange(nsIDOMEventListener* aVersionChangeListener)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(VERSIONCHANGE_EVT_STR),
|
||||
mOnVersionChangeListener,
|
||||
aVersionChangeListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBDatabase::GetOnversionchange(nsIDOMEventListener** aVersionChangeListener)
|
||||
{
|
||||
return GetInnerEventListener(mOnVersionChangeListener,
|
||||
aVersionChangeListener);
|
||||
}
|
||||
|
||||
nsresult
|
||||
IDBDatabase::PostHandleEvent(nsEventChainPostVisitor& aVisitor)
|
||||
{
|
||||
|
|
|
@ -41,13 +41,12 @@
|
|||
#define mozilla_dom_indexeddb_idbdatabase_h__
|
||||
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
||||
#include "mozilla/dom/indexedDB/FileManager.h"
|
||||
|
||||
#include "nsIDocument.h"
|
||||
#include "nsIIDBDatabase.h"
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsIDocument.h"
|
||||
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
||||
#include "mozilla/dom/indexedDB/FileManager.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
class nsPIDOMWindow;
|
||||
|
@ -61,7 +60,7 @@ class IDBObjectStore;
|
|||
class IDBTransaction;
|
||||
class IndexedDatabaseManager;
|
||||
|
||||
class IDBDatabase : public nsDOMEventTargetHelper,
|
||||
class IDBDatabase : public IDBWrapperCache,
|
||||
public nsIIDBDatabase
|
||||
{
|
||||
friend class AsyncConnectionHelper;
|
||||
|
@ -71,12 +70,10 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIIDBDATABASE
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBDatabase, IDBWrapperCache)
|
||||
|
||||
static already_AddRefed<IDBDatabase>
|
||||
Create(nsIScriptContext* aScriptContext,
|
||||
nsPIDOMWindow* aOwner,
|
||||
Create(IDBWrapperCache* aOwnerCache,
|
||||
already_AddRefed<DatabaseInfo> aDatabaseInfo,
|
||||
const nsACString& aASCIIOrigin,
|
||||
FileManager* aFileManager);
|
||||
|
@ -104,16 +101,6 @@ public:
|
|||
return mFilePath;
|
||||
}
|
||||
|
||||
nsIScriptContext* ScriptContext()
|
||||
{
|
||||
return mScriptContext;
|
||||
}
|
||||
|
||||
nsPIDOMWindow* Owner()
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
already_AddRefed<nsIDocument> GetOwnerDocument()
|
||||
{
|
||||
if (!mOwner) {
|
||||
|
@ -168,9 +155,9 @@ private:
|
|||
nsRefPtr<FileManager> mFileManager;
|
||||
|
||||
// Only touched on the main thread.
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnAbortListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnVersionChangeListener;
|
||||
NS_DECL_EVENT_HANDLER(abort);
|
||||
NS_DECL_EVENT_HANDLER(error);
|
||||
NS_DECL_EVENT_HANDLER(versionchange);
|
||||
};
|
||||
|
||||
END_INDEXEDDB_NAMESPACE
|
||||
|
|
|
@ -69,7 +69,6 @@
|
|||
#include "IDBKeyRange.h"
|
||||
#include "IndexedDatabaseManager.h"
|
||||
#include "Key.h"
|
||||
#include "nsIScriptSecurityManager.h"
|
||||
|
||||
using namespace mozilla;
|
||||
|
||||
|
@ -91,28 +90,46 @@ struct ObjectStoreInfoMap
|
|||
} // anonymous namespace
|
||||
|
||||
IDBFactory::IDBFactory()
|
||||
: mOwningObject(nsnull)
|
||||
{
|
||||
IDBFactory::NoteUsedByProcessType(XRE_GetProcessType());
|
||||
}
|
||||
|
||||
IDBFactory::~IDBFactory()
|
||||
{
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<nsIIDBFactory>
|
||||
IDBFactory::Create(nsPIDOMWindow* aWindow)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (aWindow && aWindow->IsOuterWindow()) {
|
||||
NS_ENSURE_TRUE(aWindow, nsnull);
|
||||
|
||||
if (aWindow->IsOuterWindow()) {
|
||||
aWindow = aWindow->GetCurrentInnerWindow();
|
||||
NS_ENSURE_TRUE(aWindow, nsnull);
|
||||
}
|
||||
|
||||
nsRefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mWindow = aWindow;
|
||||
return factory.forget();
|
||||
}
|
||||
|
||||
if (aWindow) {
|
||||
factory->mWindow = do_GetWeakReference(aWindow);
|
||||
NS_ENSURE_TRUE(factory->mWindow, nsnull);
|
||||
}
|
||||
// static
|
||||
already_AddRefed<nsIIDBFactory>
|
||||
IDBFactory::Create(JSContext* aCx,
|
||||
JSObject* aOwningObject)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(aCx, "Null context!");
|
||||
NS_ASSERTION(aOwningObject, "Null object!");
|
||||
NS_ASSERTION(JS_GetGlobalForObject(aCx, aOwningObject) == aOwningObject,
|
||||
"Not a global object!");
|
||||
|
||||
nsRefPtr<IDBFactory> factory = new IDBFactory();
|
||||
factory->mOwningObject = aOwningObject;
|
||||
return factory.forget();
|
||||
}
|
||||
|
||||
|
@ -400,15 +417,36 @@ IDBFactory::SetDatabaseMetadata(DatabaseInfo* aDatabaseInfo,
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMPL_ADDREF(IDBFactory)
|
||||
NS_IMPL_RELEASE(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBFactory)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTING_ADDREF(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTING_RELEASE(IDBFactory)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBFactory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsISupports)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIDBFactory)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBFactory)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBFactory)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBFactory)
|
||||
if (tmp->mOwningObject) {
|
||||
tmp->mOwningObject = nsnull;
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mWindow)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN(IDBFactory)
|
||||
if (tmp->mOwningObject) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mOwningObject,
|
||||
"mOwningObject")
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
DOMCI_DATA(IDBFactory, IDBFactory)
|
||||
|
||||
nsresult
|
||||
|
@ -418,6 +456,7 @@ IDBFactory::OpenCommon(const nsAString& aName,
|
|||
nsIIDBOpenDBRequest** _retval)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(mWindow || mOwningObject, "Must have one of these!");
|
||||
|
||||
if (XRE_GetProcessType() == GeckoProcessType_Content) {
|
||||
// Force ContentChild to cache the path from the parent, so that
|
||||
|
@ -430,16 +469,19 @@ IDBFactory::OpenCommon(const nsAString& aName,
|
|||
nsCOMPtr<nsPIDOMWindow> window;
|
||||
nsCOMPtr<nsIScriptGlobalObject> sgo;
|
||||
nsIScriptContext* context = nsnull;
|
||||
JSObject* scriptOwner = nsnull;
|
||||
|
||||
if (mWindow) {
|
||||
window = do_QueryReferent(mWindow);
|
||||
NS_ENSURE_TRUE(window, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
sgo = do_QueryInterface(window);
|
||||
sgo = do_QueryInterface(mWindow);
|
||||
NS_ENSURE_TRUE(sgo, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
|
||||
context = sgo->GetContext();
|
||||
NS_ENSURE_TRUE(context, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
window = mWindow;
|
||||
}
|
||||
else {
|
||||
scriptOwner = mOwningObject;
|
||||
}
|
||||
|
||||
nsCString origin;
|
||||
|
@ -448,7 +490,7 @@ IDBFactory::OpenCommon(const nsAString& aName,
|
|||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsRefPtr<IDBOpenDBRequest> request =
|
||||
IDBOpenDBRequest::Create(context, window);
|
||||
IDBOpenDBRequest::Create(context, window, scriptOwner);
|
||||
NS_ENSURE_TRUE(request, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
nsRefPtr<OpenDatabaseHelper> openHelper =
|
||||
|
|
|
@ -45,11 +45,11 @@
|
|||
#include "mozIStorageConnection.h"
|
||||
#include "nsIIDBFactory.h"
|
||||
|
||||
#include "nsIWeakReferenceUtils.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsXULAppAPI.h"
|
||||
|
||||
class nsPIDOMWindow;
|
||||
class nsIAtom;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
BEGIN_INDEXEDDB_NAMESPACE
|
||||
|
||||
|
@ -60,12 +60,17 @@ struct ObjectStoreInfo;
|
|||
class IDBFactory : public nsIIDBFactory
|
||||
{
|
||||
typedef nsTArray<nsRefPtr<ObjectStoreInfo> > ObjectStoreInfoArray;
|
||||
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTING_ISUPPORTS
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(IDBFactory)
|
||||
NS_DECL_NSIIDBFACTORY
|
||||
|
||||
static already_AddRefed<nsIIDBFactory> Create(nsPIDOMWindow* aWindow);
|
||||
|
||||
static already_AddRefed<nsIIDBFactory> Create(JSContext* aCx,
|
||||
JSObject* aOwningObject);
|
||||
|
||||
static already_AddRefed<mozIStorageConnection>
|
||||
GetConnection(const nsAString& aDatabaseFilePath);
|
||||
|
||||
|
@ -96,7 +101,7 @@ public:
|
|||
|
||||
private:
|
||||
IDBFactory();
|
||||
~IDBFactory() { }
|
||||
~IDBFactory();
|
||||
|
||||
nsresult
|
||||
OpenCommon(const nsAString& aName,
|
||||
|
@ -104,7 +109,10 @@ private:
|
|||
bool aDeleting,
|
||||
nsIIDBOpenDBRequest** _retval);
|
||||
|
||||
nsCOMPtr<nsIWeakReference> mWindow;
|
||||
// If this factory lives on a window then mWindow must be non-null. Otherwise
|
||||
// mOwningObject must be non-null.
|
||||
nsCOMPtr<nsPIDOMWindow> mWindow;
|
||||
JSObject* mOwningObject;
|
||||
};
|
||||
|
||||
END_INDEXEDDB_NAMESPACE
|
||||
|
|
|
@ -294,8 +294,7 @@ GenerateRequest(IDBIndex* aIndex)
|
|||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
IDBTransaction* transaction = aIndex->ObjectStore()->Transaction();
|
||||
IDBDatabase* database = transaction->Database();
|
||||
return IDBRequest::Create(aIndex, database->ScriptContext(),
|
||||
database->Owner(), transaction);
|
||||
return IDBRequest::Create(aIndex, database, transaction);
|
||||
}
|
||||
|
||||
} // anonymous namespace
|
||||
|
@ -313,9 +312,6 @@ IDBIndex::Create(IDBObjectStore* aObjectStore,
|
|||
|
||||
nsRefPtr<IDBIndex> index = new IDBIndex();
|
||||
|
||||
index->mScriptContext = database->ScriptContext();
|
||||
index->mOwner = database->Owner();
|
||||
|
||||
index->mObjectStore = aObjectStore;
|
||||
index->mId = aIndexInfo->id;
|
||||
index->mName = aIndexInfo->name;
|
||||
|
@ -343,14 +339,10 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(IDBIndex)
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBIndex)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mObjectStore)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mScriptContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBIndex)
|
||||
// Don't unlink mObjectStore!
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mScriptContext)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION(IDBIndex)
|
||||
|
|
|
@ -113,9 +113,6 @@ private:
|
|||
|
||||
nsRefPtr<IDBObjectStore> mObjectStore;
|
||||
|
||||
nsCOMPtr<nsIScriptContext> mScriptContext;
|
||||
nsCOMPtr<nsPIDOMWindow> mOwner;
|
||||
|
||||
PRInt64 mId;
|
||||
nsString mName;
|
||||
nsString mKeyPath;
|
||||
|
|
|
@ -507,8 +507,8 @@ GenerateRequest(IDBObjectStore* aObjectStore)
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
IDBDatabase* database = aObjectStore->Transaction()->Database();
|
||||
return IDBRequest::Create(aObjectStore, database->ScriptContext(),
|
||||
database->Owner(), aObjectStore->Transaction());
|
||||
return IDBRequest::Create(aObjectStore, database,
|
||||
aObjectStore->Transaction());
|
||||
}
|
||||
|
||||
JSClass gDummyPropClass = {
|
||||
|
@ -532,9 +532,6 @@ IDBObjectStore::Create(IDBTransaction* aTransaction,
|
|||
|
||||
nsRefPtr<IDBObjectStore> objectStore = new IDBObjectStore();
|
||||
|
||||
objectStore->mScriptContext = aTransaction->Database()->ScriptContext();
|
||||
objectStore->mOwner = aTransaction->Database()->Owner();
|
||||
|
||||
objectStore->mTransaction = aTransaction;
|
||||
objectStore->mName = aStoreInfo->name;
|
||||
objectStore->mId = aStoreInfo->id;
|
||||
|
@ -1376,8 +1373,6 @@ NS_IMPL_CYCLE_COLLECTION_CLASS(IDBObjectStore)
|
|||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN(IDBObjectStore)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mTransaction,
|
||||
nsIDOMEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mScriptContext)
|
||||
|
||||
for (PRUint32 i = 0; i < tmp->mCreatedIndexes.Length(); i++) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCreatedIndexes[i]");
|
||||
|
@ -1387,8 +1382,6 @@ NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
|||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN(IDBObjectStore)
|
||||
// Don't unlink mTransaction!
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOwner)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mScriptContext)
|
||||
|
||||
tmp->mCreatedIndexes.Clear();
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
|
|
@ -41,13 +41,14 @@
|
|||
#define mozilla_dom_indexeddb_idbobjectstore_h__
|
||||
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
||||
#include "mozilla/dom/indexedDB/IDBTransaction.h"
|
||||
|
||||
#include "nsIIDBObjectStore.h"
|
||||
#include "nsIIDBTransaction.h"
|
||||
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
#include "mozilla/dom/indexedDB/IDBTransaction.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
class nsPIDOMWindow;
|
||||
|
||||
|
@ -204,9 +205,6 @@ protected:
|
|||
private:
|
||||
nsRefPtr<IDBTransaction> mTransaction;
|
||||
|
||||
nsCOMPtr<nsIScriptContext> mScriptContext;
|
||||
nsCOMPtr<nsPIDOMWindow> mOwner;
|
||||
|
||||
PRInt64 mId;
|
||||
nsString mName;
|
||||
nsString mKeyPath;
|
||||
|
|
|
@ -62,8 +62,8 @@ USING_INDEXEDDB_NAMESPACE
|
|||
IDBRequest::IDBRequest()
|
||||
: mResultVal(JSVAL_VOID),
|
||||
mErrorCode(0),
|
||||
mResultValRooted(false),
|
||||
mHaveResultOrErrorCode(false)
|
||||
mHaveResultOrErrorCode(false),
|
||||
mRooted(false)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
}
|
||||
|
@ -72,19 +72,13 @@ IDBRequest::~IDBRequest()
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (mResultValRooted) {
|
||||
// Calling a virtual from the destructor is bad... But we know that we won't
|
||||
// call a subclass' implementation because mResultValRooted will be set to
|
||||
// false.
|
||||
UnrootResultVal();
|
||||
}
|
||||
UnrootResultVal();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBRequest>
|
||||
IDBRequest::Create(nsISupports* aSource,
|
||||
nsIScriptContext* aScriptContext,
|
||||
nsPIDOMWindow* aOwner,
|
||||
IDBWrapperCache* aOwnerCache,
|
||||
IDBTransaction* aTransaction)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
@ -92,8 +86,9 @@ IDBRequest::Create(nsISupports* aSource,
|
|||
|
||||
request->mSource = aSource;
|
||||
request->mTransaction = aTransaction;
|
||||
request->mScriptContext = aScriptContext;
|
||||
request->mOwner = aOwner;
|
||||
request->mScriptContext = aOwnerCache->GetScriptContext();
|
||||
request->mOwner = aOwnerCache->GetOwner();
|
||||
request->mScriptOwner = aOwnerCache->GetScriptOwner();
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -105,9 +100,7 @@ IDBRequest::Reset()
|
|||
mResultVal = JSVAL_VOID;
|
||||
mHaveResultOrErrorCode = false;
|
||||
mErrorCode = 0;
|
||||
if (mResultValRooted) {
|
||||
UnrootResultVal();
|
||||
}
|
||||
UnrootResultVal();
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -115,7 +108,7 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
NS_ASSERTION(!mHaveResultOrErrorCode, "Already called!");
|
||||
NS_ASSERTION(!mResultValRooted, "Already rooted?!");
|
||||
NS_ASSERTION(!PreservingWrapper(), "Already rooted?!");
|
||||
NS_ASSERTION(JSVAL_IS_VOID(mResultVal), "Should be undefined!");
|
||||
|
||||
// See if our window is still valid. If not then we're going to pretend that
|
||||
|
@ -135,45 +128,40 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
|||
}
|
||||
|
||||
// Otherwise we need to get the result from the helper.
|
||||
JSContext* cx = nsnull;
|
||||
JSObject* obj = nsnull;
|
||||
if (mScriptContext) {
|
||||
cx = mScriptContext->GetNativeContext();
|
||||
NS_ASSERTION(cx, "Failed to get a context!");
|
||||
|
||||
obj = mScriptContext->GetNativeGlobal();
|
||||
NS_ASSERTION(obj, "Failed to get global object!");
|
||||
}
|
||||
else {
|
||||
JSContext* cx;
|
||||
if (mScriptOwner) {
|
||||
nsIThreadJSContextStack* cxStack = nsContentUtils::ThreadJSContextStack();
|
||||
NS_ASSERTION(cxStack, "Failed to get thread context stack!");
|
||||
|
||||
NS_ENSURE_SUCCESS(cxStack->GetSafeJSContext(&cx),
|
||||
NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
|
||||
obj = GetWrapper();
|
||||
NS_ENSURE_TRUE(obj, NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR);
|
||||
if (NS_FAILED(cxStack->GetSafeJSContext(&cx))) {
|
||||
NS_WARNING("Failed to get safe JSContext!");
|
||||
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
mErrorCode = NS_ERROR_GET_CODE(rv);
|
||||
return rv;
|
||||
}
|
||||
}
|
||||
else {
|
||||
cx = mScriptContext->GetNativeContext();
|
||||
NS_ASSERTION(cx, "Failed to get a context!");
|
||||
}
|
||||
|
||||
JSObject* global = GetParentObject();
|
||||
NS_ASSERTION(global, "This should never be null!");
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JSAutoEnterCompartment ac;
|
||||
if (!ac.enter(cx, obj)) {
|
||||
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
else {
|
||||
if (ac.enter(cx, global)) {
|
||||
RootResultVal();
|
||||
|
||||
rv = aHelper->GetSuccessResult(cx, &mResultVal);
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
// Unroot if we don't really need to be rooted.
|
||||
if (!JSVAL_IS_GCTHING(mResultVal)) {
|
||||
UnrootResultVal();
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (NS_FAILED(rv)) {
|
||||
NS_WARNING("GetSuccessResult failed!");
|
||||
}
|
||||
}
|
||||
else {
|
||||
NS_WARNING("Failed to enter correct compartment!");
|
||||
rv = NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
|
||||
}
|
||||
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mErrorCode = 0;
|
||||
|
@ -187,19 +175,15 @@ IDBRequest::NotifyHelperCompleted(HelperBase* aHelper)
|
|||
}
|
||||
|
||||
void
|
||||
IDBRequest::RootResultVal()
|
||||
IDBRequest::RootResultValInternal()
|
||||
{
|
||||
NS_ASSERTION(!mResultValRooted, "This should be false!");
|
||||
NS_HOLD_JS_OBJECTS(this, IDBRequest);
|
||||
mResultValRooted = true;
|
||||
}
|
||||
|
||||
void
|
||||
IDBRequest::UnrootResultVal()
|
||||
IDBRequest::UnrootResultValInternal()
|
||||
{
|
||||
NS_ASSERTION(mResultValRooted, "This should be true!");
|
||||
NS_DROP_JS_OBJECTS(this, IDBRequest);
|
||||
mResultValRooted = false;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
@ -262,66 +246,30 @@ IDBRequest::GetErrorCode(PRUint16* aErrorCode)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::SetOnsuccess(nsIDOMEventListener* aSuccessListener)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(SUCCESS_EVT_STR),
|
||||
mOnSuccessListener, aSuccessListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetOnsuccess(nsIDOMEventListener** aSuccessListener)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return GetInnerEventListener(mOnSuccessListener, aSuccessListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::SetOnerror(nsIDOMEventListener* aErrorListener)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(ERROR_EVT_STR),
|
||||
mOnErrorListener, aErrorListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBRequest::GetOnerror(nsIDOMEventListener** aErrorListener)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return GetInnerEventListener(mOnErrorListener, aErrorListener);
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBRequest)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnSuccessListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
// Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because
|
||||
// nsDOMEventTargetHelper does it for us.
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(success)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(error)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mSource)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mTransaction,
|
||||
nsPIDOMEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
if (tmp->mResultValRooted) {
|
||||
tmp->mResultVal = JSVAL_VOID;
|
||||
tmp->UnrootResultVal();
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnSuccessListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
tmp->mResultVal = JSVAL_VOID;
|
||||
tmp->UnrootResultVal();
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(success)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(error)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mSource)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mTransaction)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
||||
// nsDOMEventTargetHelper does it for us.
|
||||
if (JSVAL_IS_GCTHING(tmp->mResultVal)) {
|
||||
void *gcThing = JSVAL_TO_GCTHING(tmp->mResultVal);
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(gcThing, "mResultVal")
|
||||
|
@ -331,13 +279,16 @@ NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
|||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBRequest)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIIDBRequest)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBRequest)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBRequest, nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBRequest, nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBRequest, IDBWrapperCache)
|
||||
|
||||
DOMCI_DATA(IDBRequest, IDBRequest)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(IDBRequest, success);
|
||||
NS_IMPL_EVENT_HANDLER(IDBRequest, error);
|
||||
|
||||
nsresult
|
||||
IDBRequest::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
{
|
||||
|
@ -352,21 +303,21 @@ IDBOpenDBRequest::~IDBOpenDBRequest()
|
|||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
if (mResultValRooted) {
|
||||
UnrootResultVal();
|
||||
}
|
||||
UnrootResultVal();
|
||||
}
|
||||
|
||||
// static
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
IDBOpenDBRequest::Create(nsIScriptContext* aScriptContext,
|
||||
nsPIDOMWindow* aOwner)
|
||||
nsPIDOMWindow* aOwner,
|
||||
JSObject* aScriptOwner)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
nsRefPtr<IDBOpenDBRequest> request(new IDBOpenDBRequest());
|
||||
|
||||
request->mScriptContext = aScriptContext;
|
||||
request->mOwner = aOwner;
|
||||
request->mScriptOwner = aScriptOwner;
|
||||
|
||||
return request.forget();
|
||||
}
|
||||
|
@ -378,36 +329,29 @@ IDBOpenDBRequest::SetTransaction(IDBTransaction* aTransaction)
|
|||
}
|
||||
|
||||
void
|
||||
IDBOpenDBRequest::RootResultVal()
|
||||
IDBOpenDBRequest::RootResultValInternal()
|
||||
{
|
||||
NS_ASSERTION(!mResultValRooted, "This should be false!");
|
||||
NS_HOLD_JS_OBJECTS(this, IDBOpenDBRequest);
|
||||
mResultValRooted = true;
|
||||
}
|
||||
|
||||
void
|
||||
IDBOpenDBRequest::UnrootResultVal()
|
||||
IDBOpenDBRequest::UnrootResultValInternal()
|
||||
{
|
||||
NS_ASSERTION(mResultValRooted, "This should be true!");
|
||||
NS_DROP_JS_OBJECTS(this, IDBOpenDBRequest);
|
||||
mResultValRooted = false;
|
||||
}
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, blocked)
|
||||
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, upgradeneeded)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBOpenDBRequest)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBOpenDBRequest,
|
||||
IDBRequest)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnupgradeneededListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnblockedListener)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(upgradeneeded)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(blocked)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBOpenDBRequest,
|
||||
IDBRequest)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnupgradeneededListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnblockedListener)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(upgradeneeded)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(blocked)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBOpenDBRequest)
|
||||
|
@ -419,3 +363,6 @@ NS_IMPL_ADDREF_INHERITED(IDBOpenDBRequest, IDBRequest)
|
|||
NS_IMPL_RELEASE_INHERITED(IDBOpenDBRequest, IDBRequest)
|
||||
|
||||
DOMCI_DATA(IDBOpenDBRequest, IDBOpenDBRequest)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, blocked);
|
||||
NS_IMPL_EVENT_HANDLER(IDBOpenDBRequest, upgradeneeded);
|
||||
|
|
|
@ -46,8 +46,7 @@
|
|||
#include "nsIIDBRequest.h"
|
||||
#include "nsIIDBOpenDBRequest.h"
|
||||
|
||||
#include "nsDOMEventTargetWrapperCache.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
||||
|
||||
class nsIScriptContext;
|
||||
class nsPIDOMWindow;
|
||||
|
@ -57,19 +56,18 @@ BEGIN_INDEXEDDB_NAMESPACE
|
|||
class HelperBase;
|
||||
class IDBTransaction;
|
||||
|
||||
class IDBRequest : public nsDOMEventTargetWrapperCache,
|
||||
class IDBRequest : public IDBWrapperCache,
|
||||
public nsIIDBRequest
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_NSIIDBREQUEST
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(IDBRequest,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
IDBWrapperCache)
|
||||
|
||||
static
|
||||
already_AddRefed<IDBRequest> Create(nsISupports* aSource,
|
||||
nsIScriptContext* aScriptContext,
|
||||
nsPIDOMWindow* aOwner,
|
||||
IDBWrapperCache* aOwnerCache,
|
||||
IDBTransaction* aTransaction);
|
||||
|
||||
// nsIDOMEventTarget
|
||||
|
@ -92,34 +90,40 @@ public:
|
|||
mErrorCode = rv;
|
||||
}
|
||||
|
||||
nsIScriptContext* ScriptContext()
|
||||
{
|
||||
return mScriptContext;
|
||||
}
|
||||
|
||||
nsPIDOMWindow* Owner()
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
virtual void RootResultVal();
|
||||
virtual void UnrootResultVal();
|
||||
|
||||
protected:
|
||||
IDBRequest();
|
||||
~IDBRequest();
|
||||
|
||||
virtual void RootResultValInternal();
|
||||
virtual void UnrootResultValInternal();
|
||||
|
||||
void RootResultVal()
|
||||
{
|
||||
if (!mRooted) {
|
||||
RootResultValInternal();
|
||||
mRooted = true;
|
||||
}
|
||||
}
|
||||
|
||||
void UnrootResultVal()
|
||||
{
|
||||
if (mRooted) {
|
||||
UnrootResultValInternal();
|
||||
mRooted = false;
|
||||
}
|
||||
}
|
||||
|
||||
nsCOMPtr<nsISupports> mSource;
|
||||
nsRefPtr<IDBTransaction> mTransaction;
|
||||
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnSuccessListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
|
||||
NS_DECL_EVENT_HANDLER(success);
|
||||
NS_DECL_EVENT_HANDLER(error);
|
||||
|
||||
jsval mResultVal;
|
||||
|
||||
PRUint16 mErrorCode;
|
||||
bool mResultValRooted;
|
||||
bool mHaveResultOrErrorCode;
|
||||
bool mRooted;
|
||||
};
|
||||
|
||||
class IDBOpenDBRequest : public IDBRequest,
|
||||
|
@ -129,24 +133,33 @@ public:
|
|||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_FORWARD_NSIIDBREQUEST(IDBRequest::)
|
||||
NS_DECL_NSIIDBOPENDBREQUEST
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBOpenDBRequest,
|
||||
IDBRequest)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBOpenDBRequest, IDBRequest)
|
||||
|
||||
static
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
Create(nsIScriptContext* aScriptContext,
|
||||
nsPIDOMWindow* aOwner);
|
||||
nsPIDOMWindow* aOwner,
|
||||
JSObject* aScriptOwner);
|
||||
|
||||
static
|
||||
already_AddRefed<IDBOpenDBRequest>
|
||||
Create(IDBWrapperCache* aOwnerCache)
|
||||
{
|
||||
return Create(aOwnerCache->GetScriptContext(), aOwnerCache->GetOwner(),
|
||||
aOwnerCache->GetScriptOwner());
|
||||
}
|
||||
|
||||
void SetTransaction(IDBTransaction* aTransaction);
|
||||
|
||||
virtual void RootResultVal();
|
||||
virtual void UnrootResultVal();
|
||||
|
||||
protected:
|
||||
~IDBOpenDBRequest();
|
||||
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnblockedListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnupgradeneededListener;
|
||||
virtual void RootResultValInternal();
|
||||
virtual void UnrootResultValInternal();
|
||||
|
||||
// Only touched on the main thread.
|
||||
NS_DECL_EVENT_HANDLER(blocked);
|
||||
NS_DECL_EVENT_HANDLER(upgradeneeded);
|
||||
};
|
||||
|
||||
END_INDEXEDDB_NAMESPACE
|
||||
|
|
|
@ -42,6 +42,7 @@
|
|||
#include "nsIScriptContext.h"
|
||||
|
||||
#include "mozilla/storage.h"
|
||||
#include "nsContentUtils.h"
|
||||
#include "nsDOMClassInfoID.h"
|
||||
#include "nsDOMLists.h"
|
||||
#include "nsEventDispatcher.h"
|
||||
|
@ -116,8 +117,9 @@ IDBTransaction::Create(IDBDatabase* aDatabase,
|
|||
|
||||
nsRefPtr<IDBTransaction> transaction = new IDBTransaction();
|
||||
|
||||
transaction->mScriptContext = aDatabase->ScriptContext();
|
||||
transaction->mOwner = aDatabase->Owner();
|
||||
transaction->mScriptContext = aDatabase->GetScriptContext();
|
||||
transaction->mOwner = aDatabase->GetOwner();
|
||||
transaction->mScriptOwner = aDatabase->GetScriptOwner();
|
||||
|
||||
transaction->mDatabase = aDatabase;
|
||||
transaction->mMode = aMode;
|
||||
|
@ -184,6 +186,8 @@ IDBTransaction::~IDBTransaction()
|
|||
NS_ASSERTION(!mConnection, "Should have called CommitOrRollback!");
|
||||
NS_ASSERTION(!mCreating, "Should have been cleared already!");
|
||||
NS_ASSERTION(mFiredCompleteOrAbort, "Should have fired event!");
|
||||
|
||||
nsContentUtils::ReleaseWrapper(static_cast<nsIDOMEventTarget*>(this), this);
|
||||
}
|
||||
|
||||
void
|
||||
|
@ -474,27 +478,25 @@ IDBTransaction::ClearCreatedFileInfos()
|
|||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBTransaction)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBTransaction,
|
||||
nsDOMEventTargetHelper)
|
||||
IDBWrapperCache)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR_AMBIGUOUS(mDatabase,
|
||||
nsIDOMEventTarget)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnCompleteListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_NSCOMPTR(mOnAbortListener)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(error)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(complete)
|
||||
NS_CYCLE_COLLECTION_TRAVERSE_EVENT_HANDLER(abort)
|
||||
|
||||
for (PRUint32 i = 0; i < tmp->mCreatedObjectStores.Length(); i++) {
|
||||
NS_CYCLE_COLLECTION_NOTE_EDGE_NAME(cb, "mCreatedObjectStores[i]");
|
||||
cb.NoteXPCOMChild(static_cast<nsIIDBObjectStore*>(
|
||||
tmp->mCreatedObjectStores[i].get()));
|
||||
}
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBTransaction,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
// Don't unlink mDatabase!
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnErrorListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnCompleteListener)
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_NSCOMPTR(mOnAbortListener)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(error)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(complete)
|
||||
NS_CYCLE_COLLECTION_UNLINK_EVENT_HANDLER(abort)
|
||||
|
||||
tmp->mCreatedObjectStores.Clear();
|
||||
|
||||
|
@ -504,13 +506,17 @@ NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBTransaction)
|
|||
NS_INTERFACE_MAP_ENTRY(nsIIDBTransaction)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIThreadObserver)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(IDBTransaction)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetHelper)
|
||||
NS_INTERFACE_MAP_END_INHERITING(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBTransaction, nsDOMEventTargetHelper)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBTransaction, nsDOMEventTargetHelper)
|
||||
NS_IMPL_ADDREF_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
|
||||
DOMCI_DATA(IDBTransaction, IDBTransaction)
|
||||
|
||||
NS_IMPL_EVENT_HANDLER(IDBTransaction, error);
|
||||
NS_IMPL_EVENT_HANDLER(IDBTransaction, complete);
|
||||
NS_IMPL_EVENT_HANDLER(IDBTransaction, abort);
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::GetDb(nsIIDBDatabase** aDB)
|
||||
{
|
||||
|
@ -626,53 +632,6 @@ IDBTransaction::Abort()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::SetOnerror(nsIDOMEventListener* aErrorListener)
|
||||
{
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(ERROR_EVT_STR),
|
||||
mOnErrorListener, aErrorListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::GetOnerror(nsIDOMEventListener** aErrorListener)
|
||||
{
|
||||
return GetInnerEventListener(mOnErrorListener, aErrorListener);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::GetOncomplete(nsIDOMEventListener** aOncomplete)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return GetInnerEventListener(mOnCompleteListener, aOncomplete);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::SetOncomplete(nsIDOMEventListener* aOncomplete)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(COMPLETE_EVT_STR),
|
||||
mOnCompleteListener, aOncomplete);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::GetOnabort(nsIDOMEventListener** aOnabort)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return GetInnerEventListener(mOnAbortListener, aOnabort);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
IDBTransaction::SetOnabort(nsIDOMEventListener* aOnabort)
|
||||
{
|
||||
NS_ASSERTION(NS_IsMainThread(), "Wrong thread!");
|
||||
|
||||
return RemoveAddEventListener(NS_LITERAL_STRING(ABORT_EVT_STR),
|
||||
mOnAbortListener, aOnabort);
|
||||
}
|
||||
|
||||
nsresult
|
||||
IDBTransaction::PreHandleEvent(nsEventChainPreVisitor& aVisitor)
|
||||
{
|
||||
|
@ -817,7 +776,7 @@ CommitHelper::Run()
|
|||
}
|
||||
|
||||
if (mConnection) {
|
||||
IndexedDatabaseManager::SetCurrentWindow(database->Owner());
|
||||
IndexedDatabaseManager::SetCurrentWindow(database->GetOwner());
|
||||
|
||||
if (!mAborted && mUpdateFileRefcountFunction &&
|
||||
NS_FAILED(mUpdateFileRefcountFunction->UpdateDatabase(mConnection))) {
|
||||
|
|
|
@ -41,8 +41,6 @@
|
|||
#define mozilla_dom_indexeddb_idbtransaction_h__
|
||||
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
||||
#include "mozilla/dom/indexedDB/IDBDatabase.h"
|
||||
#include "mozilla/dom/indexedDB/FileInfo.h"
|
||||
|
||||
#include "mozIStorageConnection.h"
|
||||
#include "mozIStorageStatement.h"
|
||||
|
@ -51,14 +49,15 @@
|
|||
#include "nsIRunnable.h"
|
||||
#include "nsIThreadInternal.h"
|
||||
|
||||
#include "nsDOMEventTargetHelper.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
|
||||
#include "nsAutoPtr.h"
|
||||
#include "nsClassHashtable.h"
|
||||
#include "nsHashKeys.h"
|
||||
#include "nsInterfaceHashtable.h"
|
||||
|
||||
#include "mozilla/dom/indexedDB/IDBDatabase.h"
|
||||
#include "mozilla/dom/indexedDB/IDBWrapperCache.h"
|
||||
#include "mozilla/dom/indexedDB/FileInfo.h"
|
||||
|
||||
class nsIThread;
|
||||
|
||||
BEGIN_INDEXEDDB_NAMESPACE
|
||||
|
@ -78,7 +77,7 @@ public:
|
|||
virtual nsresult NotifyTransactionComplete(IDBTransaction* aTransaction) = 0;
|
||||
};
|
||||
|
||||
class IDBTransaction : public nsDOMEventTargetHelper,
|
||||
class IDBTransaction : public IDBWrapperCache,
|
||||
public nsIIDBTransaction,
|
||||
public nsIThreadObserver
|
||||
{
|
||||
|
@ -92,8 +91,7 @@ public:
|
|||
NS_DECL_NSIIDBTRANSACTION
|
||||
NS_DECL_NSITHREADOBSERVER
|
||||
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction,
|
||||
nsDOMEventTargetHelper)
|
||||
NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(IDBTransaction, IDBWrapperCache)
|
||||
|
||||
static already_AddRefed<IDBTransaction>
|
||||
Create(IDBDatabase* aDatabase,
|
||||
|
@ -180,9 +178,9 @@ private:
|
|||
PRUint32 mCreatedRecursionDepth;
|
||||
|
||||
// Only touched on the main thread.
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnErrorListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnCompleteListener;
|
||||
nsRefPtr<nsDOMEventListenerWrapper> mOnAbortListener;
|
||||
NS_DECL_EVENT_HANDLER(error);
|
||||
NS_DECL_EVENT_HANDLER(complete);
|
||||
NS_DECL_EVENT_HANDLER(abort);
|
||||
|
||||
nsInterfaceHashtable<nsCStringHashKey, mozIStorageStatement>
|
||||
mCachedStatements;
|
||||
|
|
|
@ -0,0 +1,38 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#include "IDBWrapperCache.h"
|
||||
|
||||
USING_INDEXEDDB_NAMESPACE
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_CLASS(IDBWrapperCache)
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_BEGIN_INHERITED(IDBWrapperCache,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
// Don't need NS_IMPL_CYCLE_COLLECTION_TRAVERSE_SCRIPT_OBJECTS because
|
||||
// nsDOMEventTargetHelper does it for us.
|
||||
NS_IMPL_CYCLE_COLLECTION_TRAVERSE_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_BEGIN_INHERITED(IDBWrapperCache,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
tmp->mScriptOwner = nsnull;
|
||||
NS_IMPL_CYCLE_COLLECTION_UNLINK_END
|
||||
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_BEGIN_INHERITED(IDBWrapperCache,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
// Don't need NS_IMPL_CYCLE_COLLECTION_TRACE_PRESERVED_WRAPPER because
|
||||
// nsDOMEventTargetHelper does it for us.
|
||||
if (tmp->mScriptOwner) {
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_JS_CALLBACK(tmp->mScriptOwner,
|
||||
"mScriptOwner")
|
||||
}
|
||||
NS_IMPL_CYCLE_COLLECTION_TRACE_END
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN_CYCLE_COLLECTION_INHERITED(IDBWrapperCache)
|
||||
NS_INTERFACE_MAP_END_INHERITING(nsDOMEventTargetWrapperCache)
|
||||
|
||||
NS_IMPL_ADDREF_INHERITED(IDBWrapperCache, nsDOMEventTargetWrapperCache)
|
||||
NS_IMPL_RELEASE_INHERITED(IDBWrapperCache, nsDOMEventTargetWrapperCache)
|
|
@ -0,0 +1,71 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* vim: set ts=2 et sw=2 tw=80: */
|
||||
/* This Source Code Form is subject to the terms of the Mozilla Public
|
||||
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
#ifndef mozilla_dom_indexeddb_idbwrappercache_h__
|
||||
#define mozilla_dom_indexeddb_idbwrappercache_h__
|
||||
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabase.h"
|
||||
|
||||
#include "nsDOMEventTargetWrapperCache.h"
|
||||
|
||||
BEGIN_INDEXEDDB_NAMESPACE
|
||||
|
||||
class IDBWrapperCache : public nsDOMEventTargetWrapperCache
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS_INHERITED
|
||||
NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS_INHERITED(
|
||||
IDBWrapperCache,
|
||||
nsDOMEventTargetWrapperCache)
|
||||
|
||||
JSObject* GetScriptOwner() const
|
||||
{
|
||||
return mScriptOwner;
|
||||
}
|
||||
|
||||
nsIScriptContext* GetScriptContext() const
|
||||
{
|
||||
return mScriptContext;
|
||||
}
|
||||
|
||||
nsPIDOMWindow* GetOwner() const
|
||||
{
|
||||
return mOwner;
|
||||
}
|
||||
|
||||
JSObject* GetParentObject()
|
||||
{
|
||||
if (mScriptOwner) {
|
||||
return mScriptOwner;
|
||||
}
|
||||
|
||||
// Do what nsEventTargetSH::PreCreate does.
|
||||
nsCOMPtr<nsIScriptGlobalObject> parent;
|
||||
nsDOMEventTargetWrapperCache::GetParentObject(getter_AddRefs(parent));
|
||||
|
||||
return parent ? parent->GetGlobalJSObject() : nsnull;
|
||||
}
|
||||
|
||||
static IDBWrapperCache* FromSupports(nsISupports* aSupports)
|
||||
{
|
||||
return static_cast<IDBWrapperCache*>(
|
||||
nsDOMEventTargetWrapperCache::FromSupports(aSupports));
|
||||
}
|
||||
|
||||
protected:
|
||||
IDBWrapperCache()
|
||||
: mScriptOwner(nsnull)
|
||||
{ }
|
||||
|
||||
virtual ~IDBWrapperCache()
|
||||
{ }
|
||||
|
||||
JSObject* mScriptOwner;
|
||||
};
|
||||
|
||||
END_INDEXEDDB_NAMESPACE
|
||||
|
||||
#endif // mozilla_dom_indexeddb_idbwrappercache_h__
|
|
@ -505,7 +505,7 @@ IndexedDatabaseManager::AbortCloseDatabasesForWindow(nsPIDOMWindow* aWindow)
|
|||
|
||||
for (PRUint32 index = 0; index < liveDatabases.Length(); index++) {
|
||||
IDBDatabase*& database = liveDatabases[index];
|
||||
if (database->Owner() == aWindow) {
|
||||
if (database->GetOwner() == aWindow) {
|
||||
if (NS_FAILED(database->Close())) {
|
||||
NS_WARNING("Failed to close database for dying window!");
|
||||
}
|
||||
|
@ -533,7 +533,7 @@ IndexedDatabaseManager::HasOpenTransactions(nsPIDOMWindow* aWindow)
|
|||
|
||||
for (PRUint32 index = 0; index < liveDatabases.Length(); index++) {
|
||||
IDBDatabase*& database = liveDatabases[index];
|
||||
if (database->Owner() == aWindow &&
|
||||
if (database->GetOwner() == aWindow &&
|
||||
pool->HasTransactionsForDatabase(database)) {
|
||||
return true;
|
||||
}
|
||||
|
@ -1591,32 +1591,32 @@ NS_IMETHODIMP
|
|||
IndexedDatabaseManager::InitWindowless(const jsval& aObj, JSContext* aCx)
|
||||
{
|
||||
NS_ENSURE_TRUE(nsContentUtils::IsCallerChrome(), NS_ERROR_NOT_AVAILABLE);
|
||||
|
||||
NS_ENSURE_ARG(!JSVAL_IS_PRIMITIVE(aObj));
|
||||
|
||||
// Instantiating this class will register exception providers so even
|
||||
// in xpcshell we will get typed (dom) exceptions, instead of general exceptions.
|
||||
// in xpcshell we will get typed (dom) exceptions, instead of general
|
||||
// exceptions.
|
||||
nsCOMPtr<nsIDOMScriptObjectFactory> sof(do_GetService(kDOMSOF_CID));
|
||||
|
||||
// Defining IDBKeyrange static functions on the global.
|
||||
if (JSVAL_IS_PRIMITIVE(aObj)) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIIDBFactory> factory = IDBFactory::Create(nsnull);
|
||||
NS_ASSERTION(factory, "IDBFactory should not be null.");
|
||||
|
||||
JSObject* obj = JSVAL_TO_OBJECT(aObj);
|
||||
|
||||
JSObject* global = JS_GetGlobalForObject(aCx, obj);
|
||||
|
||||
nsCOMPtr<nsIIDBFactory> factory = IDBFactory::Create(aCx, global);
|
||||
NS_ENSURE_TRUE(factory, NS_ERROR_FAILURE);
|
||||
|
||||
jsval mozIndexedDBVal;
|
||||
nsresult rv = nsContentUtils::WrapNative(aCx, obj, factory, &mozIndexedDBVal);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!JS_DefineProperty(aCx, obj, "mozIndexedDB", mozIndexedDBVal,
|
||||
nsnull, nsnull, JSPROP_ENUMERATE)) {
|
||||
if (!JS_DefineProperty(aCx, obj, "mozIndexedDB", mozIndexedDBVal, nsnull,
|
||||
nsnull, JSPROP_ENUMERATE)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
JSObject* keyrangeObj = JS_NewObject(aCx, nsnull, nsnull, nsnull);
|
||||
NS_ENSURE_TRUE(keyrangeObj, NS_ERROR_OUT_OF_MEMORY);
|
||||
|
||||
|
||||
if (!IDBKeyRange::DefineConstructors(aCx, keyrangeObj)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
|
|
@ -61,16 +61,17 @@ CPPSRCS = \
|
|||
IDBCursor.cpp \
|
||||
IDBDatabase.cpp \
|
||||
IDBEvents.cpp \
|
||||
IDBFactory.cpp \
|
||||
IDBIndex.cpp \
|
||||
IDBKeyRange.cpp \
|
||||
IDBObjectStore.cpp \
|
||||
IDBRequest.cpp \
|
||||
IDBTransaction.cpp \
|
||||
IDBFactory.cpp \
|
||||
IDBWrapperCache.cpp \
|
||||
IndexedDatabaseManager.cpp \
|
||||
Key.cpp \
|
||||
OpenDatabaseHelper.cpp \
|
||||
TransactionThreadPool.cpp \
|
||||
Key.cpp \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS_mozilla/dom/indexedDB = \
|
||||
|
@ -82,6 +83,7 @@ EXPORTS_mozilla/dom/indexedDB = \
|
|||
IDBObjectStore.h \
|
||||
IDBRequest.h \
|
||||
IDBTransaction.h \
|
||||
IDBWrapperCache.h \
|
||||
IndexedDatabase.h \
|
||||
IndexedDatabaseManager.h \
|
||||
IDBFactory.h \
|
||||
|
|
|
@ -1611,7 +1611,9 @@ OpenDatabaseHelper::DoDatabaseWork()
|
|||
|
||||
NS_ASSERTION(mOpenDBRequest, "This should never be null!");
|
||||
|
||||
nsPIDOMWindow* window = mOpenDBRequest->Owner();
|
||||
// This will be null for non-window contexts.
|
||||
nsPIDOMWindow* window = mOpenDBRequest->GetOwner();
|
||||
|
||||
AutoEnterWindow autoWindow(window);
|
||||
|
||||
nsCOMPtr<nsIFile> dbDirectory;
|
||||
|
@ -2111,8 +2113,7 @@ OpenDatabaseHelper::EnsureSuccessResult()
|
|||
dbInfo->nextIndexId = mLastIndexId + 1;
|
||||
|
||||
nsRefPtr<IDBDatabase> database =
|
||||
IDBDatabase::Create(mOpenDBRequest->ScriptContext(),
|
||||
mOpenDBRequest->Owner(),
|
||||
IDBDatabase::Create(mOpenDBRequest,
|
||||
dbInfo.forget(),
|
||||
mASCIIOrigin,
|
||||
mFileManager);
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Boris Zbarsky <bzbarsky@mit.edu> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMDOMError interface is "An non-zero implementation
|
||||
* dependent error code describing the error, or 0 if there is no
|
||||
* error." [sic]
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020409/core.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(475790ce-d8fa-4e02-a167-e6308ba9b120)]
|
||||
interface nsIDOMDOMError : nsISupports
|
||||
{
|
||||
const unsigned short SEVERITY_WARNING = 0;
|
||||
const unsigned short SEVERITY_ERROR = 1;
|
||||
const unsigned short SEVERITY_FATAL_ERROR = 2;
|
||||
readonly attribute unsigned short severity;
|
||||
readonly attribute DOMString message;
|
||||
// XXX This should be a DOMObject, not an nsISupports; do we need to
|
||||
// do some magic to make that work?
|
||||
readonly attribute nsISupports relatedException;
|
||||
readonly attribute nsIDOMDOMLocator location;
|
||||
};
|
|
@ -1,54 +0,0 @@
|
|||
/* -*- Mode: IDL; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2002
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Boris Zbarsky <bzbarsky@mit.edu> (original author)
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either the GNU General Public License Version 2 or later (the "GPL"), or
|
||||
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "domstubs.idl"
|
||||
|
||||
/**
|
||||
* The nsIDOMDOMErrorHandler interface is a basic interface for DOM
|
||||
* error handlers
|
||||
*
|
||||
* For more information on this interface please see
|
||||
* http://www.w3.org/TR/2002/WD-DOM-Level-3-Core-20020409/core.html
|
||||
*/
|
||||
|
||||
[scriptable, uuid(2d958bdf-740d-43f4-9e5c-5d930f4f3876)]
|
||||
interface nsIDOMDOMErrorHandler : nsISupports
|
||||
{
|
||||
boolean handleError(in nsIDOMDOMError error);
|
||||
};
|
||||
|
|
@ -35,9 +35,15 @@ Tests of DOM Worker Threads XHR(Bug 450452 )
|
|||
worker.postMessage("start");
|
||||
}
|
||||
|
||||
runTest();
|
||||
|
||||
SimpleTest.waitForExplicitFinish();
|
||||
|
||||
const isWinXP = navigator.userAgent.indexOf("Windows NT 5.1") != -1;
|
||||
if (isWinXP){
|
||||
todo(false, "Test disabled on WinXP due to bug 718260 crashes");
|
||||
SimpleTest.finish();
|
||||
} else {
|
||||
runTest();
|
||||
}
|
||||
</script>
|
||||
</pre>
|
||||
</body>
|
||||
|
|
|
@ -44,14 +44,8 @@ include $(DEPTH)/config/autoconf.mk
|
|||
|
||||
MODULE = chardet
|
||||
|
||||
XPIDLSRCS = \
|
||||
nsIDocumentCharsetInfo.idl \
|
||||
nsIDocCharset.idl \
|
||||
$(NULL)
|
||||
|
||||
EXPORTS = \
|
||||
nsDetectionConfident.h \
|
||||
nsDocumentCharsetInfoCID.h \
|
||||
nsICharsetDetectionObserver.h \
|
||||
nsICharsetDetector.h \
|
||||
nsIStringCharsetDetector.h \
|
||||
|
|
|
@ -1,13 +0,0 @@
|
|||
#ifndef nsDocumentCharsetInfoCID_h__
|
||||
#define nsDocumentCharsetInfoCID_h__
|
||||
|
||||
#include "nscore.h"
|
||||
|
||||
#define NS_DOCUMENTCHARSETINFO_CONTRACTID "@mozilla.org/document-charset-info;1"
|
||||
|
||||
// {D25E0511-2BAE-11d4-9D10-0050040007B2}
|
||||
#define NS_DOCUMENTCHARSETINFO_CID \
|
||||
{0xd25e0511, 0x2bae, 0x11d4, {0x9d, 0x10, 0x0, 0x50, 0x4, 0x0, 0x7, 0xb2}}
|
||||
|
||||
#endif // nsDocumentCharsetInfoCID_h__
|
||||
|
|
@ -1,86 +0,0 @@
|
|||
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 2001
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Brian Stell <bstell@netscape.com>
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsISupports.idl"
|
||||
|
||||
/**
|
||||
* The nsIDocCharset interface allows the user to view,
|
||||
* hint, and set which converter is used to read the document's
|
||||
* data.
|
||||
*
|
||||
* <P>Inside Mozilla all text is encoded as Unicode. By standardizing
|
||||
* on Unicode every piece of code that handles characters no longer
|
||||
* needs to:
|
||||
*
|
||||
* Have access to a character encoding parameter.
|
||||
* Ask is the data stateful?
|
||||
* Ask is the data single byte?
|
||||
* Ask is the data multi-byte?
|
||||
* If multi-byte: have access to a routine that can
|
||||
* determine how many bytes in the current character.
|
||||
*
|
||||
* When the document is read in a converter is used to convert
|
||||
* the document's data to Unicode.
|
||||
*
|
||||
* nsIDocCharset provides the ability to:
|
||||
*
|
||||
* See what converter was used when inputting the documents
|
||||
* data.
|
||||
*
|
||||
* Override the character set for documents where the specified
|
||||
* fallback, or auto-detected character set is incorrect
|
||||
*
|
||||
*/
|
||||
[scriptable, uuid(9c18bb4e-1dd1-11b2-bf91-9cc82c275823)]
|
||||
interface nsIDocCharset : nsISupports
|
||||
{
|
||||
|
||||
/**
|
||||
* Get/sets the encoding (converter) used to read the
|
||||
* document. Get returns the encoding used. Set forces
|
||||
* (overrides) the encoding. After forcing the charset the
|
||||
* embedding application will need to cause the data to be
|
||||
* reparsed in order to update the DOM / display.
|
||||
*
|
||||
* A force also sets the fallback encoding for this frame.
|
||||
*/
|
||||
attribute string charset;
|
||||
|
||||
};
|
||||
|
||||
|
|
@ -1,17 +0,0 @@
|
|||
#include "nsISupports.idl"
|
||||
#include "nsIAtom.idl"
|
||||
|
||||
// XXX doc me
|
||||
// XXX mark the right params "const"
|
||||
|
||||
[scriptable, uuid(2d40b291-01e1-11d4-9d0e-0050040007b2)]
|
||||
interface nsIDocumentCharsetInfo : nsISupports
|
||||
{
|
||||
attribute nsIAtom forcedCharset;
|
||||
|
||||
attribute boolean forcedDetector;
|
||||
|
||||
attribute nsIAtom parentCharset;
|
||||
|
||||
attribute PRInt32 parentCharsetSource;
|
||||
};
|
|
@ -55,7 +55,6 @@ CPPSRCS = \
|
|||
nsObserverBase.cpp \
|
||||
nsDebugDetector.cpp \
|
||||
nsCyrillicDetector.cpp \
|
||||
nsDocumentCharsetInfo.cpp \
|
||||
nsChardetModule.cpp \
|
||||
$(NULL)
|
||||
|
||||
|
|
|
@ -48,14 +48,11 @@
|
|||
#include "nsISupports.h"
|
||||
#include "nsICharsetDetector.h"
|
||||
#include "nsICharsetAlias.h"
|
||||
#include "nsDocumentCharsetInfo.h"
|
||||
#include "nsICharsetDetectionObserver.h"
|
||||
#include "nsIStringCharsetDetector.h"
|
||||
#include "nsCyrillicDetector.h"
|
||||
#include "nsDocumentCharsetInfoCID.h"
|
||||
#include "nsXMLEncodingCID.h"
|
||||
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsDocumentCharsetInfo)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUProbDetector)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsUKProbDetector)
|
||||
NS_GENERIC_FACTORY_CONSTRUCTOR(nsRUStringProbDetector)
|
||||
|
|
|
@ -42,7 +42,6 @@
|
|||
|
||||
#include "nsCharDetConstructors.h"
|
||||
|
||||
NS_DEFINE_NAMED_CID(NS_DOCUMENTCHARSETINFO_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_RU_PROBDETECTOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_UK_PROBDETECTOR_CID);
|
||||
NS_DEFINE_NAMED_CID(NS_RU_STRING_PROBDETECTOR_CID);
|
||||
|
@ -54,7 +53,6 @@ NS_DEFINE_NAMED_CID(NS_LASTBLKDBG_DETECTOR_CID);
|
|||
#endif /* INCLUDE_DBGDETECTOR */
|
||||
|
||||
static const mozilla::Module::CIDEntry kChardetCIDs[] = {
|
||||
{ &kNS_DOCUMENTCHARSETINFO_CID, false, NULL, nsDocumentCharsetInfoConstructor },
|
||||
{ &kNS_RU_PROBDETECTOR_CID, false, NULL, nsRUProbDetectorConstructor },
|
||||
{ &kNS_UK_PROBDETECTOR_CID, false, NULL, nsUKProbDetectorConstructor },
|
||||
{ &kNS_RU_STRING_PROBDETECTOR_CID, false, NULL, nsRUStringProbDetectorConstructor },
|
||||
|
@ -68,7 +66,6 @@ static const mozilla::Module::CIDEntry kChardetCIDs[] = {
|
|||
};
|
||||
|
||||
static const mozilla::Module::ContractIDEntry kChardetContracts[] = {
|
||||
{ NS_DOCUMENTCHARSETINFO_CONTRACTID, &kNS_DOCUMENTCHARSETINFO_CID },
|
||||
{ NS_CHARSET_DETECTOR_CONTRACTID_BASE "ruprob", &kNS_RU_PROBDETECTOR_CID },
|
||||
{ NS_CHARSET_DETECTOR_CONTRACTID_BASE "ukprob", &kNS_UK_PROBDETECTOR_CID },
|
||||
{ NS_STRCDETECTOR_CONTRACTID_BASE "ruprob", &kNS_RU_STRING_PROBDETECTOR_CID },
|
||||
|
|
|
@ -1,106 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1999
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#include "nsCharDetDll.h"
|
||||
#include "nsIServiceManager.h"
|
||||
#include "nsICharsetConverterManager.h"
|
||||
#include "nsDocumentCharsetInfo.h"
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
// XXX doc me
|
||||
|
||||
NS_IMPL_THREADSAFE_ISUPPORTS1(nsDocumentCharsetInfo, nsIDocumentCharsetInfo)
|
||||
|
||||
nsDocumentCharsetInfo::nsDocumentCharsetInfo()
|
||||
{
|
||||
mParentCharsetSource = 0;
|
||||
}
|
||||
|
||||
nsDocumentCharsetInfo::~nsDocumentCharsetInfo()
|
||||
{
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::SetForcedCharset(nsIAtom * aCharset)
|
||||
{
|
||||
mForcedCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::GetForcedCharset(nsIAtom ** aResult)
|
||||
{
|
||||
*aResult = mForcedCharset;
|
||||
if (mForcedCharset) NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::SetForcedDetector(bool aForced)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::GetForcedDetector(bool * aResult)
|
||||
{
|
||||
// XXX write me
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::SetParentCharset(nsIAtom * aCharset)
|
||||
{
|
||||
mParentCharset = aCharset;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::GetParentCharset(nsIAtom ** aResult)
|
||||
{
|
||||
*aResult = mParentCharset;
|
||||
if (mParentCharset) NS_ADDREF(*aResult);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::SetParentCharsetSource(PRInt32 aCharsetSource)
|
||||
{
|
||||
mParentCharsetSource = aCharsetSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP nsDocumentCharsetInfo::GetParentCharsetSource(PRInt32 * aParentCharsetSource)
|
||||
{
|
||||
*aParentCharsetSource = mParentCharsetSource;
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
@ -1,59 +0,0 @@
|
|||
/* -*- Mode: C; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
||||
/* ***** BEGIN LICENSE BLOCK *****
|
||||
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is mozilla.org code.
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Netscape Communications Corporation.
|
||||
* Portions created by the Initial Developer are Copyright (C) 1998
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Alternatively, the contents of this file may be used under the terms of
|
||||
* either of the GNU General Public License Version 2 or later (the "GPL"),
|
||||
* or the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
|
||||
* in which case the provisions of the GPL or the LGPL are applicable instead
|
||||
* of those above. If you wish to allow use of your version of this file only
|
||||
* under the terms of either the GPL or the LGPL, and not to allow others to
|
||||
* use your version of this file under the terms of the MPL, indicate your
|
||||
* decision by deleting the provisions above and replace them with the notice
|
||||
* and other provisions required by the GPL or the LGPL. If you do not delete
|
||||
* the provisions above, a recipient may use your version of this file under
|
||||
* the terms of any one of the MPL, the GPL or the LGPL.
|
||||
*
|
||||
* ***** END LICENSE BLOCK ***** */
|
||||
|
||||
#ifndef nsDocumentCharsetInfo_h__
|
||||
#define nsDocumentCharsetInfo_h__
|
||||
|
||||
#include "nsIFactory.h"
|
||||
#include "nsIDocumentCharsetInfo.h"
|
||||
|
||||
class nsDocumentCharsetInfo : public nsIDocumentCharsetInfo
|
||||
{
|
||||
public:
|
||||
nsDocumentCharsetInfo ();
|
||||
virtual ~nsDocumentCharsetInfo ();
|
||||
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOCUMENTCHARSETINFO
|
||||
|
||||
private:
|
||||
nsCOMPtr<nsIAtom> mForcedCharset;
|
||||
nsCOMPtr<nsIAtom> mParentCharset;
|
||||
PRInt32 mParentCharsetSource;
|
||||
};
|
||||
|
||||
#endif // nsDocumentCharsetInfo_h__
|
|
@ -467,6 +467,8 @@ members = [
|
|||
'nsIIDBVersionChangeEvent.*',
|
||||
'nsIIndexedDatabaseUsageCallback.*',
|
||||
'nsIIndexedDatabaseManager.*',
|
||||
|
||||
'nsIDOMDOMError.*',
|
||||
]
|
||||
|
||||
# Most interfaces can be found by searching the includePath; to find
|
||||
|
|
|
@ -20,6 +20,8 @@ function setDefaultPrefs() {
|
|||
branch.setIntPref("dom.max_script_run_time", 0);
|
||||
branch.setIntPref("dom.max_chrome_script_run_time", 0);
|
||||
branch.setIntPref("hangmonitor.timeout", 0);
|
||||
// Ensure autoplay is enabled for all platforms.
|
||||
branch.setBoolPref("media.autoplay.enabled", true);
|
||||
}
|
||||
|
||||
var windowListener = {
|
||||
|
|
|
@ -118,6 +118,8 @@ RefTestCmdLineHandler.prototype =
|
|||
branch.setIntPref("dom.max_script_run_time", 0);
|
||||
branch.setIntPref("dom.max_chrome_script_run_time", 0);
|
||||
branch.setIntPref("hangmonitor.timeout", 0);
|
||||
// Ensure autoplay is enabled for all platforms.
|
||||
branch.setBoolPref("media.autoplay.enabled", true);
|
||||
|
||||
var wwatch = Components.classes["@mozilla.org/embedcomp/window-watcher;1"]
|
||||
.getService(nsIWindowWatcher);
|
||||
|
|
|
@ -52,7 +52,7 @@ var CharsetMenu = {
|
|||
updatePageAction: function(aNode) {
|
||||
let pref = Services.prefs.getComplexValue("browser.menu.showCharacterEncoding", Ci.nsIPrefLocalizedString).data;
|
||||
if (pref == "true") {
|
||||
let charset = getBrowser().documentCharsetInfo.forcedCharset;
|
||||
let charset = getBrowser().docShell.forcedCharset;
|
||||
if (charset) {
|
||||
charset = charset.toString();
|
||||
charset = charset.trim().toLowerCase();
|
||||
|
@ -95,7 +95,7 @@ var CharsetMenu = {
|
|||
this._charsets = Services.prefs.getComplexValue("intl.charsetmenu.browser.static", Ci.nsIPrefLocalizedString).data.split(",");
|
||||
}
|
||||
let charsets = this._charsets;
|
||||
let currentCharset = getBrowser().documentCharsetInfo.forcedCharset;
|
||||
let currentCharset = getBrowser().docShell.forcedCharset;
|
||||
|
||||
if (currentCharset) {
|
||||
currentCharset = currentCharset.toString();
|
||||
|
|
|
@ -650,8 +650,15 @@
|
|||
</property>
|
||||
|
||||
<property name="docShell"
|
||||
onget="return null"
|
||||
readonly="true"/>
|
||||
readonly="true">
|
||||
<getter><![CDATA[
|
||||
return {
|
||||
forcedCharset : this._charset,
|
||||
parentCharset : "",
|
||||
parentCharsetSource : 0
|
||||
}
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<field name="_contentTitle">null</field>
|
||||
|
||||
|
@ -683,18 +690,6 @@
|
|||
onget="return null"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="documentCharsetInfo"
|
||||
readonly="true">
|
||||
<getter><![CDATA[
|
||||
return {
|
||||
forcedCharset : this._charset,
|
||||
forcedDetector : false,
|
||||
parentCharset : "",
|
||||
parentCharsetSource : 0
|
||||
}
|
||||
]]></getter>
|
||||
</property>
|
||||
|
||||
<field name="_charset"></field>
|
||||
|
||||
<constructor>
|
||||
|
|
|
@ -595,8 +595,7 @@ let Content = {
|
|||
}
|
||||
|
||||
case "Browser:SetCharset": {
|
||||
let docCharset = docShell.QueryInterface(Ci.nsIDocCharset);
|
||||
docCharset.charset = json.charset;
|
||||
docShell.charset = json.charset;
|
||||
|
||||
let webNav = docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
webNav.reload(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
||||
|
|
|
@ -164,8 +164,7 @@ function viewSource(url)
|
|||
|
||||
try {
|
||||
if (arg === true) {
|
||||
var docCharset = gBrowser.docShell.QueryInterface(Ci.nsIDocCharset);
|
||||
docCharset.charset = charset;
|
||||
gBrowser.docShell.charset = charset;
|
||||
}
|
||||
} catch (ex) {
|
||||
// Ignore the failure and keep processing arguments...
|
||||
|
@ -712,12 +711,12 @@ function highlightSyntax()
|
|||
gPageLoader.loadPage(gPageLoader.currentDescriptor, gPageLoader.DISPLAY_NORMAL);
|
||||
}
|
||||
|
||||
// Reload after change to character encoding or autodetection
|
||||
//
|
||||
// Fix for bug 136322: this function overrides the function in
|
||||
// browser.js to call PageLoader.loadPage() instead of BrowserReloadWithFlags()
|
||||
function BrowserSetForcedCharacterSet(aCharset)
|
||||
function BrowserCharsetReload()
|
||||
{
|
||||
var docCharset = gBrowser.docShell.QueryInterface(Ci.nsIDocCharset);
|
||||
docCharset.charset = aCharset;
|
||||
if (isHistoryEnabled()) {
|
||||
gPageLoader.loadPage(gPageLoader.currentDescriptor,
|
||||
gPageLoader.DISPLAY_NORMAL);
|
||||
|
@ -726,23 +725,10 @@ function BrowserSetForcedCharacterSet(aCharset)
|
|||
}
|
||||
}
|
||||
|
||||
// fix for bug #229503
|
||||
// we need to define BrowserSetForcedDetector() so that we can
|
||||
// change auto-detect options in the "View | Character Encoding" menu.
|
||||
// As with BrowserSetForcedCharacterSet(), call PageLoader.loadPage()
|
||||
// instead of BrowserReloadWithFlags()
|
||||
function BrowserSetForcedDetector(doReload)
|
||||
function BrowserSetForcedCharacterSet(aCharset)
|
||||
{
|
||||
gBrowser.documentCharsetInfo.forcedDetector = true;
|
||||
if (doReload)
|
||||
{
|
||||
if (isHistoryEnabled()) {
|
||||
gPageLoader.loadPage(gPageLoader.currentDescriptor,
|
||||
gPageLoader.DISPLAY_NORMAL);
|
||||
} else {
|
||||
gBrowser.reloadWithFlags(Ci.nsIWebNavigation.LOAD_FLAGS_CHARSET_CHANGE);
|
||||
}
|
||||
}
|
||||
gBrowser.docShell.charset = aCharset;
|
||||
BrowserCharsetReload();
|
||||
}
|
||||
|
||||
function BrowserForward(aEvent) {
|
||||
|
|
|
@ -3,7 +3,7 @@ function MultiplexHandler(aEvent)
|
|||
MultiplexHandlerEx(
|
||||
aEvent,
|
||||
function Browser_SelectDetector(event) {
|
||||
BrowserSetForcedDetector(true/*Reload from history*/);
|
||||
BrowserCharsetReload();
|
||||
/* window.content.location.reload() will re-download everything */
|
||||
SelectDetector(event, null);
|
||||
},
|
||||
|
|
|
@ -79,8 +79,9 @@ var ZoomManager = {
|
|||
getZoomForBrowser: function ZoomManager_getZoomForBrowser(aBrowser) {
|
||||
var markupDocumentViewer = aBrowser.markupDocumentViewer;
|
||||
|
||||
return this.useFullZoom ? markupDocumentViewer.fullZoom
|
||||
: markupDocumentViewer.textZoom;
|
||||
return this.useFullZoom ||
|
||||
aBrowser.contentDocument.mozSyntheticDocument ?
|
||||
markupDocumentViewer.fullZoom : markupDocumentViewer.textZoom;
|
||||
},
|
||||
|
||||
set zoom(aVal) {
|
||||
|
@ -94,7 +95,7 @@ var ZoomManager = {
|
|||
|
||||
var markupDocumentViewer = aBrowser.markupDocumentViewer;
|
||||
|
||||
if (this.useFullZoom) {
|
||||
if (this.useFullZoom || aBrowser.contentDocument.mozSyntheticDocument) {
|
||||
markupDocumentViewer.textZoom = 1;
|
||||
markupDocumentViewer.fullZoom = aVal;
|
||||
} else {
|
||||
|
|
|
@ -180,7 +180,7 @@
|
|||
|
||||
if (aCharset) {
|
||||
try {
|
||||
this.documentCharsetInfo.parentCharset = this.mAtomService.getAtom(aCharset);
|
||||
this.docShell.parentCharset = this.mAtomService.getAtom(aCharset);
|
||||
}
|
||||
catch (e) {
|
||||
}
|
||||
|
@ -438,10 +438,6 @@
|
|||
onget="return this.docShell.contentViewer.QueryInterface(Components.interfaces.nsIContentViewerFile);"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="documentCharsetInfo"
|
||||
onget="return this.docShell.documentCharsetInfo;"
|
||||
readonly="true"/>
|
||||
|
||||
<property name="contentDocument"
|
||||
onget="return this.webNavigation.document;"
|
||||
readonly="true"/>
|
||||
|
|
|
@ -41,7 +41,6 @@
|
|||
#include "nsIServiceManager.h"
|
||||
#include "nsICategoryManager.h"
|
||||
#include "nsIObserverService.h"
|
||||
#include "nsIDocCharset.h"
|
||||
#include "nsIWebProgress.h"
|
||||
#include "nsCURILoader.h"
|
||||
#include "nsICachingChannel.h"
|
||||
|
|
Загрузка…
Ссылка в новой задаче