зеркало из https://github.com/mozilla/gecko-dev.git
merge m-c tip over to m-i
This commit is contained in:
Коммит
70775ba4c6
|
@ -101,7 +101,6 @@ XPIDLSRCS = \
|
|||
nsIDOMFileReader.idl \
|
||||
nsIDOMFileList.idl \
|
||||
nsIDOMFileException.idl \
|
||||
nsIDOMFileError.idl \
|
||||
nsIDOMFormData.idl \
|
||||
nsIDOMParser.idl \
|
||||
nsIDOMSerializer.idl \
|
||||
|
|
|
@ -43,7 +43,6 @@
|
|||
#include "nsIFile.h"
|
||||
#include "nsIDOMFile.h"
|
||||
#include "nsIDOMFileList.h"
|
||||
#include "nsIDOMFileError.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsIJSNativeInitializer.h"
|
||||
#include "nsIMutable.h"
|
||||
|
@ -53,12 +52,13 @@
|
|||
#include "nsIXMLHttpRequest.h"
|
||||
#include "prmem.h"
|
||||
#include "nsAutoPtr.h"
|
||||
#include "mozilla/dom/indexedDB/FileInfo.h"
|
||||
#include "mozilla/dom/indexedDB/FileManager.h"
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
|
||||
|
||||
#include "mozilla/GuardObjects.h"
|
||||
#include "mozilla/StandardInteger.h"
|
||||
#include "mozilla/dom/DOMError.h"
|
||||
#include "mozilla/dom/indexedDB/FileInfo.h"
|
||||
#include "mozilla/dom/indexedDB/FileManager.h"
|
||||
#include "mozilla/dom/indexedDB/IndexedDatabaseManager.h"
|
||||
|
||||
class nsIFile;
|
||||
class nsIInputStream;
|
||||
|
@ -363,18 +363,6 @@ private:
|
|||
nsCOMArray<nsIDOMFile> mFiles;
|
||||
};
|
||||
|
||||
class nsDOMFileError : public nsIDOMFileError
|
||||
{
|
||||
public:
|
||||
NS_DECL_ISUPPORTS
|
||||
NS_DECL_NSIDOMFILEERROR
|
||||
|
||||
nsDOMFileError(PRUint16 aErrorCode) : mCode(aErrorCode) {}
|
||||
|
||||
private:
|
||||
PRUint16 mCode;
|
||||
};
|
||||
|
||||
class NS_STACK_CLASS nsDOMFileInternalUrlHolder {
|
||||
public:
|
||||
nsDOMFileInternalUrlHolder(nsIDOMBlob* aFile, nsIPrincipal* aPrincipal
|
||||
|
|
|
@ -1,50 +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
|
||||
* Mozilla Corporation
|
||||
* Portions created by the Initial Developer are Copyright (C) 2007
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* 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"
|
||||
|
||||
[scriptable, uuid(4BDAFB64-15E2-49C1-A090-4315A7884A56)]
|
||||
interface nsIDOMFileError : nsISupports
|
||||
{
|
||||
const unsigned short NOT_FOUND_ERR = 1;
|
||||
const unsigned short SECURITY_ERR = 2;
|
||||
const unsigned short ABORT_ERR = 3;
|
||||
const unsigned short NOT_READABLE_ERR = 4;
|
||||
const unsigned short ENCODING_ERR = 5;
|
||||
|
||||
readonly attribute unsigned short code;
|
||||
};
|
|
@ -39,9 +39,9 @@
|
|||
|
||||
interface nsIDOMEventListener;
|
||||
interface nsIDOMBlob;
|
||||
interface nsIDOMFileError;
|
||||
interface nsIDOMDOMError;
|
||||
|
||||
[scriptable, builtinclass, uuid(d158de26-904e-4731-b42c-8b3a4d172703)]
|
||||
[scriptable, builtinclass, uuid(faed1779-b523-4060-8c3b-7199f347b273)]
|
||||
interface nsIDOMFileReader : nsIDOMEventTarget
|
||||
{
|
||||
[implicit_jscontext]
|
||||
|
@ -59,7 +59,7 @@ interface nsIDOMFileReader : nsIDOMEventTarget
|
|||
|
||||
[implicit_jscontext]
|
||||
readonly attribute jsval result;
|
||||
readonly attribute nsIDOMFileError error;
|
||||
readonly attribute nsIDOMDOMError error;
|
||||
|
||||
attribute nsIDOMEventListener onloadstart;
|
||||
attribute nsIDOMEventListener onprogress;
|
||||
|
|
|
@ -119,13 +119,13 @@ FileIOObject::DispatchError(nsresult rv, nsAString& finalEvent)
|
|||
// Set the status attribute, and dispatch the error event
|
||||
switch (rv) {
|
||||
case NS_ERROR_FILE_NOT_FOUND:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::NOT_FOUND_ERR);
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("NotFoundError"));
|
||||
break;
|
||||
case NS_ERROR_FILE_ACCESS_DENIED:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::SECURITY_ERR);
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("SecurityError"));
|
||||
break;
|
||||
default:
|
||||
mError = new nsDOMFileError(nsIDOMFileError::NOT_READABLE_ERR);
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("NotReadableError"));
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -258,14 +258,17 @@ FileIOObject::OnStopRequest(nsIRequest* aRequest, nsISupports* aContext,
|
|||
NS_IMETHODIMP
|
||||
FileIOObject::Abort()
|
||||
{
|
||||
if (mReadyState != 1)
|
||||
if (mReadyState != 1) {
|
||||
// XXX The spec doesn't say this
|
||||
return NS_ERROR_DOM_FILE_ABORT_ERR;
|
||||
}
|
||||
|
||||
ClearProgressEventTimer();
|
||||
|
||||
mReadyState = 2; // There are DONE constants on multiple interfaces,
|
||||
// but they all have value 2.
|
||||
mError = new nsDOMFileError(nsIDOMFileError::ABORT_ERR);
|
||||
// XXX The spec doesn't say this
|
||||
mError = DOMError::CreateWithName(NS_LITERAL_STRING("AbortError"));
|
||||
|
||||
nsString finalEvent;
|
||||
nsresult rv = DoAbort(finalEvent);
|
||||
|
@ -285,7 +288,7 @@ FileIOObject::GetReadyState(PRUint16 *aReadyState)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
FileIOObject::GetError(nsIDOMFileError** aError)
|
||||
FileIOObject::GetError(nsIDOMDOMError** aError)
|
||||
{
|
||||
NS_IF_ADDREF(*aError = mError);
|
||||
return NS_OK;
|
||||
|
|
|
@ -45,9 +45,10 @@
|
|||
#include "nsIDOMFile.h"
|
||||
#include "nsIStreamListener.h"
|
||||
#include "nsITimer.h"
|
||||
|
||||
#include "nsCOMPtr.h"
|
||||
|
||||
#include "mozilla/dom/DOMError.h"
|
||||
|
||||
#define NS_PROGRESS_EVENT_INTERVAL 50
|
||||
|
||||
namespace mozilla {
|
||||
|
@ -69,7 +70,7 @@ public:
|
|||
// Common methods
|
||||
NS_METHOD Abort();
|
||||
NS_METHOD GetReadyState(PRUint16* aReadyState);
|
||||
NS_METHOD GetError(nsIDOMFileError** aError);
|
||||
NS_METHOD GetError(nsIDOMDOMError** aError);
|
||||
|
||||
NS_DECL_AND_IMPL_EVENT_HANDLER(abort);
|
||||
NS_DECL_AND_IMPL_EVENT_HANDLER(error);
|
||||
|
@ -108,7 +109,7 @@ protected:
|
|||
bool mProgressEventWasDelayed;
|
||||
bool mTimerIsActive;
|
||||
|
||||
nsCOMPtr<nsIDOMFileError> mError;
|
||||
nsCOMPtr<nsIDOMDOMError> mError;
|
||||
nsCOMPtr<nsIChannel> mChannel;
|
||||
|
||||
PRUint16 mReadyState;
|
||||
|
|
|
@ -632,27 +632,6 @@ nsDOMFileList::Item(PRUint32 aIndex, nsIDOMFile **aFile)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMFileError implementation
|
||||
|
||||
DOMCI_DATA(FileError, nsDOMFileError)
|
||||
|
||||
NS_INTERFACE_MAP_BEGIN(nsDOMFileError)
|
||||
NS_INTERFACE_MAP_ENTRY_AMBIGUOUS(nsISupports, nsIDOMFileError)
|
||||
NS_INTERFACE_MAP_ENTRY(nsIDOMFileError)
|
||||
NS_DOM_INTERFACE_MAP_ENTRY_CLASSINFO(FileError)
|
||||
NS_INTERFACE_MAP_END
|
||||
|
||||
NS_IMPL_ADDREF(nsDOMFileError)
|
||||
NS_IMPL_RELEASE(nsDOMFileError)
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileError::GetCode(PRUint16* aCode)
|
||||
{
|
||||
*aCode = mCode;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
////////////////////////////////////////////////////////////////////////////
|
||||
// nsDOMFileInternalUrlHolder implementation
|
||||
|
||||
|
|
|
@ -255,7 +255,7 @@ nsDOMFileReader::GetResult(JSContext* aCx, jsval* aResult)
|
|||
}
|
||||
|
||||
NS_IMETHODIMP
|
||||
nsDOMFileReader::GetError(nsIDOMFileError** aError)
|
||||
nsDOMFileReader::GetError(nsIDOMDOMError** aError)
|
||||
{
|
||||
return FileIOObject::GetError(aError);
|
||||
}
|
||||
|
|
|
@ -54,7 +54,6 @@
|
|||
#include "nsIDOMFile.h"
|
||||
#include "nsIDOMFileReader.h"
|
||||
#include "nsIDOMFileList.h"
|
||||
#include "nsIDOMFileError.h"
|
||||
#include "nsIInputStream.h"
|
||||
#include "nsCOMPtr.h"
|
||||
#include "nsIStreamLoader.h"
|
||||
|
|
|
@ -2855,15 +2855,16 @@ nsGenericElement::GetAttributeNS(const nsAString& aNamespaceURI,
|
|||
nsContentUtils::NameSpaceManager()->GetNameSpaceID(aNamespaceURI);
|
||||
|
||||
if (nsid == kNameSpaceID_Unknown) {
|
||||
// Unknown namespace means no attr...
|
||||
|
||||
aReturn.Truncate();
|
||||
|
||||
// Unknown namespace means no attribute.
|
||||
SetDOMStringToNull(aReturn);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsCOMPtr<nsIAtom> name = do_GetAtom(aLocalName);
|
||||
GetAttr(nsid, name, aReturn);
|
||||
bool hasAttr = GetAttr(nsid, name, aReturn);
|
||||
if (!hasAttr) {
|
||||
SetDOMStringToNull(aReturn);
|
||||
}
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
|
|
@ -3,4 +3,5 @@ load 421715-1.html
|
|||
load 553938-1.html
|
||||
load 647480.html
|
||||
load 0px-size-font-667225.html
|
||||
load texImage2D.html
|
||||
load 729116.html
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
<!doctype html>
|
||||
<canvas></canvas>
|
||||
<script>
|
||||
var canvas = document.body.firstChild,
|
||||
gl = canvas.getContext("experimental-webgl");
|
||||
gl.texImage2D(0, 0, 0, 0, 0, { get width() { throw 7 }, get height() { throw 7 }, data: new Uint8ClampedArray(10) });
|
||||
gl.texSubImage2D(0, 0, 0, 0, 0, 0, { get width() { throw 7 }, get height() { throw 7 }, data: new Uint8ClampedArray(10) });
|
||||
</script>
|
|
@ -382,6 +382,133 @@ nsIDOMWebGLRenderingContext_ReadPixels(JSContext *cx, unsigned argc, jsval *vp)
|
|||
}
|
||||
|
||||
|
||||
class CallTexImage2D
|
||||
{
|
||||
private:
|
||||
nsIDOMWebGLRenderingContext* self;
|
||||
WebGLenum target;
|
||||
WebGLint level;
|
||||
WebGLenum internalformat;
|
||||
WebGLenum format;
|
||||
WebGLenum type;
|
||||
|
||||
public:
|
||||
explicit CallTexImage2D(nsIDOMWebGLRenderingContext* aSelf,
|
||||
WebGLenum aTarget,
|
||||
WebGLint aLevel,
|
||||
WebGLenum aInternalformat,
|
||||
WebGLenum aFormat,
|
||||
WebGLenum aType)
|
||||
: self(aSelf)
|
||||
, target(aTarget)
|
||||
, level(aLevel)
|
||||
, internalformat(aInternalformat)
|
||||
, format(aFormat)
|
||||
, type(aType)
|
||||
{}
|
||||
|
||||
nsresult DoCallForImageData(WebGLsizei width, WebGLsizei height,
|
||||
JSObject* pixels)
|
||||
{
|
||||
return self->TexImage2D_imageData(target, level, internalformat, width,
|
||||
height, 0, format, type, pixels);
|
||||
}
|
||||
nsresult DoCallForElement(mozilla::dom::Element* elt)
|
||||
{
|
||||
return self->TexImage2D_dom(target, level, internalformat, format, type,
|
||||
elt);
|
||||
}
|
||||
};
|
||||
|
||||
class CallTexSubImage2D
|
||||
{
|
||||
private:
|
||||
nsIDOMWebGLRenderingContext* self;
|
||||
WebGLenum target;
|
||||
WebGLint level;
|
||||
WebGLint xoffset;
|
||||
WebGLint yoffset;
|
||||
WebGLenum format;
|
||||
WebGLenum type;
|
||||
|
||||
public:
|
||||
explicit CallTexSubImage2D(nsIDOMWebGLRenderingContext* aSelf,
|
||||
WebGLenum aTarget,
|
||||
WebGLint aLevel,
|
||||
WebGLint aXoffset,
|
||||
WebGLint aYoffset,
|
||||
WebGLenum aFormat,
|
||||
WebGLenum aType)
|
||||
|
||||
: self(aSelf)
|
||||
, target(aTarget)
|
||||
, level(aLevel)
|
||||
, xoffset(aXoffset)
|
||||
, yoffset(aYoffset)
|
||||
, format(aFormat)
|
||||
, type(aType)
|
||||
{}
|
||||
|
||||
nsresult DoCallForImageData(WebGLsizei width, WebGLsizei height,
|
||||
JSObject* pixels)
|
||||
{
|
||||
return self->TexSubImage2D_imageData(target, level, xoffset, yoffset,
|
||||
width, height, format, type,
|
||||
pixels);
|
||||
}
|
||||
nsresult DoCallForElement(mozilla::dom::Element* elt)
|
||||
{
|
||||
return self->TexSubImage2D_dom(target, level, xoffset, yoffset, format,
|
||||
type, elt);
|
||||
}
|
||||
};
|
||||
|
||||
template<class T>
|
||||
static bool
|
||||
TexImage2DImageDataOrElement(JSContext* cx, T& self, JS::Value* object)
|
||||
{
|
||||
MOZ_ASSERT(object && object->isObject());
|
||||
|
||||
nsGenericElement* elt;
|
||||
xpc_qsSelfRef eltRef;
|
||||
if (NS_SUCCEEDED(xpc_qsUnwrapArg<nsGenericElement>(
|
||||
cx, *object, &elt, &eltRef.ptr, object))) {
|
||||
nsresult rv = self.DoCallForElement(elt);
|
||||
return NS_SUCCEEDED(rv) || xpc_qsThrow(cx, rv);
|
||||
}
|
||||
|
||||
// Failed to interpret object as an Element, now try to interpret it as
|
||||
// ImageData.
|
||||
JSObject* imageData = &object->toObject();
|
||||
|
||||
jsval js_width, js_height, js_data;
|
||||
if (!JS_GetProperty(cx, imageData, "width", &js_width) ||
|
||||
!JS_GetProperty(cx, imageData, "height", &js_height) ||
|
||||
!JS_GetProperty(cx, imageData, "data", &js_data)) {
|
||||
return false;
|
||||
}
|
||||
if (js_width == JSVAL_VOID ||
|
||||
js_height == JSVAL_VOID ||
|
||||
!js_data.isObject())
|
||||
{
|
||||
return xpc_qsThrow(cx, NS_ERROR_FAILURE);
|
||||
}
|
||||
int32_t int_width, int_height;
|
||||
JSObject *obj_data = JSVAL_TO_OBJECT(js_data);
|
||||
if (!JS_ValueToECMAInt32(cx, js_width, &int_width) ||
|
||||
!JS_ValueToECMAInt32(cx, js_height, &int_height))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
if (!js_IsTypedArray(obj_data))
|
||||
{
|
||||
return xpc_qsThrow(cx, NS_ERROR_FAILURE);
|
||||
}
|
||||
|
||||
nsresult rv = self.DoCallForImageData(int_width, int_height, obj_data);
|
||||
return NS_SUCCEEDED(rv) || xpc_qsThrow(cx, rv);
|
||||
}
|
||||
|
||||
/*
|
||||
* TexImage2D takes:
|
||||
* TexImage2D(uint, int, uint, int, int, int, uint, uint, ArrayBufferView)
|
||||
|
@ -412,65 +539,21 @@ nsIDOMWebGLRenderingContext_TexImage2D(JSContext *cx, unsigned argc, jsval *vp)
|
|||
// arguments common to all cases
|
||||
GET_UINT32_ARG(argv0, 0);
|
||||
GET_INT32_ARG(argv1, 1);
|
||||
GET_UINT32_ARG(argv2, 2);
|
||||
|
||||
if (argc > 5 &&
|
||||
!JSVAL_IS_PRIMITIVE(argv[5]))
|
||||
{
|
||||
if (argc > 5 && !JSVAL_IS_PRIMITIVE(argv[5])) {
|
||||
// implement the variants taking a DOMElement as argv[5]
|
||||
GET_UINT32_ARG(argv2, 2);
|
||||
GET_UINT32_ARG(argv3, 3);
|
||||
GET_UINT32_ARG(argv4, 4);
|
||||
|
||||
nsIDOMElement *elt;
|
||||
xpc_qsSelfRef eltRef;
|
||||
rv = xpc_qsUnwrapArg<nsIDOMElement>(cx, argv[5], &elt, &eltRef.ptr, &argv[5]);
|
||||
if (NS_FAILED(rv)) return JS_FALSE;
|
||||
|
||||
rv = self->TexImage2D_dom(argv0, argv1, argv2, argv3, argv4, elt);
|
||||
|
||||
// NS_ERROR_DOM_SECURITY_ERR indicates we tried to load a cross-domain element, so
|
||||
// bail out immediately, don't try to interprete as ImageData
|
||||
if (rv == NS_ERROR_DOM_SECURITY_ERR) {
|
||||
xpc_qsThrowBadArg(cx, rv, vp, 5);
|
||||
return JS_FALSE;
|
||||
CallTexImage2D selfCaller(self, argv0, argv1, argv2, argv3, argv4);
|
||||
if (!TexImage2DImageDataOrElement(cx, selfCaller, argv + 5)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// failed to interprete argv[5] as a DOMElement, now try to interprete it as ImageData
|
||||
JSObject *argv5 = JSVAL_TO_OBJECT(argv[5]);
|
||||
|
||||
jsval js_width, js_height, js_data;
|
||||
JS_GetProperty(cx, argv5, "width", &js_width);
|
||||
JS_GetProperty(cx, argv5, "height", &js_height);
|
||||
JS_GetProperty(cx, argv5, "data", &js_data);
|
||||
if (js_width == JSVAL_VOID ||
|
||||
js_height == JSVAL_VOID ||
|
||||
!js_data.isObject())
|
||||
{
|
||||
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 5);
|
||||
return JS_FALSE;
|
||||
}
|
||||
int32_t int_width, int_height;
|
||||
JSObject *obj_data = JSVAL_TO_OBJECT(js_data);
|
||||
if (!JS_ValueToECMAInt32(cx, js_width, &int_width) ||
|
||||
!JS_ValueToECMAInt32(cx, js_height, &int_height))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!js_IsTypedArray(obj_data))
|
||||
{
|
||||
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 5);
|
||||
return JS_FALSE;
|
||||
}
|
||||
rv = self->TexImage2D_imageData(argv0, argv1, argv2,
|
||||
int_width, int_height, 0,
|
||||
argv3, argv4, js::TypedArray::getTypedArray(obj_data));
|
||||
}
|
||||
} else if (argc > 8 &&
|
||||
JSVAL_IS_OBJECT(argv[8])) // here, we allow null !
|
||||
{
|
||||
rv = NS_OK;
|
||||
} else if (argc > 8 && JSVAL_IS_OBJECT(argv[8])) {
|
||||
// here, we allow null !
|
||||
// implement the variants taking a buffer/array as argv[8]
|
||||
GET_UINT32_ARG(argv2, 2);
|
||||
GET_INT32_ARG(argv3, 3);
|
||||
GET_INT32_ARG(argv4, 4);
|
||||
GET_INT32_ARG(argv5, 5);
|
||||
|
@ -536,61 +619,17 @@ nsIDOMWebGLRenderingContext_TexSubImage2D(JSContext *cx, unsigned argc, jsval *v
|
|||
GET_INT32_ARG(argv2, 2);
|
||||
GET_INT32_ARG(argv3, 3);
|
||||
|
||||
if (argc > 6 &&
|
||||
!JSVAL_IS_PRIMITIVE(argv[6]))
|
||||
{
|
||||
// implement the variants taking a DOMElement as argv[6]
|
||||
if (argc > 6 && !JSVAL_IS_PRIMITIVE(argv[6])) {
|
||||
// implement the variants taking a DOMElement or an ImageData as argv[6]
|
||||
GET_UINT32_ARG(argv4, 4);
|
||||
GET_UINT32_ARG(argv5, 5);
|
||||
|
||||
nsIDOMElement *elt;
|
||||
xpc_qsSelfRef eltRef;
|
||||
rv = xpc_qsUnwrapArg<nsIDOMElement>(cx, argv[6], &elt, &eltRef.ptr, &argv[6]);
|
||||
if (NS_FAILED(rv)) return JS_FALSE;
|
||||
|
||||
rv = self->TexSubImage2D_dom(argv0, argv1, argv2, argv3, argv4, argv5, elt);
|
||||
|
||||
// NS_ERROR_DOM_SECURITY_ERR indicates we tried to load a cross-domain element, so
|
||||
// bail out immediately, don't try to interprete as ImageData
|
||||
if (rv == NS_ERROR_DOM_SECURITY_ERR) {
|
||||
xpc_qsThrowBadArg(cx, rv, vp, 6);
|
||||
return JS_FALSE;
|
||||
CallTexSubImage2D selfCaller(self, argv0, argv1, argv2, argv3, argv4, argv5);
|
||||
if (!TexImage2DImageDataOrElement(cx, selfCaller, argv + 6)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
// failed to interprete argv[6] as a DOMElement, now try to interprete it as ImageData
|
||||
JSObject *argv6 = JSVAL_TO_OBJECT(argv[6]);
|
||||
jsval js_width, js_height, js_data;
|
||||
JS_GetProperty(cx, argv6, "width", &js_width);
|
||||
JS_GetProperty(cx, argv6, "height", &js_height);
|
||||
JS_GetProperty(cx, argv6, "data", &js_data);
|
||||
if (js_width == JSVAL_VOID ||
|
||||
js_height == JSVAL_VOID ||
|
||||
!js_data.isObject())
|
||||
{
|
||||
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6);
|
||||
return JS_FALSE;
|
||||
}
|
||||
int32_t int_width, int_height;
|
||||
JSObject *obj_data = JSVAL_TO_OBJECT(js_data);
|
||||
if (!JS_ValueToECMAInt32(cx, js_width, &int_width) ||
|
||||
!JS_ValueToECMAInt32(cx, js_height, &int_height))
|
||||
{
|
||||
return JS_FALSE;
|
||||
}
|
||||
if (!js_IsTypedArray(obj_data))
|
||||
{
|
||||
xpc_qsThrowBadArg(cx, NS_ERROR_FAILURE, vp, 6);
|
||||
return JS_FALSE;
|
||||
}
|
||||
rv = self->TexSubImage2D_imageData(argv0, argv1, argv2, argv3,
|
||||
int_width, int_height,
|
||||
argv4, argv5,
|
||||
js::TypedArray::getTypedArray(obj_data));
|
||||
}
|
||||
} else if (argc > 8 &&
|
||||
!JSVAL_IS_PRIMITIVE(argv[8]))
|
||||
{
|
||||
rv = NS_OK;
|
||||
} else if (argc > 8 && !JSVAL_IS_PRIMITIVE(argv[8])) {
|
||||
// implement the variants taking a buffer/array as argv[8]
|
||||
GET_INT32_ARG(argv4, 4);
|
||||
GET_INT32_ARG(argv5, 5);
|
||||
|
|
|
@ -815,7 +815,7 @@ protected:
|
|||
int dstFormat, bool dstPremultiplied,
|
||||
size_t dstTexelSize);
|
||||
|
||||
nsresult DOMElementToImageSurface(nsIDOMElement *imageOrCanvas,
|
||||
nsresult DOMElementToImageSurface(dom::Element* imageOrCanvas,
|
||||
gfxImageSurface **imageOut,
|
||||
int *format);
|
||||
|
||||
|
|
|
@ -70,6 +70,7 @@
|
|||
#endif
|
||||
|
||||
using namespace mozilla;
|
||||
using namespace mozilla::dom;
|
||||
|
||||
static bool BaseTypeAndSizeFromUniformType(WebGLenum uType, WebGLenum *baseType, WebGLint *unitSize);
|
||||
static WebGLenum InternalFormatForFormatAndType(WebGLenum format, WebGLenum type, bool isGLES2);
|
||||
|
@ -3966,11 +3967,10 @@ WebGLContext::ConvertImage(size_t width, size_t height, size_t srcStride, size_t
|
|||
}
|
||||
|
||||
nsresult
|
||||
WebGLContext::DOMElementToImageSurface(nsIDOMElement *imageOrCanvas,
|
||||
WebGLContext::DOMElementToImageSurface(Element* imageOrCanvas,
|
||||
gfxImageSurface **imageOut, int *format)
|
||||
{
|
||||
nsCOMPtr<nsIContent> content = do_QueryInterface(imageOrCanvas);
|
||||
if (!content) {
|
||||
if (!imageOrCanvas) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
|
@ -3984,7 +3984,7 @@ WebGLContext::DOMElementToImageSurface(nsIDOMElement *imageOrCanvas,
|
|||
flags |= nsLayoutUtils::SFE_NO_PREMULTIPLY_ALPHA;
|
||||
|
||||
nsLayoutUtils::SurfaceFromElementResult res =
|
||||
nsLayoutUtils::SurfaceFromElement(content->AsElement(), flags);
|
||||
nsLayoutUtils::SurfaceFromElement(imageOrCanvas, flags);
|
||||
if (!res.mSurface)
|
||||
return NS_ERROR_FAILURE;
|
||||
if (res.mSurface->GetType() != gfxASurface::SurfaceTypeImage) {
|
||||
|
@ -4016,7 +4016,7 @@ WebGLContext::DOMElementToImageSurface(nsIDOMElement *imageOrCanvas,
|
|||
// part 2: if the DOM element is a canvas, check that it's not write-only.
|
||||
// That would indicate a tainted canvas, i.e. a canvas that could contain
|
||||
// cross-domain image data.
|
||||
if (nsHTMLCanvasElement* canvas = nsHTMLCanvasElement::FromContent(content)) {
|
||||
if (nsHTMLCanvasElement* canvas = nsHTMLCanvasElement::FromContent(imageOrCanvas)) {
|
||||
if (canvas->IsWriteOnly()) {
|
||||
LogMessageIfVerbose("The canvas used as source for texImage2D here is tainted (write-only). It is forbidden "
|
||||
"to load a WebGL texture from a tainted canvas. A Canvas becomes tainted for example "
|
||||
|
@ -5082,7 +5082,7 @@ WebGLContext::TexImage2D_imageData(WebGLenum target, WebGLint level, WebGLenum i
|
|||
|
||||
NS_IMETHODIMP
|
||||
WebGLContext::TexImage2D_dom(WebGLenum target, WebGLint level, WebGLenum internalformat,
|
||||
WebGLenum format, GLenum type, nsIDOMElement *elt)
|
||||
WebGLenum format, GLenum type, Element* elt)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
return NS_OK;
|
||||
|
@ -5272,7 +5272,7 @@ NS_IMETHODIMP
|
|||
WebGLContext::TexSubImage2D_dom(WebGLenum target, WebGLint level,
|
||||
WebGLint xoffset, WebGLint yoffset,
|
||||
WebGLenum format, WebGLenum type,
|
||||
nsIDOMElement *elt)
|
||||
Element *elt)
|
||||
{
|
||||
if (!IsContextStable())
|
||||
return NS_OK;
|
||||
|
|
|
@ -7591,7 +7591,7 @@ ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
|
|||
<!-- [[[ test_2d.imageData.create.type.html ]]] -->
|
||||
|
||||
<p>Canvas test: 2d.imageData.create.type - bug 433004</p>
|
||||
<!-- Testing: createImageData() returns an ImageData object containing a CanvasPixelArray object -->
|
||||
<!-- Testing: createImageData() returns an ImageData object containing a Uint8ClampedArray object -->
|
||||
<canvas id="c261" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<script>
|
||||
|
||||
|
@ -7604,12 +7604,12 @@ var _thrown_outer = false;
|
|||
try {
|
||||
|
||||
todo(window.ImageData !== undefined, "window.ImageData !== undefined");
|
||||
todo(window.CanvasPixelArray !== undefined, "window.CanvasPixelArray !== undefined");
|
||||
ok(window.Uint8ClampedArray !== undefined, "window.Uint8ClampedArray !== undefined");
|
||||
window.ImageData.prototype.thisImplementsImageData = true;
|
||||
window.CanvasPixelArray.prototype.thisImplementsCanvasPixelArray = true;
|
||||
window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true;
|
||||
var imgdata = ctx.createImageData(1, 1);
|
||||
ok(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData");
|
||||
ok(imgdata.data.thisImplementsCanvasPixelArray, "imgdata.data.thisImplementsCanvasPixelArray");
|
||||
ok(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray");
|
||||
|
||||
} catch (e) {
|
||||
_thrown_outer = true;
|
||||
|
@ -7623,7 +7623,7 @@ todo(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
|
|||
<!-- [[[ test_2d.imageData.create1.type.html ]]] -->
|
||||
|
||||
<p>Canvas test: 2d.imageData.create1.type - bug 630040</p>
|
||||
<!-- Testing: createImageData(imgdata) returns an ImageData object containing a CanvasPixelArray object -->
|
||||
<!-- Testing: createImageData(imgdata) returns an ImageData object containing a Uint8ClampedArray object -->
|
||||
<canvas id="c261a" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<script>
|
||||
|
||||
|
@ -7636,12 +7636,12 @@ var _thrown_outer = false;
|
|||
try {
|
||||
|
||||
todo(window.ImageData !== undefined, "window.ImageData !== undefined");
|
||||
todo(window.CanvasPixelArray !== undefined, "window.CanvasPixelArray !== undefined");
|
||||
ok(window.Uint8ClampedArray !== undefined, "window.Uint8ClampedArray !== undefined");
|
||||
window.ImageData.prototype.thisImplementsImageData = true;
|
||||
window.CanvasPixelArray.prototype.thisImplementsCanvasPixelArray = true;
|
||||
window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true;
|
||||
var imgdata = ctx.createImageData(ctx.createImageData(1, 1));
|
||||
todo(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData");
|
||||
todo(imgdata.data.thisImplementsCanvasPixelArray, "imgdata.data.thisImplementsCanvasPixelArray");
|
||||
ok(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray");
|
||||
|
||||
} catch (e) {
|
||||
_thrown_outer = true;
|
||||
|
@ -8229,7 +8229,7 @@ ok(!_thrown_outer, ctx.canvas.id + ' should not throw exception');
|
|||
<!-- [[[ test_2d.imageData.get.type.html ]]] -->
|
||||
|
||||
<p>Canvas test: 2d.imageData.get.type</p>
|
||||
<!-- Testing: getImageData() returns an ImageData object containing a CanvasPixelArray object -->
|
||||
<!-- Testing: getImageData() returns an ImageData object containing a Uint8ClampedArray object -->
|
||||
<canvas id="c276" width="100" height="50"><p class="fallback">FAIL (fallback content)</p></canvas>
|
||||
<script>
|
||||
|
||||
|
@ -8242,12 +8242,12 @@ var _thrown_outer = false;
|
|||
try {
|
||||
|
||||
todo(window.ImageData !== undefined, "window.ImageData !== undefined");
|
||||
todo(window.CanvasPixelArray !== undefined, "window.CanvasPixelArray !== undefined");
|
||||
ok(window.Uint8ClampedArray !== undefined, "window.Uint8ClampedArray !== undefined");
|
||||
window.ImageData.prototype.thisImplementsImageData = true;
|
||||
window.CanvasPixelArray.prototype.thisImplementsCanvasPixelArray = true;
|
||||
window.Uint8ClampedArray.prototype.thisImplementsUint8ClampedArray = true;
|
||||
var imgdata = ctx.getImageData(0, 0, 1, 1);
|
||||
ok(imgdata.thisImplementsImageData, "imgdata.thisImplementsImageData");
|
||||
ok(imgdata.data.thisImplementsCanvasPixelArray, "imgdata.data.thisImplementsCanvasPixelArray");
|
||||
ok(imgdata.data.thisImplementsUint8ClampedArray, "imgdata.data.thisImplementsUint8ClampedArray");
|
||||
|
||||
} catch (e) {
|
||||
_thrown_outer = true;
|
||||
|
|
|
@ -228,23 +228,6 @@ txResultRecycler::getNodeSet(const txXPathNode& aNode, txAExprResult** aResult)
|
|||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
txResultRecycler::getNodeSet(const txXPathNode& aNode, txNodeSet** aResult)
|
||||
{
|
||||
if (mNodeSetResults.isEmpty()) {
|
||||
*aResult = new txNodeSet(aNode, this);
|
||||
NS_ENSURE_TRUE(*aResult, NS_ERROR_OUT_OF_MEMORY);
|
||||
}
|
||||
else {
|
||||
*aResult = static_cast<txNodeSet*>(mNodeSetResults.pop());
|
||||
(*aResult)->append(aNode);
|
||||
(*aResult)->mRecycler = this;
|
||||
}
|
||||
NS_ADDREF(*aResult);
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
nsresult
|
||||
txResultRecycler::getNumberResult(double aValue, txAExprResult** aResult)
|
||||
{
|
||||
|
|
|
@ -86,7 +86,6 @@ public:
|
|||
nsresult getNodeSet(txNodeSet** aResult);
|
||||
nsresult getNodeSet(txNodeSet* aNodeSet, txNodeSet** aResult);
|
||||
nsresult getNodeSet(const txXPathNode& aNode, txAExprResult** aResult);
|
||||
nsresult getNodeSet(const txXPathNode& aNode, txNodeSet** aResult);
|
||||
nsresult getNumberResult(double aValue, txAExprResult** aResult);
|
||||
|
||||
/**
|
||||
|
|
|
@ -788,11 +788,7 @@ nsXULPDGlobalObject::ClearGlobalObjectOwner()
|
|||
if (this != nsXULPrototypeDocument::gSystemGlobal)
|
||||
mCachedPrincipal = mGlobalObjectOwner->DocumentPrincipal();
|
||||
|
||||
if (mContext) {
|
||||
mContext->FinalizeContext();
|
||||
mContext = NULL;
|
||||
}
|
||||
|
||||
mContext = NULL;
|
||||
mGlobalObjectOwner = NULL;
|
||||
}
|
||||
|
||||
|
|
|
@ -452,7 +452,6 @@
|
|||
#include "nsDOMFile.h"
|
||||
#include "nsDOMFileReader.h"
|
||||
#include "nsIDOMFileException.h"
|
||||
#include "nsIDOMFileError.h"
|
||||
#include "nsIDOMFormData.h"
|
||||
|
||||
#include "nsIDOMDOMStringMap.h"
|
||||
|
@ -1394,8 +1393,6 @@ static nsDOMClassInfoData sClassInfoData[] = {
|
|||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(FileException, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(FileError, nsDOMGenericSH,
|
||||
DOM_DEFAULT_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(FileReader, nsEventTargetSH,
|
||||
EVENTTARGET_SCRIPTABLE_FLAGS)
|
||||
NS_DEFINE_CLASSINFO_DATA(MozURLProperty, nsDOMGenericSH,
|
||||
|
@ -3964,10 +3961,6 @@ nsDOMClassInfo::Init()
|
|||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileList)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(FileError, nsIDOMFileError)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMFileError)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
||||
DOM_CLASSINFO_MAP_BEGIN(Blob, nsIDOMBlob)
|
||||
DOM_CLASSINFO_MAP_ENTRY(nsIDOMBlob)
|
||||
DOM_CLASSINFO_MAP_END
|
||||
|
|
|
@ -402,7 +402,6 @@ DOMCI_CLASS(FileList)
|
|||
DOMCI_CLASS(Blob)
|
||||
DOMCI_CLASS(File)
|
||||
DOMCI_CLASS(FileException)
|
||||
DOMCI_CLASS(FileError)
|
||||
DOMCI_CLASS(FileReader)
|
||||
DOMCI_CLASS(MozURLProperty)
|
||||
DOMCI_CLASS(MozBlobBuilder)
|
||||
|
|
|
@ -5,6 +5,8 @@
|
|||
#include "jsapi.h"
|
||||
#include "nsIScriptContext.h"
|
||||
|
||||
class nsIJSArgArray;
|
||||
|
||||
// seems like overkill for just this 1 function - but let's see what else
|
||||
// falls out first.
|
||||
inline nsIScriptContext *
|
||||
|
@ -50,6 +52,6 @@ GetScriptContextPrincipalFromJSContext(JSContext *cx)
|
|||
// rooted, but all items remain NULL. This presumably means the caller will
|
||||
// then QI us for nsIJSArgArray, and set our array elements.
|
||||
nsresult NS_CreateJSArgv(JSContext *aContext, PRUint32 aArgc, void *aArgv,
|
||||
nsIArray **aArray);
|
||||
nsIJSArgArray **aArray);
|
||||
|
||||
#endif // nsDOMJSUtils_h__
|
||||
|
|
|
@ -2402,7 +2402,6 @@ nsGlobalWindow::SetDocShell(nsIDocShell* aDocShell)
|
|||
|
||||
if (mContext) {
|
||||
mContext->GC(js::gcreason::SET_DOC_SHELL);
|
||||
mContext->FinalizeContext();
|
||||
mContext = nsnull;
|
||||
}
|
||||
|
||||
|
@ -5932,7 +5931,7 @@ nsGlobalWindow::OpenDialog(const nsAString& aUrl, const nsAString& aName,
|
|||
|
||||
// Strip the url, name and options from the args seen by scripts.
|
||||
PRUint32 argOffset = argc < 3 ? argc : 3;
|
||||
nsCOMPtr<nsIArray> argvArray;
|
||||
nsCOMPtr<nsIJSArgArray> argvArray;
|
||||
rv = NS_CreateJSArgv(cx, argc - argOffset, argv + argOffset,
|
||||
getter_AddRefs(argvArray));
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
@ -6532,7 +6531,6 @@ nsGlobalWindow::ForceClose()
|
|||
nsresult
|
||||
nsGlobalWindow::FinalClose()
|
||||
{
|
||||
nsresult rv;
|
||||
// Flag that we were closed.
|
||||
mIsClosed = true;
|
||||
|
||||
|
@ -6549,38 +6547,24 @@ nsGlobalWindow::FinalClose()
|
|||
nsIScriptContext *currentCX = nsJSUtils::GetDynamicScriptContext(cx);
|
||||
|
||||
if (currentCX && currentCX == GetContextInternal()) {
|
||||
// We ignore the return value here. If setting the termination function
|
||||
// fails, it's better to fail to close the window than it is to crash
|
||||
// (which is what would tend to happen if we did this synchronously
|
||||
// here).
|
||||
rv = currentCX->SetTerminationFunction(CloseWindow,
|
||||
static_cast<nsIDOMWindow *>
|
||||
(this));
|
||||
if (NS_SUCCEEDED(rv)) {
|
||||
mHavePendingClose = true;
|
||||
}
|
||||
currentCX->SetTerminationFunction(CloseWindow, this);
|
||||
mHavePendingClose = true;
|
||||
return NS_OK;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// We may have plugins on the page that have issued this close from their
|
||||
// event loop and because we currently destroy the plugin window with
|
||||
// frames, we crash. So, if we are called from Javascript, post an event
|
||||
// to really close the window.
|
||||
rv = NS_ERROR_FAILURE;
|
||||
if (!nsContentUtils::IsCallerChrome()) {
|
||||
rv = nsCloseEvent::PostCloseEvent(this);
|
||||
}
|
||||
|
||||
if (NS_FAILED(rv)) {
|
||||
if (nsContentUtils::IsCallerChrome() ||
|
||||
NS_FAILED(nsCloseEvent::PostCloseEvent(this))) {
|
||||
ReallyCloseWindow();
|
||||
rv = NS_OK;
|
||||
} else {
|
||||
mHavePendingClose = true;
|
||||
}
|
||||
|
||||
return rv;
|
||||
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
||||
|
@ -8867,8 +8851,7 @@ nsGlobalWindow::OpenInternal(const nsAString& aUrl, const nsAString& aName,
|
|||
if (mContext == GetScriptContextFromJSContext(aJSCallerContext)) {
|
||||
mBlockScriptedClosingFlag = true;
|
||||
mContext->SetTerminationFunction(CloseBlockScriptTerminationFunc,
|
||||
static_cast<nsPIDOMWindow*>
|
||||
(this));
|
||||
this);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -56,6 +56,7 @@ class nsIObjectInputStream;
|
|||
class nsIObjectOutputStream;
|
||||
template<class> class nsScriptObjectHolder;
|
||||
class nsIScriptObjectPrincipal;
|
||||
class nsIDOMWindow;
|
||||
|
||||
typedef void (*nsScriptTerminationFunc)(nsISupports* aRef);
|
||||
|
||||
|
@ -75,8 +76,8 @@ NS_DEFINE_STATIC_IID_ACCESSOR(nsIScriptContextPrincipal,
|
|||
NS_ISCRIPTCONTEXTPRINCIPAL_IID)
|
||||
|
||||
#define NS_ISCRIPTCONTEXT_IID \
|
||||
{ 0x6d69fbee, 0x0723, 0x48f5, \
|
||||
{ 0x82, 0x48, 0xcd, 0xcf, 0x88, 0xac, 0x25, 0x74 } }
|
||||
{ 0xdfaea249, 0xaaad, 0x48bd, \
|
||||
{ 0xb8, 0x04, 0x92, 0xad, 0x30, 0x88, 0xd0, 0xc6 } }
|
||||
|
||||
/* This MUST match JSVERSION_DEFAULT. This version stuff if we don't
|
||||
know what language we have is a little silly... */
|
||||
|
@ -344,11 +345,6 @@ public:
|
|||
*/
|
||||
virtual bool IsContextInitialized() = 0;
|
||||
|
||||
/**
|
||||
* Called as the global object discards its reference to the context.
|
||||
*/
|
||||
virtual void FinalizeContext() = 0;
|
||||
|
||||
/**
|
||||
* For garbage collected systems, do a synchronous collection pass.
|
||||
* May be a no-op on other systems
|
||||
|
@ -389,8 +385,8 @@ public:
|
|||
*
|
||||
* @throws NS_ERROR_OUT_OF_MEMORY if that happens
|
||||
*/
|
||||
virtual nsresult SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
||||
nsISupports* aRef) = 0;
|
||||
virtual void SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
||||
nsIDOMWindow* aRef) = 0;
|
||||
|
||||
/**
|
||||
* Called to disable/enable script execution in this context.
|
||||
|
@ -400,7 +396,7 @@ public:
|
|||
|
||||
// SetProperty is suspect and jst believes should not be needed. Currenly
|
||||
// used only for "arguments".
|
||||
virtual nsresult SetProperty(void *aTarget, const char *aPropName, nsISupports *aVal) = 0;
|
||||
virtual nsresult SetProperty(JSObject* aTarget, const char* aPropName, nsISupports* aVal) = 0;
|
||||
/**
|
||||
* Called to set/get information if the script context is
|
||||
* currently processing a script tag
|
||||
|
|
|
@ -2293,7 +2293,7 @@ nsJSContext::InitializeExternalClasses()
|
|||
}
|
||||
|
||||
nsresult
|
||||
nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArgs)
|
||||
nsJSContext::SetProperty(JSObject* aTarget, const char* aPropName, nsISupports* aArgs)
|
||||
{
|
||||
PRUint32 argc;
|
||||
jsval *argv = nsnull;
|
||||
|
@ -2302,8 +2302,8 @@ nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArg
|
|||
|
||||
Maybe<nsRootedJSValueArray> tempStorage;
|
||||
|
||||
nsresult rv;
|
||||
rv = ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc, &argv, tempStorage);
|
||||
nsresult rv =
|
||||
ConvertSupportsTojsvals(aArgs, GetNativeGlobal(), &argc, &argv, tempStorage);
|
||||
NS_ENSURE_SUCCESS(rv, rv);
|
||||
|
||||
jsval vargs;
|
||||
|
@ -2327,11 +2327,9 @@ nsJSContext::SetProperty(void *aTarget, const char *aPropName, nsISupports *aArg
|
|||
|
||||
// Make sure to use JS_DefineProperty here so that we can override
|
||||
// readonly XPConnect properties here as well (read dialogArguments).
|
||||
rv = ::JS_DefineProperty(mContext, reinterpret_cast<JSObject *>(aTarget),
|
||||
aPropName, vargs, nsnull, nsnull, 0) ?
|
||||
NS_OK : NS_ERROR_FAILURE;
|
||||
|
||||
return rv;
|
||||
return JS_DefineProperty(mContext, aTarget, aPropName, vargs, NULL, NULL, 0)
|
||||
? NS_OK
|
||||
: NS_ERROR_FAILURE;
|
||||
}
|
||||
|
||||
nsresult
|
||||
|
@ -2360,7 +2358,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
|
|||
|
||||
if (!aArgs)
|
||||
return NS_OK;
|
||||
PRUint32 argCtr, argCount;
|
||||
PRUint32 argCount;
|
||||
// This general purpose function may need to convert an arg array
|
||||
// (window.arguments, event-handler args) and a generic property.
|
||||
nsCOMPtr<nsIArray> argsArray(do_QueryInterface(aArgs));
|
||||
|
@ -2381,7 +2379,7 @@ nsJSContext::ConvertSupportsTojsvals(nsISupports *aArgs,
|
|||
jsval *argv = aTempStorage.ref().Elements();
|
||||
|
||||
if (argsArray) {
|
||||
for (argCtr = 0; argCtr < argCount && NS_SUCCEEDED(rv); argCtr++) {
|
||||
for (PRUint32 argCtr = 0; argCtr < argCount && NS_SUCCEEDED(rv); argCtr++) {
|
||||
nsCOMPtr<nsISupports> arg;
|
||||
jsval *thisval = argv + argCtr;
|
||||
argsArray->QueryElementAt(argCtr, NS_GET_IID(nsISupports),
|
||||
|
@ -2975,12 +2973,6 @@ nsJSContext::IsContextInitialized()
|
|||
return mIsInitialized;
|
||||
}
|
||||
|
||||
void
|
||||
nsJSContext::FinalizeContext()
|
||||
{
|
||||
;
|
||||
}
|
||||
|
||||
void
|
||||
nsJSContext::ScriptEvaluated(bool aTerminated)
|
||||
{
|
||||
|
@ -3006,20 +2998,15 @@ nsJSContext::ScriptEvaluated(bool aTerminated)
|
|||
}
|
||||
}
|
||||
|
||||
nsresult
|
||||
void
|
||||
nsJSContext::SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
||||
nsISupports* aRef)
|
||||
nsIDOMWindow* aRef)
|
||||
{
|
||||
NS_PRECONDITION(GetExecutingScript(), "should be executing script");
|
||||
|
||||
nsJSContext::TerminationFuncClosure* newClosure =
|
||||
new nsJSContext::TerminationFuncClosure(aFunc, aRef, mTerminations);
|
||||
if (!newClosure) {
|
||||
return NS_ERROR_OUT_OF_MEMORY;
|
||||
}
|
||||
|
||||
mTerminations = newClosure;
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
bool
|
||||
|
@ -3922,7 +3909,7 @@ nsresult NS_CreateJSRuntime(nsIScriptRuntime **aRuntime)
|
|||
// to/from nsISupports.
|
||||
// When consumed by non-JS (eg, another script language), conversion is done
|
||||
// on-the-fly.
|
||||
class nsJSArgArray : public nsIJSArgArray, public nsIArray {
|
||||
class nsJSArgArray : public nsIJSArgArray {
|
||||
public:
|
||||
nsJSArgArray(JSContext *aContext, PRUint32 argc, jsval *argv, nsresult *prv);
|
||||
~nsJSArgArray();
|
||||
|
@ -4062,7 +4049,7 @@ NS_IMETHODIMP nsJSArgArray::Enumerate(nsISimpleEnumerator **_retval)
|
|||
|
||||
// The factory function
|
||||
nsresult NS_CreateJSArgv(JSContext *aContext, PRUint32 argc, void *argv,
|
||||
nsIArray **aArray)
|
||||
nsIJSArgArray **aArray)
|
||||
{
|
||||
nsresult rv;
|
||||
nsJSArgArray *ret = new nsJSArgArray(aContext, argc,
|
||||
|
|
|
@ -47,6 +47,7 @@
|
|||
#include "prtime.h"
|
||||
#include "nsCycleCollectionParticipant.h"
|
||||
#include "nsIXPConnect.h"
|
||||
#include "nsIArray.h"
|
||||
|
||||
class nsIXPConnectJSObjectHolder;
|
||||
class nsRootedJSValueArray;
|
||||
|
@ -143,15 +144,14 @@ public:
|
|||
virtual nsresult SetOuterObject(JSObject* aOuterObject);
|
||||
virtual nsresult InitOuterWindow();
|
||||
virtual bool IsContextInitialized();
|
||||
virtual void FinalizeContext();
|
||||
|
||||
virtual void ScriptEvaluated(bool aTerminated);
|
||||
virtual nsresult SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
||||
nsISupports* aRef);
|
||||
virtual void SetTerminationFunction(nsScriptTerminationFunc aFunc,
|
||||
nsIDOMWindow* aRef);
|
||||
virtual bool GetScriptsEnabled();
|
||||
virtual void SetScriptsEnabled(bool aEnabled, bool aFireTimeouts);
|
||||
|
||||
virtual nsresult SetProperty(void *aTarget, const char *aPropName, nsISupports *aVal);
|
||||
virtual nsresult SetProperty(JSObject* aTarget, const char* aPropName, nsISupports* aVal);
|
||||
|
||||
virtual bool GetProcessingScriptTag();
|
||||
virtual void SetProcessingScriptTag(bool aResult);
|
||||
|
@ -348,11 +348,10 @@ public:
|
|||
// nsISupports conversion. If this interface is not supported, the object will
|
||||
// be queried for nsIArray, and everything converted via xpcom objects.
|
||||
#define NS_IJSARGARRAY_IID \
|
||||
{ /*{E96FB2AE-CB4F-44a0-81F8-D91C80AFE9A3} */ \
|
||||
0xe96fb2ae, 0xcb4f, 0x44a0, \
|
||||
{ 0x81, 0xf8, 0xd9, 0x1c, 0x80, 0xaf, 0xe9, 0xa3 } }
|
||||
{ 0xb6acdac8, 0xf5c6, 0x432c, \
|
||||
{ 0xa8, 0x6e, 0x33, 0xee, 0xb1, 0xb0, 0xcd, 0xdc } }
|
||||
|
||||
class nsIJSArgArray: public nsISupports
|
||||
class nsIJSArgArray : public nsIArray
|
||||
{
|
||||
public:
|
||||
NS_DECLARE_STATIC_IID_ACCESSOR(NS_IJSARGARRAY_IID)
|
||||
|
|
|
@ -101,7 +101,7 @@ private:
|
|||
nsCString mFileName;
|
||||
PRUint32 mLineNo;
|
||||
PRUint32 mVersion;
|
||||
nsCOMPtr<nsIArray> mArgv;
|
||||
nsCOMPtr<nsIJSArgArray> mArgv;
|
||||
|
||||
// The JS expression to evaluate or function to call, if !mExpr
|
||||
JSFlatString *mExpr;
|
||||
|
@ -326,7 +326,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
|
|||
// to setTimeout or setInterval; the first two are our callback
|
||||
// and the delay, so only arguments after that need to go in our
|
||||
// array.
|
||||
nsCOMPtr<nsIArray> array;
|
||||
nsCOMPtr<nsIJSArgArray> array;
|
||||
// NS_MAX(argc - 2, 0) wouldn't work right because argc is unsigned.
|
||||
rv = NS_CreateJSArgv(cx, NS_MAX(argc, 2u) - 2, nsnull,
|
||||
getter_AddRefs(array));
|
||||
|
@ -336,8 +336,7 @@ nsJSScriptTimeoutHandler::Init(nsGlobalWindow *aWindow, bool *aIsInterval,
|
|||
|
||||
PRUint32 dummy;
|
||||
jsval *jsargv = nsnull;
|
||||
nsCOMPtr<nsIJSArgArray> jsarray(do_QueryInterface(array));
|
||||
jsarray->GetArgs(&dummy, reinterpret_cast<void **>(&jsargv));
|
||||
array->GetArgs(&dummy, reinterpret_cast<void **>(&jsargv));
|
||||
|
||||
// jsargv might be null if we have argc <= 2
|
||||
if (jsargv) {
|
||||
|
|
|
@ -59,16 +59,18 @@ typedef float WebGLclampf;
|
|||
// for jsval
|
||||
#include "jsapi.h"
|
||||
|
||||
namespace js {
|
||||
struct ArrayBuffer;
|
||||
struct TypedArray;
|
||||
}
|
||||
namespace mozilla {
|
||||
namespace dom {
|
||||
class Element;
|
||||
} // namespace dom
|
||||
} // namespace mozilla
|
||||
|
||||
/* Avoid conflict with WinAPI */
|
||||
#undef NO_ERROR
|
||||
%}
|
||||
|
||||
[ptr] native WebGLJSObjectPtr (JSObject);
|
||||
[ptr] native Element (mozilla::dom::Element);
|
||||
|
||||
//
|
||||
// OpenGL object wrappers
|
||||
|
@ -175,7 +177,7 @@ interface nsIWebGLExtensionTextureFilterAnisotropic : nsIWebGLExtension
|
|||
const WebGLenum MAX_TEXTURE_MAX_ANISOTROPY_EXT = 0x84FF;
|
||||
};
|
||||
|
||||
[scriptable, builtinclass, uuid(f000afac-11b3-4c06-a35f-8db411f1cf54)]
|
||||
[scriptable, builtinclass, uuid(020474b1-2d3f-403b-b85d-11d9082ccd92)]
|
||||
interface nsIDOMWebGLRenderingContext : nsISupports
|
||||
{
|
||||
//
|
||||
|
@ -786,7 +788,7 @@ interface nsIDOMWebGLRenderingContext : nsISupports
|
|||
|
||||
// HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
|
||||
[noscript] void texImage2D_dom(in WebGLenum target, in WebGLint level, in WebGLenum internalformat,
|
||||
in WebGLenum format, in WebGLenum type, in nsIDOMElement element);
|
||||
in WebGLenum format, in WebGLenum type, in Element element);
|
||||
|
||||
void texSubImage2D([optional] in long dummy);
|
||||
[noscript] void texSubImage2D_array(in WebGLenum target, in WebGLint level,
|
||||
|
@ -798,7 +800,7 @@ interface nsIDOMWebGLRenderingContext : nsISupports
|
|||
// HTMLImageElement, HTMLCanvasElement, HTMLVideoElement
|
||||
[noscript] void texSubImage2D_dom(in WebGLenum target, in WebGLint level,
|
||||
in WebGLint xoffset, in WebGLint yoffset, in WebGLenum format, in WebGLenum type,
|
||||
in nsIDOMElement element);
|
||||
in Element element);
|
||||
|
||||
// Modified: This replaces glTexParameterf, glTexParameterfv, glTexParameteri and glTexParameteriv
|
||||
void texParameterf(in WebGLenum target, in WebGLenum pname, in WebGLfloat param);
|
||||
|
|
|
@ -199,12 +199,15 @@ NS_IMETHODIMP nsDeviceMotion::RemoveListener(nsIDeviceMotionListener *aListener)
|
|||
|
||||
NS_IMETHODIMP nsDeviceMotion::AddWindowListener(nsIDOMWindow *aWindow)
|
||||
{
|
||||
if (mWindowListeners.IndexOf(aWindow) != NoIndex)
|
||||
return NS_OK;
|
||||
|
||||
if (mStarted == false) {
|
||||
mStarted = true;
|
||||
Startup();
|
||||
}
|
||||
if (mWindowListeners.IndexOf(aWindow) == NoIndex)
|
||||
mWindowListeners.AppendElement(aWindow);
|
||||
|
||||
mWindowListeners.AppendElement(aWindow);
|
||||
return NS_OK;
|
||||
}
|
||||
|
||||
|
@ -224,28 +227,34 @@ nsDeviceMotion::DeviceMotionChanged(PRUint32 type, double x, double y, double z)
|
|||
if (!mEnabled)
|
||||
return NS_ERROR_NOT_INITIALIZED;
|
||||
|
||||
for (PRUint32 i = mListeners.Count(); i > 0 ; ) {
|
||||
nsCOMArray<nsIDeviceMotionListener> listeners = mListeners;
|
||||
for (PRUint32 i = listeners.Count(); i > 0 ; ) {
|
||||
--i;
|
||||
nsRefPtr<nsDeviceMotionData> a = new nsDeviceMotionData(type, x, y, z);
|
||||
mListeners[i]->OnMotionChange(a);
|
||||
listeners[i]->OnMotionChange(a);
|
||||
}
|
||||
|
||||
for (PRUint32 i = mWindowListeners.Length(); i > 0 ; ) {
|
||||
nsCOMArray<nsIDOMWindow> windowListeners;
|
||||
for (PRUint32 i = 0; i < mWindowListeners.Length(); i++) {
|
||||
windowListeners.AppendObject(mWindowListeners[i]);
|
||||
}
|
||||
|
||||
for (PRUint32 i = windowListeners.Count(); i > 0 ; ) {
|
||||
--i;
|
||||
|
||||
// check to see if this window is in the background. if
|
||||
// it is, don't send any device motion to it.
|
||||
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(mWindowListeners[i]);
|
||||
nsCOMPtr<nsPIDOMWindow> pwindow = do_QueryInterface(windowListeners[i]);
|
||||
if (!pwindow ||
|
||||
!pwindow->GetOuterWindow() ||
|
||||
pwindow->GetOuterWindow()->IsBackground())
|
||||
continue;
|
||||
|
||||
nsCOMPtr<nsIDOMDocument> domdoc;
|
||||
mWindowListeners[i]->GetDocument(getter_AddRefs(domdoc));
|
||||
windowListeners[i]->GetDocument(getter_AddRefs(domdoc));
|
||||
|
||||
if (domdoc) {
|
||||
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(mWindowListeners[i]);
|
||||
nsCOMPtr<nsIDOMEventTarget> target = do_QueryInterface(windowListeners[i]);
|
||||
if (type == nsIDeviceMotionData::TYPE_ACCELERATION)
|
||||
FireDOMMotionEvent(domdoc, target, x, y, z);
|
||||
else if (type == nsIDeviceMotionData::TYPE_ORIENTATION)
|
||||
|
|
|
@ -105,7 +105,7 @@ function getAttributeNS03() {
|
|||
assertNotNull("empAddrNotNull",testAddr);
|
||||
testAddr.removeAttributeNS(namespaceURI,localName);
|
||||
attrValue = testAddr.getAttributeNS(namespaceURI,localName);
|
||||
assertEquals("throw_Equals","",attrValue);
|
||||
assertEquals("throw_Equals",null,attrValue);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
|
||||
*
|
||||
* ***** BEGIN LICENSE BLOCK *****
|
||||
/* -*- 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
|
||||
|
@ -255,30 +254,12 @@ XPCWrappedNativeScope::SetGlobal(XPCCallContext& ccx, JSObject* aGlobal,
|
|||
mScriptObjectPrincipal = sop;
|
||||
|
||||
// Lookup 'globalObject.Object.prototype' for our wrapper's proto
|
||||
{
|
||||
AutoJSErrorAndExceptionEater eater(ccx); // scoped error eater
|
||||
|
||||
jsval val;
|
||||
jsid idObj = mRuntime->GetStringID(XPCJSRuntime::IDX_OBJECT);
|
||||
jsid idProto = mRuntime->GetStringID(XPCJSRuntime::IDX_PROTOTYPE);
|
||||
|
||||
// When creating a new scope to boostrap a new global, we don't yet have
|
||||
// an XPCWrappedNative associated with the global object. However, the
|
||||
// resolve hook on the JSClass assumes there is one. So we need to avoid
|
||||
// resolving anything on the global object until things get a bit further
|
||||
// along. As such, we manually resolve |Object| before accessing it below.
|
||||
JSBool didResolve;
|
||||
|
||||
if (JS_ResolveStandardClass(ccx, aGlobal, idObj, &didResolve) &&
|
||||
JS_GetPropertyById(ccx, aGlobal, idObj, &val) &&
|
||||
!JSVAL_IS_PRIMITIVE(val) &&
|
||||
JS_GetPropertyById(ccx, JSVAL_TO_OBJECT(val), idProto, &val) &&
|
||||
!JSVAL_IS_PRIMITIVE(val)) {
|
||||
mPrototypeJSObject = JSVAL_TO_OBJECT(val);
|
||||
} else {
|
||||
NS_ERROR("Can't get globalObject.Object.prototype");
|
||||
}
|
||||
}
|
||||
JSObject *objectPrototype =
|
||||
JS_GetObjectPrototype(ccx.GetJSContext(), aGlobal);
|
||||
if (objectPrototype)
|
||||
mPrototypeJSObject = objectPrototype;
|
||||
else
|
||||
NS_ERROR("Can't get globalObject.Object.prototype");
|
||||
|
||||
// Clear the no helper wrapper prototype object so that a new one
|
||||
// gets created if needed.
|
||||
|
|
|
@ -3954,30 +3954,6 @@ private:
|
|||
PRInt64 mTimeStamp;
|
||||
};
|
||||
|
||||
/***************************************************************************/
|
||||
|
||||
class NS_STACK_CLASS AutoJSErrorAndExceptionEater
|
||||
{
|
||||
public:
|
||||
AutoJSErrorAndExceptionEater(JSContext* aCX
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_PARAM)
|
||||
: mCX(aCX),
|
||||
mOldErrorReporter(JS_SetErrorReporter(mCX, nsnull)),
|
||||
mOldExceptionState(JS_SaveExceptionState(mCX)) {
|
||||
MOZ_GUARD_OBJECT_NOTIFIER_INIT;
|
||||
}
|
||||
~AutoJSErrorAndExceptionEater()
|
||||
{
|
||||
JS_SetErrorReporter(mCX, mOldErrorReporter);
|
||||
JS_RestoreExceptionState(mCX, mOldExceptionState);
|
||||
}
|
||||
private:
|
||||
JSContext* mCX;
|
||||
JSErrorReporter mOldErrorReporter;
|
||||
JSExceptionState* mOldExceptionState;
|
||||
MOZ_DECL_USE_GUARD_OBJECT_NOTIFIER
|
||||
};
|
||||
|
||||
/******************************************************************************
|
||||
* Handles pre/post script processing and the setting/resetting the error
|
||||
* reporter
|
||||
|
|
|
@ -397,6 +397,7 @@ function StartHTTPServer()
|
|||
|
||||
function StartTests()
|
||||
{
|
||||
var uri;
|
||||
#if BOOTSTRAP
|
||||
/* These prefs are optional, so we don't need to spit an error to the log */
|
||||
try {
|
||||
|
|
|
@ -92,7 +92,6 @@ PRUint32
|
|||
HashString(const char *str)
|
||||
{
|
||||
PRUint32 code = 0;
|
||||
const char *origStr = str;
|
||||
|
||||
while (*str) {
|
||||
code = AddToHash(code, *str);
|
||||
|
@ -106,7 +105,6 @@ PRUint32
|
|||
HashString(const PRUnichar *str)
|
||||
{
|
||||
PRUint32 code = 0;
|
||||
const PRUnichar *origStr = str;
|
||||
|
||||
while (*str) {
|
||||
code = AddToHash(code, *str);
|
||||
|
|
Загрузка…
Ссылка в новой задаче