Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove JS stream usage #29881

Draft
wants to merge 15 commits into
base: main
Choose a base branch
from
37 changes: 0 additions & 37 deletions components/script/dom/bindings/codegen/CodegenRust.py
Original file line number Diff line number Diff line change
Expand Up @@ -906,40 +906,6 @@ def wrapObjectTemplate(templateBody, nullValue, isDefinitelyObject, type,

return handleOptional(templateBody, declType, handleDefault("None"))

if type.isReadableStream():
assert not isEnforceRange and not isClamp

if failureCode is None:
unwrapFailureCode = '''throw_type_error(*cx, "This object is not \
an instance of ReadableStream.");\n'''
else:
unwrapFailureCode = failureCode

templateBody = fill(
"""
{
use crate::realms::{AlreadyInRealm, InRealm};
let in_realm_proof = AlreadyInRealm::assert_for_cx(cx);
match ReadableStream::from_js(cx, $${val}.get().to_object(), InRealm::Already(&in_realm_proof)) {
Ok(val) => val,
Err(()) => {
$*{failureCode}
}
}

}
""",
failureCode=unwrapFailureCode + "\n",
)

templateBody = wrapObjectTemplate(templateBody, "None",
isDefinitelyObject, type, failureCode)

declType = CGGeneric("DomRoot<ReadableStream>")

return handleOptional(templateBody, declType,
handleDefault("None"))

elif type.isSpiderMonkeyInterface():
raise TypeError("Can't handle SpiderMonkey interface arguments other than typed arrays yet")

Expand Down Expand Up @@ -4737,9 +4703,6 @@ def getUnionTypeTemplateVars(type, descriptorProvider):
elif type.isObject():
name = type.name
typeName = "Heap<*mut JSObject>"
elif type.isReadableStream():
name = type.name
typeName = "DomRoot<ReadableStream>"
elif is_typed_array(type):
name = type.name
typeName = "typedarray::Heap" + name
Expand Down
38 changes: 4 additions & 34 deletions components/script/dom/bindings/codegen/parser/WebIDL.py
Original file line number Diff line number Diff line change
Expand Up @@ -2498,9 +2498,6 @@ def isSequence(self):
def isRecord(self):
return False

def isReadableStream(self):
return False

def isArrayBuffer(self):
return False

Expand Down Expand Up @@ -2529,7 +2526,7 @@ def isGeckoInterface(self):
def isSpiderMonkeyInterface(self):
"""Returns a boolean indicating whether this type is an 'interface'
type that is implemented in SpiderMonkey."""
return self.isInterface() and (self.isBufferSource() or self.isReadableStream())
return self.isInterface() and self.isBufferSource()

def isAny(self):
return self.tag() == IDLType.Tags.any
Expand Down Expand Up @@ -2746,9 +2743,6 @@ def isSequence(self):
def isRecord(self):
return self.inner.isRecord()

def isReadableStream(self):
return self.inner.isReadableStream()

def isArrayBuffer(self):
return self.inner.isArrayBuffer()

Expand Down Expand Up @@ -3258,9 +3252,6 @@ def isSequence(self):
def isRecord(self):
return self.inner.isRecord()

def isReadableStream(self):
return self.inner.isReadableStream()

def isDictionary(self):
return self.inner.isDictionary()

Expand Down Expand Up @@ -3606,7 +3597,6 @@ class IDLBuiltinType(IDLType):
"Uint32Array",
"Float32Array",
"Float64Array",
"ReadableStream",
)

TagLookup = {
Expand Down Expand Up @@ -3642,7 +3632,6 @@ class IDLBuiltinType(IDLType):
Types.Uint32Array: IDLType.Tags.interface,
Types.Float32Array: IDLType.Tags.interface,
Types.Float64Array: IDLType.Tags.interface,
Types.ReadableStream: IDLType.Tags.interface,
}

PrettyNames = {
Expand Down Expand Up @@ -3678,7 +3667,6 @@ class IDLBuiltinType(IDLType):
Types.Uint32Array: "Uint32Array",
Types.Float32Array: "Float32Array",
Types.Float64Array: "Float64Array",
Types.ReadableStream: "ReadableStream",
}

def __init__(
Expand Down Expand Up @@ -3842,9 +3830,6 @@ def isTypedArray(self):
and self._typeTag <= IDLBuiltinType.Types.Float64Array
)

def isReadableStream(self):
return self._typeTag == IDLBuiltinType.Types.ReadableStream

def isInterface(self):
# TypedArray things are interface types per the TypedArray spec,
# but we handle them as builtins because SpiderMonkey implements
Expand All @@ -3853,7 +3838,6 @@ def isInterface(self):
self.isArrayBuffer()
or self.isArrayBufferView()
or self.isTypedArray()
or self.isReadableStream()
)

def isNonCallbackInterface(self):
Expand Down Expand Up @@ -3948,7 +3932,6 @@ def isDistinguishableFrom(self, other):
# ArrayBuffer is distinguishable from everything
# that's not an ArrayBuffer or a callback interface
(self.isArrayBuffer() and not other.isArrayBuffer())
or (self.isReadableStream() and not other.isReadableStream())
or
# ArrayBufferView is distinguishable from everything
# that's not an ArrayBufferView or typed array.
Expand Down Expand Up @@ -4155,11 +4138,6 @@ def withExtendedAttributes(self, attrs):
"Float64Array",
IDLBuiltinType.Types.Float64Array,
),
IDLBuiltinType.Types.ReadableStream: IDLBuiltinType(
BuiltinLocation("<builtin type>"),
"ReadableStream",
IDLBuiltinType.Types.ReadableStream,
),
}


Expand Down Expand Up @@ -6909,9 +6887,6 @@ def t_INTEGER(self, t):
def t_IDENTIFIER(self, t):
r"[_-]?[A-Za-z][0-9A-Z_a-z-]*"
t.type = self.keywords.get(t.value, "IDENTIFIER")
# If Builtin readable streams are disabled, mark ReadableStream as an identifier.
if t.type == "READABLESTREAM" and not self._use_builtin_readable_streams:
t.type = "IDENTIFIER"
return t

def t_STRING(self, t):
Expand Down Expand Up @@ -7002,7 +6977,6 @@ def t_OTHER(self, t):
"setlike": "SETLIKE",
"iterable": "ITERABLE",
"namespace": "NAMESPACE",
"ReadableStream": "READABLESTREAM",
"constructor": "CONSTRUCTOR",
"symbol": "SYMBOL",
"async": "ASYNC",
Expand All @@ -7023,8 +6997,7 @@ def t_error(self, t):
],
)

def __init__(self, outputdir, lexer=None, use_builtin_readable_streams=True):
self._use_builtin_readable_streams = use_builtin_readable_streams
def __init__(self, outputdir, lexer=None):
if lexer:
self.lexer = lexer
else:
Expand Down Expand Up @@ -8513,16 +8486,13 @@ def p_DistinguishableType(self, p):
"""
DistinguishableType : PrimitiveType Null
| ARRAYBUFFER Null
| READABLESTREAM Null
| OBJECT Null
| UNDEFINED Null
"""
if p[1] == "object":
type = BuiltinTypes[IDLBuiltinType.Types.object]
elif p[1] == "ArrayBuffer":
type = BuiltinTypes[IDLBuiltinType.Types.ArrayBuffer]
elif p[1] == "ReadableStream":
type = BuiltinTypes[IDLBuiltinType.Types.ReadableStream]
elif p[1] == "undefined":
type = BuiltinTypes[IDLBuiltinType.Types.undefined]
else:
Expand Down Expand Up @@ -8861,8 +8831,8 @@ def p_error(self, p):
[Location(self.lexer, p.lineno, p.lexpos, self._filename)],
)

def __init__(self, outputdir="", lexer=None, use_builtin_readable_stream=True):
Tokenizer.__init__(self, outputdir, lexer, use_builtin_readable_stream)
def __init__(self, outputdir="", lexer=None):
Tokenizer.__init__(self, outputdir, lexer)

logger = SqueakyCleanLogger()
try:
Expand Down
162 changes: 0 additions & 162 deletions components/script/dom/bindings/codegen/parser/readable-stream.patch

This file was deleted.

1 change: 0 additions & 1 deletion components/script/dom/bindings/codegen/parser/update.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ patch < debug.patch
patch < callback-location.patch
patch < union-typedef.patch
patch < inline.patch
patch < readable-stream.patch

wget https://hg.mozilla.org/mozilla-central/archive/tip.zip/dom/bindings/parser/tests/ -O tests.zip
rm -r tests
Expand Down
2 changes: 1 addition & 1 deletion components/script/dom/bindings/interface.rs
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ pub unsafe fn create_global_object(
let mut options = RealmOptions::default();
options.creationOptions_.traceGlobal_ = Some(trace);
options.creationOptions_.sharedMemoryAndAtomics_ = false;
options.creationOptions_.streams_ = true;
options.creationOptions_.streams_ = false;
select_compartment(cx, &mut options);

let principal = ServoJSPrincipals::new(origin);
Expand Down
4 changes: 3 additions & 1 deletion components/script/dom/blob.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,9 @@ impl BlobMethods for Blob {

// <https://w3c.github.io/FileAPI/#blob-get-stream>
fn Stream(&self, _cx: JSContext) -> NonNull<JSObject> {
self.get_stream().get_js_stream()
//self.get_stream().get_js_stream()
let stream = self.get_stream();
NonNull::new(*stream.reflector().get_jsobject()).expect("shouldn't be null")
}

// https://w3c.github.io/FileAPI/#slice-method-algo
Expand Down