aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/bindings/js.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2014-12-29 11:57:45 -0700
committerbors-servo <metajack+bors@gmail.com>2014-12-29 11:57:45 -0700
commit2c259f477c41331e66beab8bda865971982a1ff4 (patch)
tree12b1b56eec1482d6b6e31e85383a309856a39dc7 /components/script/dom/bindings/js.rs
parentf76a460c53dfddef74262eceaf4b163b551adc08 (diff)
parent9a7cd3113403fe44a8919f049720b67bfa92c9f1 (diff)
downloadservo-2c259f477c41331e66beab8bda865971982a1ff4.tar.gz
servo-2c259f477c41331e66beab8bda865971982a1ff4.zip
auto merge of #4057 : jdm/servo/refcountdom, r=Ms2ger
This replaces the specialized TrustedXHRAddress and TrustedWorkerAddress code that was used for the same purpose. A non-zero refcount pins the given DOM object's reflector and prevents it from being GCed even when there are no other outstanding references visible to SpiderMonkey. This will enable us to implement asynchronous operations that refer to particular DOM objects (such as "queue a task to fire a simple event named load at the iframe element" from the spec) safely and conveniently, and paves the way for things like asynchronous network responses. Some concerns about the resulting size of XHR progress messages have been expressed, but I believe optimizations to reduce that can be implemented in subsequent PRs. r? @Ms2ger - note in particular the changes to the worker lifetime code. I couldn't figure out how to achieve an identical lifetime to the previous addref/release pairing, and I also was having trouble figuring out why the existing setup was safe. The new implementation now holds the main script task Worker object alive via the TrustedWorkerAddress field in the dedicated worker global scope, which is a significant difference.
Diffstat (limited to 'components/script/dom/bindings/js.rs')
-rw-r--r--components/script/dom/bindings/js.rs20
1 files changed, 0 insertions, 20 deletions
diff --git a/components/script/dom/bindings/js.rs b/components/script/dom/bindings/js.rs
index 1f3cb7814e0..a1957f6797a 100644
--- a/components/script/dom/bindings/js.rs
+++ b/components/script/dom/bindings/js.rs
@@ -48,8 +48,6 @@
use dom::bindings::trace::JSTraceable;
use dom::bindings::utils::{Reflector, Reflectable};
use dom::node::Node;
-use dom::xmlhttprequest::{XMLHttpRequest, TrustedXHRAddress};
-use dom::worker::{Worker, TrustedWorkerAddress};
use js::jsapi::JSObject;
use js::jsval::JSVal;
use layout_interface::TrustedNodeAddress;
@@ -142,24 +140,6 @@ impl JS<Node> {
}
}
-impl JS<XMLHttpRequest> {
- pub unsafe fn from_trusted_xhr_address(inner: TrustedXHRAddress) -> JS<XMLHttpRequest> {
- let TrustedXHRAddress(addr) = inner;
- JS {
- ptr: addr as *const XMLHttpRequest
- }
- }
-}
-
-impl JS<Worker> {
- pub unsafe fn from_trusted_worker_address(inner: TrustedWorkerAddress) -> JS<Worker> {
- let TrustedWorkerAddress(addr) = inner;
- JS {
- ptr: addr as *const Worker
- }
- }
-}
-
impl<T: Reflectable> JS<T> {
/// Create a new JS-owned value wrapped from a raw Rust pointer.
pub unsafe fn from_raw(raw: *const T) -> JS<T> {