Merge mozilla-central to mozilla-inbound

This commit is contained in:
Ed Morley 2013-04-03 13:01:49 +01:00
commit 795bc3dd77
46 changed files with 409 additions and 243 deletions

View File

@ -417,7 +417,7 @@
</vbox>
<vbox class="permission" id="permPointerLockRow" >
<label class="permissionLabel" id="permPointerLockLabel"
value="&permPointerLock;" control="pointerLockRadioGroup"/>
value="&permPointerLock2;" control="pointerLockRadioGroup"/>
<hbox id="permPointerLockBox" role="group" aria-labelledby="permPointerLockLabel">
<checkbox id="pointerLockDef" command="cmd_pointerLockDef" label="&permAskAlways;"/>
<spacer flex="1"/>

View File

@ -700,7 +700,7 @@ var tests = [
onHidden: function (popup) {
ok(!this.notifyObj.mainActionClicked, "mainAction was not clicked because it was too soon");
ok(this.notifyObj.dismissalCallbackTriggered, "dismissal callback was triggered");
},
}
},
{ // Test #24 - test security delay - after delay
run: function () {
@ -723,7 +723,7 @@ var tests = [
ok(this.notifyObj.mainActionClicked, "mainAction was clicked after the delay");
ok(!this.notifyObj.dismissalCallbackTriggered, "dismissal callback was not triggered");
PopupNotifications.buttonDelay = PREF_SECURITY_DELAY_INITIAL;
},
}
},
{ // Test #25 - reload removes notification
run: function () {
@ -827,6 +827,37 @@ var tests = [
});
});
}
},
{ // Test #29 - Existing popup notification shouldn't disappear when adding a dismissed notification
run: function () {
this.notifyObj1 = new basicNotification();
this.notifyObj1.id += "_1";
this.notifyObj1.anchorID = "default-notification-icon";
this.notification1 = showNotification(this.notifyObj1);
},
onShown: function (popup) {
// Now show a dismissed notification, and check that it doesn't clobber
// the showing one.
this.notifyObj2 = new basicNotification();
this.notifyObj2.id += "_2";
this.notifyObj2.anchorID = "geo-notification-icon";
this.notifyObj2.options.dismissed = true;
this.notification2 = showNotification(this.notifyObj2);
checkPopup(popup, this.notifyObj1);
// check that both anchor icons are showing
is(document.getElementById("default-notification-icon").getAttribute("showing"), "true",
"notification1 anchor should be visible");
is(document.getElementById("geo-notification-icon").getAttribute("showing"), "true",
"notification2 anchor should be visible");
dismissNotification(popup);
},
onHidden: function(popup) {
this.notification1.remove();
this.notification2.remove();
}
}
];
@ -846,8 +877,10 @@ function checkPopup(popup, notificationObj) {
ok(notificationObj.shownCallbackTriggered, "shown callback was triggered");
let notifications = popup.childNodes;
is(notifications.length, 1, "only one notification displayed");
is(notifications.length, 1, "one notification displayed");
let notification = notifications[0];
if (!notification)
return;
let icon = document.getAnonymousElementByAttribute(notification, "class", "popup-notification-icon");
if (notificationObj.id == "geolocation") {
isnot(icon.boxObject.width, 0, "icon for geo displayed");

View File

@ -17,9 +17,7 @@ NS_IMPL_ISUPPORTS1(AboutRedirector, nsIAboutModule)
struct RedirEntry {
const char* id;
const char* url;
uint32_t flags; // See nsIAboutModule. The URI_SAFE_FOR_UNTRUSTED_CONTENT
// flag does double duty here -- if it's not set, we don't
// drop chrome privileges.
uint32_t flags;
};
/*
@ -128,28 +126,6 @@ AboutRedirector::NewChannel(nsIURI *aURI, nsIChannel **result)
tempChannel->SetOriginalURI(aURI);
// Keep the page from getting unnecessary privileges unless it needs them
if (kRedirMap[i].flags & nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT) {
if (path.EqualsLiteral("feeds")) {
nsCOMPtr<nsIScriptSecurityManager> securityManager =
do_GetService(NS_SCRIPTSECURITYMANAGER_CONTRACTID, &rv);
NS_ENSURE_SUCCESS(rv, rv);
nsCOMPtr<nsIPrincipal> principal;
rv = securityManager->GetNoAppCodebasePrincipal(aURI, getter_AddRefs(principal));
NS_ENSURE_SUCCESS(rv, rv);
rv = tempChannel->SetOwner(principal);
}
else {
// Setting the owner to null means that we'll go through the normal
// path in GetChannelPrincipal and create a codebase principal based
// on the channel's originalURI
rv = tempChannel->SetOwner(nullptr);
NS_ENSURE_SUCCESS(rv, rv);
}
}
NS_ADDREF(*result = tempChannel);
return rv;
}

View File

@ -5,6 +5,7 @@
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
Components.utils.import("resource://gre/modules/debug.js");
Components.utils.import("resource://gre/modules/Services.jsm");
const Cc = Components.classes;
const Ci = Components.interfaces;
@ -23,8 +24,6 @@ const TYPE_MAYBE_VIDEO_FEED = "application/vnd.mozilla.maybe.video.feed";
const TYPE_MAYBE_AUDIO_FEED = "application/vnd.mozilla.maybe.audio.feed";
const TYPE_ANY = "*/*";
const FEEDHANDLER_URI = "about:feeds";
const PREF_SELECTED_APP = "browser.feeds.handlers.application";
const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice";
const PREF_SELECTED_ACTION = "browser.feeds.handler";
@ -246,12 +245,14 @@ FeedConverter.prototype = {
feedService.addFeedResult(result);
// Now load the actual XUL document.
var chromeURI = ios.newURI(FEEDHANDLER_URI, null, null);
chromeChannel = ios.newChannelFromURI(chromeURI, null);
var aboutFeedsURI = ios.newURI("about:feeds", null, null);
chromeChannel = ios.newChannelFromURI(aboutFeedsURI, null);
chromeChannel.originalURI = result.uri;
}
else
chromeChannel.owner =
Services.scriptSecurityManager.getNoAppCodebasePrincipal(aboutFeedsURI);
} else {
chromeChannel = ios.newChannelFromURI(result.uri, null);
}
chromeChannel.loadGroup = this._request.loadGroup;
chromeChannel.asyncOpen(this._listener, null);

View File

@ -51,7 +51,6 @@ const TYPE_MAYBE_FEED = "application/vnd.mozilla.maybe.feed";
const TYPE_MAYBE_AUDIO_FEED = "application/vnd.mozilla.maybe.audio.feed";
const TYPE_MAYBE_VIDEO_FEED = "application/vnd.mozilla.maybe.video.feed";
const URI_BUNDLE = "chrome://browser/locale/feeds/subscribe.properties";
const FEEDHANDLER_URI = "about:feeds";
const PREF_SELECTED_APP = "browser.feeds.handlers.application";
const PREF_SELECTED_WEB = "browser.feeds.handlers.webservice";
@ -1102,7 +1101,7 @@ FeedWriter.prototype = {
var resolvedURI = Cc["@mozilla.org/network/io-service;1"].
getService(Ci.nsIIOService).
newChannel(FEEDHANDLER_URI, null, null).URI;
newChannel("about:feeds", null, null).URI;
if (resolvedURI.equals(chan.URI))
return chan.originalURI;

View File

@ -731,7 +731,7 @@ BrowserGlue.prototype = {
var button0Title = quitBundle.GetStringFromName("saveTitle");
var button1Title = quitBundle.GetStringFromName("cancelTitle");
var button2Title = quitBundle.GetStringFromName("quitTitle");
var neverAskText = quitBundle.GetStringFromName("neverAsk");
var neverAskText = quitBundle.GetStringFromName("neverAsk2");
// This wouldn't have been set above since we shouldn't be here for
// aQuitType == "lastwindow"
@ -1817,7 +1817,7 @@ ContentPermissionPrompt.prototype = {
let originString = requestingURI.schemeIs("file") ? requestingURI.path : requestingURI.host;
let message = browserBundle.formatStringFromName(autoAllow ?
"pointerLock.autoLock.title" : "pointerLock.title",
"pointerLock.autoLock.title2" : "pointerLock.title2",
[originString], 1);
// If this is an autoAllow info prompt, offer no actions.
// _showPrompt() will allow the request when it's dismissed.
@ -1825,7 +1825,7 @@ ContentPermissionPrompt.prototype = {
if (!autoAllow) {
actions = [
{
stringId: "pointerLock.allow",
stringId: "pointerLock.allow2",
action: null,
expireType: null,
callback: function() {},

View File

@ -277,14 +277,14 @@ webNotifications.showFromSite=Would you like to show notifications from %S?
# Pointer lock UI
pointerLock.allow=Hide mouse cursor
pointerLock.allow.accesskey=H
pointerLock.allow2=Hide pointer
pointerLock.allow2.accesskey=H
pointerLock.alwaysAllow=Always allow hiding
pointerLock.alwaysAllow.accesskey=A
pointerLock.neverAllow=Never allow hiding
pointerLock.neverAllow.accesskey=N
pointerLock.title=Would you like to allow the mouse cursor to be hidden on %S?
pointerLock.autoLock.title=%S will hide the mouse cursor.
pointerLock.title2=Would you like to allow the pointer to be hidden on %S?
pointerLock.autoLock.title2=%S will hide the pointer.
# Phishing/Malware Notification Bar.
# LOCALIZATION NOTE (notAForgery, notAnAttack)

View File

@ -66,7 +66,7 @@
<!ENTITY permGeo "Share Location">
<!ENTITY permPlugins "Activate Plugins">
<!ENTITY permFullscreen "Enter Fullscreen">
<!ENTITY permPointerLock "Hide the Mouse Cursor">
<!ENTITY permPointerLock2 "Hide the Mouse Pointer">
<!ENTITY permIndexedDB "Maintain Offline Storage">
<!ENTITY permClearStorage "Clear Storage">

View File

@ -7,6 +7,6 @@ quitDialogTitle=Quit %S
quitTitle=&Quit
cancelTitle=&Cancel
saveTitle=&Save and Quit
neverAsk=Do not ask next time
neverAsk2=&Do not ask next time
message=Do you want %S to save your tabs and windows for the next time it starts?
messageNoWindows=Do you want %S to save your tabs for the next time it starts?

View File

@ -15,9 +15,7 @@ NS_IMPL_ISUPPORTS1(nsAboutRedirector, nsIAboutModule)
struct RedirEntry {
const char* id;
const char* url;
uint32_t flags; // See nsIAboutModule. The URI_SAFE_FOR_UNTRUSTED_CONTENT
// flag does double duty here -- if it's not set, we don't
// drop chrome privileges.
uint32_t flags;
};
/*
@ -99,18 +97,6 @@ nsAboutRedirector::NewChannel(nsIURI *aURI, nsIChannel **result)
tempChannel->SetOriginalURI(aURI);
// Keep the page from getting unnecessary privileges unless it needs them
if (kRedirMap[i].flags &
nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT)
{
// Setting the owner to null means that we'll go through the normal
// path in GetChannelPrincipal and create a codebase principal based
// on the channel's originalURI
rv = tempChannel->SetOwner(nullptr);
if (NS_FAILED(rv))
return rv;
}
NS_ADDREF(*result = tempChannel);
return rv;
}

View File

@ -1373,10 +1373,7 @@ GetAllKeysHelper::GetSuccessResult(JSContext* aCx,
NS_ASSERTION(mKeys.Length() <= mLimit, "Too many results!");
nsTArray<Key> keys;
if (!mKeys.SwapElements(keys)) {
NS_ERROR("Failed to swap elements!");
return NS_ERROR_DOM_INDEXEDDB_UNKNOWN_ERR;
}
mKeys.SwapElements(keys);
JSAutoRequest ar(aCx);

View File

@ -979,7 +979,6 @@ IDBObjectStore::UpdateIndexes(IDBTransaction* aTransaction,
int64_t aObjectDataId,
const nsTArray<IndexUpdateInfo>& aUpdateInfoArray)
{
nsCOMPtr<mozIStorageStatement> stmt;
nsresult rv;
NS_ASSERTION(aObjectDataId != INT64_MIN, "Bad objectData id!");
@ -987,41 +986,49 @@ IDBObjectStore::UpdateIndexes(IDBTransaction* aTransaction,
NS_NAMED_LITERAL_CSTRING(objectDataId, "object_data_id");
if (aOverwrite) {
stmt = aTransaction->GetCachedStatement(
"DELETE FROM unique_index_data "
"WHERE object_data_id = :object_data_id; "
"DELETE FROM index_data "
"WHERE object_data_id = :object_data_id");
NS_ENSURE_TRUE(stmt, NS_ERROR_FAILURE);
nsCOMPtr<mozIStorageStatement> deleteStmt =
aTransaction->GetCachedStatement(
"DELETE FROM unique_index_data "
"WHERE object_data_id = :object_data_id; "
"DELETE FROM index_data "
"WHERE object_data_id = :object_data_id");
NS_ENSURE_TRUE(deleteStmt, NS_ERROR_FAILURE);
mozStorageStatementScoper scoper(stmt);
mozStorageStatementScoper scoper(deleteStmt);
rv = stmt->BindInt64ByName(objectDataId, aObjectDataId);
rv = deleteStmt->BindInt64ByName(objectDataId, aObjectDataId);
NS_ENSURE_SUCCESS(rv, rv);
rv = stmt->Execute();
rv = deleteStmt->Execute();
NS_ENSURE_SUCCESS(rv, rv);
}
// Avoid lots of hash lookups for objectStores with lots of indexes by lazily
// holding the necessary statements on the stack outside the loop.
nsCOMPtr<mozIStorageStatement> insertUniqueStmt;
nsCOMPtr<mozIStorageStatement> insertStmt;
uint32_t infoCount = aUpdateInfoArray.Length();
for (uint32_t i = 0; i < infoCount; i++) {
const IndexUpdateInfo& updateInfo = aUpdateInfoArray[i];
// Insert new values.
stmt = updateInfo.indexUnique ?
aTransaction->GetCachedStatement(
"INSERT INTO unique_index_data "
"(index_id, object_data_id, object_data_key, value) "
"VALUES (:index_id, :object_data_id, :object_data_key, :value)") :
aTransaction->GetCachedStatement(
"INSERT OR IGNORE INTO index_data ("
"index_id, object_data_id, object_data_key, value) "
"VALUES (:index_id, :object_data_id, :object_data_key, :value)");
nsCOMPtr<mozIStorageStatement>& stmt =
updateInfo.indexUnique ? insertUniqueStmt : insertStmt;
if (!stmt) {
stmt = updateInfo.indexUnique ?
aTransaction->GetCachedStatement(
"INSERT INTO unique_index_data "
"(index_id, object_data_id, object_data_key, value) "
"VALUES (:index_id, :object_data_id, :object_data_key, :value)") :
aTransaction->GetCachedStatement(
"INSERT OR IGNORE INTO index_data ("
"index_id, object_data_id, object_data_key, value) "
"VALUES (:index_id, :object_data_id, :object_data_key, :value)");
}
NS_ENSURE_TRUE(stmt, NS_ERROR_FAILURE);
mozStorageStatementScoper scoper4(stmt);
mozStorageStatementScoper scoper(stmt);
rv = stmt->BindInt64ByName(NS_LITERAL_CSTRING("index_id"),
updateInfo.indexId);

View File

@ -1497,9 +1497,7 @@ public:
NS_ASSERTION(aRequestingDatabase, "Null pointer!");
NS_ASSERTION(aRequest, "Null pointer!");
if (!mWaitingDatabases.SwapElements(aWaitingDatabases)) {
NS_ERROR("This should never fail!");
}
mWaitingDatabases.SwapElements(aWaitingDatabases);
}
NS_IMETHOD Run()

View File

@ -146,9 +146,7 @@ public:
aWorkerPrivate->AssertIsOnWorkerThread();
NS_ASSERTION(!aIsWorkerScript || aLoadInfos.Length() == 1, "Bad args!");
if (!mLoadInfos.SwapElements(aLoadInfos)) {
NS_ERROR("This should never fail!");
}
mLoadInfos.SwapElements(aLoadInfos);
}
NS_IMETHOD

View File

@ -769,9 +769,7 @@ public:
{
aData.steal(&mData, &mDataByteCount);
if (!mClonedObjects.SwapElements(aClonedObjects)) {
NS_ERROR("This should never fail!");
}
mClonedObjects.SwapElements(aClonedObjects);
}
bool

View File

@ -1670,6 +1670,7 @@ XMLHttpRequest::SendInternal(const nsAString& aStringBody,
new SendRunnable(mWorkerPrivate, mProxy, aStringBody, aBody,
aClonedObjects, syncQueueKey, hasUploadListeners);
if (!runnable->Dispatch(cx)) {
aRv.Throw(NS_ERROR_FAILURE);
return;
}

View File

@ -70,16 +70,15 @@ var std_WeakMap_set = WeakMap.prototype.set;
/* Spec: ECMAScript Language Specification, 5.1 edition, 8.8 */
function List() {
if (List.prototype === undefined) {
var proto = std_Object_create(null);
proto.indexOf = std_Array_indexOf;
proto.join = std_Array_join;
proto.push = std_Array_push;
proto.slice = std_Array_slice;
proto.sort = std_Array_sort;
List.prototype = proto;
}
function List() {}
{
let ListProto = std_Object_create(null);
ListProto.indexOf = std_Array_indexOf;
ListProto.join = std_Array_join;
ListProto.push = std_Array_push;
ListProto.slice = std_Array_slice;
ListProto.sort = std_Array_sort;
List.prototype = ListProto;
}
MakeConstructible(List);

View File

@ -1308,7 +1308,7 @@ class LIRGraph
localSlotCount_ = localSlotCount;
}
uint32_t localSlotCount() const {
return localSlotCount_;
return AlignBytes(localSlotCount_, StackAlignment / STACK_SLOT_SIZE);
}
void setArgumentSlotCount(uint32_t argumentSlotCount) {
argumentSlotCount_ = argumentSlotCount;

View File

@ -5051,21 +5051,31 @@ JS_DefineFunctions(JSContext *cx, JSObject *objArg, const JSFunctionSpec *fs)
if (cx->runtime->isSelfHostingGlobal(cx->global()))
continue;
RootedFunction fun(cx, DefineFunction(cx, obj, id, /* native = */ NULL, fs->nargs, 0,
JSFunction::ExtendedFinalizeKind, SingletonObject));
if (!fun)
return JS_FALSE;
fun->setIsSelfHostedBuiltin();
fun->setExtendedSlot(0, PrivateValue(const_cast<JSFunctionSpec*>(fs)));
RootedAtom shAtom(cx, Atomize(cx, fs->selfHostedName, strlen(fs->selfHostedName)));
if (!shAtom)
return JS_FALSE;
RootedObject holder(cx, cx->global()->intrinsicsHolder());
if (!JS_DefinePropertyById(cx,holder, AtomToId(shAtom),
ObjectValue(*fun), NULL, NULL, 0))
{
RootedPropertyName shName(cx, shAtom->asPropertyName());
RootedValue funVal(cx);
if (!cx->runtime->maybeWrappedSelfHostedFunction(cx, shName, &funVal))
return JS_FALSE;
if (!funVal.isUndefined()) {
if (!JSObject::defineProperty(cx, obj, atom->asPropertyName(), funVal,
NULL, NULL, flags & ~JSFUN_FLAGS_MASK))
{
return JS_FALSE;
}
} else {
RawFunction fun = DefineFunction(cx, obj, id, /* native = */ NULL, fs->nargs, 0,
JSFunction::ExtendedFinalizeKind, SingletonObject);
if (!fun)
return JS_FALSE;
fun->setIsSelfHostedBuiltin();
fun->setExtendedSlot(0, PrivateValue(const_cast<JSFunctionSpec*>(fs)));
funVal.setObject(*fun);
}
RootedObject holder(cx, cx->global()->intrinsicsHolder());
if (!JSObject::defineProperty(cx, holder, shName, funVal))
return JS_FALSE;
} else {
JSFunction *fun = DefineFunction(cx, obj, id, fs->call.op, fs->nargs, flags);
if (!fun)

View File

@ -16,8 +16,6 @@
#include "jsapi.h"
#include "jsprvtd.h"
#ifdef __cplusplus
namespace js {
class PropertyName;
@ -396,6 +394,4 @@ template <> struct RootMethods<SpecialId>
} /* namespace js */
#endif /* __cplusplus */
#endif /* jsclass_h__ */

View File

@ -776,6 +776,8 @@ struct JSRuntime : private JS::shadow::Runtime,
js::Handle<JSFunction*> targetFun);
bool cloneSelfHostedValue(JSContext *cx, js::Handle<js::PropertyName*> name,
js::MutableHandleValue vp);
bool maybeWrappedSelfHostedFunction(JSContext *cx, js::Handle<js::PropertyName*> name,
js::MutableHandleValue funVal);
//-------------------------------------------------------------------------
// Locale information

View File

@ -44,6 +44,7 @@ class JSFunction : public JSObject
HAS_DEFAULTS = 0x0800, /* function has at least one default parameter */
INTERPRETED_LAZY = 0x1000, /* function is interpreted but doesn't have a script yet */
ARROW = 0x2000, /* ES6 '(args) => body' syntax */
SH_WRAPPABLE = 0x4000, /* self-hosted function is wrappable, doesn't need to be cloned */
/* Derived Flags values for convenience: */
NATIVE_FUN = 0,
@ -100,6 +101,10 @@ class JSFunction : public JSObject
bool isSelfHostedConstructor() const { return flags & SELF_HOSTED_CTOR; }
bool hasRest() const { return flags & HAS_REST; }
bool hasDefaults() const { return flags & HAS_DEFAULTS; }
bool isWrappable() const {
JS_ASSERT_IF(flags & SH_WRAPPABLE, isSelfHostedBuiltin());
return flags & SH_WRAPPABLE;
}
// Arrow functions are a little weird.
//
@ -155,6 +160,12 @@ class JSFunction : public JSObject
flags |= SELF_HOSTED_CTOR;
}
void makeWrappable() {
JS_ASSERT(isSelfHostedBuiltin());
JS_ASSERT(!isWrappable());
flags |= SH_WRAPPABLE;
}
void setIsFunctionPrototype() {
JS_ASSERT(!isFunctionPrototype());
flags |= IS_FUN_PROTO;

View File

@ -2489,7 +2489,7 @@ BEGIN_CASE(JSOP_CALLINTRINSIC)
{
RootedValue &rval = rootValue0;
if (!GetIntrinsicOperation(cx, script, regs.pc, &rval))
if (!GetIntrinsicOperation(cx, regs.pc, &rval))
goto error;
PUSH_COPY(rval);

View File

@ -418,10 +418,9 @@ FetchNameNoGC(JSObject *pobj, Shape *shape, MutableHandleValue vp)
}
inline bool
GetIntrinsicOperation(JSContext *cx, JSScript *script, jsbytecode *pc, MutableHandleValue vp)
GetIntrinsicOperation(JSContext *cx, jsbytecode *pc, MutableHandleValue vp)
{
JSOp op = JSOp(*pc);
RootedPropertyName name(cx, GetNameFromBytecode(cx, script, pc, op));
RootedPropertyName name(cx, cx->stack.currentScript()->getName(pc));
return cx->global()->getIntrinsicValue(cx, name, vp);
}

View File

@ -24,10 +24,8 @@
#include "jsapi.h"
#include "jsutil.h"
#ifdef __cplusplus
#include "js/HashTable.h"
#include "js/Vector.h"
#endif
/*
* Convenience constants.
@ -65,10 +63,6 @@ typedef struct JSSpecializedNative JSSpecializedNative;
* may possibly be wrapped in an extern "C" block which does not agree with
* templates.
*/
#ifdef __cplusplus
extern "C++" {
class JSDependentString;
class JSExtensibleString;
class JSExternalString;
@ -235,14 +229,6 @@ class BumpPointerAllocator;
} /* namespace WTF */
} /* export "C++" */
#else
typedef struct JSAtom JSAtom;
#endif /* __cplusplus */
/* "Friend" types used by jscntxt.h and jsdbgapi.h. */
typedef enum JSTrapStatus {
JSTRAP_ERROR,

View File

@ -45,8 +45,6 @@ struct Zone;
* oblivious to the change. This feature can be explicitly disabled in debug
* builds by defining JS_NO_JSVAL_JSID_STRUCT_TYPES.
*/
#ifdef __cplusplus
# if defined(DEBUG) && !defined(JS_NO_JSVAL_JSID_STRUCT_TYPES)
# define JS_USE_JSID_STRUCT_TYPES
# endif
@ -63,10 +61,6 @@ struct jsid
typedef ptrdiff_t jsid;
# define JSID_BITS(id) (id)
# endif /* defined(JS_USE_JSID_STRUCT_TYPES) */
#else /* defined(__cplusplus) */
typedef ptrdiff_t jsid;
# define JSID_BITS(id) (id)
#endif
#ifdef WIN32
typedef wchar_t jschar;
@ -190,20 +184,12 @@ typedef struct JSStructuredCloneReader JSStructuredCloneReader;
typedef struct JSStructuredCloneWriter JSStructuredCloneWriter;
typedef struct JSTracer JSTracer;
#ifdef __cplusplus
class JSFlatString;
class JSFunction;
class JSObject;
class JSScript;
class JSStableString; // long story
class JSString;
#else
typedef struct JSFlatString JSFlatString;
typedef struct JSFunction JSFunction;
typedef struct JSObject JSObject;
typedef struct JSScript JSScript;
typedef struct JSString JSString;
#endif /* !__cplusplus */
#ifdef JS_THREADSAFE
typedef struct PRCallOnceType JSCallOnceType;
@ -212,8 +198,6 @@ typedef JSBool JSCallOnceType;
#endif
typedef JSBool (*JSInitCallback)(void);
#ifdef __cplusplus
namespace JS {
namespace shadow {
@ -383,6 +367,4 @@ struct PerThreadDataFriendFields
} /* namespace js */
#endif /* __cplusplus */
#endif /* jspubtd_h___ */

View File

@ -34,7 +34,6 @@ js_memcpy(void *dst_, const void *src_, size_t len)
return memcpy(dst, src, len);
}
#ifdef __cplusplus
namespace js {
template <class T>
@ -309,7 +308,6 @@ bool DecompressString(const unsigned char *inp, size_t inplen,
#endif
} /* namespace js */
#endif /* __cplusplus */
/* Crash diagnostics */
#ifdef DEBUG

View File

@ -25,6 +25,7 @@
#include "InlineFrameAssembler.h"
#include "jscompartment.h"
#include "jsopcodeinlines.h"
#include "jsworkers.h"
#include "builtin/RegExp.h"
#include "vm/RegExpStatics.h"
@ -965,7 +966,7 @@ IonGetsFirstChance(JSContext *cx, JSScript *script, jsbytecode *pc, CompileReque
// let JM take over until the PC is reached. Don't do this until the script
// reaches a high use count, as if we do this prematurely we may get stuck
// in JM code.
if (ion::js_IonOptions.parallelCompilation && script->hasIonScript() &&
if (OffThreadCompilationEnabled(cx) && script->hasIonScript() &&
pc && script->ionScript()->osrPc() && script->ionScript()->osrPc() != pc &&
script->getUseCount() >= ion::js_IonOptions.usesBeforeCompile * 2)
{
@ -4064,7 +4065,7 @@ mjit::Compiler::ionCompileHelper()
#endif
stubcc.linkExitDirect(trigger.inlineJump,
ion::js_IonOptions.parallelCompilation
OffThreadCompilationEnabled(cx)
? secondTest
: trigger.stubLabel);

View File

@ -16,6 +16,7 @@
#include "jsbool.h"
#include "assembler/assembler/MacroAssemblerCodeRef.h"
#include "jstypes.h"
#include "jsworkers.h"
#include "gc/Marking.h"
#include "ion/AsmJS.h"
@ -776,7 +777,7 @@ stubs::TriggerIonCompile(VMFrame &f)
{
RootedScript script(f.cx, f.script());
if (ion::js_IonOptions.parallelCompilation && !f.cx->runtime->profilingScripts) {
if (OffThreadCompilationEnabled(f.cx) && !f.cx->runtime->profilingScripts) {
if (script->hasIonScript()) {
/*
* Normally TriggerIonCompile is not called if !script->ion, but the

View File

@ -142,6 +142,19 @@ intrinsic_MakeConstructible(JSContext *cx, unsigned argc, Value *vp)
JS_ASSERT(args[0].isObject());
JS_ASSERT(args[0].toObject().isFunction());
args[0].toObject().toFunction()->setIsSelfHostedConstructor();
args.rval().setUndefined();
return true;
}
static JSBool
intrinsic_MakeWrappable(JSContext *cx, unsigned argc, Value *vp)
{
CallArgs args = CallArgsFromVp(argc, vp);
JS_ASSERT(args.length() >= 1);
JS_ASSERT(args[0].isObject());
JS_ASSERT(args[0].toObject().isFunction());
args[0].toObject().toFunction()->makeWrappable();
args.rval().setUndefined();
return true;
}
@ -204,6 +217,7 @@ intrinsic_SetScriptHints(JSContext *cx, unsigned argc, Value *vp)
if (ToBoolean(propv))
funScript->shouldCloneAtCallsite = true;
args.rval().setUndefined();
return true;
}
@ -217,7 +231,6 @@ js::intrinsic_Dump(JSContext *cx, unsigned argc, Value *vp)
CallArgs args = CallArgsFromVp(argc, vp);
RootedValue val(cx, args[0]);
js_DumpValue(val);
fprintf(stderr, "\n");
args.rval().setUndefined();
return true;
}
@ -458,6 +471,7 @@ JSFunctionSpec intrinsic_functions[] = {
JS_FN("AssertionFailed", intrinsic_AssertionFailed, 1,0),
JS_FN("SetScriptHints", intrinsic_SetScriptHints, 2,0),
JS_FN("MakeConstructible", intrinsic_MakeConstructible, 1,0),
JS_FN("MakeWrappable", intrinsic_MakeWrappable, 1,0),
JS_FN("DecompileArg", intrinsic_DecompileArg, 2,0),
JS_FN("RuntimeDefaultLocale", intrinsic_RuntimeDefaultLocale, 0,0),
@ -515,6 +529,8 @@ JSRuntime::initSelfHosting(JSContext *cx)
CompileOptions options(cx);
options.setFileAndLine("self-hosted", 1);
options.setSelfHostingMode(true);
options.setSourcePolicy(CompileOptions::NO_SOURCE);
options.setVersion(JSVERSION_LATEST);
/*
* Set a temporary error reporter printing to stderr because it is too
@ -606,8 +622,14 @@ CloneObject(JSContext *cx, HandleObject srcObj, CloneMemory &clonedObjects)
return p->value;
RootedObject clone(cx);
if (srcObj->isFunction()) {
RootedFunction fun(cx, srcObj->toFunction());
clone = CloneFunctionObject(cx, fun, cx->global(), fun->getAllocKind());
if (srcObj->toFunction()->isWrappable()) {
clone = srcObj;
if (!cx->compartment->wrap(cx, clone.address()))
return NULL;
} else {
RootedFunction fun(cx, srcObj->toFunction());
clone = CloneFunctionObject(cx, fun, cx->global(), fun->getAllocKind());
}
} else if (srcObj->isRegExp()) {
RegExpObject &reobj = srcObj->asRegExp();
RootedAtom source(cx, reobj.getSource());
@ -679,7 +701,7 @@ JSRuntime::cloneSelfHostedFunctionScript(JSContext *cx, Handle<PropertyName*> na
return false;
RootedFunction sourceFun(cx, funVal.toObject().toFunction());
Rooted<JSScript*> sourceScript(cx, sourceFun->nonLazyScript());
RootedScript sourceScript(cx, sourceFun->nonLazyScript());
JS_ASSERT(!sourceScript->enclosingStaticScope());
RawScript cscript = CloneScript(cx, NullPtr(), targetFun, sourceScript);
if (!cscript)
@ -713,3 +735,23 @@ JSRuntime::cloneSelfHostedValue(JSContext *cx, Handle<PropertyName*> name, Mutab
vp.set(val);
return true;
}
bool
JSRuntime::maybeWrappedSelfHostedFunction(JSContext *cx, Handle<PropertyName*> name,
MutableHandleValue funVal)
{
RootedObject shg(cx, selfHostingGlobal_);
RootedId id(cx, NameToId(name));
if (!GetUnclonedValue(cx, shg, id, funVal))
return false;
JS_ASSERT(funVal.isObject());
JS_ASSERT(funVal.toObject().isCallable());
if (!funVal.toObject().toFunction()->isWrappable()) {
funVal.setUndefined();
return true;
}
return cx->compartment->wrap(cx, funVal);
}

View File

@ -131,7 +131,23 @@ nsRangeFrame::BuildDisplayList(nsDisplayListBuilder* aBuilder,
const nsRect& aDirtyRect,
const nsDisplayListSet& aLists)
{
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
if (IsThemed()) {
DisplayBorderBackgroundOutline(aBuilder, aLists);
// Only create items for the thumb. Specifically, we do not want
// the track to paint, since *our* background is used to paint
// the track, and we don't want the unthemed track painting over
// the top of the themed track.
// This logic is copied from
// nsContainerFrame::BuildDisplayListForNonBlockChildren as
// called by BuildDisplayListForInline.
nsIFrame* thumb = mThumbDiv->GetPrimaryFrame();
if (thumb) {
nsDisplayListSet set(aLists, aLists.Content());
BuildDisplayListForChild(aBuilder, thumb, aDirtyRect, set, DISPLAY_CHILD_INLINE);
}
} else {
BuildDisplayListForInline(aBuilder, aDirtyRect, aLists);
}
}
NS_IMETHODIMP

View File

@ -725,7 +725,7 @@ meter {
}
input[type=range] {
-moz-appearance: none;
-moz-appearance: range;
display: inline-block;
width: 12em;
height: 1.3em;

View File

@ -775,8 +775,14 @@ nsUserFontSet::LogMessage(gfxMixedFontFamily *aFamily,
nsCOMPtr<nsIDOMCSSStyleSheet> sheet;
rv = rule->GetParentStyleSheet(getter_AddRefs(sheet));
NS_ENSURE_SUCCESS(rv, rv);
rv = sheet->GetHref(href);
NS_ENSURE_SUCCESS(rv, rv);
// if the style sheet is removed while the font is loading can be null
if (sheet) {
rv = sheet->GetHref(href);
NS_ENSURE_SUCCESS(rv, rv);
} else {
NS_WARNING("null parent stylesheet for @font-face rule");
href.AssignLiteral("unknown");
}
}
nsCOMPtr<nsIScriptError> scriptError =

View File

@ -22,7 +22,6 @@
<RelativeLayout android:id="@+id/gecko_layout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_below="@+id/toolbar_spacer"
android:layout_above="@+id/find_in_page">
<include layout="@layout/shared_ui_components"/>

View File

@ -4393,6 +4393,8 @@ var ErrorPageEventHandler = {
let isMalware = /e=malwareBlocked/.test(errorDoc.documentURI);
let bucketName = isMalware ? "WARNING_MALWARE_PAGE_" : "WARNING_PHISHING_PAGE_";
let nsISecTel = Ci.nsISecurityUITelemetry;
let isIframe = (aOwnerDoc.defaultView.parent === aOwnerDoc.defaultView);
bucketName += isIframe ? "TOP_" : "FRAME_";
let formatter = Cc["@mozilla.org/toolkit/URLFormatterService;1"].getService(Ci.nsIURLFormatter);

View File

@ -781,23 +781,19 @@ nsCookieService::TryInitDB(bool aRecreateDB)
NS_ENSURE_SUCCESS(rv, RESULT_FAILURE);
}
Telemetry::ID histID;
TimeStamp start = TimeStamp::Now();
// rand() is being used here as a poor-man's solution for a/b testing
if (rand() % 2) {
histID = Telemetry::MOZ_SQLITE_COOKIES_OPEN_READAHEAD_MS;
// This block provides scope for the Telemetry AutoTimer
{
Telemetry::AutoTimer<Telemetry::MOZ_SQLITE_COOKIES_OPEN_READAHEAD_MS>
telemetry;
ReadAheadFile(mDefaultDBState->cookieFile);
} else {
histID = Telemetry::MOZ_SQLITE_COOKIES_OPEN_MS;
}
// open a connection to the cookie database, and only cache our connection
// and statements upon success. The connection is opened unshared to eliminate
// cache contention between the main and background threads.
rv = mStorageService->OpenUnsharedDatabase(mDefaultDBState->cookieFile,
getter_AddRefs(mDefaultDBState->dbConn));
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
Telemetry::AccumulateDelta_impl<Telemetry::Millisecond>::compute(histID, start);
// open a connection to the cookie database, and only cache our connection
// and statements upon success. The connection is opened unshared to eliminate
// cache contention between the main and background threads.
rv = mStorageService->OpenUnsharedDatabase(mDefaultDBState->cookieFile,
getter_AddRefs(mDefaultDBState->dbConn));
NS_ENSURE_SUCCESS(rv, RESULT_RETRY);
}
// Set up our listeners.
mDefaultDBState->insertListener = new InsertCookieDBListener(mDefaultDBState);

View File

@ -26,6 +26,13 @@
static NS_DEFINE_CID(kSimpleURICID, NS_SIMPLEURI_CID);
static NS_DEFINE_CID(kNestedAboutURICID, NS_NESTEDABOUTURI_CID);
static bool IsSafeForUntrustedContent(nsIAboutModule *aModule, nsIURI *aURI) {
uint32_t flags;
nsresult rv = aModule->GetURIFlags(aURI, &flags);
NS_ENSURE_SUCCESS(rv, false);
return (flags & nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT) != 0;
}
////////////////////////////////////////////////////////////////////////////////
NS_IMPL_ISUPPORTS1(nsAboutProtocolHandler, nsIProtocolHandler)
@ -80,13 +87,7 @@ nsAboutProtocolHandler::NewURI(const nsACString &aSpec,
nsCOMPtr<nsIAboutModule> aboutMod;
rv = NS_GetAboutModule(url, getter_AddRefs(aboutMod));
if (NS_SUCCEEDED(rv)) {
// The standard return case
uint32_t flags;
rv = aboutMod->GetURIFlags(url, &flags);
NS_ENSURE_SUCCESS(rv, rv);
isSafe =
((flags & nsIAboutModule::URI_SAFE_FOR_UNTRUSTED_CONTENT) != 0);
isSafe = IsSafeForUntrustedContent(aboutMod, url);
}
if (isSafe) {
@ -133,6 +134,15 @@ nsAboutProtocolHandler::NewChannel(nsIURI* uri, nsIChannel* *result)
// The standard return case:
rv = aboutMod->NewChannel(uri, result);
if (NS_SUCCEEDED(rv)) {
// If this URI is safe for untrusted content, enforce that its
// principal be based on the channel's originalURI by setting the
// owner to null.
// Note: this relies on aboutMod's newChannel implementation
// having set the proper originalURI, which probably isn't ideal.
if (IsSafeForUntrustedContent(aboutMod, uri)) {
(*result)->SetOwner(nullptr);
}
nsRefPtr<nsNestedAboutURI> aboutURI;
nsresult rv2 = uri->QueryInterface(kNestedAboutURICID,
getter_AddRefs(aboutURI));

View File

@ -21,8 +21,11 @@ interface nsIAboutModule : nsISupports
/**
* A flag that indicates whether a URI is safe for untrusted
* content. If it is, web pages and so forth will be allowed to
* link to this about: URI. Otherwise, only chrome will be able
* to link to it.
* link to this about: URI, and the about: protocol handler will
* enforce that the principal of channels created for it be based
* on their originalURI or URI (depending on the channel flags),
* by setting their "owner" to null.
* Otherwise, only chrome will be able to link to it.
*/
const unsigned long URI_SAFE_FOR_UNTRUSTED_CONTENT = (1 << 0);

View File

@ -0,0 +1,45 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
let Ci = Components.interfaces;
let Cc = Components.classes;
Components.utils.import("resource://gre/modules/Services.jsm");
Components.utils.import("resource://gre/modules/XPCOMUtils.jsm");
let unsafeAboutModule = {
QueryInterface: XPCOMUtils.generateQI([Ci.nsIAboutModule]),
newChannel: function (aURI) {
let chan = Services.io.newChannel("about:blank", null, null);
chan.owner = Services.scriptSecurityManager.getSystemPrincipal();
return chan;
},
getURIFlags: function (aURI) {
return Ci.nsIAboutModule.URI_SAFE_FOR_UNTRUSTED_CONTENT;
}
};
let factory = {
createInstance: function(aOuter, aIID) {
if (aOuter)
throw Components.results.NS_ERROR_NO_AGGREGATION;
return unsafeAboutModule.QueryInterface(aIID);
},
lockFactory: function(aLock) {
throw Components.results.NS_ERROR_NOT_IMPLEMENTED;
},
QueryInterface: XPCOMUtils.generateQI([Ci.nsIFactory])
};
function run_test() {
let registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar);
let classID = Cc["@mozilla.org/uuid-generator;1"].getService(Ci.nsIUUIDGenerator).generateUUID();
registrar.registerFactory(classID, "", "@mozilla.org/network/protocol/about;1?what=unsafe", factory);
let aboutUnsafeURI = Services.io.newURI("about:unsafe", null, null);
let aboutUnsafeChan = Services.io.newChannelFromURI(aboutUnsafeURI);
do_check_null(aboutUnsafeChan.owner, "URI_SAFE_FOR_UNTRUSTED_CONTENT channel has no owner");
registrar.unregisterFactory(classID, factory);
}

View File

@ -212,3 +212,4 @@ run-if = hasNode
[test_bug826063.js]
[test_bug812167.js]
[test_tldservice_nextsubdomain.js]
[test_about_protocol.js]

View File

@ -1698,13 +1698,6 @@
"extended_statistics_ok": true,
"description": "Time spent on SQLite read() (ms)"
},
"MOZ_SQLITE_COOKIES_OPEN_MS": {
"kind": "exponential",
"high": "3000",
"n_buckets": 10,
"extended_statistics_ok": true,
"description": "Time spent on cookie DB open (ms)"
},
"MOZ_SQLITE_COOKIES_OPEN_READAHEAD_MS": {
"kind": "exponential",
"high": "3000",

View File

@ -255,7 +255,7 @@ PopupNotifications.prototype = {
let fm = Cc["@mozilla.org/focus-manager;1"].getService(Ci.nsIFocusManager);
if (browser == this.tabbrowser.selectedBrowser && fm.activeWindow == this.window) {
// show panel now
this._update(notification.anchorElement);
this._update(notification.anchorElement, true);
} else {
// Otherwise, update() will display the notification the next time the
// relevant tab/window is selected.
@ -550,8 +550,14 @@ PopupNotifications.prototype = {
/**
* Updates the notification state in response to window activation or tab
* selection changes.
*
* @param anchor is a XUL element reprensenting the anchor whose notifications
* should be shown.
* @param dismissShowing if true, dismiss any currently visible notifications
* if there are no notifications to show. Otherwise,
* currently displayed notifications will be left alone.
*/
_update: function PopupNotifications_update(anchor) {
_update: function PopupNotifications_update(anchor, dismissShowing = false) {
if (this.iconBox) {
// hide icons of the previous tab.
this._hideIcons();
@ -584,9 +590,12 @@ PopupNotifications.prototype = {
// Notify observers that we're not showing the popup (useful for testing)
this._notify("updateNotShowing");
// Dismiss the panel if needed. _onPopupHidden will ensure we never call
// a dismissal handler on a notification that's been removed.
this._dismiss();
// Close the panel if there are no notifications to show.
// When called from PopupNotifications.show() we should never close the
// panel, however. It may just be adding a dismissed notification, in
// which case we want to continue showing any existing notifications.
if (!dismissShowing)
this._dismiss();
// Only hide the iconBox if we actually have no notifications (as opposed
// to not having any showable notifications)

View File

@ -782,6 +782,8 @@ nsNativeThemeWin::GetTheme(uint8_t aWidgetType)
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
return nsUXThemeData::GetTheme(eUXScrollbar);
case NS_THEME_RANGE:
case NS_THEME_RANGE_THUMB:
case NS_THEME_SCALE_HORIZONTAL:
case NS_THEME_SCALE_VERTICAL:
case NS_THEME_SCALE_THUMB_HORIZONTAL:
@ -1124,18 +1126,33 @@ nsNativeThemeWin::GetThemePartAndState(nsIFrame* aFrame, uint8_t aWidgetType,
}
return NS_OK;
}
case NS_THEME_RANGE:
case NS_THEME_SCALE_HORIZONTAL:
case NS_THEME_SCALE_VERTICAL: {
aPart = (aWidgetType == NS_THEME_SCALE_HORIZONTAL) ?
TKP_TRACK : TKP_TRACKVERT;
aState = TS_NORMAL;
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
(aWidgetType == NS_THEME_RANGE &&
IsRangeHorizontal(aFrame))) {
aPart = TKP_TRACK;
aState = TRS_NORMAL;
} else {
aPart = TKP_TRACKVERT;
aState = TRVS_NORMAL;
}
return NS_OK;
}
case NS_THEME_RANGE_THUMB:
case NS_THEME_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL: {
aPart = (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL) ?
TKP_THUMB : TKP_THUMBVERT;
if (aWidgetType == NS_THEME_RANGE_THUMB) {
if (IsRangeHorizontal(aFrame)) {
aPart = TKP_THUMBBOTTOM;
} else {
aPart = IsFrameRTL(aFrame) ? TKP_THUMBLEFT : TKP_THUMBRIGHT;
}
} else {
aPart = (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL) ?
TKP_THUMB : TKP_THUMBVERT;
}
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
if (!aFrame)
aState = TS_NORMAL;
@ -1672,7 +1689,8 @@ RENDER_AGAIN:
// widgetRect is the bounding box for a widget, yet the scale track is only
// a small portion of this size, so the edges of the scale need to be
// adjusted to the real size of the track.
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
if (aWidgetType == NS_THEME_RANGE ||
aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
aWidgetType == NS_THEME_SCALE_VERTICAL) {
RECT contentRect;
GetThemeBackgroundContentRect(theme, hdc, part, state, &widgetRect, &contentRect);
@ -1680,17 +1698,21 @@ RENDER_AGAIN:
SIZE siz;
GetThemePartSize(theme, hdc, part, state, &widgetRect, TS_TRUE, &siz);
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL) {
int32_t adjustment = (contentRect.bottom - contentRect.top - siz.cy) / 2 + 1;
contentRect.top += adjustment;
contentRect.bottom -= adjustment;
// When rounding is necessary, we round the position of the track
// away from the chevron of the thumb to make it look better.
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
(aWidgetType == NS_THEME_RANGE && IsRangeHorizontal(aFrame))) {
contentRect.top += (contentRect.bottom - contentRect.top - siz.cy) / 2;
contentRect.bottom = contentRect.top + siz.cy;
}
else {
int32_t adjustment = (contentRect.right - contentRect.left - siz.cx) / 2 + 1;
// need to subtract one from the left position, otherwise the scale's
// border isn't visible
contentRect.left += adjustment - 1;
contentRect.right -= adjustment;
if (!IsFrameRTL(aFrame)) {
contentRect.left += (contentRect.right - contentRect.left - siz.cx) / 2;
contentRect.right = contentRect.left + siz.cx;
} else {
contentRect.right -= (contentRect.right - contentRect.left - siz.cx) / 2;
contentRect.left = contentRect.right - siz.cx;
}
}
DrawThemeBackground(theme, hdc, part, state, &contentRect, &clipRect);
@ -1811,6 +1833,7 @@ RENDER_AGAIN:
// XXX it'd be nice to draw these outside of the frame
if (((aWidgetType == NS_THEME_CHECKBOX || aWidgetType == NS_THEME_RADIO) &&
aFrame->GetContent()->IsHTML()) ||
aWidgetType == NS_THEME_RANGE ||
aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
aWidgetType == NS_THEME_SCALE_VERTICAL) {
nsEventStates contentState = GetContentState(aFrame, aWidgetType);
@ -2285,6 +2308,7 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* a
*aIsOverridable = false;
break;
case NS_THEME_RANGE_THUMB:
case NS_THEME_SCALE_THUMB_HORIZONTAL:
case NS_THEME_SCALE_THUMB_VERTICAL:
{
@ -2292,7 +2316,8 @@ nsNativeThemeWin::GetMinimumWidgetSize(nsRenderingContext* aContext, nsIFrame* a
// on Vista, GetThemePartAndState returns odd values for
// scale thumbs, so use a hardcoded size instead.
if (WinUtils::GetWindowsVersion() >= WinUtils::VISTA_VERSION) {
if (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL) {
if (aWidgetType == NS_THEME_SCALE_THUMB_HORIZONTAL ||
(aWidgetType == NS_THEME_RANGE_THUMB && IsRangeHorizontal(aFrame))) {
aResult->width = 12;
aResult->height = 20;
}
@ -2585,6 +2610,7 @@ nsNativeThemeWin::GetWidgetTransparency(nsIFrame* aFrame, uint8_t aWidgetType)
case NS_THEME_PROGRESSBAR_VERTICAL:
case NS_THEME_PROGRESSBAR_CHUNK:
case NS_THEME_PROGRESSBAR_CHUNK_VERTICAL:
case NS_THEME_RANGE:
return eTransparent;
}
@ -2640,6 +2666,8 @@ nsNativeThemeWin::ClassicThemeSupportsWidget(nsPresContext* aPresContext,
case NS_THEME_TEXTFIELD_MULTILINE:
case NS_THEME_CHECKBOX:
case NS_THEME_RADIO:
case NS_THEME_RANGE:
case NS_THEME_RANGE_THUMB:
case NS_THEME_GROUPBOX:
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
@ -2825,6 +2853,17 @@ nsNativeThemeWin::ClassicGetMinimumWidgetSize(nsRenderingContext* aContext, nsIF
// (*aResult).height = ::GetSystemMetrics(SM_CYVTHUMB) << 1;
break;
case NS_THEME_RANGE_THUMB: {
if (IsRangeHorizontal(aFrame)) {
(*aResult).width = 12;
(*aResult).height = 20;
} else {
(*aResult).width = 20;
(*aResult).height = 12;
}
*aIsOverridable = false;
break;
}
case NS_THEME_SCALE_THUMB_HORIZONTAL:
(*aResult).width = 12;
(*aResult).height = 20;
@ -3087,6 +3126,8 @@ nsresult nsNativeThemeWin::ClassicGetThemePartAndState(nsIFrame* aFrame, uint8_t
case NS_THEME_TEXTFIELD_MULTILINE:
case NS_THEME_DROPDOWN:
case NS_THEME_DROPDOWN_TEXTFIELD:
case NS_THEME_RANGE:
case NS_THEME_RANGE_THUMB:
case NS_THEME_SCROLLBAR_THUMB_VERTICAL:
case NS_THEME_SCROLLBAR_THUMB_HORIZONTAL:
case NS_THEME_SCROLLBAR_TRACK_VERTICAL:
@ -3582,6 +3623,7 @@ RENDER_AGAIN:
::DrawEdge(hdc, &widgetRect, EDGE_RAISED, BF_RECT | BF_MIDDLE);
break;
case NS_THEME_RANGE_THUMB:
case NS_THEME_SCALE_THUMB_VERTICAL:
case NS_THEME_SCALE_THUMB_HORIZONTAL: {
nsEventStates eventState = GetContentState(aFrame, aWidgetType);
@ -3620,17 +3662,25 @@ RENDER_AGAIN:
break;
}
// Draw scale track background
case NS_THEME_RANGE:
case NS_THEME_SCALE_VERTICAL:
case NS_THEME_SCALE_HORIZONTAL: {
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL) {
int32_t adjustment = (widgetRect.bottom - widgetRect.top) / 2 - 2;
widgetRect.top += adjustment;
widgetRect.bottom -= adjustment;
case NS_THEME_SCALE_HORIZONTAL: {
const int32_t trackWidth = 4;
// When rounding is necessary, we round the position of the track
// away from the chevron of the thumb to make it look better.
if (aWidgetType == NS_THEME_SCALE_HORIZONTAL ||
(aWidgetType == NS_THEME_RANGE && IsRangeHorizontal(aFrame))) {
widgetRect.top += (widgetRect.bottom - widgetRect.top - trackWidth) / 2;
widgetRect.bottom = widgetRect.top + trackWidth;
}
else {
int32_t adjustment = (widgetRect.right - widgetRect.left) / 2 - 2;
widgetRect.left += adjustment;
widgetRect.right -= adjustment;
if (!IsFrameRTL(aFrame)) {
widgetRect.left += (widgetRect.right - widgetRect.left - trackWidth) / 2;
widgetRect.right = widgetRect.left + trackWidth;
} else {
widgetRect.right -= (widgetRect.right - widgetRect.left - trackWidth) / 2;
widgetRect.left = widgetRect.right - trackWidth;
}
}
::DrawEdge(hdc, &widgetRect, EDGE_SUNKEN, BF_RECT | BF_ADJUST);
@ -3882,6 +3932,8 @@ nsNativeThemeWin::GetWidgetNativeDrawingFlags(uint8_t aWidgetType)
gfxWindowsNativeDrawing::CANNOT_COMPLEX_TRANSFORM;
// need to check these others
case NS_THEME_RANGE:
case NS_THEME_RANGE_THUMB:
case NS_THEME_SCROLLBAR_BUTTON_UP:
case NS_THEME_SCROLLBAR_BUTTON_DOWN:
case NS_THEME_SCROLLBAR_BUTTON_LEFT:

View File

@ -72,7 +72,17 @@
#define TKP_TRACK 1
#define TKP_TRACKVERT 2
#define TKP_THUMB 3
#define TKP_THUMBBOTTOM 4
#define TKP_THUMBTOP 5
#define TKP_THUMBVERT 6
#define TKP_THUMBLEFT 7
#define TKP_THUMBRIGHT 8
// Track state contstants
#define TRS_NORMAL 1
// Track vertical state constants
#define TRVS_NORMAL 1
// Spin constants
#define SPNP_UP 1

View File

@ -300,7 +300,7 @@ nsTArray_base<Alloc>::IsAutoArrayRestorer::~IsAutoArrayRestorer() {
template<class Alloc>
template<class Allocator>
bool
typename Alloc::ResultTypeProxy
nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
size_type elemSize,
size_t elemAlign) {
@ -321,14 +321,14 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
if (!EnsureNotUsingAutoArrayBuffer(elemSize) ||
!other.EnsureNotUsingAutoArrayBuffer(elemSize)) {
return false;
return Alloc::FailureResult();
}
Header *temp = mHdr;
mHdr = other.mHdr;
other.mHdr = temp;
return true;
return Alloc::SuccessResult();
}
// Swap the two arrays using memcpy, since at least one is using an auto
@ -344,7 +344,7 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
if (!Alloc::Successful(EnsureCapacity(other.Length(), elemSize)) ||
!Allocator::Successful(other.EnsureCapacity(Length(), elemSize))) {
return false;
return Alloc::FailureResult();
}
// The EnsureCapacity calls above shouldn't have caused *both* arrays to
@ -372,7 +372,7 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
// could, in theory, allocate a huge AutoTArray on the heap.)
nsAutoArrayBase<nsTArray_Impl<uint8_t, Alloc>, 64> temp;
if (!Alloc::Successful(temp.EnsureCapacity(smallerLength, elemSize))) {
return false;
return Alloc::FailureResult();
}
memcpy(temp.Elements(), smallerElements, smallerLength * elemSize);
@ -387,7 +387,7 @@ nsTArray_base<Alloc>::SwapArrayElements(nsTArray_base<Allocator>& other,
mHdr->mLength = other.Length();
other.mHdr->mLength = tempLength;
return true;
return Alloc::SuccessResult();
}
template<class Alloc>

View File

@ -424,9 +424,10 @@ protected:
protected:
template<class Allocator>
bool SwapArrayElements(nsTArray_base<Allocator>& other,
size_type elemSize,
size_t elemAlign);
typename Alloc::ResultTypeProxy
SwapArrayElements(nsTArray_base<Allocator>& other,
size_type elemSize,
size_t elemAlign);
// This is an RAII class used in SwapArrayElements.
class IsAutoArrayRestorer {
@ -1157,8 +1158,10 @@ public:
// This method causes the elements contained in this array and the given
// array to be swapped.
template<class Allocator>
bool SwapElements(nsTArray_Impl<E, Allocator>& other) {
return this->SwapArrayElements(other, sizeof(elem_type), MOZ_ALIGNOF(elem_type));
typename Alloc::ResultType
SwapElements(nsTArray_Impl<E, Allocator>& other) {
return Alloc::Result(this->SwapArrayElements(other, sizeof(elem_type),
MOZ_ALIGNOF(elem_type)));
}
//