aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/serializable.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2019-12-19 16:16:56 -0500
committerGitHub <noreply@github.com>2019-12-19 16:16:56 -0500
commitbac9903fbeed0a394a86c0091e727aada665433d (patch)
tree15f61a4fdcc8bbcc09f10a39e25495fb49cb9a75 /components/script/dom/bindings/serializable.rs
parentaa36d5f657eb32b59d994d08b177a02372b4b01c (diff)
parent6e8a85482c2068d4dbccb992954271f725570f91 (diff)
downloadservo-bac9903fbeed0a394a86c0091e727aada665433d.tar.gz
servo-bac9903fbeed0a394a86c0091e727aada665433d.zip
Auto merge of #24123 - gterzian:redo_blob, r=jdm
Restructure Blob, structured serialization <!-- Please describe your changes on the following line: --> FIX #24052 and also address the "cloning" half of FIX #23917 --- <!-- Thank you for contributing to Servo! Please replace each `[ ]` by `[X]` when the step is complete, and replace `___` with appropriate data: --> - [ ] `./mach build -d` does not report any errors - [ ] `./mach test-tidy` does not report any errors - [ ] These changes fix #___ (GitHub issue number if applicable) <!-- Either: --> - [ ] There are tests for these changes OR - [ ] These changes do not require tests because ___ <!-- Also, please make sure that "Allow edits from maintainers" checkbox is checked, so that we can help you if you get stuck somewhere along the way.--> <!-- Pull requests that do not address these steps are welcome, but they will require additional verification as part of the review process. --> <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/24123) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/bindings/serializable.rs')
-rw-r--r--components/script/dom/bindings/serializable.rs32
1 files changed, 32 insertions, 0 deletions
diff --git a/components/script/dom/bindings/serializable.rs b/components/script/dom/bindings/serializable.rs
new file mode 100644
index 00000000000..004b9ef4d73
--- /dev/null
+++ b/components/script/dom/bindings/serializable.rs
@@ -0,0 +1,32 @@
+/* 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/. */
+
+//! Trait representing the concept of [serializable objects]
+//! (https://html.spec.whatwg.org/multipage/#serializable-objects).
+
+use crate::dom::bindings::reflector::DomObject;
+use crate::dom::bindings::root::DomRoot;
+use crate::dom::bindings::structuredclone::StructuredDataHolder;
+use crate::dom::globalscope::GlobalScope;
+
+/// The key corresponding to the storage location
+/// of a serialized platform object stored in a StructuredDataHolder.
+#[derive(Clone, Copy, Debug, Eq, Hash, PartialEq)]
+pub struct StorageKey {
+ pub index: u32,
+ pub name_space: u32,
+}
+
+/// Interface for serializable platform objects.
+/// <https://html.spec.whatwg.org/multipage/#serializable>
+pub trait Serializable: DomObject {
+ /// <https://html.spec.whatwg.org/multipage/#serialization-steps>
+ fn serialize(&self, sc_holder: &mut StructuredDataHolder) -> Result<StorageKey, ()>;
+ /// <https://html.spec.whatwg.org/multipage/#deserialization-steps>
+ fn deserialize(
+ owner: &DomRoot<GlobalScope>,
+ sc_holder: &mut StructuredDataHolder,
+ extra_data: StorageKey,
+ ) -> Result<(), ()>;
+}