aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom
diff options
context:
space:
mode:
Diffstat (limited to 'components/script/dom')
-rw-r--r--components/script/dom/bindings/codegen/CodegenRust.py171
-rw-r--r--components/script/dom/bindings/error.rs3
-rw-r--r--components/script/dom/bindings/interface.rs16
-rw-r--r--components/script/dom/bindings/namespace.rs5
-rw-r--r--components/script/dom/bindings/proxyhandler.rs6
-rw-r--r--components/script/dom/bindings/record.rs4
-rw-r--r--components/script/dom/bindings/root.rs27
-rw-r--r--components/script/dom/bindings/structuredclone.rs3
-rw-r--r--components/script/dom/bindings/trace.rs6
-rw-r--r--components/script/dom/bindings/utils.rs12
-rw-r--r--components/script/dom/document.rs5
-rw-r--r--components/script/dom/eventtarget.rs25
-rw-r--r--components/script/dom/globalscope.rs19
-rw-r--r--components/script/dom/htmlcanvaselement.rs2
-rw-r--r--components/script/dom/htmlmediaelement.rs6
-rw-r--r--components/script/dom/promise.rs6
-rw-r--r--components/script/dom/webgl2renderingcontext.rs37
-rw-r--r--components/script/dom/webglframebuffer.rs57
-rw-r--r--components/script/dom/webglprogram.rs24
-rw-r--r--components/script/dom/webidls/WebGL2RenderingContext.webidl6
-rw-r--r--components/script/dom/window.rs8
21 files changed, 312 insertions, 136 deletions
diff --git a/components/script/dom/bindings/codegen/CodegenRust.py b/components/script/dom/bindings/codegen/CodegenRust.py
index 7f56c3b2f15..f7ce60cc80c 100644
--- a/components/script/dom/bindings/codegen/CodegenRust.py
+++ b/components/script/dom/bindings/codegen/CodegenRust.py
@@ -1654,7 +1654,7 @@ class MethodDefiner(PropertyDefiner):
if any(m.isGetter() and m.isIndexed() for m in methods):
self.regular.append({"name": '@@iterator',
"methodInfo": False,
- "selfHostedName": "ArrayValues",
+ "selfHostedName": "$ArrayValues",
"length": 0,
"flags": "0", # Not enumerable, per spec.
"condition": "Condition::Satisfied"})
@@ -1678,7 +1678,7 @@ class MethodDefiner(PropertyDefiner):
self.regular.append({
"name": "values",
"methodInfo": False,
- "selfHostedName": "ArrayValues",
+ "selfHostedName": "$ArrayValues",
"length": 0,
"flags": "JSPROP_ENUMERATE",
"condition": PropertyDefiner.getControllingCondition(m,
@@ -1731,7 +1731,7 @@ class MethodDefiner(PropertyDefiner):
selfHostedName = '%s as *const u8 as *const libc::c_char' % str_to_const_array(m["selfHostedName"])
assert not m.get("methodInfo", True)
accessor = "None"
- jitinfo = "0 as *const JSJitInfo"
+ jitinfo = "ptr::null()"
else:
selfHostedName = "0 as *const libc::c_char"
if m.get("methodInfo", True):
@@ -1743,28 +1743,30 @@ class MethodDefiner(PropertyDefiner):
jitinfo = "&%s_methodinfo as *const _ as *const JSJitInfo" % identifier
accessor = "Some(generic_method)"
else:
- jitinfo = "0 as *const JSJitInfo"
+ jitinfo = "ptr::null()"
accessor = 'Some(%s)' % m.get("nativeName", m["name"])
if m["name"].startswith("@@"):
- return ('(SymbolCode::%s as i32 + 1)'
- % m["name"][2:], accessor, jitinfo, m["length"], flags, selfHostedName)
- return (str_to_const_array(m["name"]), accessor, jitinfo, m["length"], flags, selfHostedName)
+ name = 'JSPropertySpec_Name { symbol_: SymbolCode::%s as usize + 1 }' % m["name"][2:]
+ else:
+ name = ('JSPropertySpec_Name { string_: %s as *const u8 as *const libc::c_char }'
+ % str_to_const_array(m["name"]))
+ return (name, accessor, jitinfo, m["length"], flags, selfHostedName)
return self.generateGuardedArray(
array, name,
' JSFunctionSpec {\n'
- ' name: %s as *const u8 as *const libc::c_char,\n'
+ ' name: %s,\n'
' call: JSNativeWrapper { op: %s, info: %s },\n'
' nargs: %s,\n'
' flags: (%s) as u16,\n'
' selfHostedName: %s\n'
' }',
' JSFunctionSpec {\n'
- ' name: 0 as *const libc::c_char,\n'
- ' call: JSNativeWrapper { op: None, info: 0 as *const JSJitInfo },\n'
+ ' name: JSPropertySpec_Name { string_: ptr::null() },\n'
+ ' call: JSNativeWrapper { op: None, info: ptr::null() },\n'
' nargs: 0,\n'
' flags: 0,\n'
- ' selfHostedName: 0 as *const libc::c_char\n'
+ ' selfHostedName: ptr::null()\n'
' }',
'JSFunctionSpec',
condition, specData)
@@ -1834,14 +1836,14 @@ class AttrDefiner(PropertyDefiner):
return self.generateGuardedArray(
array, name,
' JSPropertySpec {\n'
- ' name: %s as *const u8 as *const libc::c_char,\n'
+ ' name: JSPropertySpec_Name { string_: %s as *const u8 as *const libc::c_char },\n'
' flags: (%s) as u8,\n'
- ' __bindgen_anon_1: JSPropertySpec__bindgen_ty_1 {\n'
- ' accessors: JSPropertySpec__bindgen_ty_1__bindgen_ty_1 {\n'
- ' getter: JSPropertySpec__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1 {\n'
+ ' u: JSPropertySpec_AccessorsOrValue {\n'
+ ' accessors: JSPropertySpec_AccessorsOrValue_Accessors {\n'
+ ' getter: JSPropertySpec_Accessor {\n'
' native: %s,\n'
' },\n'
- ' setter: JSPropertySpec__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2 {\n'
+ ' setter: JSPropertySpec_Accessor {\n'
' native: %s,\n'
' }\n'
' }\n'
@@ -2203,7 +2205,9 @@ static Class: DOMJSClass = DOMJSClass {
(((%(slots)s) & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT)
/* JSCLASS_HAS_RESERVED_SLOTS(%(slots)s) */,
cOps: &CLASS_OPS,
- reserved: [0 as *mut _; 3],
+ spec: ptr::null(),
+ ext: ptr::null(),
+ oOps: ptr::null(),
},
dom_class: %(domClass)s
};
@@ -2274,7 +2278,9 @@ static PrototypeClass: JSClass = JSClass {
// JSCLASS_HAS_RESERVED_SLOTS(%(slotCount)s)
(%(slotCount)s & JSCLASS_RESERVED_SLOTS_MASK) << JSCLASS_RESERVED_SLOTS_SHIFT,
cOps: 0 as *const _,
- reserved: [0 as *mut os::raw::c_void; 3]
+ spec: ptr::null(),
+ ext: ptr::null(),
+ oOps: ptr::null(),
};
""" % {'name': name, 'slotCount': slotCount}
@@ -2722,7 +2728,7 @@ assert!(!obj.is_null());
SetProxyReservedSlot(
obj.get(),
0,
- &PrivateValue(&*raw as *const %(concreteType)s as *const libc::c_void),
+ &PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
);
"""
else:
@@ -2736,7 +2742,7 @@ assert!(!obj.is_null());
JS_SetReservedSlot(
obj.get(),
DOM_OBJECT_SLOT,
- &PrivateValue(&*raw as *const %(concreteType)s as *const libc::c_void),
+ &PrivateValue(raw.as_ptr() as *const %(concreteType)s as *const libc::c_void),
);
"""
create = create % {"concreteType": self.descriptor.concreteType}
@@ -2759,11 +2765,11 @@ GetProtoObject(cx, scope, proto.handle_mut());
assert!(!proto.is_null());
%(createObject)s
-raw.init_reflector(obj.get());
+let root = raw.reflect_with(obj.get());
%(copyUnforgeable)s
-DomRoot::from_ref(&*raw)\
+DomRoot::from_ref(&*root)\
""" % {'copyUnforgeable': unforgeable, 'createObject': create})
@@ -2803,12 +2809,12 @@ rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
create_global_object(
cx,
&Class.base,
- &*raw as *const %(concreteType)s as *const libc::c_void,
+ raw.as_ptr() as *const %(concreteType)s as *const libc::c_void,
_trace,
obj.handle_mut());
assert!(!obj.is_null());
-raw.init_reflector(obj.get());
+let root = raw.reflect_with(obj.get());
let _ac = JSAutoRealm::new(*cx, obj.get());
rooted!(in(*cx) let mut proto = ptr::null_mut::<JSObject>());
@@ -2822,7 +2828,7 @@ assert!(immutable);
%(unforgeable)s
-DomRoot::from_ref(&*raw)\
+DomRoot::from_ref(&*root)\
""" % values)
@@ -2916,9 +2922,9 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
Generate the CollectJSONAttributes method for an interface descriptor
"""
def __init__(self, descriptor, toJSONMethod):
- args = [Argument('SafeJSContext', 'cx'),
- Argument('HandleObject', 'obj'),
- Argument('*const %s' % descriptor.concreteType, 'this'),
+ args = [Argument('*mut JSContext', 'cx'),
+ Argument('RawHandleObject', 'obj'),
+ Argument('*mut libc::c_void', 'this'),
Argument('&RootedGuard<*mut JSObject>', 'result')]
CGAbstractMethod.__init__(self, descriptor, 'CollectJSONAttributes',
'bool', args, pub=True, unsafe=True)
@@ -2932,11 +2938,11 @@ class CGCollectJSONAttributesMethod(CGAbstractMethod):
name = m.identifier.name
ret += fill(
"""
- rooted!(in(*cx) let mut temp = UndefinedValue());
+ rooted!(in(cx) let mut temp = UndefinedValue());
if !get_${name}(cx, obj, this, JSJitGetterCallArgs { _base: temp.handle_mut().into() }) {
return false;
}
- if !JS_DefineProperty(*cx, result.handle().into(),
+ if !JS_DefineProperty(cx, result.handle().into(),
${nameAsArray} as *const u8 as *const libc::c_char,
temp.handle(), JSPROP_ENUMERATE as u32) {
return false;
@@ -3668,8 +3674,9 @@ class CGSpecializedMethod(CGAbstractExternMethod):
def __init__(self, descriptor, method):
self.method = method
name = method.identifier.name
- args = [Argument('SafeJSContext', 'cx'), Argument('HandleObject', '_obj'),
- Argument('*const %s' % descriptor.concreteType, 'this'),
+ args = [Argument('*mut JSContext', 'cx'),
+ Argument('RawHandleObject', '_obj'),
+ Argument('*mut libc::c_void', 'this'),
Argument('*const JSJitMethodCallArgs', 'args')]
CGAbstractExternMethod.__init__(self, descriptor, name, 'bool', args)
@@ -3678,7 +3685,8 @@ class CGSpecializedMethod(CGAbstractExternMethod):
self.method)
return CGWrapper(CGMethodCall([], nativeName, self.method.isStatic(),
self.descriptor, self.method),
- pre="let this = &*this;\n"
+ pre="let cx = SafeJSContext::from_ptr(cx);\n" +
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType) +
"let args = &*args;\n"
"let argc = args.argc_;\n")
@@ -3701,7 +3709,7 @@ class CGDefaultToJSONMethod(CGSpecializedMethod):
def definition_body(self):
ret = dedent("""
use crate::dom::bindings::inheritance::HasParent;
- rooted!(in(*cx) let result = JS_NewPlainObject(*cx));
+ rooted!(in(cx) let result = JS_NewPlainObject(cx));
if result.is_null() {
return false;
}
@@ -3717,17 +3725,16 @@ class CGDefaultToJSONMethod(CGSpecializedMethod):
parents = len(jsonDescriptors) - 1
form = """
- if !${parentclass}CollectJSONAttributes(cx, _obj, this${asparent}, &result) {
+ if !${parentclass}CollectJSONAttributes(cx, _obj, this, &result) {
return false;
}
"""
# Iterate the array in reverse: oldest ancestor first
for descriptor in jsonDescriptors[:0:-1]:
- ret += fill(form, parentclass=toBindingNamespace(descriptor.name) + "::",
- asparent=".as_ref().unwrap()" + ".as_parent()" * parents)
+ ret += fill(form, parentclass=toBindingNamespace(descriptor.name) + "::")
parents -= 1
- ret += fill(form, parentclass="", asparent="")
+ ret += fill(form, parentclass="")
ret += ('(*args).rval().set(ObjectValue(*result));\n'
'return true;\n')
return CGGeneric(ret)
@@ -3759,9 +3766,9 @@ class CGSpecializedGetter(CGAbstractExternMethod):
def __init__(self, descriptor, attr):
self.attr = attr
name = 'get_' + descriptor.internalNameFor(attr.identifier.name)
- args = [Argument('SafeJSContext', 'cx'),
- Argument('HandleObject', '_obj'),
- Argument('*const %s' % descriptor.concreteType, 'this'),
+ args = [Argument('*mut JSContext', 'cx'),
+ Argument('RawHandleObject', '_obj'),
+ Argument('*mut libc::c_void', 'this'),
Argument('JSJitGetterCallArgs', 'args')]
CGAbstractExternMethod.__init__(self, descriptor, name, "bool", args)
@@ -3771,7 +3778,8 @@ class CGSpecializedGetter(CGAbstractExternMethod):
return CGWrapper(CGGetterCall([], self.attr.type, nativeName,
self.descriptor, self.attr),
- pre="let this = &*this;\n")
+ pre="let cx = SafeJSContext::from_ptr(cx);\n" +
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
@staticmethod
def makeNativeName(descriptor, attr):
@@ -3815,9 +3823,9 @@ class CGSpecializedSetter(CGAbstractExternMethod):
def __init__(self, descriptor, attr):
self.attr = attr
name = 'set_' + descriptor.internalNameFor(attr.identifier.name)
- args = [Argument('SafeJSContext', 'cx'),
- Argument('HandleObject', 'obj'),
- Argument('*const %s' % descriptor.concreteType, 'this'),
+ args = [Argument('*mut JSContext', 'cx'),
+ Argument('RawHandleObject', 'obj'),
+ Argument('*mut libc::c_void', 'this'),
Argument('JSJitSetterCallArgs', 'args')]
CGAbstractExternMethod.__init__(self, descriptor, name, "bool", args)
@@ -3826,7 +3834,8 @@ class CGSpecializedSetter(CGAbstractExternMethod):
self.attr)
return CGWrapper(CGSetterCall([], self.attr.type, nativeName,
self.descriptor, self.attr),
- pre="let this = &*this;\n")
+ pre="let cx = SafeJSContext::from_ptr(cx);\n" +
+ ("let this = &*(this as *const %s);\n" % self.descriptor.concreteType))
@staticmethod
def makeNativeName(descriptor, attr):
@@ -3875,8 +3884,9 @@ class CGSpecializedForwardingSetter(CGSpecializedSetter):
assert all(ord(c) < 128 for c in attrName)
assert all(ord(c) < 128 for c in forwardToAttrName)
return CGGeneric("""\
+let cx = SafeJSContext::from_ptr(cx);
rooted!(in(*cx) let mut v = UndefinedValue());
-if !JS_GetProperty(*cx, obj, %s as *const u8 as *const libc::c_char, v.handle_mut()) {
+if !JS_GetProperty(*cx, HandleObject::from_raw(obj), %s as *const u8 as *const libc::c_char, v.handle_mut()) {
return false;
}
if !v.is_object() {
@@ -3901,7 +3911,7 @@ class CGSpecializedReplaceableSetter(CGSpecializedSetter):
# JS_DefineProperty can only deal with ASCII.
assert all(ord(c) < 128 for c in name)
return CGGeneric("""\
-JS_DefineProperty(*cx, obj, %s as *const u8 as *const libc::c_char,
+JS_DefineProperty(cx, HandleObject::from_raw(obj), %s as *const u8 as *const libc::c_char,
HandleValue::from_raw(args.get(0)), JSPROP_ENUMERATE as u32)""" % name)
@@ -3931,27 +3941,34 @@ class CGMemberJITInfo(CGThing):
initializer = fill(
"""
JSJitInfo {
- call: ${opName} as *const os::raw::c_void,
- protoID: PrototypeList::ID::${name} as u16,
- depth: ${depth},
- _bitfield_1: new_jsjitinfo_bitfield_1!(
- JSJitInfo_OpType::${opType} as u8,
- JSJitInfo_AliasSet::${aliasSet} as u8,
- JSValueType::${returnType} as u8,
- ${isInfallible},
- ${isMovable},
- ${isEliminatable},
- ${isAlwaysInSlot},
- ${isLazilyCachedInSlot},
- ${isTypedMethod},
- ${slotIndex},
- ),
+ __bindgen_anon_1: JSJitInfo__bindgen_ty_1 {
+ ${opKind}: Some(${opName})
+ },
+ __bindgen_anon_2: JSJitInfo__bindgen_ty_2 {
+ protoID: PrototypeList::ID::${name} as u16,
+ },
+ __bindgen_anon_3: JSJitInfo__bindgen_ty_3 { depth: ${depth} },
+ _bitfield_1: unsafe {
+ mem::transmute(new_jsjitinfo_bitfield_1!(
+ JSJitInfo_OpType::${opType} as u8,
+ JSJitInfo_AliasSet::${aliasSet} as u8,
+ JSValueType::${returnType} as u8,
+ ${isInfallible},
+ ${isMovable},
+ ${isEliminatable},
+ ${isAlwaysInSlot},
+ ${isLazilyCachedInSlot},
+ ${isTypedMethod},
+ ${slotIndex},
+ ))
+ },
}
""",
opName=opName,
name=self.descriptor.name,
depth=self.descriptor.interface.inheritanceDepth(),
opType=opType,
+ opKind=opType.lower(),
aliasSet=aliasSet,
returnType=functools.reduce(CGMemberJITInfo.getSingleReturnType, returnTypes,
""),
@@ -4211,7 +4228,7 @@ class CGMemberJITInfo(CGThing):
return "JSJitInfo_ArgType::Object as i32"
if t.isUnion():
u = t.unroll()
- type = "JSJitInfo::Null as i32" if u.hasNullableType else ""
+ type = "JSJitInfo_ArgType::Null as i32" if u.hasNullableType else ""
return functools.reduce(CGMemberJITInfo.getSingleArgType,
u.flatMemberTypes, type)
if t.isDictionary():
@@ -5311,7 +5328,7 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
def __init__(self, descriptor):
args = [Argument('*mut JSContext', 'cx'),
Argument('RawHandleObject', 'proxy'),
- Argument('*mut AutoIdVector', 'props')]
+ Argument('RawMutableHandleIdVector', 'props')]
CGAbstractExternMethod.__init__(self, descriptor, "own_property_keys", "bool", args)
self.descriptor = descriptor
@@ -5328,7 +5345,7 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
for i in 0..(*unwrapped_proxy).Length() {
rooted!(in(*cx) let mut rooted_jsid: jsid);
int_to_jsid(i as i32, rooted_jsid.handle_mut());
- AppendToAutoIdVector(props, rooted_jsid.handle());
+ AppendToIdVector(props, rooted_jsid.handle());
}
""")
@@ -5341,7 +5358,7 @@ class CGDOMJSProxyHandler_ownPropertyKeys(CGAbstractExternMethod):
rooted!(in(*cx) let rooted = jsstring);
rooted!(in(*cx) let mut rooted_jsid: jsid);
RUST_INTERNED_STRING_TO_JSID(*cx, rooted.handle().get(), rooted_jsid.handle_mut());
- AppendToAutoIdVector(props, rooted_jsid.handle());
+ AppendToIdVector(props, rooted_jsid.handle());
}
""")
@@ -5369,7 +5386,7 @@ class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
descriptor.interface.getExtendedAttribute("LegacyUnenumerableNamedProperties"))
args = [Argument('*mut JSContext', 'cx'),
Argument('RawHandleObject', 'proxy'),
- Argument('*mut AutoIdVector', 'props')]
+ Argument('RawMutableHandleIdVector', 'props')]
CGAbstractExternMethod.__init__(self, descriptor,
"getOwnEnumerablePropertyKeys", "bool", args)
self.descriptor = descriptor
@@ -5387,7 +5404,7 @@ class CGDOMJSProxyHandler_getOwnEnumerablePropertyKeys(CGAbstractExternMethod):
for i in 0..(*unwrapped_proxy).Length() {
rooted!(in(*cx) let mut rooted_jsid: jsid);
int_to_jsid(i as i32, rooted_jsid.handle_mut());
- AppendToAutoIdVector(props, rooted_jsid.handle());
+ AppendToIdVector(props, rooted_jsid.handle());
}
""")
@@ -5917,11 +5934,9 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::JS_CALLEE',
'js::error::throw_type_error',
'js::error::throw_internal_error',
- 'js::jsapi::AutoIdVector',
'js::rust::wrappers::Call',
'js::jsapi::CallArgs',
'js::jsapi::CurrentGlobalOrNull',
- 'js::jsapi::FreeOp',
'js::rust::wrappers::GetPropertyKeys',
'js::jsapi::GetWellKnownSymbol',
'js::rust::Handle',
@@ -5948,6 +5963,9 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::jsapi::JSITER_SYMBOLS',
'js::jsapi::JSJitGetterCallArgs',
'js::jsapi::JSJitInfo',
+ 'js::jsapi::JSJitInfo__bindgen_ty_1',
+ 'js::jsapi::JSJitInfo__bindgen_ty_2',
+ 'js::jsapi::JSJitInfo__bindgen_ty_3',
'js::jsapi::JSJitInfo_AliasSet',
'js::jsapi::JSJitInfo_ArgType',
'js::jsapi::JSJitInfo_OpType',
@@ -5960,10 +5978,10 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::jsapi::JSPROP_PERMANENT',
'js::jsapi::JSPROP_READONLY',
'js::jsapi::JSPropertySpec',
- 'js::jsapi::JSPropertySpec__bindgen_ty_1',
- 'js::jsapi::JSPropertySpec__bindgen_ty_1__bindgen_ty_1',
- 'js::jsapi::JSPropertySpec__bindgen_ty_1__bindgen_ty_1__bindgen_ty_1',
- 'js::jsapi::JSPropertySpec__bindgen_ty_1__bindgen_ty_1__bindgen_ty_2',
+ 'js::jsapi::JSPropertySpec_Accessor',
+ 'js::jsapi::JSPropertySpec_AccessorsOrValue',
+ 'js::jsapi::JSPropertySpec_AccessorsOrValue_Accessors',
+ 'js::jsapi::JSPropertySpec_Name',
'js::jsapi::JSString',
'js::jsapi::JSTracer',
'js::jsapi::JSType',
@@ -6005,6 +6023,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::jsapi::MutableHandleObject as RawMutableHandleObject',
'js::rust::MutableHandleValue',
'js::jsapi::MutableHandleValue as RawMutableHandleValue',
+ 'js::jsapi::MutableHandleIdVector as RawMutableHandleIdVector',
'js::jsapi::ObjectOpResult',
'js::jsapi::PropertyDescriptor',
'js::jsapi::Rooted',
@@ -6020,7 +6039,7 @@ def generate_imports(config, cgthings, descriptors, callbacks=None, dictionaries
'js::jsval::PrivateValue',
'js::jsval::UndefinedValue',
'js::jsapi::UndefinedHandleValue',
- 'js::rust::wrappers::AppendToAutoIdVector',
+ 'js::rust::wrappers::AppendToIdVector',
'js::glue::CallJitGetterOp',
'js::glue::CallJitMethodOp',
'js::glue::CallJitSetterOp',
diff --git a/components/script/dom/bindings/error.rs b/components/script/dom/bindings/error.rs
index b88a6cabed3..f678611423b 100644
--- a/components/script/dom/bindings/error.rs
+++ b/components/script/dom/bindings/error.rs
@@ -19,6 +19,7 @@ use crate::script_runtime::JSContext as SafeJSContext;
#[cfg(feature = "js_backtrace")]
use backtrace::Backtrace;
use js::error::{throw_range_error, throw_type_error};
+use js::jsapi::ExceptionStackBehavior;
use js::jsapi::JSContext;
use js::jsapi::JS_ClearPendingException;
use js::jsapi::JS_IsExceptionPending;
@@ -161,7 +162,7 @@ pub fn throw_dom_exception(cx: SafeJSContext, global: &GlobalScope, result: Erro
let exception = DOMException::new(global, code);
rooted!(in(*cx) let mut thrown = UndefinedValue());
exception.to_jsval(*cx, thrown.handle_mut());
- JS_SetPendingException(*cx, thrown.handle());
+ JS_SetPendingException(*cx, thrown.handle(), ExceptionStackBehavior::Capture);
}
}
diff --git a/components/script/dom/bindings/interface.rs b/components/script/dom/bindings/interface.rs
index 2097769cb31..d0b3771890e 100644
--- a/components/script/dom/bindings/interface.rs
+++ b/components/script/dom/bindings/interface.rs
@@ -15,8 +15,8 @@ use js::error::throw_type_error;
use js::glue::UncheckedUnwrapObject;
use js::jsapi::GetWellKnownSymbol;
use js::jsapi::HandleObject as RawHandleObject;
-use js::jsapi::{jsid, Class, ClassOps};
-use js::jsapi::{JSAutoRealm, JSClass, JSContext, JSFunctionSpec, JSObject, JSFUN_CONSTRUCTOR};
+use js::jsapi::{jsid, JSClass, JSClassOps};
+use js::jsapi::{JSAutoRealm, JSContext, JSFunctionSpec, JSObject, JSFUN_CONSTRUCTOR};
use js::jsapi::{JSPropertySpec, JSString, JSTracer, JS_AtomizeAndPinString};
use js::jsapi::{JS_GetFunctionObject, JS_NewFunction, JS_NewGlobalObject};
use js::jsapi::{JS_NewObject, JS_NewPlainObject};
@@ -38,8 +38,8 @@ use std::ptr;
/// The class of a non-callback interface object.
#[derive(Clone, Copy)]
pub struct NonCallbackInterfaceObjectClass {
- /// The SpiderMonkey Class structure.
- pub class: Class,
+ /// The SpiderMonkey class structure.
+ pub class: JSClass,
/// The prototype id of that interface, used in the hasInstance hook.
pub proto_id: PrototypeList::ID,
/// The prototype depth of that interface, used in the hasInstance hook.
@@ -59,7 +59,7 @@ impl NonCallbackInterfaceObjectClass {
proto_depth: u16,
) -> NonCallbackInterfaceObjectClass {
NonCallbackInterfaceObjectClass {
- class: Class {
+ class: JSClass {
name: b"Function\0" as *const _ as *const libc::c_char,
flags: 0,
cOps: &constructor_behavior.0,
@@ -84,12 +84,12 @@ pub type ConstructorClassHook =
unsafe extern "C" fn(cx: *mut JSContext, argc: u32, vp: *mut Value) -> bool;
/// The constructor behavior of a non-callback interface object.
-pub struct InterfaceConstructorBehavior(ClassOps);
+pub struct InterfaceConstructorBehavior(JSClassOps);
impl InterfaceConstructorBehavior {
/// An interface constructor that unconditionally throws a type error.
pub const fn throw() -> Self {
- InterfaceConstructorBehavior(ClassOps {
+ InterfaceConstructorBehavior(JSClassOps {
addProperty: None,
delProperty: None,
enumerate: None,
@@ -106,7 +106,7 @@ impl InterfaceConstructorBehavior {
/// An interface constructor that calls a native Rust function.
pub const fn call(hook: ConstructorClassHook) -> Self {
- InterfaceConstructorBehavior(ClassOps {
+ InterfaceConstructorBehavior(JSClassOps {
addProperty: None,
delProperty: None,
enumerate: None,
diff --git a/components/script/dom/bindings/namespace.rs b/components/script/dom/bindings/namespace.rs
index 82b7bd8834e..64b7b0b2626 100644
--- a/components/script/dom/bindings/namespace.rs
+++ b/components/script/dom/bindings/namespace.rs
@@ -9,6 +9,7 @@ use crate::dom::bindings::interface::{create_object, define_on_global_object};
use crate::script_runtime::JSContext;
use js::jsapi::{JSClass, JSFunctionSpec};
use js::rust::{HandleObject, MutableHandleObject};
+use std::ptr;
/// The class of a namespace object.
#[derive(Clone, Copy)]
@@ -23,7 +24,9 @@ impl NamespaceObjectClass {
name: name as *const _ as *const libc::c_char,
flags: 0,
cOps: 0 as *mut _,
- reserved: [0 as *mut _; 3],
+ spec: ptr::null(),
+ ext: ptr::null(),
+ oOps: ptr::null(),
})
}
}
diff --git a/components/script/dom/bindings/proxyhandler.rs b/components/script/dom/bindings/proxyhandler.rs
index a4b5f418cd2..11913c03642 100644
--- a/components/script/dom/bindings/proxyhandler.rs
+++ b/components/script/dom/bindings/proxyhandler.rs
@@ -55,7 +55,11 @@ pub unsafe extern "C" fn shadow_check_callback(
/// Initialize the infrastructure for DOM proxy objects.
pub unsafe fn init() {
- SetDOMProxyInformation(GetProxyHandlerFamily(), Some(shadow_check_callback));
+ SetDOMProxyInformation(
+ GetProxyHandlerFamily(),
+ Some(shadow_check_callback),
+ ptr::null(),
+ );
}
/// Defines an expando on the given `proxy`.
diff --git a/components/script/dom/bindings/record.rs b/components/script/dom/bindings/record.rs
index 86453b59fc3..c54a2403d70 100644
--- a/components/script/dom/bindings/record.rs
+++ b/components/script/dom/bindings/record.rs
@@ -120,12 +120,12 @@ where
}
rooted!(in(cx) let object = value.to_object());
- let ids = IdVector::new(cx);
+ let mut ids = IdVector::new(cx);
if !GetPropertyKeys(
cx,
object.handle(),
JSITER_OWNONLY | JSITER_HIDDEN | JSITER_SYMBOLS,
- ids.get(),
+ ids.handle_mut(),
) {
return Err(());
}
diff --git a/components/script/dom/bindings/root.rs b/components/script/dom/bindings/root.rs
index 1fea453e35a..0ba69687dba 100644
--- a/components/script/dom/bindings/root.rs
+++ b/components/script/dom/bindings/root.rs
@@ -26,7 +26,7 @@
use crate::dom::bindings::conversions::DerivedFrom;
use crate::dom::bindings::inheritance::Castable;
-use crate::dom::bindings::reflector::{DomObject, Reflector};
+use crate::dom::bindings::reflector::{DomObject, MutDomObject, Reflector};
use crate::dom::bindings::trace::trace_reflector;
use crate::dom::bindings::trace::JSTraceable;
use crate::dom::node::Node;
@@ -262,7 +262,10 @@ impl RootCollection {
unsafe fn unroot(&self, object: *const dyn JSTraceable) {
debug_assert!(thread_state::get().is_script());
let roots = &mut *self.roots.get();
- match roots.iter().rposition(|r| *r == object) {
+ match roots
+ .iter()
+ .rposition(|r| *r as *const () == object as *const ())
+ {
Some(idx) => {
roots.remove(idx);
},
@@ -385,15 +388,25 @@ where
}
}
-impl<T> Deref for MaybeUnreflectedDom<T>
+impl<T> Root<MaybeUnreflectedDom<T>>
where
T: DomObject,
{
- type Target = T;
+ pub fn as_ptr(&self) -> *const T {
+ self.value.ptr.as_ptr()
+ }
+}
- fn deref(&self) -> &T {
- debug_assert!(thread_state::get().is_script());
- unsafe { &*self.ptr.as_ptr() }
+impl<T> Root<MaybeUnreflectedDom<T>>
+where
+ T: MutDomObject,
+{
+ pub unsafe fn reflect_with(self, obj: *mut JSObject) -> DomRoot<T> {
+ let ptr = self.as_ptr();
+ drop(self);
+ let root = DomRoot::from_ref(&*ptr);
+ root.init_reflector(obj);
+ root
}
}
diff --git a/components/script/dom/bindings/structuredclone.rs b/components/script/dom/bindings/structuredclone.rs
index dbf852907a8..511b8d1650e 100644
--- a/components/script/dom/bindings/structuredclone.rs
+++ b/components/script/dom/bindings/structuredclone.rs
@@ -361,6 +361,9 @@ pub fn read(
JS_STRUCTURED_CLONE_VERSION,
StructuredCloneScope::DifferentProcess,
rval,
+ CloneDataPolicy {
+ sharedArrayBuffer_: false,
+ },
&STRUCTURED_CLONE_CALLBACKS,
sc_holder_ptr as *mut raw::c_void,
);
diff --git a/components/script/dom/bindings/trace.rs b/components/script/dom/bindings/trace.rs
index 631731e39a6..2d6b6c04379 100644
--- a/components/script/dom/bindings/trace.rs
+++ b/components/script/dom/bindings/trace.rs
@@ -891,7 +891,11 @@ impl RootedTraceableSet {
unsafe fn remove(traceable: *const dyn JSTraceable) {
ROOTED_TRACEABLES.with(|ref traceables| {
let mut traceables = traceables.borrow_mut();
- let idx = match traceables.set.iter().rposition(|x| *x == traceable) {
+ let idx = match traceables
+ .set
+ .iter()
+ .rposition(|x| *x as *const () == traceable as *const ())
+ {
Some(idx) => idx,
None => unreachable!(),
};
diff --git a/components/script/dom/bindings/utils.rs b/components/script/dom/bindings/utils.rs
index 56b2112e498..21f82be9cee 100644
--- a/components/script/dom/bindings/utils.rs
+++ b/components/script/dom/bindings/utils.rs
@@ -23,8 +23,9 @@ use js::glue::{
};
use js::jsapi::HandleId as RawHandleId;
use js::jsapi::HandleObject as RawHandleObject;
+use js::jsapi::MutableHandleIdVector as RawMutableHandleIdVector;
use js::jsapi::MutableHandleObject as RawMutableHandleObject;
-use js::jsapi::{AutoIdVector, CallArgs, DOMCallbacks, GetNonCCWObjectGlobal};
+use js::jsapi::{CallArgs, DOMCallbacks, GetNonCCWObjectGlobal};
use js::jsapi::{Heap, JSAutoRealm, JSContext, JS_FreezeObject};
use js::jsapi::{JSJitInfo, JSObject, JSTracer, JSWrapObjectCallbacks};
use js::jsapi::{JS_EnumerateStandardClasses, JS_GetLatin1StringCharsAndLength};
@@ -375,7 +376,7 @@ pub unsafe fn trace_global(tracer: *mut JSTracer, obj: *mut JSObject) {
pub unsafe extern "C" fn enumerate_global(
cx: *mut JSContext,
obj: RawHandleObject,
- _props: *mut AutoIdVector,
+ _props: RawMutableHandleIdVector,
_enumerable_only: bool,
) -> bool {
assert!(JS_IsGlobalObject(obj.get()));
@@ -439,6 +440,7 @@ unsafe extern "C" fn wrap(
unsafe extern "C" fn pre_wrap(
cx: *mut JSContext,
_scope: RawHandleObject,
+ _orig_obj: RawHandleObject,
obj: RawHandleObject,
_object_passed_to_wrap: RawHandleObject,
rval: RawMutableHandleObject,
@@ -482,7 +484,7 @@ unsafe fn generic_call(
let args = CallArgs::from_vp(vp, argc);
let info = RUST_FUNCTION_VALUE_TO_JITINFO(JS_CALLEE(cx, vp));
- let proto_id = (*info).protoID;
+ let proto_id = (*info).__bindgen_anon_2.protoID;
let thisobj = args.thisv();
if !thisobj.get().is_null_or_undefined() && !thisobj.get().is_object() {
@@ -495,7 +497,7 @@ unsafe fn generic_call(
} else {
GetNonCCWObjectGlobal(JS_CALLEE(cx, vp).to_object_or_null())
});
- let depth = (*info).depth;
+ let depth = (*info).__bindgen_anon_3.depth;
let proto_check =
|class: &'static DOMClass| class.interface_chain[depth as usize] as u16 == proto_id;
let this = match private_from_proto_check(obj.get(), cx, proto_check) {
@@ -582,7 +584,7 @@ pub unsafe extern "C" fn generic_lenient_setter(
}
unsafe extern "C" fn instance_class_has_proto_at_depth(
- clasp: *const js::jsapi::Class,
+ clasp: *const js::jsapi::JSClass,
proto_id: u32,
depth: u32,
) -> bool {
diff --git a/components/script/dom/document.rs b/components/script/dom/document.rs
index 1253202ed8b..303c51660f0 100644
--- a/components/script/dom/document.rs
+++ b/components/script/dom/document.rs
@@ -1636,11 +1636,10 @@ impl Document {
.borrow_mut()
.push((ident, Some(callback)));
- // TODO: Should tick animation only when document is visible
-
// If we are running 'fake' animation frames, we unconditionally
// set up a one-shot timer for script to execute the rAF callbacks.
- if self.is_faking_animation_frames() {
+ if self.is_faking_animation_frames() && self.window().visible() {
+ warn!("Scheduling fake animation frame. Animation frames tick too fast.");
let callback = FakeRequestAnimationFrameCallback {
document: Trusted::new(self),
};
diff --git a/components/script/dom/eventtarget.rs b/components/script/dom/eventtarget.rs
index 4020f938b24..90e533c8cc3 100644
--- a/components/script/dom/eventtarget.rs
+++ b/components/script/dom/eventtarget.rs
@@ -37,9 +37,9 @@ use crate::dom::workerglobalscope::WorkerGlobalScope;
use crate::realms::{enter_realm, InRealm};
use dom_struct::dom_struct;
use fnv::FnvHasher;
-use js::jsapi::{JSFunction, JS_GetFunctionObject, SourceText};
+use js::jsapi::{JS_GetFunctionObject, SourceText};
use js::rust::wrappers::CompileFunction;
-use js::rust::{AutoObjectVectorWrapper, CompileOptionsWrapper};
+use js::rust::{CompileOptionsWrapper, RootedObjectVectorWrapper};
use libc::c_char;
use servo_atoms::Atom;
use servo_url::ServoUrl;
@@ -51,7 +51,6 @@ use std::hash::BuildHasherDefault;
use std::marker::PhantomData;
use std::mem;
use std::ops::{Deref, DerefMut};
-use std::ptr;
use std::rc::Rc;
#[derive(Clone, JSTraceable, MallocSizeOf, PartialEq)]
@@ -491,9 +490,10 @@ impl EventTarget {
// source text, we handle parse errors later
// Step 3.8 TODO: settings objects not implemented
+ let window = document.window();
+ let _ac = enter_realm(&*window);
// Step 3.9
- let window = document.window();
let url_serialized = CString::new(handler.url.to_string()).unwrap();
let name = CString::new(&**ty).unwrap();
@@ -517,10 +517,12 @@ impl EventTarget {
};
let cx = window.get_cx();
- let options = CompileOptionsWrapper::new(*cx, url_serialized.as_ptr(), handler.line as u32);
+ let options = unsafe {
+ CompileOptionsWrapper::new(*cx, url_serialized.as_ptr(), handler.line as u32)
+ };
// Step 3.9, subsection Scope steps 1-6
- let scopechain = AutoObjectVectorWrapper::new(*cx);
+ let scopechain = RootedObjectVectorWrapper::new(*cx);
if let Some(element) = element {
scopechain.append(document.reflector().get_jsobject().get());
@@ -530,12 +532,10 @@ impl EventTarget {
scopechain.append(element.reflector().get_jsobject().get());
}
- let _ac = enter_realm(&*window); // TODO 3.8 should replace this
- rooted!(in(*cx) let mut handler = ptr::null_mut::<JSFunction>());
- let rv = unsafe {
+ rooted!(in(*cx) let mut handler = unsafe {
CompileFunction(
*cx,
- scopechain.ptr,
+ scopechain.handle(),
options.ptr,
name.as_ptr(),
args.len() as u32,
@@ -546,10 +546,9 @@ impl EventTarget {
ownsUnits_: false,
_phantom_0: PhantomData,
},
- handler.handle_mut().into(),
)
- };
- if !rv || handler.get().is_null() {
+ });
+ if handler.get().is_null() {
// Step 3.7
unsafe {
let ar = enter_realm(&*self);
diff --git a/components/script/dom/globalscope.rs b/components/script/dom/globalscope.rs
index 8eed617d0fa..9e55f593f59 100644
--- a/components/script/dom/globalscope.rs
+++ b/components/script/dom/globalscope.rs
@@ -65,13 +65,12 @@ use embedder_traits::EmbedderMsg;
use ipc_channel::ipc::{self, IpcSender};
use ipc_channel::router::ROUTER;
use js::glue::{IsWrapper, UnwrapObjectDynamic};
-use js::jsapi::JSContext;
-use js::jsapi::JSObject;
use js::jsapi::{CurrentGlobalOrNull, GetNonCCWObjectGlobal};
use js::jsapi::{HandleObject, Heap};
+use js::jsapi::{JSContext, JSObject, SourceText};
use js::jsval::{JSVal, UndefinedValue};
use js::panic::maybe_resume_unwind;
-use js::rust::wrappers::EvaluateUtf8;
+use js::rust::wrappers::Evaluate2;
use js::rust::{get_object_class, CompileOptionsWrapper, ParentRuntime, Runtime};
use js::rust::{HandleValue, MutableHandleValue};
use js::{JSCLASS_IS_DOMJSCLASS, JSCLASS_IS_GLOBAL};
@@ -98,6 +97,7 @@ use std::cell::{Cell, RefCell, RefMut};
use std::collections::hash_map::Entry;
use std::collections::{HashMap, VecDeque};
use std::ffi::CString;
+use std::marker::PhantomData;
use std::mem;
use std::ops::Index;
use std::rc::Rc;
@@ -2158,15 +2158,20 @@ impl GlobalScope {
let ar = enter_realm(&*self);
let _aes = AutoEntryScript::new(self);
- let options = CompileOptionsWrapper::new(*cx, filename.as_ptr(), line_number);
+ let options =
+ unsafe { CompileOptionsWrapper::new(*cx, filename.as_ptr(), line_number) };
debug!("evaluating Dom string");
let result = unsafe {
- EvaluateUtf8(
+ Evaluate2(
*cx,
options.ptr,
- code.as_ptr() as *const _,
- code.len() as libc::size_t,
+ &mut SourceText {
+ units_: code.as_ptr() as *const _,
+ length_: code.len() as u32,
+ ownsUnits_: false,
+ _phantom_0: PhantomData,
+ },
rval,
)
};
diff --git a/components/script/dom/htmlcanvaselement.rs b/components/script/dom/htmlcanvaselement.rs
index e800a89bdf1..e56ca4a8266 100644
--- a/components/script/dom/htmlcanvaselement.rs
+++ b/components/script/dom/htmlcanvaselement.rs
@@ -392,7 +392,7 @@ impl HTMLCanvasElementMethods for HTMLCanvasElement {
// FIXME(nox): https://github.com/PistonDevelopers/image-png/issues/86
// FIXME(nox): https://github.com/PistonDevelopers/image-png/issues/87
PNGEncoder::new(&mut png)
- .encode(&file, self.Width(), self.Height(), ColorType::RGBA(8))
+ .encode(&file, self.Width(), self.Height(), ColorType::Rgba8)
.unwrap();
let mut url = "data:image/png;base64,".to_owned();
// FIXME(nox): Should this use base64::URL_SAFE?
diff --git a/components/script/dom/htmlmediaelement.rs b/components/script/dom/htmlmediaelement.rs
index 6cbb25157ff..f8c686d34f2 100644
--- a/components/script/dom/htmlmediaelement.rs
+++ b/components/script/dom/htmlmediaelement.rs
@@ -96,7 +96,8 @@ use std::rc::Rc;
use std::sync::{Arc, Mutex};
use time::{self, Duration, Timespec};
use webrender_api::{ExternalImageData, ExternalImageId, ExternalImageType, TextureTarget};
-use webrender_api::{ImageData, ImageDescriptor, ImageFormat, ImageKey, Transaction};
+use webrender_api::{ImageData, ImageDescriptor, ImageDescriptorFlags, ImageFormat};
+use webrender_api::{ImageKey, Transaction};
#[derive(PartialEq)]
enum FrameStatus {
@@ -186,8 +187,7 @@ impl VideoFrameRenderer for MediaFrameRenderer {
frame.get_width(),
frame.get_height(),
ImageFormat::BGRA8,
- false,
- false,
+ ImageDescriptorFlags::empty(),
);
match self.current_frame {
diff --git a/components/script/dom/promise.rs b/components/script/dom/promise.rs
index 37baedcc663..5e60507f8fc 100644
--- a/components/script/dom/promise.rs
+++ b/components/script/dom/promise.rs
@@ -91,7 +91,7 @@ impl Promise {
pub fn new_in_current_realm(global: &GlobalScope, _comp: InRealm) -> Rc<Promise> {
let cx = global.get_cx();
rooted!(in(*cx) let mut obj = ptr::null_mut::<JSObject>());
- Promise::create_js_promise(cx, HandleObject::null(), obj.handle_mut());
+ Promise::create_js_promise(cx, obj.handle_mut());
Promise::new_with_js_promise(obj.handle(), cx)
}
@@ -117,7 +117,7 @@ impl Promise {
}
#[allow(unsafe_code)]
- fn create_js_promise(cx: SafeJSContext, proto: HandleObject, mut obj: MutableHandleObject) {
+ fn create_js_promise(cx: SafeJSContext, mut obj: MutableHandleObject) {
unsafe {
let do_nothing_func = JS_NewFunction(
*cx,
@@ -129,7 +129,7 @@ impl Promise {
assert!(!do_nothing_func.is_null());
rooted!(in(*cx) let do_nothing_obj = JS_GetFunctionObject(do_nothing_func));
assert!(!do_nothing_obj.is_null());
- obj.set(NewPromiseObject(*cx, do_nothing_obj.handle(), proto));
+ obj.set(NewPromiseObject(*cx, do_nothing_obj.handle()));
assert!(!obj.is_null());
}
}
diff --git a/components/script/dom/webgl2renderingcontext.rs b/components/script/dom/webgl2renderingcontext.rs
index f3c88cbb7c8..d6452a88043 100644
--- a/components/script/dom/webgl2renderingcontext.rs
+++ b/components/script/dom/webgl2renderingcontext.rs
@@ -82,6 +82,7 @@ fn typedarray_elem_size(typeid: Type) -> usize {
Type::Int16 | Type::Uint16 => 2,
Type::Int32 | Type::Uint32 | Type::Float32 => 4,
Type::Int64 | Type::Float64 => 8,
+ Type::BigInt64 | Type::BigUint64 => 8,
Type::MaxTypedArrayViewType => unreachable!(),
}
}
@@ -1466,6 +1467,12 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
self.base.GetAttribLocation(program, name)
}
+ /// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.7
+ fn GetFragDataLocation(&self, program: &WebGLProgram, name: DOMString) -> i32 {
+ handle_potential_webgl_error!(self.base, self.base.validate_ownership(program), return -1);
+ handle_potential_webgl_error!(self.base, program.get_frag_data_location(name), -1)
+ }
+
/// https://www.khronos.org/registry/webgl/specs/latest/1.0/#5.14.9
fn GetProgramInfoLog(&self, program: &WebGLProgram) -> Option<DOMString> {
self.base.GetProgramInfoLog(program)
@@ -3581,6 +3588,36 @@ impl WebGL2RenderingContextMethods for WebGL2RenderingContext {
height,
))
}
+
+ /// https://www.khronos.org/registry/webgl/specs/latest/2.0/#3.7.4
+ fn FramebufferTextureLayer(
+ &self,
+ target: u32,
+ attachment: u32,
+ texture: Option<&WebGLTexture>,
+ level: i32,
+ layer: i32,
+ ) {
+ if let Some(tex) = texture {
+ handle_potential_webgl_error!(self.base, self.base.validate_ownership(tex), return);
+ }
+
+ let fb_slot = match target {
+ constants::FRAMEBUFFER | constants::DRAW_FRAMEBUFFER => {
+ self.base.get_draw_framebuffer_slot()
+ },
+ constants::READ_FRAMEBUFFER => self.base.get_read_framebuffer_slot(),
+ _ => return self.base.webgl_error(InvalidEnum),
+ };
+
+ match fb_slot.get() {
+ Some(fb) => handle_potential_webgl_error!(
+ self.base,
+ fb.texture_layer(attachment, texture, level, layer)
+ ),
+ None => self.base.webgl_error(InvalidOperation),
+ }
+ }
}
impl LayoutCanvasWebGLRenderingContextHelpers for LayoutDom<WebGL2RenderingContext> {
diff --git a/components/script/dom/webglframebuffer.rs b/components/script/dom/webglframebuffer.rs
index 8f5f499072a..c285145d994 100644
--- a/components/script/dom/webglframebuffer.rs
+++ b/components/script/dom/webglframebuffer.rs
@@ -468,7 +468,7 @@ impl WebGLFramebuffer {
return CompleteForRendering::Complete;
}
- if self.colors.iter().any(|att| att.borrow().is_none()) {
+ if self.colors.iter().all(|att| att.borrow().is_none()) {
return CompleteForRendering::MissingColorAttachment;
}
@@ -727,6 +727,61 @@ impl WebGLFramebuffer {
Ok(())
}
+ pub fn texture_layer(
+ &self,
+ attachment: u32,
+ texture: Option<&WebGLTexture>,
+ level: i32,
+ layer: i32,
+ ) -> WebGLResult<()> {
+ let binding = self
+ .attachment_binding(attachment)
+ .ok_or(WebGLError::InvalidEnum)?;
+
+ let context = self.upcast::<WebGLObject>().context();
+
+ let tex_id = match texture {
+ Some(texture) => {
+ let (max_level, max_layer) = match texture.target() {
+ Some(constants::TEXTURE_3D) => (
+ log2(context.limits().max_3d_texture_size),
+ context.limits().max_3d_texture_size - 1,
+ ),
+ Some(constants::TEXTURE_2D) => (
+ log2(context.limits().max_tex_size),
+ context.limits().max_array_texture_layers - 1,
+ ),
+ _ => return Err(WebGLError::InvalidOperation),
+ };
+
+ if level < 0 || level as u32 >= max_level {
+ return Err(WebGLError::InvalidValue);
+ }
+ if layer < 0 || layer as u32 >= max_layer {
+ return Err(WebGLError::InvalidValue);
+ }
+
+ *binding.borrow_mut() = Some(WebGLFramebufferAttachment::Texture {
+ texture: Dom::from_ref(texture),
+ level: level,
+ });
+ texture.attach_to_framebuffer(self);
+
+ Some(texture.id())
+ },
+ _ => None,
+ };
+
+ context.send_command(WebGLCommand::FramebufferTextureLayer(
+ self.target.get().unwrap(),
+ attachment,
+ tex_id,
+ level,
+ layer,
+ ));
+ Ok(())
+ }
+
fn with_matching_renderbuffers<F>(&self, rb: &WebGLRenderbuffer, mut closure: F)
where
F: FnMut(&DomRefCell<Option<WebGLFramebufferAttachment>>, u32),
diff --git a/components/script/dom/webglprogram.rs b/components/script/dom/webglprogram.rs
index 556573aae2e..4bb59fb1428 100644
--- a/components/script/dom/webglprogram.rs
+++ b/components/script/dom/webglprogram.rs
@@ -365,6 +365,30 @@ impl WebGLProgram {
Ok(location)
}
+ /// glGetFragDataLocation
+ pub fn get_frag_data_location(&self, name: DOMString) -> WebGLResult<i32> {
+ if !self.is_linked() || self.is_deleted() {
+ return Err(WebGLError::InvalidOperation);
+ }
+
+ if !validate_glsl_name(&name)? {
+ return Ok(-1);
+ }
+ if name.starts_with("gl_") {
+ return Ok(-1);
+ }
+
+ let (sender, receiver) = webgl_channel().unwrap();
+ self.upcast::<WebGLObject>()
+ .context()
+ .send_command(WebGLCommand::GetFragDataLocation(
+ self.id,
+ name.into(),
+ sender,
+ ));
+ Ok(receiver.recv().unwrap())
+ }
+
/// glGetUniformLocation
pub fn get_uniform_location(
&self,
diff --git a/components/script/dom/webidls/WebGL2RenderingContext.webidl b/components/script/dom/webidls/WebGL2RenderingContext.webidl
index 6043c49cec3..157fe38f892 100644
--- a/components/script/dom/webidls/WebGL2RenderingContext.webidl
+++ b/components/script/dom/webidls/WebGL2RenderingContext.webidl
@@ -312,8 +312,8 @@ interface mixin WebGL2RenderingContextBase
/* Framebuffer objects */
// void blitFramebuffer(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0,
// GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter);
- // void framebufferTextureLayer(GLenum target, GLenum attachment, WebGLTexture? texture, GLint level,
- // GLint layer);
+ void framebufferTextureLayer(GLenum target, GLenum attachment, WebGLTexture? texture, GLint level,
+ GLint layer);
void invalidateFramebuffer(GLenum target, sequence<GLenum> attachments);
void invalidateSubFramebuffer(GLenum target, sequence<GLenum> attachments,
GLint x, GLint y, GLsizei width, GLsizei height);
@@ -422,7 +422,7 @@ interface mixin WebGL2RenderingContextBase
// optional GLuint srcLengthOverride = 0);
/* Programs and shaders */
- // [WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram program, DOMString name);
+ [WebGLHandlesContextLoss] GLint getFragDataLocation(WebGLProgram program, DOMString name);
/* Uniforms */
void uniform1ui(WebGLUniformLocation? location, GLuint v0);
diff --git a/components/script/dom/window.rs b/components/script/dom/window.rs
index e06eb243856..6b3b51f9a79 100644
--- a/components/script/dom/window.rs
+++ b/components/script/dom/window.rs
@@ -332,6 +332,8 @@ pub struct Window {
/// A mechanism to force the compositor to process events.
#[ignore_malloc_size_of = "traits are cumbersome"]
event_loop_waker: Option<Box<dyn EventLoopWaker>>,
+
+ visible: Cell<bool>,
}
impl Window {
@@ -2185,6 +2187,7 @@ impl Window {
/// Slow down/speed up timers based on visibility.
pub fn alter_resource_utilization(&self, visible: bool) {
+ self.visible.set(visible);
if visible {
self.upcast::<GlobalScope>().speed_up_timers();
} else {
@@ -2192,6 +2195,10 @@ impl Window {
}
}
+ pub fn visible(&self) -> bool {
+ self.visible.get()
+ }
+
pub fn unminified_js_dir(&self) -> Option<String> {
self.unminified_js_dir.borrow().clone()
}
@@ -2339,6 +2346,7 @@ impl Window {
replace_surrogates,
player_context,
event_loop_waker,
+ visible: Cell::new(true),
});
unsafe { WindowBinding::Wrap(JSContext::from_ptr(runtime.cx()), win) }