mirror of
https://github.com/roytam1/palemoon27.git
synced 2026-05-26 14:30:27 +00:00
68ea640f88
- Bug 1246575 - Inline RegExp.prototype.{global,ignoreCase,multiline,sticky,unicode} getters. r=h4writer (4c1dd91f65)
- Bug 1240796 - Inline SIMD operations that return scalars. r=bbouvier (e9a4985d96)
- Bug 1241872: Fix inlining of SIMD extractLanes in self-hosting; r=jolesen (337ab5c171)
- Bug 1240796 - Detemplatize getOrCreateSimdTypeDescr(). r=bbouvier (d1721d193d)
- Bug 1240796 - Extract baseline code to GetTemplateObjectForSimd(). r=bbouvier (302921629a)
- Bug 1240796 - Connect SIMD.Uint32x4 operations to the Ion inliner. r=bbouvier (24a2e4801b)
- Bug 1243810: Remove storage class of SimdOperation; r=jolesen (b5f74d5d74)
- Bug 1224374 - Profiler labels for the 25 top chrome hangs;r=BenWa,MarcoZ (b0ee441936)
- Bug 1211401 - Use global message manager as parent of <iframe mozbrowser> MM (r=smaug,ahal) (496e94f133)
- When mix-blending, only copy intersecting backdrop pixels. (bug 1235995 part 2, r=mattwoodrow) (f3a2211866)
- Fix the backdrop copy rect in nested mix-blend containers. (bug 1241273, r=mstange) (00ae1f2375)
- Bug 1246403: Implement call_import when caller returns float32; r=luke (f59d6303a6)
- Bug 1239506 - Make console formatter return NaN instead of nan with %f;r=baku (44aa78fba7)
- Bug 1202735 - Add nsIObserver to avoid warning. r=eeejay (93bf7d87e7)
- Bug 1228134 - Should check media.webspeech.synth.enabled on Windows SAPI backend. r=eeejay (4e04c701cb)
- Bug 1003464 - Support Web Speech API synthesis via speech-dispatcher. r=kdavis (bc6c839f1d)
- Bug 1003452 - Implement OSX backend for WebSpeech Synthesis. r=eeejay (85c3b95baa)
- Bug 1223153 - Create new thread to enumerate voice items. r=eeejay (6246ad40a0)
- fix refptr (075d2a7614)
- Bug 1211974 - Implement nsIObserver in SpeechDispatcherService. r=smaug (1fe398291f)
- Bug 1227848 - Separate construction from off-main-thread setup in SpeechDispatcherService. r=smaug (df4e431ad0)
- Bug 1191667 - Part 1. Add onVolumeChanged method to nsISpeechTaskCallback. r=eitan (119271d432)
- Bug 1191667 - Part 2. Call onVolumeChanged when changing volume. r=eitan (9aeb12f90f)
- Bug 1191667 - Part 3. Call NotifyStartedPlaying to show audio indicator. r=eitan (7c0a62f004)
- Bug 1187151 (part 13) - Replace nsBaseHashtable::Enumerate() calls in dom/ with iterators. r=baku. (aac6428d17)
- Bug 1225928 - Fix hang on linux when sending an empty string to speech synth. r=smaug (f21d1d9c2e)
- Bug 1221520 - nullcheck for mSpeechdClient. r=eeejay (3b38bd7fda)
- Bug 1230428 - Part 1. Check mTask since end event is posted asynchronized. r=eeejay (5b5ecaddd8)
- Bug 1239494 - Followup to fix a spurious hazard analysis failure; r=meow (7c6eac2f31)
- Bug 1224374 - Profiler labels for the top 26-100 chrome hangs;r=BenWa (f3edb68e7e)
- Bug 1242214 - Rename JSPropertyDescriptor JS::PropertyDescriptor in js. r=sstangl (b5fa6fc75c)
- Bug 1242072 - Continue using getPropertyDescriptor for get in Sandbox. r=bholley (3315e39b91)
- Bug 1242072 - Continue using getPropertyDescriptor for get in XrayWrapper. r=bholley (d9506cbe6a)
- Bug 1242214 - Rename JSPropertyDescriptor JS::PropertyDescriptor everywhere else. r=smaug (f5bf388f8b)
- Bug 1239822: Part 1 - Add a close method to windowless browsers, and only destroy when safe. r=bz (28cd84032e)
- apply (and revert little bit of PM) Bug 1218364 - windowless browser windows should not crash on Troubleshoot. (2ef4a8e4f7)
- Bug 1224105 - [webext] Use <browser> element for background page (r=kmag) (34b4e7a807)
- Bug 1239822: Part 2a - [webext] Explicitly destroy windowless browsers on unload. r=billm (737d05f57c)
- Bug 1239822: Part 2b - Destroy windowless browsers created for add-on SDK page workers. (de9bcd0438)
- Bug 1239822: Part 2c - Destroy windowless browsers created by browser parsable CSS tests. r=gijs (6e04b09bc6)
- Bug 1217307 - Remove some unnecessary null checks in dom/xslt/. r=njn (4208056baf)
- Bug 1222624: Make XSLT stylesheet parsing use nsIPrincipals and nsIURIs rather than strings. r=peterv (34984e2115)
- Bug 1222475 - use UniquePtr<T[]> instead of nsAutoArrayPtr<T> in dom/; r=baku,bz,terrence (2d33fa1b22)
- Bug 1237445 - Use GCHashSet for BaseShapeSet and InitialShapeSet, r=terrence (a4c8056f3a)
- Bug 1244365 - Remove Traceable; r=sfink (5a7d3ed42e)
- Bug 1236473 - Do not merge scripts that didn't successfully compile. (r=jandem) (8f03cbd52c)
- Bug 1240416 Disallow setting GC mark stack size to zero, and assert on attempt to realloc() zero bytes r=terrence (f28ea7d8f3)
- Bug 1232113 - "Make the format specifiers in JS_snprintf() invocations more portable". r=sphink (deb4e3bd14)
- Bug 1232672 - Use MOZ_WARN_UNUSED_RESULT to make ordered hash table clients check for failure r=sfink (541737edf1)
- Bug 1220703 - Remove AutoDisableStoreBuffer; r=jonco (e1b44b7696)
- Bug 1236523 part 1 - Remove Shape NON_NATIVE flag. r=bhackett (64dfe2f282)
- Bug 1236523 part 2 - Cache isBigEnoughForAShapeTable on the Shape. r=bhackett (86b6c65dc6)
- Bug 1236523 part 3 - Templatize Shape::search and ShapeTable::search. r=bhackett (9ca2f75776)
348 lines
9.3 KiB
C++
348 lines
9.3 KiB
C++
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- */
|
|
/* vim: set ts=8 sts=2 et sw=2 tw=80: */
|
|
/* This Source Code Form is subject to the terms of the Mozilla Public
|
|
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
|
* You can obtain one at http://mozilla.org/MPL/2.0/. */
|
|
|
|
#include "mozilla/dom/DOMJSProxyHandler.h"
|
|
#include "xpcpublic.h"
|
|
#include "xpcprivate.h"
|
|
#include "XPCWrapper.h"
|
|
#include "WrapperFactory.h"
|
|
#include "nsDOMClassInfo.h"
|
|
#include "nsWrapperCacheInlines.h"
|
|
#include "mozilla/dom/BindingUtils.h"
|
|
|
|
#include "jsapi.h"
|
|
|
|
using namespace JS;
|
|
|
|
namespace mozilla {
|
|
namespace dom {
|
|
|
|
jsid s_length_id = JSID_VOID;
|
|
|
|
bool
|
|
DefineStaticJSVals(JSContext* cx)
|
|
{
|
|
return AtomizeAndPinJSString(cx, s_length_id, "length");
|
|
}
|
|
|
|
const char DOMProxyHandler::family = 0;
|
|
|
|
js::DOMProxyShadowsResult
|
|
DOMProxyShadows(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id)
|
|
{
|
|
JS::Rooted<JSObject*> expando(cx, DOMProxyHandler::GetExpandoObject(proxy));
|
|
JS::Value v = js::GetProxyExtra(proxy, JSPROXYSLOT_EXPANDO);
|
|
bool isOverrideBuiltins = !v.isObject() && !v.isUndefined();
|
|
if (expando) {
|
|
bool hasOwn;
|
|
if (!JS_AlreadyHasOwnPropertyById(cx, expando, id, &hasOwn))
|
|
return js::ShadowCheckFailed;
|
|
|
|
if (hasOwn) {
|
|
return isOverrideBuiltins ?
|
|
js::ShadowsViaIndirectExpando : js::ShadowsViaDirectExpando;
|
|
}
|
|
}
|
|
|
|
if (!isOverrideBuiltins) {
|
|
// Our expando, if any, didn't shadow, so we're not shadowing at all.
|
|
return js::DoesntShadow;
|
|
}
|
|
|
|
bool hasOwn;
|
|
if (!GetProxyHandler(proxy)->hasOwn(cx, proxy, id, &hasOwn))
|
|
return js::ShadowCheckFailed;
|
|
|
|
return hasOwn ? js::Shadows : js::DoesntShadowUnique;
|
|
}
|
|
|
|
// Store the information for the specialized ICs.
|
|
struct SetDOMProxyInformation
|
|
{
|
|
SetDOMProxyInformation() {
|
|
js::SetDOMProxyInformation((const void*) &DOMProxyHandler::family,
|
|
JSPROXYSLOT_EXPANDO, DOMProxyShadows);
|
|
}
|
|
};
|
|
|
|
SetDOMProxyInformation gSetDOMProxyInformation;
|
|
|
|
// static
|
|
JSObject*
|
|
DOMProxyHandler::GetAndClearExpandoObject(JSObject* obj)
|
|
{
|
|
MOZ_ASSERT(IsDOMProxy(obj), "expected a DOM proxy object");
|
|
JS::Value v = js::GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
|
|
if (v.isUndefined()) {
|
|
return nullptr;
|
|
}
|
|
|
|
if (v.isObject()) {
|
|
js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, UndefinedValue());
|
|
xpc::ObjectScope(obj)->RemoveDOMExpandoObject(obj);
|
|
} else {
|
|
js::ExpandoAndGeneration* expandoAndGeneration =
|
|
static_cast<js::ExpandoAndGeneration*>(v.toPrivate());
|
|
v = expandoAndGeneration->expando;
|
|
if (v.isUndefined()) {
|
|
return nullptr;
|
|
}
|
|
expandoAndGeneration->expando = UndefinedValue();
|
|
}
|
|
|
|
|
|
return &v.toObject();
|
|
}
|
|
|
|
// static
|
|
JSObject*
|
|
DOMProxyHandler::EnsureExpandoObject(JSContext* cx, JS::Handle<JSObject*> obj)
|
|
{
|
|
NS_ASSERTION(IsDOMProxy(obj), "expected a DOM proxy object");
|
|
JS::Value v = js::GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
|
|
if (v.isObject()) {
|
|
return &v.toObject();
|
|
}
|
|
|
|
js::ExpandoAndGeneration* expandoAndGeneration;
|
|
if (!v.isUndefined()) {
|
|
expandoAndGeneration = static_cast<js::ExpandoAndGeneration*>(v.toPrivate());
|
|
if (expandoAndGeneration->expando.isObject()) {
|
|
return &expandoAndGeneration->expando.toObject();
|
|
}
|
|
} else {
|
|
expandoAndGeneration = nullptr;
|
|
}
|
|
|
|
JS::Rooted<JSObject*> expando(cx,
|
|
JS_NewObjectWithGivenProto(cx, nullptr, nullptr));
|
|
if (!expando) {
|
|
return nullptr;
|
|
}
|
|
|
|
nsISupports* native = UnwrapDOMObject<nsISupports>(obj);
|
|
nsWrapperCache* cache;
|
|
CallQueryInterface(native, &cache);
|
|
if (!cache) {
|
|
return expando;
|
|
}
|
|
|
|
if (expandoAndGeneration) {
|
|
cache->PreserveWrapper(native);
|
|
expandoAndGeneration->expando.setObject(*expando);
|
|
|
|
return expando;
|
|
}
|
|
|
|
if (!xpc::ObjectScope(obj)->RegisterDOMExpandoObject(obj)) {
|
|
return nullptr;
|
|
}
|
|
|
|
cache->SetPreservingWrapper(true);
|
|
js::SetProxyExtra(obj, JSPROXYSLOT_EXPANDO, ObjectValue(*expando));
|
|
|
|
return expando;
|
|
}
|
|
|
|
bool
|
|
DOMProxyHandler::preventExtensions(JSContext* cx, JS::Handle<JSObject*> proxy,
|
|
JS::ObjectOpResult& result) const
|
|
{
|
|
// always extensible per WebIDL
|
|
return result.failCantPreventExtensions();
|
|
}
|
|
|
|
bool
|
|
DOMProxyHandler::isExtensible(JSContext *cx, JS::Handle<JSObject*> proxy, bool *extensible) const
|
|
{
|
|
*extensible = true;
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
BaseDOMProxyHandler::getOwnPropertyDescriptor(JSContext* cx,
|
|
JS::Handle<JSObject*> proxy,
|
|
JS::Handle<jsid> id,
|
|
MutableHandle<PropertyDescriptor> desc) const
|
|
{
|
|
return getOwnPropDescriptor(cx, proxy, id, /* ignoreNamedProps = */ false,
|
|
desc);
|
|
}
|
|
|
|
bool
|
|
DOMProxyHandler::defineProperty(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
|
Handle<PropertyDescriptor> desc,
|
|
JS::ObjectOpResult &result, bool *defined) const
|
|
{
|
|
if (desc.hasGetterObject() && desc.setter() == JS_StrictPropertyStub) {
|
|
return result.failGetterOnly();
|
|
}
|
|
|
|
if (xpc::WrapperFactory::IsXrayWrapper(proxy)) {
|
|
return result.succeed();
|
|
}
|
|
|
|
JS::Rooted<JSObject*> expando(cx, EnsureExpandoObject(cx, proxy));
|
|
if (!expando) {
|
|
return false;
|
|
}
|
|
|
|
if (!JS_DefinePropertyById(cx, expando, id, desc, result)) {
|
|
return false;
|
|
}
|
|
*defined = true;
|
|
return true;
|
|
}
|
|
|
|
bool
|
|
DOMProxyHandler::set(JSContext *cx, Handle<JSObject*> proxy, Handle<jsid> id,
|
|
Handle<JS::Value> v, Handle<JS::Value> receiver,
|
|
ObjectOpResult &result) const
|
|
{
|
|
MOZ_ASSERT(!xpc::WrapperFactory::IsXrayWrapper(proxy),
|
|
"Should not have a XrayWrapper here");
|
|
bool done;
|
|
if (!setCustom(cx, proxy, id, v, &done)) {
|
|
return false;
|
|
}
|
|
if (done) {
|
|
return result.succeed();
|
|
}
|
|
|
|
// Make sure to ignore our named properties when checking for own
|
|
// property descriptors for a set.
|
|
JS::Rooted<PropertyDescriptor> ownDesc(cx);
|
|
if (!getOwnPropDescriptor(cx, proxy, id, /* ignoreNamedProps = */ true,
|
|
&ownDesc)) {
|
|
return false;
|
|
}
|
|
return js::SetPropertyIgnoringNamedGetter(cx, proxy, id, v, receiver, ownDesc, result);
|
|
}
|
|
|
|
bool
|
|
DOMProxyHandler::delete_(JSContext* cx, JS::Handle<JSObject*> proxy,
|
|
JS::Handle<jsid> id, JS::ObjectOpResult &result) const
|
|
{
|
|
JS::Rooted<JSObject*> expando(cx);
|
|
if (!xpc::WrapperFactory::IsXrayWrapper(proxy) && (expando = GetExpandoObject(proxy))) {
|
|
return JS_DeletePropertyById(cx, expando, id, result);
|
|
}
|
|
|
|
return result.succeed();
|
|
}
|
|
|
|
bool
|
|
BaseDOMProxyHandler::watch(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
|
JS::Handle<JSObject*> callable) const
|
|
{
|
|
return js::WatchGuts(cx, proxy, id, callable);
|
|
}
|
|
|
|
bool
|
|
BaseDOMProxyHandler::unwatch(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id) const
|
|
{
|
|
return js::UnwatchGuts(cx, proxy, id);
|
|
}
|
|
|
|
bool
|
|
BaseDOMProxyHandler::ownPropertyKeys(JSContext* cx,
|
|
JS::Handle<JSObject*> proxy,
|
|
JS::AutoIdVector& props) const
|
|
{
|
|
return ownPropNames(cx, proxy, JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS, props);
|
|
}
|
|
|
|
bool
|
|
BaseDOMProxyHandler::getOwnEnumerablePropertyKeys(JSContext* cx,
|
|
JS::Handle<JSObject*> proxy,
|
|
JS::AutoIdVector& props) const
|
|
{
|
|
return ownPropNames(cx, proxy, JSITER_OWNONLY, props);
|
|
}
|
|
|
|
bool
|
|
BaseDOMProxyHandler::enumerate(JSContext *cx, JS::Handle<JSObject*> proxy,
|
|
JS::MutableHandle<JSObject*> objp) const
|
|
{
|
|
return BaseProxyHandler::enumerate(cx, proxy, objp);
|
|
}
|
|
|
|
bool
|
|
DOMProxyHandler::has(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id, bool* bp) const
|
|
{
|
|
if (!hasOwn(cx, proxy, id, bp)) {
|
|
return false;
|
|
}
|
|
|
|
if (*bp) {
|
|
// We have the property ourselves; no need to worry about our prototype
|
|
// chain.
|
|
return true;
|
|
}
|
|
|
|
// OK, now we have to look at the proto
|
|
JS::Rooted<JSObject*> proto(cx);
|
|
if (!js::GetObjectProto(cx, proxy, &proto)) {
|
|
return false;
|
|
}
|
|
if (!proto) {
|
|
return true;
|
|
}
|
|
bool protoHasProp;
|
|
bool ok = JS_HasPropertyById(cx, proto, id, &protoHasProp);
|
|
if (ok) {
|
|
*bp = protoHasProp;
|
|
}
|
|
return ok;
|
|
}
|
|
|
|
int32_t
|
|
IdToInt32(JSContext* cx, JS::Handle<jsid> id)
|
|
{
|
|
JS::Rooted<JS::Value> idval(cx);
|
|
double array_index;
|
|
int32_t i;
|
|
if (JSID_IS_SYMBOL(id) ||
|
|
!::JS_IdToValue(cx, id, &idval) ||
|
|
!JS::ToNumber(cx, idval, &array_index) ||
|
|
!::JS_DoubleIsInt32(array_index, &i)) {
|
|
return -1;
|
|
}
|
|
|
|
return i;
|
|
}
|
|
|
|
bool
|
|
DOMProxyHandler::setCustom(JSContext* cx, JS::Handle<JSObject*> proxy, JS::Handle<jsid> id,
|
|
JS::Handle<JS::Value> v, bool *done) const
|
|
{
|
|
*done = false;
|
|
return true;
|
|
}
|
|
|
|
//static
|
|
JSObject *
|
|
DOMProxyHandler::GetExpandoObject(JSObject *obj)
|
|
{
|
|
MOZ_ASSERT(IsDOMProxy(obj), "expected a DOM proxy object");
|
|
JS::Value v = js::GetProxyExtra(obj, JSPROXYSLOT_EXPANDO);
|
|
if (v.isObject()) {
|
|
return &v.toObject();
|
|
}
|
|
|
|
if (v.isUndefined()) {
|
|
return nullptr;
|
|
}
|
|
|
|
js::ExpandoAndGeneration* expandoAndGeneration =
|
|
static_cast<js::ExpandoAndGeneration*>(v.toPrivate());
|
|
v = expandoAndGeneration->expando;
|
|
return v.isUndefined() ? nullptr : &v.toObject();
|
|
}
|
|
|
|
} // namespace dom
|
|
} // namespace mozilla
|