mirror of
https://github.com/servo/servo.git
synced 2025-06-06 16:45:39 +00:00
Use IDL sequence default value
This commit is contained in:
parent
4ad08fff04
commit
01e0b2cb5e
13 changed files with 40 additions and 65 deletions
|
@ -6388,8 +6388,11 @@ class CGDictionary(CGThing):
|
||||||
def struct(self):
|
def struct(self):
|
||||||
d = self.dictionary
|
d = self.dictionary
|
||||||
if d.parent:
|
if d.parent:
|
||||||
inheritance = " pub parent: %s::%s,\n" % (self.makeModuleName(d.parent),
|
typeName = "%s::%s" % (self.makeModuleName(d.parent),
|
||||||
self.makeClassName(d.parent))
|
self.makeClassName(d.parent))
|
||||||
|
if type_needs_tracing(d.parent):
|
||||||
|
typeName = "RootedTraceableBox<%s>" % typeName
|
||||||
|
inheritance = " pub parent: %s,\n" % typeName
|
||||||
else:
|
else:
|
||||||
inheritance = ""
|
inheritance = ""
|
||||||
memberDecls = [" pub %s: %s," %
|
memberDecls = [" pub %s: %s," %
|
||||||
|
@ -6520,10 +6523,7 @@ class CGDictionary(CGThing):
|
||||||
})
|
})
|
||||||
|
|
||||||
def membersNeedTracing(self):
|
def membersNeedTracing(self):
|
||||||
for member, _ in self.memberInfo:
|
return type_needs_tracing(self.dictionary)
|
||||||
if type_needs_tracing(member.type):
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def makeDictionaryName(dictionary):
|
def makeDictionaryName(dictionary):
|
||||||
|
|
|
@ -164,7 +164,7 @@ impl Bluetooth {
|
||||||
&self,
|
&self,
|
||||||
p: &Rc<Promise>,
|
p: &Rc<Promise>,
|
||||||
filters: &Option<Vec<BluetoothLEScanFilterInit>>,
|
filters: &Option<Vec<BluetoothLEScanFilterInit>>,
|
||||||
optional_services: &Option<Vec<BluetoothServiceUUID>>,
|
optional_services: &[BluetoothServiceUUID],
|
||||||
sender: IpcSender<BluetoothResponseResult>,
|
sender: IpcSender<BluetoothResponseResult>,
|
||||||
) {
|
) {
|
||||||
// TODO: Step 1: Triggered by user activation.
|
// TODO: Step 1: Triggered by user activation.
|
||||||
|
@ -197,23 +197,21 @@ impl Bluetooth {
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut optional_services_uuids = vec![];
|
let mut optional_services_uuids = vec![];
|
||||||
if let &Some(ref opt_services) = optional_services {
|
for opt_service in optional_services {
|
||||||
for opt_service in opt_services {
|
// Step 2.5 - 2.6.
|
||||||
// Step 2.5 - 2.6.
|
let uuid = match BluetoothUUID::service(opt_service.clone()) {
|
||||||
let uuid = match BluetoothUUID::service(opt_service.clone()) {
|
Ok(u) => u.to_string(),
|
||||||
Ok(u) => u.to_string(),
|
Err(e) => {
|
||||||
Err(e) => {
|
p.reject_error(e);
|
||||||
p.reject_error(e);
|
return;
|
||||||
return;
|
},
|
||||||
},
|
};
|
||||||
};
|
|
||||||
|
|
||||||
// Step 2.7.
|
// Step 2.7.
|
||||||
// Note: What we are doing here, is adding the not blocklisted UUIDs to the result vector,
|
// Note: What we are doing here, is adding the not blocklisted UUIDs to the result vector,
|
||||||
// instead of removing them from an already filled vector.
|
// instead of removing them from an already filled vector.
|
||||||
if !uuid_is_blocklisted(uuid.as_ref(), Blocklist::All) {
|
if !uuid_is_blocklisted(uuid.as_ref(), Blocklist::All) {
|
||||||
optional_services_uuids.push(uuid);
|
optional_services_uuids.push(uuid);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -619,8 +619,6 @@ impl DedicatedWorkerGlobalScopeMethods for DedicatedWorkerGlobalScope {
|
||||||
let mut rooted = CustomAutoRooter::new(
|
let mut rooted = CustomAutoRooter::new(
|
||||||
options
|
options
|
||||||
.transfer
|
.transfer
|
||||||
.as_ref()
|
|
||||||
.unwrap_or(&Vec::with_capacity(0))
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
|
@ -141,15 +141,9 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
||||||
cx: JSContext,
|
cx: JSContext,
|
||||||
message: HandleValue,
|
message: HandleValue,
|
||||||
target_origin: USVString,
|
target_origin: USVString,
|
||||||
mut transfer: CustomAutoRooterGuard<Option<Vec<*mut JSObject>>>,
|
transfer: CustomAutoRooterGuard<Vec<*mut JSObject>>,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
if transfer.is_some() {
|
self.post_message_impl(&target_origin, cx, message, transfer)
|
||||||
let mut rooted = CustomAutoRooter::new(transfer.take().unwrap());
|
|
||||||
let transfer = Some(CustomAutoRooterGuard::new(*cx, &mut rooted));
|
|
||||||
self.post_message_impl(&target_origin, cx, message, transfer)
|
|
||||||
} else {
|
|
||||||
self.post_message_impl(&target_origin, cx, message, None)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// https://html.spec.whatwg.org/multipage/#dom-window-postmessage-options
|
/// https://html.spec.whatwg.org/multipage/#dom-window-postmessage-options
|
||||||
|
@ -161,14 +155,13 @@ impl DissimilarOriginWindowMethods for DissimilarOriginWindow {
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
let mut rooted = CustomAutoRooter::new(
|
let mut rooted = CustomAutoRooter::new(
|
||||||
options
|
options
|
||||||
|
.parent
|
||||||
.transfer
|
.transfer
|
||||||
.as_ref()
|
|
||||||
.unwrap_or(&Vec::with_capacity(0))
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
let transfer = Some(CustomAutoRooterGuard::new(*cx, &mut rooted));
|
let transfer = CustomAutoRooterGuard::new(*cx, &mut rooted);
|
||||||
|
|
||||||
self.post_message_impl(&options.targetOrigin, cx, message, transfer)
|
self.post_message_impl(&options.targetOrigin, cx, message, transfer)
|
||||||
}
|
}
|
||||||
|
@ -208,10 +201,10 @@ impl DissimilarOriginWindow {
|
||||||
target_origin: &USVString,
|
target_origin: &USVString,
|
||||||
cx: JSContext,
|
cx: JSContext,
|
||||||
message: HandleValue,
|
message: HandleValue,
|
||||||
transfer: Option<CustomAutoRooterGuard<Vec<*mut JSObject>>>,
|
transfer: CustomAutoRooterGuard<Vec<*mut JSObject>>,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
// Step 6-7.
|
// Step 6-7.
|
||||||
let data = structuredclone::write(cx, message, transfer)?;
|
let data = structuredclone::write(cx, message, Some(transfer))?;
|
||||||
|
|
||||||
self.post_message(target_origin, data)
|
self.post_message(target_origin, data)
|
||||||
}
|
}
|
||||||
|
|
|
@ -294,8 +294,6 @@ impl MessagePortMethods for MessagePort {
|
||||||
let mut rooted = CustomAutoRooter::new(
|
let mut rooted = CustomAutoRooter::new(
|
||||||
options
|
options
|
||||||
.transfer
|
.transfer
|
||||||
.as_ref()
|
|
||||||
.unwrap_or(&Vec::with_capacity(0))
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
|
@ -141,8 +141,6 @@ impl ServiceWorkerMethods for ServiceWorker {
|
||||||
let mut rooted = CustomAutoRooter::new(
|
let mut rooted = CustomAutoRooter::new(
|
||||||
options
|
options
|
||||||
.transfer
|
.transfer
|
||||||
.as_ref()
|
|
||||||
.unwrap_or(&Vec::with_capacity(0))
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
|
@ -21,7 +21,7 @@ dictionary BluetoothLEScanFilterInit {
|
||||||
|
|
||||||
dictionary RequestDeviceOptions {
|
dictionary RequestDeviceOptions {
|
||||||
sequence<BluetoothLEScanFilterInit> filters;
|
sequence<BluetoothLEScanFilterInit> filters;
|
||||||
sequence<BluetoothServiceUUID> optionalServices /*= []*/;
|
sequence<BluetoothServiceUUID> optionalServices = [];
|
||||||
boolean acceptAllDevices = false;
|
boolean acceptAllDevices = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,7 +8,7 @@ dictionary BluetoothPermissionDescriptor : PermissionDescriptor {
|
||||||
DOMString deviceId;
|
DOMString deviceId;
|
||||||
// These match RequestDeviceOptions.
|
// These match RequestDeviceOptions.
|
||||||
sequence<BluetoothLEScanFilterInit> filters;
|
sequence<BluetoothLEScanFilterInit> filters;
|
||||||
sequence<BluetoothServiceUUID> optionalServices/* = []*/;
|
sequence<BluetoothServiceUUID> optionalServices = [];
|
||||||
boolean acceptAllDevices = false;
|
boolean acceptAllDevices = false;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -25,7 +25,7 @@ interface DissimilarOriginWindow : GlobalScope {
|
||||||
|
|
||||||
void close();
|
void close();
|
||||||
readonly attribute boolean closed;
|
readonly attribute boolean closed;
|
||||||
[Throws] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer /*= []*/);
|
[Throws] void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
|
||||||
[Throws] void postMessage(any message, optional WindowPostMessageOptions options = {});
|
[Throws] void postMessage(any message, optional WindowPostMessageOptions options = {});
|
||||||
attribute any opener;
|
attribute any opener;
|
||||||
void blur();
|
void blur();
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
|
|
||||||
[Exposed=(Window,Worker)]
|
[Exposed=(Window,Worker)]
|
||||||
interface MessagePort : EventTarget {
|
interface MessagePort : EventTarget {
|
||||||
[Throws] void postMessage(any message, sequence<object> transfer /*= []*/);
|
[Throws] void postMessage(any message, sequence<object> transfer);
|
||||||
[Throws] void postMessage(any message, optional PostMessageOptions options = {});
|
[Throws] void postMessage(any message, optional PostMessageOptions options = {});
|
||||||
void start();
|
void start();
|
||||||
void close();
|
void close();
|
||||||
|
@ -19,5 +19,5 @@ interface MessagePort : EventTarget {
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary PostMessageOptions {
|
dictionary PostMessageOptions {
|
||||||
sequence<object> transfer;
|
sequence<object> transfer = [];
|
||||||
};
|
};
|
||||||
|
|
|
@ -64,7 +64,7 @@
|
||||||
void cancelAnimationFrame(unsigned long handle);
|
void cancelAnimationFrame(unsigned long handle);
|
||||||
|
|
||||||
[Throws]
|
[Throws]
|
||||||
void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer /*= []*/);
|
void postMessage(any message, USVString targetOrigin, optional sequence<object> transfer = []);
|
||||||
[Throws]
|
[Throws]
|
||||||
void postMessage(any message, optional WindowPostMessageOptions options = {});
|
void postMessage(any message, optional WindowPostMessageOptions options = {});
|
||||||
|
|
||||||
|
@ -175,7 +175,6 @@ partial interface Window {
|
||||||
readonly attribute unsigned long runningAnimationCount;
|
readonly attribute unsigned long runningAnimationCount;
|
||||||
};
|
};
|
||||||
|
|
||||||
dictionary WindowPostMessageOptions {
|
dictionary WindowPostMessageOptions : PostMessageOptions {
|
||||||
USVString targetOrigin = "/";
|
USVString targetOrigin = "/";
|
||||||
sequence<object> transfer;
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -979,19 +979,13 @@ impl WindowMethods for Window {
|
||||||
cx: JSContext,
|
cx: JSContext,
|
||||||
message: HandleValue,
|
message: HandleValue,
|
||||||
target_origin: USVString,
|
target_origin: USVString,
|
||||||
mut transfer: CustomAutoRooterGuard<Option<Vec<*mut JSObject>>>,
|
transfer: CustomAutoRooterGuard<Vec<*mut JSObject>>,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
let incumbent = GlobalScope::incumbent().expect("no incumbent global?");
|
let incumbent = GlobalScope::incumbent().expect("no incumbent global?");
|
||||||
let source = incumbent.as_window();
|
let source = incumbent.as_window();
|
||||||
let source_origin = source.Document().origin().immutable().clone();
|
let source_origin = source.Document().origin().immutable().clone();
|
||||||
|
|
||||||
if transfer.is_some() {
|
self.post_message_impl(&target_origin, source_origin, source, cx, message, transfer)
|
||||||
let mut rooted = CustomAutoRooter::new(transfer.take().unwrap());
|
|
||||||
let transfer = Some(CustomAutoRooterGuard::new(*cx, &mut rooted));
|
|
||||||
self.post_message_impl(&target_origin, source_origin, source, cx, message, transfer)
|
|
||||||
} else {
|
|
||||||
self.post_message_impl(&target_origin, source_origin, source, cx, message, None)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <https://html.spec.whatwg.org/multipage/#dom-messageport-postmessage>
|
/// <https://html.spec.whatwg.org/multipage/#dom-messageport-postmessage>
|
||||||
|
@ -1003,14 +997,13 @@ impl WindowMethods for Window {
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
let mut rooted = CustomAutoRooter::new(
|
let mut rooted = CustomAutoRooter::new(
|
||||||
options
|
options
|
||||||
|
.parent
|
||||||
.transfer
|
.transfer
|
||||||
.as_ref()
|
|
||||||
.unwrap_or(&Vec::with_capacity(0))
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
||||||
.collect(),
|
.collect(),
|
||||||
);
|
);
|
||||||
let transfer = Some(CustomAutoRooterGuard::new(*cx, &mut rooted));
|
let transfer = CustomAutoRooterGuard::new(*cx, &mut rooted);
|
||||||
|
|
||||||
let incumbent = GlobalScope::incumbent().expect("no incumbent global?");
|
let incumbent = GlobalScope::incumbent().expect("no incumbent global?");
|
||||||
let source = incumbent.as_window();
|
let source = incumbent.as_window();
|
||||||
|
@ -1330,10 +1323,10 @@ impl Window {
|
||||||
source: &Window,
|
source: &Window,
|
||||||
cx: JSContext,
|
cx: JSContext,
|
||||||
message: HandleValue,
|
message: HandleValue,
|
||||||
transfer: Option<CustomAutoRooterGuard<Vec<*mut JSObject>>>,
|
transfer: CustomAutoRooterGuard<Vec<*mut JSObject>>,
|
||||||
) -> ErrorResult {
|
) -> ErrorResult {
|
||||||
// Step 1-2, 6-8.
|
// Step 1-2, 6-8.
|
||||||
let data = structuredclone::write(cx, message, transfer)?;
|
let data = structuredclone::write(cx, message, Some(transfer))?;
|
||||||
|
|
||||||
// Step 3-5.
|
// Step 3-5.
|
||||||
let target_origin = match target_origin.0[..].as_ref() {
|
let target_origin = match target_origin.0[..].as_ref() {
|
||||||
|
|
|
@ -218,8 +218,6 @@ impl WorkerMethods for Worker {
|
||||||
let mut rooted = CustomAutoRooter::new(
|
let mut rooted = CustomAutoRooter::new(
|
||||||
options
|
options
|
||||||
.transfer
|
.transfer
|
||||||
.as_ref()
|
|
||||||
.unwrap_or(&Vec::with_capacity(0))
|
|
||||||
.iter()
|
.iter()
|
||||||
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
.map(|js: &RootedTraceableBox<Heap<*mut JSObject>>| js.get())
|
||||||
.collect(),
|
.collect(),
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue