aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmliframeelement.rs
diff options
context:
space:
mode:
authorbors-servo <metajack+bors@gmail.com>2015-06-19 16:46:55 -0600
committerbors-servo <metajack+bors@gmail.com>2015-06-19 16:46:55 -0600
commite7808c526c348fea5e3b48af70b7f1a066652097 (patch)
tree640b22869e8a7eb7d5657df3074f0b0ccd528c29 /components/script/dom/htmliframeelement.rs
parenta256f39796270cd3a5f40f33eaa4e407117b0cc6 (diff)
parent675267b7822d2d6c30c0e36fc22e0191b741b973 (diff)
downloadservo-e7808c526c348fea5e3b48af70b7f1a066652097.tar.gz
servo-e7808c526c348fea5e3b48af70b7f1a066652097.zip
Auto merge of #6150 - servo:smupgrade3, r=mbrubeck
Upgrade to Spidermonkey 39 > Here it is. > > ~~There's two major things that are unfinished here:~~ > - ~~Dealing with the unroot_must_root lint. I'm not sure about the value of this lint with the new rooting API.~~ Done. > - ~~Updating the Cargo.locks to point to the new SM and SM binding.~~ Done. > > I also included my fixes for the rust update, but these will disappear in a rebase. A rust update is necessary to support calling `Drop` on `Heap<T>` correctly when `Heap<T>` is inside a `Rc<T>`. Otherwise `&self` points to the wrong location. > > Incremental GC is disabled here. I'm not sure how to deal with the incremental barriers so that's left for later. > > Generational GC works. SM doesn't work without it. > > The biggest change here is to the rooting API. `Root` was made movable, and `Temporary` and `JSRef` was removed. Movable `Root`s means there's no need for `Temporary`, and `JSRef`s aren't needed generally since it can be assumed that being able to obtain a reference to a dom object means it's already rooted. References have their lifetime bound to the Roots that provided them. DOM objects that haven't passed through `reflect_dom_object` don't need to be rooted, and DOM objects that have passed through `reflect_dom_object` can't be obtained without being rooted through `native_from_reflector_jsmanaged` or `JS::<T>::root()`. > > Support for `Heap<T>` ended up messier than I expected. It's split into two commits, but only because it's a bit difficult to fold them together. Supporting `Heap<T>` properly requires that that `Heap::<T>::set()` be called on something that won't move. I removed the Copy and Clone trait from `Heap<T>` so `Cell` can't hold `Heap<T>` - only `UnsafeCell` can hold it. > > `CallbackObject` is a bit tricky - I moved all callbacks into `Rc<T>` in order to make sure that the pointer inside to a `*mut JSObject` doesn't move. This is necessary for supporting `Heap<T>`. > > `RootedCollectionSet` is very general purpose now. Anything with `JSTraceable` can be rooted by `RootedCollectionSet`/`RootedTraceable`. Right now, `RootedTraceable` is only used to hold down dom objects before they're fully attached to their reflector. I had to make a custom mechanism to dispatch the trace call - couldn't figure out how to get trait objects working for this case. > > This has been tested with the following zeal settings: > > GC after every allocation > JS_GC_ZEAL=2,1 > > GC after every 100 allocations (important for catching use-after-free bugs) > JS_GC_ZEAL=2,100 > > Verify pre barriers > JS_GC_ZEAL=4,1 > > Verify post barriers > JS_GC_ZEAL=11,1 <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/6150) <!-- Reviewable:end -->
Diffstat (limited to 'components/script/dom/htmliframeelement.rs')
-rw-r--r--components/script/dom/htmliframeelement.rs84
1 files changed, 44 insertions, 40 deletions
diff --git a/components/script/dom/htmliframeelement.rs b/components/script/dom/htmliframeelement.rs
index 13ec9d9c5a1..cf1c07b69f5 100644
--- a/components/script/dom/htmliframeelement.rs
+++ b/components/script/dom/htmliframeelement.rs
@@ -13,11 +13,11 @@ use dom::bindings::conversions::ToJSValConvertible;
use dom::bindings::error::{ErrorResult, Fallible};
use dom::bindings::error::Error::NotSupported;
use dom::bindings::global::GlobalRef;
-use dom::bindings::js::{JSRef, OptionalRootable, Rootable, Temporary};
+use dom::bindings::js::{Root};
use dom::customevent::CustomEvent;
use dom::document::Document;
-use dom::element::{self, AttributeHandlers, Element};
-use dom::event::{Event, EventHelpers};
+use dom::element::{self, AttributeHandlers};
+use dom::event::EventHelpers;
use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::element::ElementTypeId;
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
@@ -39,6 +39,8 @@ use std::borrow::ToOwned;
use std::cell::Cell;
use url::{Url, UrlParser};
use util::str::{self, LengthOrPercentageOrAuto};
+use js::jsapi::RootedValue;
+use js::jsval::UndefinedValue;
enum SandboxAllowance {
AllowNothing = 0x00,
@@ -82,19 +84,19 @@ pub trait RawHTMLIFrameElementHelpers {
fn get_height(&self) -> LengthOrPercentageOrAuto;
}
-impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
+impl<'a> HTMLIFrameElementHelpers for &'a HTMLIFrameElement {
fn is_sandboxed(self) -> bool {
self.sandbox.get().is_some()
}
fn get_url(self) -> Option<Url> {
- let element: JSRef<Element> = ElementCast::from_ref(self);
- element.get_attribute(&ns!(""), &atom!("src")).root().and_then(|src| {
+ let element = ElementCast::from_ref(self);
+ element.get_attribute(&ns!(""), &atom!("src")).and_then(|src| {
let url = src.r().value();
if url.is_empty() {
None
} else {
- let window = window_from_node(self).root();
+ let window = window_from_node(self);
UrlParser::new().base_url(&window.r().get_url())
.parse(&url).ok()
}
@@ -103,7 +105,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
fn generate_new_subpage_id(self) -> (SubpageId, Option<SubpageId>) {
let old_subpage_id = self.subpage_id.get();
- let win = window_from_node(self).root();
+ let win = window_from_node(self);
let subpage_id = win.r().get_next_subpage_id();
self.subpage_id.set(Some(subpage_id));
(subpage_id, old_subpage_id)
@@ -116,7 +118,7 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
IFrameUnsandboxed
};
- let window = window_from_node(self).root();
+ let window = window_from_node(self);
let window = window.r();
let (new_subpage_id, old_subpage_id) = self.generate_new_subpage_id();
@@ -151,15 +153,17 @@ impl<'a> HTMLIFrameElementHelpers for JSRef<'a, HTMLIFrameElement> {
assert!(opts::experimental_enabled());
if self.Mozbrowser() {
- let window = window_from_node(self).root();
+ let window = window_from_node(self);
let cx = window.r().get_cx();
+ let mut detail = RootedValue::new(cx, UndefinedValue());
+ event.detail().to_jsval(cx, detail.handle_mut());
let custom_event = CustomEvent::new(GlobalRef::Window(window.r()),
event.name().to_owned(),
true,
true,
- event.detail().to_jsval(cx)).root();
- let target: JSRef<EventTarget> = EventTargetCast::from_ref(self);
- let event: JSRef<Event> = EventCast::from_ref(custom_event.r());
+ detail.handle());
+ let target = EventTargetCast::from_ref(self);
+ let event = EventCast::from_ref(custom_event.r());
event.fire(target);
}
}
@@ -176,7 +180,7 @@ impl RawHTMLIFrameElementHelpers for HTMLIFrameElement {
element::get_attr_for_layout(ElementCast::from_actual(&*self),
&ns!(""),
&atom!("width")).map(|attribute| {
- str::parse_length(&**(*attribute.unsafe_get()).value())
+ str::parse_length(&**(*attribute.unsafe_get()).value_for_layout())
}).unwrap_or(LengthOrPercentageOrAuto::Auto)
}
}
@@ -187,7 +191,7 @@ impl RawHTMLIFrameElementHelpers for HTMLIFrameElement {
element::get_attr_for_layout(ElementCast::from_actual(&*self),
&ns!(""),
&atom!("height")).map(|attribute| {
- str::parse_length(&**(*attribute.unsafe_get()).value())
+ str::parse_length(&**(*attribute.unsafe_get()).value_for_layout())
}).unwrap_or(LengthOrPercentageOrAuto::Auto)
}
}
@@ -196,7 +200,7 @@ impl RawHTMLIFrameElementHelpers for HTMLIFrameElement {
impl HTMLIFrameElement {
fn new_inherited(localName: DOMString,
prefix: Option<DOMString>,
- document: JSRef<Document>) -> HTMLIFrameElement {
+ document: &Document) -> HTMLIFrameElement {
HTMLIFrameElement {
htmlelement:
HTMLElement::new_inherited(HTMLElementTypeId::HTMLIFrameElement, localName, prefix, document),
@@ -209,7 +213,7 @@ impl HTMLIFrameElement {
#[allow(unrooted_must_root)]
pub fn new(localName: DOMString,
prefix: Option<DOMString>,
- document: JSRef<Document>) -> Temporary<HTMLIFrameElement> {
+ document: &Document) -> Root<HTMLIFrameElement> {
let element = HTMLIFrameElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLIFrameElementBinding::Wrap)
}
@@ -225,46 +229,46 @@ impl HTMLIFrameElement {
}
}
-impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
+impl<'a> HTMLIFrameElementMethods for &'a HTMLIFrameElement {
fn Src(self) -> DOMString {
- let element: JSRef<Element> = ElementCast::from_ref(self);
+ let element = ElementCast::from_ref(self);
element.get_string_attribute(&atom!("src"))
}
fn SetSrc(self, src: DOMString) {
- let element: JSRef<Element> = ElementCast::from_ref(self);
+ let element = ElementCast::from_ref(self);
element.set_url_attribute(&atom!("src"), src)
}
fn Sandbox(self) -> DOMString {
- let element: JSRef<Element> = ElementCast::from_ref(self);
+ let element = ElementCast::from_ref(self);
element.get_string_attribute(&atom!("sandbox"))
}
fn SetSandbox(self, sandbox: DOMString) {
- let element: JSRef<Element> = ElementCast::from_ref(self);
+ let element = ElementCast::from_ref(self);
element.set_tokenlist_attribute(&atom!("sandbox"), sandbox);
}
- fn GetContentWindow(self) -> Option<Temporary<Window>> {
+ fn GetContentWindow(self) -> Option<Root<Window>> {
self.subpage_id.get().and_then(|subpage_id| {
- let window = window_from_node(self).root();
+ let window = window_from_node(self);
let window = window.r();
let children = window.page().children.borrow();
children.iter().find(|page| {
- let window = page.window().root();
+ let window = page.window();
window.r().subpage() == Some(subpage_id)
}).map(|page| page.window())
})
}
- fn GetContentDocument(self) -> Option<Temporary<Document>> {
- self.GetContentWindow().root().and_then(|window| {
+ fn GetContentDocument(self) -> Option<Root<Document>> {
+ self.GetContentWindow().and_then(|window| {
let self_url = match self.get_url() {
Some(self_url) => self_url,
None => return None,
};
- let win_url = window_from_node(self).root().r().get_url();
+ let win_url = window_from_node(self).r().get_url();
if UrlHelper::SameOrigin(&self_url, &win_url) {
Some(window.r().Document())
@@ -284,7 +288,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
// https://developer.mozilla.org/en-US/docs/Web/HTML/Element/iframe#attr-mozbrowser
fn Mozbrowser(self) -> bool {
if opts::experimental_enabled() {
- let element: JSRef<Element> = ElementCast::from_ref(self);
+ let element = ElementCast::from_ref(self);
element.has_attribute(&Atom::from_slice("mozbrowser"))
} else {
false
@@ -293,7 +297,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
fn SetMozbrowser(self, value: bool) -> ErrorResult {
if opts::experimental_enabled() {
- let element: JSRef<Element> = ElementCast::from_ref(self);
+ let element = ElementCast::from_ref(self);
element.set_bool_attribute(&Atom::from_slice("mozbrowser"), value);
}
Ok(())
@@ -302,9 +306,9 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goBack
fn GoBack(self) -> Fallible<()> {
if self.Mozbrowser() {
- let node: JSRef<Node> = NodeCast::from_ref(self);
+ let node = NodeCast::from_ref(self);
if node.is_in_doc() {
- let window = window_from_node(self).root();
+ let window = window_from_node(self);
let window = window.r();
let pipeline_info = Some((self.containing_page_pipeline_id().unwrap(),
@@ -324,9 +328,9 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
// https://developer.mozilla.org/en-US/docs/Web/API/HTMLIFrameElement/goForward
fn GoForward(self) -> Fallible<()> {
if self.Mozbrowser() {
- let node: JSRef<Node> = NodeCast::from_ref(self);
+ let node = NodeCast::from_ref(self);
if node.is_in_doc() {
- let window = window_from_node(self).root();
+ let window = window_from_node(self);
let window = window.r();
let pipeline_info = Some((self.containing_page_pipeline_id().unwrap(),
@@ -362,13 +366,13 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
make_setter!(SetHeight, "height");
}
-impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
+impl<'a> VirtualMethods for &'a HTMLIFrameElement {
fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> {
- let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
+ let htmlelement: &&HTMLElement = HTMLElementCast::from_borrowed_ref(self);
Some(htmlelement as &VirtualMethods)
}
- fn after_set_attr(&self, attr: JSRef<Attr>) {
+ fn after_set_attr(&self, attr: &Attr) {
if let Some(ref s) = self.super_type() {
s.after_set_attr(attr);
}
@@ -392,7 +396,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
self.sandbox.set(Some(modes));
}
&atom!("src") => {
- let node: JSRef<Node> = NodeCast::from_ref(*self);
+ let node = NodeCast::from_ref(*self);
if node.is_in_doc() {
self.process_the_iframe_attributes()
}
@@ -408,7 +412,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
}
}
- fn before_remove_attr(&self, attr: JSRef<Attr>) {
+ fn before_remove_attr(&self, attr: &Attr) {
if let Some(ref s) = self.super_type() {
s.before_remove_attr(attr);
}
@@ -437,7 +441,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLIFrameElement> {
// https://html.spec.whatwg.org/multipage/#a-browsing-context-is-discarded
match (self.containing_page_pipeline_id(), self.subpage_id()) {
(Some(containing_pipeline_id), Some(subpage_id)) => {
- let window = window_from_node(*self).root();
+ let window = window_from_node(*self);
let window = window.r();
let ConstellationChan(ref chan) = window.constellation_chan();