From b5f8461038b856f0569e361a8786c9e4897a0547 Mon Sep 17 00:00:00 2001 From: Ehsan Akhgari Date: Thu, 15 Sep 2011 15:32:42 -0400 Subject: [PATCH 01/12] Bug 681229 - Sanitize the platform linebreaks to DOM linebreaks when pasting or drag-dropping text into text controls; r=roc --- .../text/nsPlaintextDataTransfer.cpp | 5 ++ editor/libeditor/text/tests/Makefile.in | 1 + .../libeditor/text/tests/test_bug681229.html | 51 +++++++++++++++++++ .../specialpowers/content/specialpowers.js | 6 +++ 4 files changed, 63 insertions(+) create mode 100644 editor/libeditor/text/tests/test_bug681229.html diff --git a/editor/libeditor/text/nsPlaintextDataTransfer.cpp b/editor/libeditor/text/nsPlaintextDataTransfer.cpp index 0b6c79564d6..209c08f575a 100644 --- a/editor/libeditor/text/nsPlaintextDataTransfer.cpp +++ b/editor/libeditor/text/nsPlaintextDataTransfer.cpp @@ -68,6 +68,7 @@ #include "nsISelectionPrivate.h" #include "nsFrameSelection.h" #include "nsEventDispatcher.h" +#include "nsContentUtils.h" NS_IMETHODIMP nsPlaintextEditor::PrepareTransferable(nsITransferable **transferable) { @@ -136,6 +137,10 @@ NS_IMETHODIMP nsPlaintextEditor::InsertTextFromTransferable(nsITransferable *aTr nsAutoString stuffToPaste; textDataObj->GetData(stuffToPaste); NS_ASSERTION(stuffToPaste.Length() <= (len/2), "Invalid length!"); + + // Sanitize possible carriage returns in the string to be inserted + nsContentUtils::PlatformToDOMLineBreaks(stuffToPaste); + nsAutoEditBatch beginBatching(this); rv = InsertTextAt(stuffToPaste, aDestinationNode, aDestOffset, aDoDeleteSelection); } diff --git a/editor/libeditor/text/tests/Makefile.in b/editor/libeditor/text/tests/Makefile.in index 4572909aac5..ac9980328c2 100644 --- a/editor/libeditor/text/tests/Makefile.in +++ b/editor/libeditor/text/tests/Makefile.in @@ -63,6 +63,7 @@ _TEST_FILES = \ test_bug638596.html \ test_bug641466.html \ test_bug645914.html \ + test_bug681229.html \ $(NULL) # disables the key handling test on gtk2 because gtk2 overrides some key events diff --git a/editor/libeditor/text/tests/test_bug681229.html b/editor/libeditor/text/tests/test_bug681229.html new file mode 100644 index 00000000000..05710e4eb16 --- /dev/null +++ b/editor/libeditor/text/tests/test_bug681229.html @@ -0,0 +1,51 @@ + + + + + Test for Bug 681229 + + + + + + +Mozilla Bug 681229 +

+
+ +
+
+
+
+ + diff --git a/testing/mochitest/specialpowers/content/specialpowers.js b/testing/mochitest/specialpowers/content/specialpowers.js index 89c260fe26c..7b4c141d6b6 100644 --- a/testing/mochitest/specialpowers/content/specialpowers.js +++ b/testing/mochitest/specialpowers/content/specialpowers.js @@ -418,6 +418,12 @@ SpecialPowers.prototype = { getDocumentURIObject: function(aDocument) { return aDocument.documentURIObject; }, + + copyString: function(str) { + Cc["@mozilla.org/widget/clipboardhelper;1"]. + getService(Ci.nsIClipboardHelper). + copyString(str); + }, }; // Expose everything but internal APIs (starting with underscores) to From e56f86df9c6641eba386fbf0ccf7f644ed48a966 Mon Sep 17 00:00:00 2001 From: Lucas Rocha Date: Mon, 26 Sep 2011 17:56:43 +0100 Subject: [PATCH 02/12] Bug 688796 - Change number of tabs in toolbar to be bold (r=mbrubeck) --- mobile/themes/core/honeycomb/browser.css | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/mobile/themes/core/honeycomb/browser.css b/mobile/themes/core/honeycomb/browser.css index 96a087ae71a..4a8648efdd2 100644 --- a/mobile/themes/core/honeycomb/browser.css +++ b/mobile/themes/core/honeycomb/browser.css @@ -377,8 +377,9 @@ toolbarbutton.urlbar-button { color: @color_text_toolbutton_inverse@; display: -moz-box; font-size: @font_small@ !important; - -moz-transform: translateY(-0.56em); - -moz-padding-end: 33px; /* correct position and alignment */ + font-weight: bold !important; + -moz-transform: translateY(-0.50em); + -moz-padding-end: 32px; /* correct position and alignment */ } #tool-menu { From f48850d85ef802d572c69b2cd0bd2f2e68b4d339 Mon Sep 17 00:00:00 2001 From: Matt Brubeck Date: Mon, 26 Sep 2011 10:45:42 -0700 Subject: [PATCH 03/12] Bug 689194 - Load ctypes.jsm in Fennec Contacts code only when it's needed [r=mfinkle] --- mobile/modules/contacts.jsm | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/mobile/modules/contacts.jsm b/mobile/modules/contacts.jsm index e3eec106164..56846125628 100644 --- a/mobile/modules/contacts.jsm +++ b/mobile/modules/contacts.jsm @@ -38,8 +38,6 @@ let EXPORTED_SYMBOLS = ["Contacts"]; const Cu = Components.utils; -Cu.import("resource://gre/modules/ctypes.jsm"); - let Contacts = { _providers: [], _contacts: [], @@ -88,6 +86,7 @@ let Contacts = { #ifndef ANDROID #ifndef XP_MACOSX #ifdef XP_UNIX +Cu.import("resource://gre/modules/ctypes.jsm"); Cu.import("resource:///modules/linuxTypes.jsm"); function EBookProvider() { From 9f724d9f0fe6f9f0c74e57f00242d22753ad0f3b Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Mon, 2 May 2011 16:36:42 -0400 Subject: [PATCH 04/12] Bug 686002 - Refactor Boolean class initialization. r=bhackett --HG-- extra : rebase_source : 0bbe5cf03528ce1b4fcc4ed2df6941448c19d147 --- js/src/jsbool.cpp | 34 ++++++++++++++++++++++++++-------- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/js/src/jsbool.cpp b/js/src/jsbool.cpp index d19cf235c18..2fc0e55a05f 100644 --- a/js/src/jsbool.cpp +++ b/js/src/jsbool.cpp @@ -55,6 +55,8 @@ #include "jsstr.h" #include "jsvector.h" +#include "vm/GlobalObject.h" + #include "jsinferinlines.h" #include "jsinterpinlines.h" #include "jsobjinlines.h" @@ -65,9 +67,7 @@ using namespace js::types; Class js::BooleanClass = { "Boolean", - JSCLASS_HAS_RESERVED_SLOTS(1) | - JSCLASS_HAS_CACHED_PROTO(JSProto_Boolean), - JS_PropertyStub, /* addProperty */ + JSCLASS_HAS_RESERVED_SLOTS(1) | JSCLASS_HAS_CACHED_PROTO(JSProto_Boolean), JS_PropertyStub, /* addProperty */ JS_PropertyStub, /* delProperty */ JS_PropertyStub, /* getProperty */ JS_StrictPropertyStub, /* setProperty */ @@ -152,12 +152,30 @@ Boolean(JSContext *cx, uintN argc, Value *vp) JSObject * js_InitBooleanClass(JSContext *cx, JSObject *obj) { - JSObject *proto = js_InitClass(cx, obj, NULL, &BooleanClass, Boolean, 1, - NULL, boolean_methods, NULL, NULL); - if (!proto) + JS_ASSERT(obj->isNative()); + + GlobalObject *global = obj->asGlobal(); + + JSObject *booleanProto = global->createBlankPrototype(cx, &BooleanClass); + if (!booleanProto) return NULL; - proto->setPrimitiveThis(BooleanValue(false)); - return proto; + booleanProto->setPrimitiveThis(BooleanValue(false)); + + JSFunction *ctor = global->createConstructor(cx, Boolean, &BooleanClass, + CLASS_ATOM(cx, Boolean), 1); + if (!ctor) + return NULL; + + if (!LinkConstructorAndPrototype(cx, ctor, booleanProto)) + return NULL; + + if (!DefinePropertiesAndBrand(cx, booleanProto, NULL, boolean_methods)) + return NULL; + + if (!DefineConstructorAndPrototype(cx, global, JSProto_Boolean, ctor, booleanProto)) + return NULL; + + return booleanProto; } JSString * From 0cb6bc323592e60d00f650250f2e47a0e5c86373 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Mon, 2 May 2011 17:03:47 -0400 Subject: [PATCH 05/12] Bug 686002 - Refactor Number class initialization. r=bhackett --HG-- extra : rebase_source : dfcfd4ce1e78c921ce9348f44fb50ed4be646fda --- js/src/jsnum.cpp | 53 +++++++++++++++++++++++++++++++----------------- 1 file changed, 34 insertions(+), 19 deletions(-) diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 3be9c3215b3..6a9fabf1628 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -75,6 +75,8 @@ #include "jsvector.h" #include "jslibmath.h" +#include "vm/GlobalObject.h" + #include "jsatominlines.h" #include "jsinferinlines.h" #include "jsinterpinlines.h" @@ -1099,39 +1101,52 @@ FinishRuntimeNumberState(JSRuntime *rt) JSObject * js_InitNumberClass(JSContext *cx, JSObject *obj) { - JSObject *proto, *ctor; - JSRuntime *rt; + JS_ASSERT(obj->isNative()); /* XXX must do at least once per new thread, so do it per JSContext... */ FIX_FPU(); - proto = js_InitClass(cx, obj, NULL, &NumberClass, Number, 1, - NULL, number_methods, NULL, NULL); - if (!proto || !(ctor = JS_GetConstructor(cx, proto))) - return NULL; - proto->setPrimitiveThis(Int32Value(0)); + GlobalObject *global = obj->asGlobal(); - if (!JS_DefineFunctions(cx, obj, number_functions)) + JSObject *numberProto = global->createBlankPrototype(cx, &NumberClass); + if (!numberProto) + return NULL; + numberProto->setPrimitiveThis(Int32Value(0)); + + JSFunction *ctor = global->createConstructor(cx, Number, &NumberClass, + CLASS_ATOM(cx, Number), 1); + if (!ctor) return NULL; + if (!LinkConstructorAndPrototype(cx, ctor, numberProto)) + return NULL; + + /* Add numeric constants (MAX_VALUE, NaN, &c.) to the Number constructor. */ if (!JS_DefineConstDoubles(cx, ctor, number_constants)) return NULL; - /* ECMA 15.1.1.1 */ - rt = cx->runtime; - if (!JS_DefineProperty(cx, obj, js_NaN_str, rt->NaNValue, - JS_PropertyStub, JS_StrictPropertyStub, - JSPROP_PERMANENT | JSPROP_READONLY)) { + if (!DefinePropertiesAndBrand(cx, numberProto, NULL, number_methods)) + return NULL; + + if (!JS_DefineFunctions(cx, global, number_functions)) + return NULL; + + /* ES5 15.1.1.1, 15.1.1.2 */ + if (!DefineNativeProperty(cx, global, ATOM_TO_JSID(cx->runtime->atomState.NaNAtom), + cx->runtime->NaNValue, JS_PropertyStub, JS_StrictPropertyStub, + JSPROP_PERMANENT | JSPROP_READONLY, 0, 0) || + !DefineNativeProperty(cx, global, ATOM_TO_JSID(cx->runtime->atomState.InfinityAtom), + cx->runtime->positiveInfinityValue, + JS_PropertyStub, JS_StrictPropertyStub, + JSPROP_PERMANENT | JSPROP_READONLY, 0, 0)) + { return NULL; } - /* ECMA 15.1.1.2 */ - if (!JS_DefineProperty(cx, obj, js_Infinity_str, rt->positiveInfinityValue, - JS_PropertyStub, JS_StrictPropertyStub, - JSPROP_PERMANENT | JSPROP_READONLY)) { + if (!DefineConstructorAndPrototype(cx, global, JSProto_Number, ctor, numberProto)) return NULL; - } - return proto; + + return numberProto; } namespace v8 { From 937f6db9d9af41f36e6664c94df24a762c6ab310 Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Tue, 3 May 2011 15:18:36 -0400 Subject: [PATCH 06/12] Bug 686002 - Refactor Date class initialization. r=bhackett --HG-- extra : rebase_source : 0dcb02dc1f79b23a29655dd91dd48957b10d8344 --- js/src/jsdate.cpp | 52 ++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 16 deletions(-) diff --git a/js/src/jsdate.cpp b/js/src/jsdate.cpp index 204b2e33947..72a2a8eb2fb 100644 --- a/js/src/jsdate.cpp +++ b/js/src/jsdate.cpp @@ -72,6 +72,8 @@ #include "jsstr.h" #include "jslibmath.h" +#include "vm/GlobalObject.h" + #include "jsinferinlines.h" #include "jsobjinlines.h" @@ -2605,34 +2607,52 @@ js_Date(JSContext *cx, uintN argc, Value *vp) JSObject * js_InitDateClass(JSContext *cx, JSObject *obj) { - /* set static LocalTZA */ + JS_ASSERT(obj->isNative()); + + /* Set the static LocalTZA. */ LocalTZA = -(PRMJ_LocalGMTDifference() * msPerSecond); - JSObject *proto = js_InitClass(cx, obj, NULL, &DateClass, js_Date, MAXARGS, - NULL, date_methods, NULL, date_static_methods); - if (!proto) + + GlobalObject *global = obj->asGlobal(); + + JSObject *dateProto = global->createBlankPrototype(cx, &DateClass); + if (!dateProto) + return NULL; + SetDateToNaN(cx, dateProto); + + JSFunction *ctor = global->createConstructor(cx, js_Date, &DateClass, + CLASS_ATOM(cx, Date), MAXARGS); + if (!ctor) return NULL; - AutoObjectRooter tvr(cx, proto); + if (!LinkConstructorAndPrototype(cx, ctor, dateProto)) + return NULL; - SetDateToNaN(cx, proto); + if (!DefinePropertiesAndBrand(cx, ctor, NULL, date_static_methods)) + return NULL; /* - * ES5 B.2.6: - * The Function object that is the initial value of - * Date.prototype.toGMTString is the same Function - * object that is the initial value of - * Date.prototype.toUTCString. + * Define all Date.prototype.* functions, then brand for trace-jitted code. + * Date.prototype.toGMTString has the same initial value as + * Date.prototype.toUTCString. */ - AutoValueRooter toUTCStringFun(cx); + if (!JS_DefineFunctions(cx, dateProto, date_methods)) + return NULL; + Value toUTCStringFun; jsid toUTCStringId = ATOM_TO_JSID(cx->runtime->atomState.toUTCStringAtom); jsid toGMTStringId = ATOM_TO_JSID(cx->runtime->atomState.toGMTStringAtom); - if (!js_GetProperty(cx, proto, toUTCStringId, toUTCStringFun.addr()) || - !js_DefineProperty(cx, proto, toGMTStringId, toUTCStringFun.addr(), - JS_PropertyStub, JS_StrictPropertyStub, 0)) { + if (!js_GetProperty(cx, dateProto, toUTCStringId, &toUTCStringFun) || + !js_DefineProperty(cx, dateProto, toGMTStringId, &toUTCStringFun, + JS_PropertyStub, JS_StrictPropertyStub, 0)) + { return NULL; } + if (!cx->typeInferenceEnabled()) + dateProto->brand(cx); - return proto; + if (!DefineConstructorAndPrototype(cx, global, JSProto_Date, ctor, dateProto)) + return NULL; + + return dateProto; } JS_FRIEND_API(JSObject *) From a9361aa15ad6479574dfab272dc19f8e8bb5953c Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Wed, 4 May 2011 16:54:24 -0400 Subject: [PATCH 07/12] Bug 686002 - Refactor WeakMap class initialization. r=bhackett --HG-- extra : rebase_source : cccef99e3ed5b084fa28bb59a1338ca6e7045e54 --- js/src/jsweakmap.cpp | 27 ++++++++++++++++++++++----- 1 file changed, 22 insertions(+), 5 deletions(-) diff --git a/js/src/jsweakmap.cpp b/js/src/jsweakmap.cpp index aae824f51e7..00fbdd0f390 100644 --- a/js/src/jsweakmap.cpp +++ b/js/src/jsweakmap.cpp @@ -49,6 +49,8 @@ #include "jsgcmark.h" #include "jsweakmap.h" +#include "vm/GlobalObject.h" + #include "jsgcinlines.h" #include "jsobjinlines.h" @@ -290,12 +292,27 @@ static JSFunctionSpec weak_map_methods[] = { JSObject * js_InitWeakMapClass(JSContext *cx, JSObject *obj) { - JSObject *proto = js_InitClass(cx, obj, NULL, &WeakMapClass, WeakMap_construct, 0, - NULL, weak_map_methods, NULL, NULL); - if (!proto) + JS_ASSERT(obj->isNative()); + + GlobalObject *global = obj->asGlobal(); + + JSObject *weakMapProto = global->createBlankPrototype(cx, &WeakMapClass); + if (!weakMapProto) + return NULL; + weakMapProto->setPrivate(NULL); + + JSFunction *ctor = global->createConstructor(cx, WeakMap_construct, &WeakMapClass, + CLASS_ATOM(cx, WeakMap), 0); + if (!ctor) return NULL; - proto->setPrivate(NULL); + if (!LinkConstructorAndPrototype(cx, ctor, weakMapProto)) + return NULL; - return proto; + if (!DefinePropertiesAndBrand(cx, weakMapProto, NULL, weak_map_methods)) + return NULL; + + if (!DefineConstructorAndPrototype(cx, global, JSProto_WeakMap, ctor, weakMapProto)) + return NULL; + return weakMapProto; } From 3ad1ea15a9efcc9a442b5a4c3628ffe29053af3a Mon Sep 17 00:00:00 2001 From: Jeff Walden Date: Fri, 13 May 2011 14:12:15 -0700 Subject: [PATCH 08/12] Bug 656810 - Implement js::NumberObject. r=njn --HG-- extra : rebase_source : 0ca4eba24d64c8baac02a6c95b9079a7940fa345 --- js/src/jsnum.cpp | 3 +- js/src/jsobj.cpp | 8 ++-- js/src/jsobj.h | 2 + js/src/vm/NumberObject-inl.h | 80 ++++++++++++++++++++++++++++++++ js/src/vm/NumberObject.h | 89 ++++++++++++++++++++++++++++++++++++ 5 files changed, 178 insertions(+), 4 deletions(-) create mode 100644 js/src/vm/NumberObject-inl.h create mode 100644 js/src/vm/NumberObject.h diff --git a/js/src/jsnum.cpp b/js/src/jsnum.cpp index 6a9fabf1628..acc8c51342e 100644 --- a/js/src/jsnum.cpp +++ b/js/src/jsnum.cpp @@ -84,6 +84,7 @@ #include "jsobjinlines.h" #include "jsstrinlines.h" +#include "vm/NumberObject-inl.h" #include "vm/String-inl.h" using namespace js; @@ -1111,7 +1112,7 @@ js_InitNumberClass(JSContext *cx, JSObject *obj) JSObject *numberProto = global->createBlankPrototype(cx, &NumberClass); if (!numberProto) return NULL; - numberProto->setPrimitiveThis(Int32Value(0)); + numberProto->asNumber()->setPrimitiveValue(0); JSFunction *ctor = global->createConstructor(cx, Number, &NumberClass, CLASS_ATOM(cx, Number), 1); diff --git a/js/src/jsobj.cpp b/js/src/jsobj.cpp index cfa9555dc30..0b7c1df0e57 100644 --- a/js/src/jsobj.cpp +++ b/js/src/jsobj.cpp @@ -89,6 +89,7 @@ #include "jsscriptinlines.h" #include "jsobjinlines.h" +#include "vm/NumberObject-inl.h" #include "vm/StringObject-inl.h" #if JS_HAS_GENERATORS @@ -6763,10 +6764,11 @@ PrimitiveToObject(JSContext *cx, const Value &v) { if (v.isString()) return StringObject::create(cx, v.toString()); + if (v.isNumber()) + return NumberObject::create(cx, v.toNumber()); - JS_ASSERT(v.isNumber() || v.isBoolean()); - Class *clasp = v.isNumber() ? &NumberClass : &BooleanClass; - JSObject *obj = NewBuiltinClassInstance(cx, clasp); + JS_ASSERT(v.isBoolean()); + JSObject *obj = NewBuiltinClassInstance(cx, &BooleanClass); if (!obj) return NULL; diff --git a/js/src/jsobj.h b/js/src/jsobj.h index 210641c2e86..2ffeaee3b10 100644 --- a/js/src/jsobj.h +++ b/js/src/jsobj.h @@ -380,6 +380,7 @@ extern Class XMLFilterClass; class ArgumentsObject; class GlobalObject; class NormalArgumentsObject; +class NumberObject; class StrictArgumentsObject; class StringObject; @@ -1052,6 +1053,7 @@ struct JSObject : js::gc::Cell { } public: + inline js::NumberObject *asNumber(); inline js::StringObject *asString(); /* diff --git a/js/src/vm/NumberObject-inl.h b/js/src/vm/NumberObject-inl.h new file mode 100644 index 00000000000..2b7c1549e2f --- /dev/null +++ b/js/src/vm/NumberObject-inl.h @@ -0,0 +1,80 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=78: + * + * ***** 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 SpiderMonkey string object code. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Jeff Walden (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 ***** */ + +#ifndef NumberObject_inl_h___ +#define NumberObject_inl_h___ + +#include "NumberObject.h" + +inline js::NumberObject * +JSObject::asNumber() +{ + JS_ASSERT(isNumber()); + return static_cast(const_cast(this)); +} + +namespace js { + +inline NumberObject * +NumberObject::create(JSContext *cx, jsdouble d) +{ + JSObject *obj = NewBuiltinClassInstance(cx, &NumberClass); + if (!obj) + return NULL; + NumberObject *numobj = obj->asNumber(); + numobj->setPrimitiveValue(d); + return numobj; +} + +inline NumberObject * +NumberObject::createWithProto(JSContext *cx, jsdouble d, JSObject &proto) +{ + JSObject *obj = NewObjectWithClassProto(cx, &NumberClass, &proto, + gc::GetGCObjectKind(RESERVED_SLOTS)); + if (!obj) + return NULL; + NumberObject *numobj = obj->asNumber(); + numobj->setPrimitiveValue(d); + return numobj; +} + +} // namespace js + +#endif /* NumberObject_inl_h__ */ diff --git a/js/src/vm/NumberObject.h b/js/src/vm/NumberObject.h new file mode 100644 index 00000000000..d52efcf016e --- /dev/null +++ b/js/src/vm/NumberObject.h @@ -0,0 +1,89 @@ +/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*- + * vim: set ts=8 sw=4 et tw=78: + * + * ***** 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 SpiderMonkey string object code. + * + * The Initial Developer of the Original Code is + * the Mozilla Foundation. + * Portions created by the Initial Developer are Copyright (C) 2011 + * the Initial Developer. All Rights Reserved. + * + * Contributor(s): + * Jeff Walden (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 ***** */ + +#ifndef NumberObject_h___ +#define NumberObject_h___ + +#include "jsnum.h" + +namespace js { + +class NumberObject : public ::JSObject +{ + /* Stores this Number object's [[PrimitiveValue]]. */ + static const uintN PRIMITIVE_VALUE_SLOT = 0; + + public: + static const uintN RESERVED_SLOTS = 1; + + /* + * Creates a new Number object boxing the given number. The object's + * [[Prototype]] is determined from context. + */ + static inline NumberObject *create(JSContext *cx, jsdouble d); + + /* + * Identical to create(), but uses |proto| as [[Prototype]]. This method + * must not be used to create |Number.prototype|. + */ + static inline NumberObject *createWithProto(JSContext *cx, jsdouble d, JSObject &proto); + + Value unbox() const { + JS_ASSERT(getSlot(PRIMITIVE_VALUE_SLOT).isNumber()); + return getSlot(PRIMITIVE_VALUE_SLOT); + } + + private: + inline void setPrimitiveValue(jsdouble d) { + setSlot(PRIMITIVE_VALUE_SLOT, NumberValue(d)); + } + + /* For access to init, as Number.prototype is special. */ + friend JSObject * + ::js_InitNumberClass(JSContext *cx, JSObject *global); + + private: + NumberObject(); + NumberObject &operator=(const NumberObject &so); +}; + +} // namespace js + +#endif /* NumberObject_h__ */ From 2e31bbbe25ed4be80c08c3ba7fae0c530f66152b Mon Sep 17 00:00:00 2001 From: Ted Mielczarek Date: Mon, 26 Sep 2011 14:40:09 -0400 Subject: [PATCH 09/12] bug 688877 - fix some usage of GetDlgItemText in Windows crashreporter. r=ehsan --- toolkit/crashreporter/client/crashreporter_win.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/toolkit/crashreporter/client/crashreporter_win.cpp b/toolkit/crashreporter/client/crashreporter_win.cpp index f00c7353755..5f0e95b42c4 100644 --- a/toolkit/crashreporter/client/crashreporter_win.cpp +++ b/toolkit/crashreporter/client/crashreporter_win.cpp @@ -447,7 +447,8 @@ static void EndCrashReporterDialog(HWND hwndDlg, int code) { // Save the current values to the registry wchar_t email[MAX_EMAIL_LENGTH]; - GetDlgItemText(hwndDlg, IDC_EMAILTEXT, email, sizeof(email)); + GetDlgItemTextW(hwndDlg, IDC_EMAILTEXT, email, + sizeof(email) / sizeof(email[0])); SetStringKey(gCrashReporterKey.c_str(), EMAIL_VALUE, email); SetBoolKey(gCrashReporterKey.c_str(), INCLUDE_URL_VALUE, @@ -590,7 +591,8 @@ static void UpdateEmail(HWND hwndDlg) { if (IsDlgButtonChecked(hwndDlg, IDC_EMAILMECHECK)) { wchar_t email[MAX_EMAIL_LENGTH]; - GetDlgItemText(hwndDlg, IDC_EMAILTEXT, email, sizeof(email)); + GetDlgItemTextW(hwndDlg, IDC_EMAILTEXT, email, + sizeof(email) / sizeof(email[0])); gQueryParameters[L"Email"] = email; if (IsDlgButtonChecked(hwndDlg, IDC_SUBMITREPORTCHECK)) EnableWindow(GetDlgItem(hwndDlg, IDC_EMAILTEXT), true); @@ -603,7 +605,8 @@ static void UpdateEmail(HWND hwndDlg) static void UpdateComment(HWND hwndDlg) { wchar_t comment[MAX_COMMENT_LENGTH + 1]; - GetDlgItemText(hwndDlg, IDC_COMMENTTEXT, comment, sizeof(comment)); + GetDlgItemTextW(hwndDlg, IDC_COMMENTTEXT, comment, + sizeof(comment) / sizeof(comment[0])); if (wcslen(comment) > 0) gQueryParameters[L"Comments"] = comment; else From 08db208d766a6257563024283980f8b81b46fa73 Mon Sep 17 00:00:00 2001 From: Alex Pakhotin Date: Wed, 21 Sep 2011 18:23:11 -0700 Subject: [PATCH 10/12] Bug 687204 - android.text.ClipboardManager in android.text has been deprecated. r=blassey --- embedding/android/GeckoAppShell.java | 33 +++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 6 deletions(-) diff --git a/embedding/android/GeckoAppShell.java b/embedding/android/GeckoAppShell.java index 098d05d1ae2..8ed1d3f9504 100644 --- a/embedding/android/GeckoAppShell.java +++ b/embedding/android/GeckoAppShell.java @@ -863,10 +863,25 @@ public class GeckoAppShell getHandler().post(new Runnable() { public void run() { Context context = GeckoApp.surfaceView.getContext(); - android.text.ClipboardManager cm = (android.text.ClipboardManager) - context.getSystemService(Context.CLIPBOARD_SERVICE); + String text = null; + if (android.os.Build.VERSION.SDK_INT >= 11) { + android.content.ClipboardManager cm = (android.content.ClipboardManager) + context.getSystemService(Context.CLIPBOARD_SERVICE); + if (cm.hasPrimaryClip()) { + ClipData clip = cm.getPrimaryClip(); + if (clip != null) { + ClipData.Item item = clip.getItemAt(0); + text = item.coerceToText(context).toString(); + } + } + } else { + android.text.ClipboardManager cm = (android.text.ClipboardManager) + context.getSystemService(Context.CLIPBOARD_SERVICE); + if (cm.hasText()) + text = cm.getText().toString(); + } try { - sClipboardQueue.put(cm.hasText() ? cm.getText().toString() : ""); + sClipboardQueue.put(text != null ? text : ""); } catch (InterruptedException ie) {} }}); try { @@ -880,9 +895,15 @@ public class GeckoAppShell getHandler().post(new Runnable() { public void run() { Context context = GeckoApp.surfaceView.getContext(); - android.text.ClipboardManager cm = (android.text.ClipboardManager) - context.getSystemService(Context.CLIPBOARD_SERVICE); - cm.setText(text); + if (android.os.Build.VERSION.SDK_INT >= 11) { + android.content.ClipboardManager cm = (android.content.ClipboardManager) + context.getSystemService(Context.CLIPBOARD_SERVICE); + cm.setPrimaryClip(ClipData.newPlainText("Text", text)); + } else { + android.text.ClipboardManager cm = (android.text.ClipboardManager) + context.getSystemService(Context.CLIPBOARD_SERVICE); + cm.setText(text); + } }}); } From d71effbf2cf977daa63de741684c6354831b92ce Mon Sep 17 00:00:00 2001 From: Justin Lebar Date: Mon, 26 Sep 2011 14:53:55 -0400 Subject: [PATCH 11/12] Bug 688233 - Don't abort about:memory when a memory reporter throws an exception. r=khuey --HG-- extra : rebase_source : 537f2937019720a0be872d54313767f4c84922e6 --- .../aboutmemory/content/aboutMemory.js | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/toolkit/components/aboutmemory/content/aboutMemory.js b/toolkit/components/aboutmemory/content/aboutMemory.js index 98462e8acb3..515a4032e52 100644 --- a/toolkit/components/aboutmemory/content/aboutMemory.js +++ b/toolkit/components/aboutmemory/content/aboutMemory.js @@ -279,13 +279,24 @@ function getReportersByProcess() var e = mgr.enumerateReporters(); while (e.hasMoreElements()) { var rOrig = e.getNext().QueryInterface(Ci.nsIMemoryReporter); - addReporter(rOrig.process, rOrig.path, rOrig.kind, rOrig.units, - rOrig.amount, rOrig.description); + try { + addReporter(rOrig.process, rOrig.path, rOrig.kind, rOrig.units, + rOrig.amount, rOrig.description); + } + catch(e) { + debug("An error occurred when collecting results from the memory reporter " + + rOrig.path + ": " + e); + } } var e = mgr.enumerateMultiReporters(); while (e.hasMoreElements()) { var mrOrig = e.getNext().QueryInterface(Ci.nsIMemoryMultiReporter); - mrOrig.collectReports(addReporter, null); + try { + mrOrig.collectReports(addReporter, null); + } + catch(e) { + debug("An error occurred when collecting a multi-reporter's results: " + e); + } } return reportersByProcess; @@ -1073,4 +1084,3 @@ function debug(x) div.innerHTML = JSON.stringify(x); content.appendChild(div); } - From 319514f0997400fd9f11fbb32fde39211cdbf6ea Mon Sep 17 00:00:00 2001 From: Matthew Noorenberghe Date: Mon, 26 Sep 2011 10:48:59 -0700 Subject: [PATCH 12/12] Bug 639092 - Catch exception accessing nsIRequest.name from nsLoginManager r=dolske --- toolkit/components/passwordmgr/nsLoginManager.js | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/toolkit/components/passwordmgr/nsLoginManager.js b/toolkit/components/passwordmgr/nsLoginManager.js index 78ca963cc33..b5e6a9e0371 100644 --- a/toolkit/components/passwordmgr/nsLoginManager.js +++ b/toolkit/components/passwordmgr/nsLoginManager.js @@ -288,10 +288,18 @@ LoginManager.prototype = { // Only process things which might have HTML forms. if (!(domDoc instanceof Ci.nsIDOMHTMLDocument)) return; - - this._pwmgr.log("onStateChange accepted: req = " + - (aRequest ? aRequest.name : "(null)") + - ", flags = 0x" + aStateFlags.toString(16)); + if (this._pwmgr._debug) { + let requestName = "(null)"; + if (aRequest) { + try { + requestName = aRequest.name; + } catch (ex if ex.result == Components.results.NS_ERROR_NOT_IMPLEMENTED) { + // do nothing - leave requestName = "(null)" + } + } + this._pwmgr.log("onStateChange accepted: req = " + requestName + + ", flags = 0x" + aStateFlags.toString(16)); + } // Fastback doesn't fire DOMContentLoaded, so process forms now. if (aStateFlags & Ci.nsIWebProgressListener.STATE_RESTORING) {