mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
Upgrade to SM 39
This commit is contained in:
parent
a256f39796
commit
675267b782
205 changed files with 6546 additions and 5340 deletions
|
@ -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();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue