mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Reduce indexing boilerplate for serializable/transferrable objects. (#36624)
Rather than creating unique types for each pipeline-namespaced index type (eg. MessagePortId, DomExceptionId, etc.), we can create a generic common type that uses a marker to prevent type confusion. This change allows us to reduce the boilerplate code required when implementing serializable/transferable interfaces, since the structured clone implementation can rely on the common type. Testing: Existing WPT tests for serialization and transferring provide coverage. --------- Signed-off-by: Josh Matthews <josh@joshmatthews.net>
This commit is contained in:
parent
0b8645d422
commit
7b16ae26b4
13 changed files with 170 additions and 337 deletions
|
@ -81,18 +81,14 @@ impl<WebView> WebViewManager<WebView> {
|
|||
|
||||
#[cfg(test)]
|
||||
mod test {
|
||||
use std::num::NonZeroU32;
|
||||
|
||||
use base::id::{
|
||||
BrowsingContextId, BrowsingContextIndex, PipelineNamespace, PipelineNamespaceId, WebViewId,
|
||||
};
|
||||
use base::id::{BrowsingContextId, Index, PipelineNamespace, PipelineNamespaceId, WebViewId};
|
||||
|
||||
use crate::webview_manager::WebViewManager;
|
||||
|
||||
fn id(namespace_id: u32, index: u32) -> WebViewId {
|
||||
WebViewId(BrowsingContextId {
|
||||
namespace_id: PipelineNamespaceId(namespace_id),
|
||||
index: BrowsingContextIndex(NonZeroU32::new(index).expect("Incorrect test case")),
|
||||
index: Index::new(index).expect("Incorrect test case"),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue