aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/extendableevent.rs
diff options
context:
space:
mode:
authorbors-servo <lbergstrom+bors@mozilla.com>2017-09-25 16:07:47 -0500
committerGitHub <noreply@github.com>2017-09-25 16:07:47 -0500
commit532dee36c10b7dd5d33e560b55cf65c7243ef1d3 (patch)
treee6474f4893df3fbfe3ec9bca7c7e709bb47ea669 /components/script/dom/extendableevent.rs
parent86b926b4cf78ae3436b946e42caad8362b4841d1 (diff)
parent44822c364c2f1970705834fb0f95df1411089f9d (diff)
downloadservo-532dee36c10b7dd5d33e560b55cf65c7243ef1d3.tar.gz
servo-532dee36c10b7dd5d33e560b55cf65c7243ef1d3.zip
Auto merge of #17056 - jdm:heapdict, r=emilio
Make dictionaries and unions containing GC values safer Problems: * the Heap::new constructor is memory-unsafe with any value other than Undefined/Null * this means that moving dictionaries containing Heap values (ie. any/object) is memory-unsafe * unions containing GC pointers are similarly unsafe Solutions: - dictionaries containing GC pointers are now wrapped in RootedTraceableBox (even inside other dictionaries) - instead of using Heap::new, dictionaries containing GC pointers are now initialized to a default value (by deriving Default) and mutated one field at a time - dictionaries containing GC pointers are marked #[must_root] - FromJSVal for dictionaries containing GC pointers now returns RootedTraceableBox<Dictionary> - unions wrap their variants that require rooting in RootedTraceableBox Rather than attempting to derive Default for all dictionaries, we only do so for the dictionaries that require it. Because some dictionaries that require it inherit from dictionaries that do not, we need to write manual implementations for those parent dictionaries. This is a better option than having to figure out a default value for types like `Root<T>`, which would be required for deriving Default for all dictionaries. I would still like to come up with an automated test for this, but I figured I would get eyes on this first. --- - [X] `./mach build -d` does not report any errors - [X] `./mach test-tidy` does not report any errors - [X] These changes fix #16952 - [ ] There are tests for these changes <!-- 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/17056) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/extendableevent.rs')
-rw-r--r--components/script/dom/extendableevent.rs10
1 files changed, 9 insertions, 1 deletions
diff --git a/components/script/dom/extendableevent.rs b/components/script/dom/extendableevent.rs
index 8cc88706fb1..553ed7a1fe4 100644
--- a/components/script/dom/extendableevent.rs
+++ b/components/script/dom/extendableevent.rs
@@ -2,7 +2,7 @@
* 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/. */
-use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
+use dom::bindings::codegen::Bindings::EventBinding::{self, EventMethods};
use dom::bindings::codegen::Bindings::ExtendableEventBinding;
use dom::bindings::error::{Error, ErrorResult, Fallible};
use dom::bindings::inheritance::Castable;
@@ -67,3 +67,11 @@ impl ExtendableEvent {
self.event.IsTrusted()
}
}
+
+impl Default for ExtendableEventBinding::ExtendableEventInit {
+ fn default() -> ExtendableEventBinding::ExtendableEventInit {
+ ExtendableEventBinding::ExtendableEventInit {
+ parent: EventBinding::EventInit::default(),
+ }
+ }
+}