зеркало из https://github.com/mozilla/pjs.git
Fixing second part of bug 453571. Use more [optional] idl arguments, and less nsAXPCNativeCallContext. r+sr=bzbarsky@mit.edu
This commit is contained in:
Родитель
86662e7eb4
Коммит
cb71eeaa2c
|
@ -128,14 +128,15 @@ interface nsIDOMParser : nsISupports
|
|||
* The nsIDOMParserJS interface provides a scriptable way of calling init().
|
||||
* Do NOT use this interface from languages other than JavaScript.
|
||||
*/
|
||||
[scriptable, uuid(dca92fe9-ae7a-44b7-80aa-d151216698ac)]
|
||||
[scriptable, uuid(ba6bcd6c-63d8-49b3-bc8a-1e5e895645bc)]
|
||||
interface nsIDOMParserJS : nsISupports
|
||||
{
|
||||
/**
|
||||
* Just like nsIDOMParser.init, but callable from JS. It'll pick up the args
|
||||
* from XPConnect.
|
||||
* Just like nsIDOMParser.init, but callable from JS.
|
||||
*/
|
||||
void init();
|
||||
void init(in nsIPrincipal principal,
|
||||
in nsIURI documentURI,
|
||||
in nsIURI baseURI);
|
||||
};
|
||||
|
||||
%{ C++
|
||||
|
|
|
@ -506,39 +506,14 @@ nsDOMParser::Initialize(nsISupports* aOwner, JSContext* cx, JSObject* obj,
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMParser::Init()
|
||||
nsDOMParser::Init(nsIPrincipal *principal, nsIURI *documentURI, nsIURI *baseURI)
|
||||
{
|
||||
AttemptedInitMarker marker(&mAttemptedInit);
|
||||
|
||||
nsAXPCNativeCallContext *ncc = nsnull;
|
||||
|
||||
nsresult rv = nsContentUtils::XPConnect()->
|
||||
GetCurrentNativeCallContext(&ncc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
NS_ENSURE_TRUE(ncc, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSContext *cx = nsnull;
|
||||
rv = ncc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
JSContext *cx = nsContentUtils::GetCurrentJSContext();
|
||||
NS_ENSURE_TRUE(cx, NS_ERROR_UNEXPECTED);
|
||||
|
||||
PRUint32 argc;
|
||||
jsval *argv = nsnull;
|
||||
ncc->GetArgc(&argc);
|
||||
ncc->GetArgvPtr(&argv);
|
||||
|
||||
if (argc != 3) {
|
||||
return NS_ERROR_INVALID_ARG;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIPrincipal> prin;
|
||||
nsCOMPtr<nsIURI> documentURI;
|
||||
nsCOMPtr<nsIURI> baseURI;
|
||||
rv = GetInitArgs(cx, argc, argv, getter_AddRefs(prin),
|
||||
getter_AddRefs(documentURI), getter_AddRefs(baseURI));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsIScriptContext* scriptContext = GetScriptContextFromJSContext(cx);
|
||||
return Init(prin, documentURI, baseURI,
|
||||
return Init(principal, documentURI, baseURI,
|
||||
scriptContext ? scriptContext->GetGlobalObject() : nsnull);
|
||||
}
|
||||
|
|
|
@ -65,8 +65,6 @@ XPIDLSRCS = \
|
|||
nsIDOMLocation.idl \
|
||||
nsIDOMMimeType.idl \
|
||||
nsIDOMMimeTypeArray.idl \
|
||||
nsIDOMNSHistory.idl \
|
||||
nsIDOMNSLocation.idl \
|
||||
nsIDOMNavigator.idl \
|
||||
nsIDOMPkcs11.idl \
|
||||
nsIDOMPlugin.idl \
|
||||
|
|
|
@ -50,7 +50,6 @@ interface nsIDOMHistory : nsISupports
|
|||
void back();
|
||||
void forward();
|
||||
|
||||
// go() gets special treatment in nsIDOMNSHistory
|
||||
[noscript] void go(in long aDelta);
|
||||
void go([optional] in long aDelta);
|
||||
DOMString item(in unsigned long index);
|
||||
};
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
|
||||
#include "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(c8188620-1dd1-11b2-bc88-df8440498add)]
|
||||
[scriptable, uuid(8fcfcc79-054f-437b-965d-807d9b602d0f)]
|
||||
interface nsIDOMJSWindow : nsISupports
|
||||
{
|
||||
void dump(in DOMString str);
|
||||
|
@ -76,12 +76,6 @@ interface nsIDOMJSWindow : nsISupports
|
|||
void enableExternalCapture();
|
||||
void disableExternalCapture();
|
||||
|
||||
/**
|
||||
* The prompt method takes up to four arguments, the arguments are
|
||||
* message, initial prompt value, title and a save password flag
|
||||
*/
|
||||
DOMString prompt();
|
||||
|
||||
/**
|
||||
* These are the scriptable versions of nsIDOMWindowInternal::open() and
|
||||
* nsIDOMWindowInternal::openDialog() that take 3 optional arguments. Unlike
|
||||
|
@ -104,16 +98,4 @@ interface nsIDOMJSWindow : nsISupports
|
|||
* This property is "replaceable" in JavaScript.
|
||||
*/
|
||||
readonly attribute nsIDOMWindow frames;
|
||||
|
||||
/* Scriptable version of find(). See nsIDOMWindowInternal for the
|
||||
* non-scriptable version. It takes 7 optional arguments:
|
||||
* @param searchString: the search string
|
||||
* @param caseSensitive: is the search case sensitive?
|
||||
* @param backwards: should we search backwards?
|
||||
* @param wrapAround: should wrap the search?
|
||||
* @param wholeWord: should we search only for whole words?
|
||||
* @param searchInFrames: should we search in all frames?
|
||||
* @param showDialog: should we show the Find Dialog?
|
||||
*/
|
||||
boolean find();
|
||||
};
|
||||
|
|
|
@ -56,8 +56,7 @@ interface nsIDOMLocation : nsISupports
|
|||
attribute DOMString protocol;
|
||||
attribute DOMString search;
|
||||
|
||||
// XXX is this needed?
|
||||
[noscript] void reload(in boolean forceget);
|
||||
void reload([optional] in boolean forceget);
|
||||
void replace(in DOMString url);
|
||||
void assign(in DOMString url);
|
||||
|
||||
|
|
|
@ -1,49 +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) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@netscape.com> (original author)
|
||||
*
|
||||
* 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 "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(5fb96f46-1dd2-11b2-a5dc-998ca8636ea9)]
|
||||
interface nsIDOMNSHistory : nsISupports
|
||||
{
|
||||
/**
|
||||
* go() can be called with an integer argument or no arguments (a
|
||||
* nop) from JS
|
||||
*/
|
||||
void go(/* ... */);
|
||||
};
|
|
@ -1,45 +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) 2000
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
* Johnny Stenback <jst@netscape.com> (original author)
|
||||
*
|
||||
* 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 "domstubs.idl"
|
||||
|
||||
[scriptable, uuid(a6cf9108-15b3-11d2-932e-00805f8add32)]
|
||||
interface nsIDOMNSLocation : nsISupports
|
||||
{
|
||||
void reload(/* ... */);
|
||||
};
|
|
@ -47,12 +47,5 @@ interface nsIDOMPluginArray : nsISupports
|
|||
nsIDOMPlugin item(in unsigned long index);
|
||||
nsIDOMPlugin namedItem(in DOMString name);
|
||||
|
||||
[noscript] void refresh(in boolean reloadDocuments);
|
||||
};
|
||||
|
||||
|
||||
[scriptable, uuid(ee753352-1dd1-11b2-b18d-b0b7320a28c3)]
|
||||
interface nsIDOMJSPluginArray : nsISupports
|
||||
{
|
||||
void refresh();
|
||||
void refresh([optional] in boolean reloadDocuments);
|
||||
};
|
||||
|
|
|
@ -123,10 +123,10 @@ interface nsIDOMWindowInternal : nsIDOMWindow2
|
|||
boolean confirm(in DOMString text);
|
||||
|
||||
// prompt() should return a null string if cancel is pressed
|
||||
DOMString prompt(in DOMString aMessage,
|
||||
in DOMString aInitial,
|
||||
in DOMString aTitle,
|
||||
in unsigned long aSavePassword);
|
||||
DOMString prompt([optional] in DOMString aMessage,
|
||||
[optional] in DOMString aInitial,
|
||||
[optional] in DOMString aTitle,
|
||||
[optional] in unsigned long aSavePassword);
|
||||
|
||||
void focus();
|
||||
void blur();
|
||||
|
@ -174,7 +174,7 @@ interface nsIDOMWindowInternal : nsIDOMWindow2
|
|||
// XXX Should this be in nsIDOMChromeWindow?
|
||||
void updateCommands(in DOMString action);
|
||||
|
||||
/* See nsIDOMJSWindow for the scriptable version of find()
|
||||
/* Find in page.
|
||||
* @param str: the search pattern
|
||||
* @param caseSensitive: is the search caseSensitive
|
||||
* @param backwards: should we search backwards
|
||||
|
@ -183,13 +183,13 @@ interface nsIDOMWindowInternal : nsIDOMWindow2
|
|||
* @param searchInFrames: should we search through all frames
|
||||
* @param showDialog: should we show the Find dialog
|
||||
*/
|
||||
[noscript] boolean find(in DOMString str,
|
||||
in boolean caseSensitive,
|
||||
in boolean backwards,
|
||||
in boolean wrapAround,
|
||||
in boolean wholeWord,
|
||||
in boolean searchInFrames,
|
||||
in boolean showDialog);
|
||||
boolean find([optional] in DOMString str,
|
||||
[optional] in boolean caseSensitive,
|
||||
[optional] in boolean backwards,
|
||||
[optional] in boolean wrapAround,
|
||||
[optional] in boolean wholeWord,
|
||||
[optional] in boolean searchInFrames,
|
||||
[optional] in boolean showDialog);
|
||||
|
||||
// Ascii base64 data to binary data and vice versa...
|
||||
DOMString atob(in DOMString aAsciiString);
|
||||
|
|
|
@ -104,14 +104,12 @@
|
|||
#include "nsIDOMPlugin.h"
|
||||
#include "nsIDOMMimeTypeArray.h"
|
||||
#include "nsIDOMMimeType.h"
|
||||
#include "nsIDOMNSLocation.h"
|
||||
#include "nsIDOMLocation.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsPIDOMWindow.h"
|
||||
#include "nsIDOMJSWindow.h"
|
||||
#include "nsIDOMWindowCollection.h"
|
||||
#include "nsIDOMHistory.h"
|
||||
#include "nsIDOMNSHistory.h"
|
||||
#include "nsIDOMMediaList.h"
|
||||
#include "nsIDOMChromeWindow.h"
|
||||
#include "nsIDOMConstructor.h"
|
||||
|
@ -1958,7 +1956,6 @@ nsDOMClassInfo::Init()
|
|||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Location, nsIDOMLocation)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMLocation)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSLocation)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Navigator, nsIDOMNavigator)
|
||||
|
@ -1974,7 +1971,6 @@ nsDOMClassInfo::Init()
|
|||
|
||||
DOM_CLASSINFO_MAP_BEGIN(PluginArray, nsIDOMPluginArray)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMPluginArray)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMJSPluginArray)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(MimeType, nsIDOMMimeType)
|
||||
|
@ -1991,7 +1987,6 @@ nsDOMClassInfo::Init()
|
|||
|
||||
DOM_CLASSINFO_MAP_BEGIN(History, nsIDOMHistory)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMHistory)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMNSHistory)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Screen, nsIDOMScreen)
|
||||
|
|
|
@ -4083,6 +4083,12 @@ nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
|
|||
// prompt(). IE and Opera ignore it too. See Mozilla bug 334893.
|
||||
SetDOMStringToNull(aReturn);
|
||||
|
||||
// This code depends on aSavePassword being defaulted to
|
||||
// nsIAuthPrompt::SAVE_PASSWORD_NEVER, which happens to have the
|
||||
// value 0. If that ever changes, this code needs to deal!
|
||||
|
||||
PR_STATIC_ASSERT(nsIAuthPrompt::SAVE_PASSWORD_NEVER == 0);
|
||||
|
||||
nsresult rv;
|
||||
nsCOMPtr<nsIWindowWatcher> wwatch =
|
||||
do_GetService(NS_WINDOWWATCHER_CONTRACTID, &rv);
|
||||
|
@ -4125,57 +4131,6 @@ nsGlobalWindow::Prompt(const nsAString& aMessage, const nsAString& aInitial,
|
|||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::Prompt(nsAString& aReturn)
|
||||
{
|
||||
FORWARD_TO_OUTER(Prompt, (aReturn), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
NS_ENSURE_STATE(mDocShell);
|
||||
|
||||
nsresult rv = NS_OK;
|
||||
nsAXPCNativeCallContext *ncc = nsnull;
|
||||
|
||||
rv = nsContentUtils::XPConnect()->
|
||||
GetCurrentNativeCallContext(&ncc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!ncc)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
JSContext *cx = nsnull;
|
||||
|
||||
rv = ncc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
nsAutoString message, initial, title;
|
||||
|
||||
PRUint32 argc;
|
||||
jsval *argv = nsnull;
|
||||
|
||||
ncc->GetArgc(&argc);
|
||||
ncc->GetArgvPtr(&argv);
|
||||
|
||||
PRUint32 savePassword = nsIAuthPrompt::SAVE_PASSWORD_NEVER;
|
||||
|
||||
if (argc > 0) {
|
||||
JSAutoRequest ar(cx);
|
||||
switch (argc) {
|
||||
default:
|
||||
case 4:
|
||||
nsJSUtils::ConvertJSValToUint32(&savePassword, cx, argv[3]);
|
||||
case 3:
|
||||
nsJSUtils::ConvertJSValToString(title, cx, argv[2]);
|
||||
case 2:
|
||||
nsJSUtils::ConvertJSValToString(initial, cx, argv[1]);
|
||||
case 1:
|
||||
nsJSUtils::ConvertJSValToString(message, cx, argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return Prompt(message, initial, title, savePassword, aReturn);
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::Focus()
|
||||
{
|
||||
|
@ -6173,114 +6128,16 @@ nsGlobalWindow::GetSelection(nsISelection** aSelection)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
// Non-scriptable version of window.find(), part of nsIDOMWindowInternal
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::Find(const nsAString& aStr, PRBool aCaseSensitive,
|
||||
PRBool aBackwards, PRBool aWrapAround, PRBool aWholeWord,
|
||||
PRBool aSearchInFrames, PRBool aShowDialog,
|
||||
PRBool *aDidFind)
|
||||
{
|
||||
return FindInternal(aStr, aCaseSensitive, aBackwards, aWrapAround,
|
||||
aWholeWord, aSearchInFrames, aShowDialog, aDidFind);
|
||||
}
|
||||
FORWARD_TO_OUTER(Find, (aStr, aCaseSensitive, aBackwards, aWrapAround,
|
||||
aWholeWord, aSearchInFrames, aShowDialog, aDidFind),
|
||||
NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
// Scriptable version of window.find() which takes a variable number of
|
||||
// arguments, part of nsIDOMJSWindow.
|
||||
NS_IMETHODIMP
|
||||
nsGlobalWindow::Find(PRBool *aDidFind)
|
||||
{
|
||||
nsresult rv = NS_OK;
|
||||
|
||||
// We get the arguments passed to the function using the XPConnect native
|
||||
// call context.
|
||||
nsAXPCNativeCallContext *ncc = nsnull;
|
||||
|
||||
rv = nsContentUtils::XPConnect()->
|
||||
GetCurrentNativeCallContext(&ncc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
NS_ASSERTION(ncc, "No Native Call Context."
|
||||
"Please don't call this method from C++.");
|
||||
if (!ncc) {
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
}
|
||||
|
||||
JSContext *cx = nsnull;
|
||||
|
||||
rv = ncc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
PRUint32 argc;
|
||||
jsval *argv = nsnull;
|
||||
|
||||
ncc->GetArgc(&argc);
|
||||
ncc->GetArgvPtr(&argv);
|
||||
|
||||
// Parse the arguments passed to the function
|
||||
nsAutoString searchStr;
|
||||
PRBool caseSensitive = PR_FALSE;
|
||||
PRBool backwards = PR_FALSE;
|
||||
PRBool wrapAround = PR_FALSE;
|
||||
PRBool showDialog = PR_FALSE;
|
||||
PRBool wholeWord = PR_FALSE;
|
||||
PRBool searchInFrames = PR_FALSE;
|
||||
|
||||
if (argc > 0) {
|
||||
JSAutoRequest ar(cx);
|
||||
switch (argc) {
|
||||
default:
|
||||
case 7:
|
||||
if (!JS_ValueToBoolean(cx, argv[6], &showDialog)) {
|
||||
// Seventh arg specifies whether we should search in all frames
|
||||
showDialog = PR_FALSE;
|
||||
}
|
||||
case 6:
|
||||
if (!JS_ValueToBoolean(cx, argv[5], &searchInFrames)) {
|
||||
// Sixth arg specifies whether we should search only for whole words
|
||||
searchInFrames = PR_FALSE;
|
||||
}
|
||||
case 5:
|
||||
if (!JS_ValueToBoolean(cx, argv[4], &wholeWord)) {
|
||||
// Fifth arg specifies whether we should show the Find dialog
|
||||
wholeWord = PR_FALSE;
|
||||
}
|
||||
case 4:
|
||||
if (!JS_ValueToBoolean(cx, argv[3], &wrapAround)) {
|
||||
// Fourth arg specifies whether we should wrap the search
|
||||
wrapAround = PR_FALSE;
|
||||
}
|
||||
case 3:
|
||||
if (!JS_ValueToBoolean(cx, argv[2], &backwards)) {
|
||||
// Third arg specifies whether to search backwards
|
||||
backwards = PR_FALSE;
|
||||
}
|
||||
case 2:
|
||||
if (!JS_ValueToBoolean(cx, argv[1], &caseSensitive)) {
|
||||
// Second arg is the case sensitivity
|
||||
caseSensitive = PR_FALSE;
|
||||
}
|
||||
case 1:
|
||||
// First arg is the search pattern
|
||||
nsJSUtils::ConvertJSValToString(searchStr, cx, argv[0]);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
return FindInternal(searchStr, caseSensitive, backwards, wrapAround,
|
||||
wholeWord, searchInFrames, showDialog, aDidFind);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsGlobalWindow::FindInternal(const nsAString& aStr, PRBool caseSensitive,
|
||||
PRBool backwards, PRBool wrapAround,
|
||||
PRBool wholeWord, PRBool searchInFrames,
|
||||
PRBool showDialog, PRBool *aDidFind)
|
||||
{
|
||||
FORWARD_TO_OUTER(FindInternal, (aStr, caseSensitive, backwards, wrapAround,
|
||||
wholeWord, searchInFrames, showDialog,
|
||||
aDidFind), NS_ERROR_NOT_INITIALIZED);
|
||||
|
||||
NS_ENSURE_ARG_POINTER(aDidFind);
|
||||
nsresult rv = NS_OK;
|
||||
*aDidFind = PR_FALSE;
|
||||
|
||||
|
@ -6289,11 +6146,11 @@ nsGlobalWindow::FindInternal(const nsAString& aStr, PRBool caseSensitive,
|
|||
// Set the options of the search
|
||||
rv = finder->SetSearchString(PromiseFlatString(aStr).get());
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
finder->SetMatchCase(caseSensitive);
|
||||
finder->SetFindBackwards(backwards);
|
||||
finder->SetWrapFind(wrapAround);
|
||||
finder->SetEntireWord(wholeWord);
|
||||
finder->SetSearchFrames(searchInFrames);
|
||||
finder->SetMatchCase(aCaseSensitive);
|
||||
finder->SetFindBackwards(aBackwards);
|
||||
finder->SetWrapFind(aWrapAround);
|
||||
finder->SetEntireWord(aWholeWord);
|
||||
finder->SetSearchFrames(aSearchInFrames);
|
||||
|
||||
// the nsIWebBrowserFind is initialized to use this window
|
||||
// as the search root, but uses focus to set the current search
|
||||
|
@ -6306,7 +6163,7 @@ nsGlobalWindow::FindInternal(const nsAString& aStr, PRBool caseSensitive,
|
|||
}
|
||||
|
||||
// The Find API does not accept empty strings. Launch the Find Dialog.
|
||||
if (aStr.IsEmpty() || showDialog) {
|
||||
if (aStr.IsEmpty() || aShowDialog) {
|
||||
// See if the find dialog is already up using nsIWindowMediator
|
||||
nsCOMPtr<nsIWindowMediator> windowMediator =
|
||||
do_GetService(NS_WINDOWMEDIATOR_CONTRACTID);
|
||||
|
@ -8149,6 +8006,7 @@ nsGlobalWindow::ClearTimeoutOrInterval()
|
|||
|
||||
JSAutoRequest ar(cx);
|
||||
|
||||
// XXXjst: Can we deal with this w/o using GetCurrentNativeCallContext()
|
||||
if (argv[0] == JSVAL_VOID || !::JS_ValueToInt32(cx, argv[0], &timer_id) ||
|
||||
timer_id <= 0) {
|
||||
// Undefined or non-positive number passed as argument, return
|
||||
|
@ -9405,6 +9263,8 @@ nsNavigator::sPrefInternal_id = JSVAL_VOID;
|
|||
NS_IMETHODIMP
|
||||
nsNavigator::Preference()
|
||||
{
|
||||
// XXXjst: We could get rid of this GetCurrentNativeCallContext()
|
||||
// call if this method returned a variant...
|
||||
nsAXPCNativeCallContext *ncc = nsnull;
|
||||
nsresult rv = nsContentUtils::XPConnect()->
|
||||
GetCurrentNativeCallContext(&ncc);
|
||||
|
|
|
@ -66,7 +66,7 @@
|
|||
#include "nsIDOMNSEventTarget.h"
|
||||
#include "nsIDOMNavigator.h"
|
||||
#include "nsIDOMNavigatorGeolocation.h"
|
||||
#include "nsIDOMNSLocation.h"
|
||||
#include "nsIDOMLocation.h"
|
||||
#include "nsIDOMWindowInternal.h"
|
||||
#include "nsIInterfaceRequestor.h"
|
||||
#include "nsIInterfaceRequestorUtils.h"
|
||||
|
@ -572,12 +572,6 @@ protected:
|
|||
|
||||
static PRBool CanMoveResizeWindows();
|
||||
|
||||
// Helper for window.find()
|
||||
nsresult FindInternal(const nsAString& aStr, PRBool caseSensitive,
|
||||
PRBool backwards, PRBool wrapAround, PRBool wholeWord,
|
||||
PRBool searchInFrames, PRBool showDialog,
|
||||
PRBool *aReturn);
|
||||
|
||||
nsresult ConvertCharset(const nsAString& aStr, char** aDest);
|
||||
|
||||
PRBool GetBlurSuppression();
|
||||
|
@ -845,8 +839,7 @@ class nsIURI;
|
|||
// nsLocation: Script "location" object
|
||||
//*****************************************************************************
|
||||
|
||||
class nsLocation : public nsIDOMLocation,
|
||||
public nsIDOMNSLocation
|
||||
class nsLocation : public nsIDOMLocation
|
||||
{
|
||||
public:
|
||||
nsLocation(nsIDocShell *aDocShell);
|
||||
|
@ -860,9 +853,6 @@ public:
|
|||
// nsIDOMLocation
|
||||
NS_DECL_NSIDOMLOCATION
|
||||
|
||||
// nsIDOMNSLocation
|
||||
NS_DECL_NSIDOMNSLOCATION
|
||||
|
||||
protected:
|
||||
// In the case of jar: uris, we sometimes want the place the jar was
|
||||
// fetched from as the URI instead of the jar: uri itself. Pass in
|
||||
|
|
|
@ -74,7 +74,6 @@ nsHistory::~nsHistory()
|
|||
NS_INTERFACE_MAP_BEGIN(nsHistory)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMHistory)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSHistory)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(History)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -222,61 +221,7 @@ nsHistory::Forward()
|
|||
NS_IMETHODIMP
|
||||
nsHistory::Go(PRInt32 aDelta)
|
||||
{
|
||||
nsCOMPtr<nsISHistory> session_history;
|
||||
|
||||
GetSessionHistoryFromDocShell(mDocShell, getter_AddRefs(session_history));
|
||||
NS_ENSURE_TRUE(session_history, NS_ERROR_FAILURE);
|
||||
|
||||
// QI SHistory to nsIWebNavigation
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(session_history));
|
||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 curIndex=-1;
|
||||
PRInt32 len = 0;
|
||||
nsresult rv = session_history->GetIndex(&curIndex);
|
||||
rv = session_history->GetCount(&len);
|
||||
|
||||
PRInt32 index = curIndex + aDelta;
|
||||
if (index > -1 && index < len)
|
||||
webnav->GotoIndex(index);
|
||||
// We always want to return a NS_OK, since returning errors
|
||||
// from GotoIndex() can lead to exceptions and a possible leak
|
||||
// of history length
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsHistory::Go()
|
||||
{
|
||||
nsAXPCNativeCallContext *ncc = nsnull;
|
||||
nsresult rv = nsContentUtils::XPConnect()->
|
||||
GetCurrentNativeCallContext(&ncc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!ncc)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
PRUint32 argc;
|
||||
ncc->GetArgc(&argc);
|
||||
|
||||
PRInt32 delta = 0;
|
||||
|
||||
if (argc > 0) {
|
||||
jsval *argv = nsnull;
|
||||
|
||||
ncc->GetArgvPtr(&argv);
|
||||
NS_ENSURE_TRUE(argv, NS_ERROR_UNEXPECTED);
|
||||
|
||||
if (!JSVAL_IS_INT(argv[0])) {
|
||||
// Not an index, don't do anything.
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
delta = JSVAL_TO_INT(argv[0]);
|
||||
}
|
||||
|
||||
if (delta == 0) {
|
||||
if (aDelta == 0) {
|
||||
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(mDocShell));
|
||||
|
||||
if (window && window->IsHandlingResizeEvent()) {
|
||||
|
@ -302,7 +247,29 @@ nsHistory::Go()
|
|||
}
|
||||
}
|
||||
|
||||
return Go(delta);
|
||||
nsCOMPtr<nsISHistory> session_history;
|
||||
|
||||
GetSessionHistoryFromDocShell(mDocShell, getter_AddRefs(session_history));
|
||||
NS_ENSURE_TRUE(session_history, NS_ERROR_FAILURE);
|
||||
|
||||
// QI SHistory to nsIWebNavigation
|
||||
nsCOMPtr<nsIWebNavigation> webnav(do_QueryInterface(session_history));
|
||||
NS_ENSURE_TRUE(webnav, NS_ERROR_FAILURE);
|
||||
|
||||
PRInt32 curIndex=-1;
|
||||
PRInt32 len = 0;
|
||||
nsresult rv = session_history->GetIndex(&curIndex);
|
||||
rv = session_history->GetCount(&len);
|
||||
|
||||
PRInt32 index = curIndex + aDelta;
|
||||
if (index > -1 && index < len)
|
||||
webnav->GotoIndex(index);
|
||||
|
||||
// We always want to return a NS_OK, since returning errors
|
||||
// from GotoIndex() can lead to exceptions and a possible leak
|
||||
// of history length
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -38,7 +38,6 @@
|
|||
#define nsHistory_h___
|
||||
|
||||
#include "nsIDOMHistory.h"
|
||||
#include "nsIDOMNSHistory.h"
|
||||
#include "nsISupports.h"
|
||||
#include "nscore.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
@ -47,8 +46,7 @@
|
|||
class nsIDocShell;
|
||||
|
||||
// Script "History" object
|
||||
class nsHistory : public nsIDOMHistory,
|
||||
public nsIDOMNSHistory
|
||||
class nsHistory : public nsIDOMHistory
|
||||
{
|
||||
public:
|
||||
nsHistory(nsIDocShell* aDocShell);
|
||||
|
@ -60,9 +58,6 @@ public:
|
|||
// nsIDOMHistory
|
||||
NS_DECL_NSIDOMHISTORY
|
||||
|
||||
// nsIDOMNSHistory
|
||||
NS_DECL_NSIDOMNSHISTORY
|
||||
|
||||
void SetDocShell(nsIDocShell *aDocShell);
|
||||
|
||||
protected:
|
||||
|
|
|
@ -148,7 +148,6 @@ nsLocation::~nsLocation()
|
|||
|
||||
// QueryInterface implementation for nsLocation
|
||||
NS_INTERFACE_MAP_BEGIN(nsLocation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMNSLocation)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMLocation)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMLocation)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(Location)
|
||||
|
@ -842,40 +841,6 @@ nsLocation::Reload(PRBool aForceget)
|
|||
nsresult rv;
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
|
||||
nsCOMPtr<nsIWebNavigation> webNav(do_QueryInterface(docShell));
|
||||
|
||||
if (webNav) {
|
||||
PRUint32 reloadFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
|
||||
|
||||
if (aForceget) {
|
||||
reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
|
||||
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
|
||||
}
|
||||
rv = webNav->Reload(reloadFlags);
|
||||
if (rv == NS_BINDING_ABORTED) {
|
||||
// This happens when we attempt to reload a POST result and the user says
|
||||
// no at the "do you want to reload?" prompt. Don't propagate this one
|
||||
// back to callers.
|
||||
rv = NS_OK;
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsLocation::Reload()
|
||||
{
|
||||
nsAXPCNativeCallContext *ncc = nsnull;
|
||||
nsresult rv = nsContentUtils::XPConnect()->
|
||||
GetCurrentNativeCallContext(&ncc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!ncc)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
nsCOMPtr<nsIDocShell> docShell(do_QueryReferent(mDocShell));
|
||||
nsCOMPtr<nsPIDOMWindow> window(do_GetInterface(docShell));
|
||||
|
||||
if (window && window->IsHandlingResizeEvent()) {
|
||||
|
@ -898,28 +863,25 @@ nsLocation::Reload()
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
PRBool force_get = PR_FALSE;
|
||||
if (webNav) {
|
||||
PRUint32 reloadFlags = nsIWebNavigation::LOAD_FLAGS_NONE;
|
||||
|
||||
PRUint32 argc;
|
||||
|
||||
ncc->GetArgc(&argc);
|
||||
|
||||
if (argc > 0) {
|
||||
jsval *argv = nsnull;
|
||||
|
||||
ncc->GetArgvPtr(&argv);
|
||||
NS_ENSURE_TRUE(argv, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSContext *cx = nsnull;
|
||||
|
||||
rv = ncc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JS_ValueToBoolean(cx, argv[0], &force_get);
|
||||
if (aForceget) {
|
||||
reloadFlags = nsIWebNavigation::LOAD_FLAGS_BYPASS_CACHE |
|
||||
nsIWebNavigation::LOAD_FLAGS_BYPASS_PROXY;
|
||||
}
|
||||
rv = webNav->Reload(reloadFlags);
|
||||
if (rv == NS_BINDING_ABORTED) {
|
||||
// This happens when we attempt to reload a POST result and the user says
|
||||
// no at the "do you want to reload?" prompt. Don't propagate this one
|
||||
// back to callers.
|
||||
rv = NS_OK;
|
||||
}
|
||||
} else {
|
||||
rv = NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
return Reload(force_get);
|
||||
return rv;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
|
|
|
@ -78,7 +78,6 @@ nsPluginArray::~nsPluginArray()
|
|||
NS_INTERFACE_MAP_BEGIN(nsPluginArray)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMPluginArray)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMPluginArray)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMJSPluginArray)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(PluginArray)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
|
@ -242,41 +241,6 @@ nsPluginArray::Refresh(PRBool aReloadDocuments)
|
|||
return res;
|
||||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsPluginArray::Refresh()
|
||||
{
|
||||
nsAXPCNativeCallContext *ncc = nsnull;
|
||||
nsresult rv = nsContentUtils::XPConnect()->
|
||||
GetCurrentNativeCallContext(&ncc);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
if (!ncc)
|
||||
return NS_ERROR_NOT_AVAILABLE;
|
||||
|
||||
PRBool reload_doc = PR_FALSE;
|
||||
|
||||
PRUint32 argc;
|
||||
|
||||
ncc->GetArgc(&argc);
|
||||
|
||||
if (argc > 0) {
|
||||
jsval *argv = nsnull;
|
||||
|
||||
ncc->GetArgvPtr(&argv);
|
||||
NS_ENSURE_TRUE(argv, NS_ERROR_UNEXPECTED);
|
||||
|
||||
JSContext *cx = nsnull;
|
||||
|
||||
rv = ncc->GetJSContext(&cx);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
JSAutoRequest ar(cx);
|
||||
JS_ValueToBoolean(cx, argv[0], &reload_doc);
|
||||
}
|
||||
|
||||
return Refresh(reload_doc);
|
||||
}
|
||||
|
||||
nsresult
|
||||
nsPluginArray::GetPlugins()
|
||||
{
|
||||
|
|
|
@ -47,8 +47,7 @@ class nsNavigator;
|
|||
class nsIDocShell;
|
||||
class nsIPluginHost;
|
||||
|
||||
class nsPluginArray : public nsIDOMPluginArray,
|
||||
public nsIDOMJSPluginArray
|
||||
class nsPluginArray : public nsIDOMPluginArray
|
||||
{
|
||||
public:
|
||||
nsPluginArray(nsNavigator* navigator, nsIDocShell *aDocShell);
|
||||
|
@ -59,9 +58,6 @@ public:
|
|||
// nsIDOMPluginArray
|
||||
NS_DECL_NSIDOMPLUGINARRAY
|
||||
|
||||
// nsIDOMJSPluginArray
|
||||
NS_DECL_NSIDOMJSPLUGINARRAY
|
||||
|
||||
nsresult GetPluginHost(nsIPluginHost** aPluginHost);
|
||||
|
||||
private:
|
||||
|
|
Загрузка…
Ссылка в новой задаче