auto merge of #3666 : ttaubert/servo/issue/3644-privatize-dom, r=Manishearth

This PR removes public fields from all (hope I didn't miss any) DOM structs. Should |Page| be privatized as well? This PR additionally introduces a #[privatize] lint to ensure nobody accidentally re-introduces a public field.

All changesets compile separately if applied in the same order. Hope that helps reviewing but I can of course squash them before merging.
This commit is contained in:
bors-servo 2014-10-13 22:00:37 -06:00
commit f350879574
131 changed files with 803 additions and 381 deletions

View file

@ -78,20 +78,20 @@ pub trait LayoutDataAccess {
impl<'ln> LayoutDataAccess for LayoutNode<'ln> {
#[inline(always)]
unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> {
mem::transmute(self.get().layout_data.borrow_unchecked())
mem::transmute(self.get().layout_data_unchecked())
}
#[inline(always)]
fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
unsafe {
mem::transmute(self.get().layout_data.borrow())
mem::transmute(self.get().layout_data())
}
}
#[inline(always)]
fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
unsafe {
mem::transmute(self.get().layout_data.borrow_mut())
mem::transmute(self.get().layout_data_mut())
}
}
}

View file

@ -116,8 +116,8 @@ pub trait TLayoutNode {
fail!("not an iframe element!")
}
let iframe_element: JS<HTMLIFrameElement> = self.get_jsmanaged().transmute_copy();
let size = (*iframe_element.unsafe_get()).size.get().unwrap();
(size.pipeline_id, size.subpage_id)
let size = (*iframe_element.unsafe_get()).size().unwrap();
(*size.pipeline_id(), *size.subpage_id())
}
}
@ -189,7 +189,7 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
unsafe {
if self.get().is_text() {
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
(*text.unsafe_get()).characterdata.data.borrow().clone()
(*text.unsafe_get()).characterdata().data().clone()
} else if self.get().is_htmlinputelement() {
let input: JS<HTMLInputElement> = self.get_jsmanaged().transmute_copy();
input.get_value_for_layout()
@ -425,7 +425,7 @@ pub struct LayoutElement<'le> {
impl<'le> LayoutElement<'le> {
pub fn style_attribute(&self) -> &'le Option<PropertyDeclarationBlock> {
let style: &Option<PropertyDeclarationBlock> = unsafe {
let style: &RefCell<Option<PropertyDeclarationBlock>> = &self.element.style_attribute;
let style: &RefCell<Option<PropertyDeclarationBlock>> = self.element.style_attribute();
// cast to the direct reference to T placed on the head of RefCell<T>
mem::transmute(style)
};
@ -436,12 +436,12 @@ impl<'le> LayoutElement<'le> {
impl<'le> TElement<'le> for LayoutElement<'le> {
#[inline]
fn get_local_name(self) -> &'le Atom {
&self.element.local_name
self.element.local_name()
}
#[inline]
fn get_namespace(self) -> &'le Namespace {
&self.element.namespace
self.element.namespace()
}
#[inline]
@ -456,7 +456,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
fn get_link(self) -> Option<&'le str> {
// FIXME: This is HTML only.
match self.element.node.type_id_for_layout() {
match self.element.node().type_id_for_layout() {
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
// selector-link
ElementNodeTypeId(HTMLAnchorElementTypeId) |
@ -470,7 +470,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
fn get_hover_state(self) -> bool {
unsafe {
self.element.node.get_hover_state_for_layout()
self.element.node().get_hover_state_for_layout()
}
}
@ -481,13 +481,13 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
fn get_disabled_state(self) -> bool {
unsafe {
self.element.node.get_disabled_state_for_layout()
self.element.node().get_disabled_state_for_layout()
}
}
fn get_enabled_state(self) -> bool {
unsafe {
self.element.node.get_enabled_state_for_layout()
self.element.node().get_enabled_state_for_layout()
}
}
@ -721,7 +721,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
#[inline(always)]
pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
unsafe {
mem::transmute(self.get().layout_data.borrow())
mem::transmute(self.get().layout_data())
}
}
@ -729,7 +729,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
#[inline(always)]
pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
unsafe {
mem::transmute(self.get().layout_data.borrow_mut())
mem::transmute(self.get().layout_data_mut())
}
}
@ -765,7 +765,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
Some(TextNodeTypeId) => {
unsafe {
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
if !is_whitespace((*text.unsafe_get()).characterdata.data.borrow().as_slice()) {
if !is_whitespace((*text.unsafe_get()).characterdata().data().as_slice()) {
return false
}

View file

@ -27,6 +27,7 @@ mod jstraceable;
pub fn plugin_registrar(reg: &mut Registry) {
reg.register_lint_pass(box lints::TransmutePass as LintPassObject);
reg.register_lint_pass(box lints::UnrootedPass as LintPassObject);
reg.register_lint_pass(box lints::PrivatizePass as LintPassObject);
reg.register_syntax_extension(intern("jstraceable"), Decorator(box jstraceable::expand_jstraceable))
}

View file

@ -2,7 +2,8 @@
* 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 syntax::{ast, codemap, visit};
use syntax::{ast, ast_util, codemap, visit};
use syntax::ast::Public;
use syntax::attr::AttrMetaMethods;
use rustc::lint::{Context, LintPass, LintArray};
use rustc::middle::ty::expr_ty;
@ -14,9 +15,12 @@ declare_lint!(TRANSMUTE_TYPE_LINT, Allow,
"Warn and report types being transmuted")
declare_lint!(UNROOTED_MUST_ROOT, Deny,
"Warn and report usage of unrooted jsmanaged objects")
declare_lint!(PRIVATIZE, Deny,
"Allows to enforce private fields for struct definitions")
pub struct TransmutePass;
pub struct UnrootedPass;
pub struct PrivatizePass;
impl LintPass for TransmutePass {
fn get_lints(&self) -> LintArray {
@ -146,3 +150,22 @@ impl LintPass for UnrootedPass {
}
}
impl LintPass for PrivatizePass {
fn get_lints(&self) -> LintArray {
lint_array!(PRIVATIZE)
}
fn check_struct_def(&mut self, cx: &Context, def: &ast::StructDef, _i: ast::Ident, _gen: &ast::Generics, id: ast::NodeId) {
if ty::has_attr(cx.tcx, ast_util::local_def(id), "privatize") {
for field in def.fields.iter() {
match field.node {
ast::StructField_ { kind: ast::NamedField(ident, visibility), .. } if visibility == Public => {
cx.span_lint(PRIVATIZE, field.span,
format!("Field {} is public where only private fields are allowed", ident.name).as_slice());
}
_ => {}
}
}
}
}
}

View file

@ -72,13 +72,14 @@ impl Str for AttrValue {
#[jstraceable]
#[must_root]
#[privatize]
pub struct Attr {
reflector_: Reflector,
local_name: Atom,
value: RefCell<AttrValue>,
pub name: Atom,
pub namespace: Namespace,
pub prefix: Option<DOMString>,
name: Atom,
namespace: Namespace,
prefix: Option<DOMString>,
/// the element that owns this attribute.
owner: JS<Element>,
@ -111,6 +112,21 @@ impl Attr {
reflect_dom_object(box Attr::new_inherited(local_name, value, name, namespace, prefix, owner),
&global::Window(window), AttrBinding::Wrap)
}
#[inline]
pub fn name<'a>(&'a self) -> &'a Atom {
&self.name
}
#[inline]
pub fn namespace<'a>(&'a self) -> &'a Namespace {
&self.namespace
}
#[inline]
pub fn prefix<'a>(&'a self) -> &'a Option<DOMString> {
&self.prefix
}
}
impl<'a> AttrMethods for JSRef<'a, Attr> {

View file

@ -5452,7 +5452,7 @@ class GlobalGenRoots():
protoDescriptor = config.getDescriptor(protoName)
delegate = string.Template('''impl ${selfName} for ${baseName} {
fn ${fname}(&self) -> bool {
self.${parentName}.${fname}()
self.${parentName}().${fname}()
}
}
''').substitute({'fname': 'is_' + name.lower(),

View file

@ -83,7 +83,7 @@ impl<'a> GlobalRef<'a> {
/// thread.
pub fn script_chan<'b>(&'b self) -> &'b ScriptChan {
match *self {
Window(ref window) => &window.script_chan,
Window(ref window) => window.script_chan(),
Worker(ref worker) => worker.script_chan(),
}
}

View file

@ -660,7 +660,7 @@ pub extern fn outerize_global(_cx: *mut JSContext, obj: JSHandleObject) -> *mut
IDLInterface::get_prototype_depth(None::<window::Window>))
.unwrap()
.root();
win.browser_context.borrow().as_ref().unwrap().window_proxy()
win.browser_context().as_ref().unwrap().window_proxy()
}
}

View file

@ -17,6 +17,7 @@ pub enum BlobType {
#[jstraceable]
#[must_root]
#[privatize]
pub struct Blob {
reflector_: Reflector,
type_: BlobType

View file

@ -15,6 +15,7 @@ use std::ptr;
#[allow(raw_pointer_deriving)]
#[jstraceable]
#[privatize]
pub struct BrowserContext {
history: Vec<SessionHistoryEntry>,
active_index: uint,
@ -38,7 +39,7 @@ impl BrowserContext {
pub fn active_window(&self) -> Temporary<Window> {
let doc = self.active_document().root();
Temporary::new(doc.window.clone())
Temporary::new(doc.window().clone())
}
pub fn window_proxy(&self) -> *mut JSObject {
@ -66,6 +67,7 @@ impl BrowserContext {
#[jstraceable]
#[must_root]
#[privatize]
pub struct SessionHistoryEntry {
document: JS<Document>,
children: Vec<BrowserContext>

View file

@ -17,6 +17,7 @@ use canvas::canvas_render_task::{CanvasMsg, CanvasRenderTask, ClearRect, Close,
#[jstraceable]
#[must_root]
#[privatize]
pub struct CanvasRenderingContext2D {
reflector_: Reflector,
global: GlobalField,

View file

@ -14,18 +14,19 @@ use dom::eventtarget::{EventTarget, NodeTargetTypeId};
use dom::node::{CommentNodeTypeId, Node, NodeTypeId, TextNodeTypeId, ProcessingInstructionNodeTypeId, NodeHelpers};
use servo_util::str::DOMString;
use std::cell::RefCell;
use std::cell::{Ref, RefCell};
#[jstraceable]
#[must_root]
#[privatize]
pub struct CharacterData {
pub node: Node,
pub data: RefCell<DOMString>,
node: Node,
data: RefCell<DOMString>,
}
impl CharacterDataDerived for EventTarget {
fn is_characterdata(&self) -> bool {
match self.type_id {
match *self.type_id() {
NodeTargetTypeId(TextNodeTypeId) |
NodeTargetTypeId(CommentNodeTypeId) |
NodeTargetTypeId(ProcessingInstructionNodeTypeId) => true,
@ -41,6 +42,21 @@ impl CharacterData {
data: RefCell::new(data),
}
}
#[inline]
pub fn node<'a>(&'a self) -> &'a Node {
&self.node
}
#[inline]
pub fn data(&self) -> Ref<DOMString> {
self.data.borrow()
}
#[inline]
pub fn set_data(&self, data: DOMString) {
*self.data.borrow_mut() = data;
}
}
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {

View file

@ -18,13 +18,14 @@ use servo_util::str::DOMString;
/// An HTML comment.
#[jstraceable]
#[must_root]
#[privatize]
pub struct Comment {
pub characterdata: CharacterData,
characterdata: CharacterData,
}
impl CommentDerived for EventTarget {
fn is_comment(&self) -> bool {
self.type_id == NodeTargetTypeId(CommentNodeTypeId)
*self.type_id() == NodeTargetTypeId(CommentNodeTypeId)
}
}
@ -44,6 +45,11 @@ impl Comment {
let document = global.as_window().Document().root();
Ok(Comment::new(data, *document))
}
#[inline]
pub fn characterdata<'a>(&'a self) -> &'a CharacterData {
&self.characterdata
}
}
impl Reflectable for Comment {

View file

@ -11,8 +11,9 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct Console {
pub reflector_: Reflector
reflector_: Reflector
}
impl Console {

View file

@ -19,6 +19,7 @@ use std::cell::Cell;
#[jstraceable]
#[must_root]
#[privatize]
pub struct CustomEvent {
event: Event,
detail: Cell<JSVal>,
@ -26,7 +27,7 @@ pub struct CustomEvent {
impl CustomEventDerived for Event {
fn is_customevent(&self) -> bool {
self.type_id == CustomEventTypeId
*self.type_id() == CustomEventTypeId
}
}

View file

@ -37,6 +37,7 @@ use url::Url;
#[jstraceable]
#[must_root]
#[privatize]
pub struct DedicatedWorkerGlobalScope {
workerglobalscope: WorkerGlobalScope,
receiver: Receiver<ScriptMsg>,
@ -192,7 +193,7 @@ impl Reflectable for DedicatedWorkerGlobalScope {
impl DedicatedWorkerGlobalScopeDerived for EventTarget {
fn is_dedicatedworkerglobalscope(&self) -> bool {
match self.type_id {
match *self.type_id() {
WorkerGlobalScopeTypeId(DedicatedGlobalScope) => true,
_ => false
}

View file

@ -62,7 +62,7 @@ use url::Url;
use std::collections::hashmap::HashMap;
use std::ascii::StrAsciiExt;
use std::cell::{Cell, RefCell};
use std::cell::{Cell, Ref, RefCell};
use std::default::Default;
use time;
@ -75,16 +75,17 @@ pub enum IsHTMLDocument {
#[jstraceable]
#[must_root]
#[privatize]
pub struct Document {
pub node: Node,
node: Node,
reflector_: Reflector,
pub window: JS<Window>,
window: JS<Window>,
idmap: RefCell<HashMap<Atom, Vec<JS<Element>>>>,
implementation: MutNullableJS<DOMImplementation>,
content_type: DOMString,
last_modified: RefCell<Option<DOMString>>,
pub encoding_name: RefCell<DOMString>,
pub is_html_document: bool,
encoding_name: RefCell<DOMString>,
is_html_document: bool,
url: Url,
quirks_mode: Cell<QuirksMode>,
images: MutNullableJS<HTMLCollection>,
@ -98,7 +99,7 @@ pub struct Document {
impl DocumentDerived for EventTarget {
fn is_document(&self) -> bool {
self.type_id == NodeTargetTypeId(DocumentNodeTypeId)
*self.type_id() == NodeTargetTypeId(DocumentNodeTypeId)
}
}
@ -343,6 +344,21 @@ impl Document {
node.set_owner_doc(*document);
Temporary::from_rooted(*document)
}
#[inline]
pub fn window<'a>(&'a self) -> &'a JS<Window> {
&self.window
}
#[inline]
pub fn encoding_name(&self) -> Ref<DOMString> {
self.encoding_name.borrow()
}
#[inline]
pub fn is_html_document(&self) -> bool {
self.is_html_document
}
}
impl Reflectable for Document {
@ -641,7 +657,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
for child in title_elem.children() {
if child.is_text() {
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
title.push_str(text.characterdata.data.borrow().as_slice());
title.push_str(text.characterdata().data().as_slice());
}
}
});

View file

@ -20,13 +20,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct DocumentFragment {
pub node: Node,
node: Node,
}
impl DocumentFragmentDerived for EventTarget {
fn is_documentfragment(&self) -> bool {
self.type_id == NodeTargetTypeId(DocumentFragmentNodeTypeId)
*self.type_id() == NodeTargetTypeId(DocumentFragmentNodeTypeId)
}
}

View file

@ -15,16 +15,17 @@ use servo_util::str::DOMString;
/// The `DOCTYPE` tag.
#[jstraceable]
#[must_root]
#[privatize]
pub struct DocumentType {
pub node: Node,
pub name: DOMString,
pub public_id: DOMString,
pub system_id: DOMString,
node: Node,
name: DOMString,
public_id: DOMString,
system_id: DOMString,
}
impl DocumentTypeDerived for EventTarget {
fn is_documenttype(&self) -> bool {
self.type_id == NodeTargetTypeId(DoctypeNodeTypeId)
*self.type_id() == NodeTargetTypeId(DoctypeNodeTypeId)
}
}
@ -53,6 +54,21 @@ impl DocumentType {
document);
Node::reflect_node(box documenttype, document, DocumentTypeBinding::Wrap)
}
#[inline]
pub fn name<'a>(&'a self) -> &'a DOMString {
&self.name
}
#[inline]
pub fn public_id<'a>(&'a self) -> &'a DOMString {
&self.public_id
}
#[inline]
pub fn system_id<'a>(&'a self) -> &'a DOMString {
&self.system_id
}
}
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {

View file

@ -62,9 +62,10 @@ impl DOMErrorName {
#[jstraceable]
#[must_root]
#[privatize]
pub struct DOMException {
pub code: DOMErrorName,
pub reflector_: Reflector
code: DOMErrorName,
reflector_: Reflector
}
impl DOMException {

View file

@ -24,6 +24,7 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct DOMImplementation {
document: JS<Document>,
reflector_: Reflector,
@ -38,7 +39,7 @@ impl DOMImplementation {
}
pub fn new(document: JSRef<Document>) -> Temporary<DOMImplementation> {
let window = document.window.root();
let window = document.window().root();
reflect_dom_object(box DOMImplementation::new_inherited(document),
&Window(*window),
DOMImplementationBinding::Wrap)
@ -72,7 +73,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
fn CreateDocument(self, namespace: Option<DOMString>, qname: DOMString,
maybe_doctype: Option<JSRef<DocumentType>>) -> Fallible<Temporary<Document>> {
let doc = self.document.root();
let win = doc.window.root();
let win = doc.window().root();
// Step 1.
let doc = Document::new(*win, None, NonHTMLDocument, None).root();
@ -117,7 +118,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
fn CreateHTMLDocument(self, title: Option<DOMString>) -> Temporary<Document> {
let document = self.document.root();
let win = document.window.root();
let win = document.window().root();
// Step 1-2.
let doc = Document::new(*win, None, HTMLDocument, None).root();

View file

@ -16,6 +16,7 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct DOMParser {
window: JS<Window>, //XXXjdm Document instead?
reflector_: Reflector

View file

@ -12,6 +12,7 @@ use servo_util::geometry::Au;
#[jstraceable]
#[must_root]
#[privatize]
pub struct DOMRect {
reflector_: Reflector,
top: f32,

View file

@ -12,6 +12,7 @@ use dom::window::Window;
#[jstraceable]
#[must_root]
#[privatize]
pub struct DOMRectList {
reflector_: Reflector,
rects: Vec<JS<DOMRect>>,

View file

@ -17,6 +17,7 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct DOMTokenList {
reflector_: Reflector,
element: JS<Element>,

View file

@ -35,7 +35,7 @@ use servo_util::namespace;
use servo_util::str::DOMString;
use std::ascii::StrAsciiExt;
use std::cell::RefCell;
use std::cell::{Ref, RefMut, RefCell};
use std::default::Default;
use std::mem;
use std::slice::Items;
@ -44,20 +44,21 @@ use url::UrlParser;
#[jstraceable]
#[must_root]
#[privatize]
pub struct Element {
pub node: Node,
pub local_name: Atom,
pub namespace: Namespace,
pub prefix: Option<DOMString>,
pub attrs: RefCell<Vec<JS<Attr>>>,
pub style_attribute: RefCell<Option<style::PropertyDeclarationBlock>>,
pub attr_list: MutNullableJS<NamedNodeMap>,
node: Node,
local_name: Atom,
namespace: Namespace,
prefix: Option<DOMString>,
attrs: RefCell<Vec<JS<Attr>>>,
style_attribute: RefCell<Option<style::PropertyDeclarationBlock>>,
attr_list: MutNullableJS<NamedNodeMap>,
class_list: MutNullableJS<DOMTokenList>,
}
impl ElementDerived for EventTarget {
fn is_element(&self) -> bool {
match self.type_id {
match *self.type_id() {
NodeTargetTypeId(ElementNodeTypeId(_)) => true,
_ => false
}
@ -166,6 +167,41 @@ impl Element {
Node::reflect_node(box Element::new_inherited(ElementTypeId_, local_name, namespace, prefix, document),
document, ElementBinding::Wrap)
}
#[inline]
pub fn node<'a>(&'a self) -> &'a Node {
&self.node
}
#[inline]
pub fn local_name<'a>(&'a self) -> &'a Atom {
&self.local_name
}
#[inline]
pub fn namespace<'a>(&'a self) -> &'a Namespace {
&self.namespace
}
#[inline]
pub fn prefix<'a>(&'a self) -> &'a Option<DOMString> {
&self.prefix
}
#[inline]
pub fn attrs(&self) -> Ref<Vec<JS<Attr>>> {
self.attrs.borrow()
}
#[inline]
pub fn attrs_mut(&self) -> RefMut<Vec<JS<Attr>>> {
self.attrs.borrow_mut()
}
#[inline]
pub fn style_attribute<'a>(&'a self) -> &'a RefCell<Option<style::PropertyDeclarationBlock>> {
&self.style_attribute
}
}
pub trait RawLayoutElementHelpers {
@ -186,7 +222,7 @@ impl RawLayoutElementHelpers for Element {
(*attrs).iter().find(|attr: & &JS<Attr>| {
let attr = attr.unsafe_get();
name == (*attr).local_name_atom_forever().as_slice() &&
(*attr).namespace == *namespace
*(*attr).namespace() == *namespace
}).map(|attr| {
let attr = attr.unsafe_get();
(*attr).value_ref_forever()
@ -217,7 +253,7 @@ impl RawLayoutElementHelpers for Element {
(*attrs).iter().find(|attr: & &JS<Attr>| {
let attr = attr.unsafe_get();
name == (*attr).local_name_atom_forever().as_slice() &&
(*attr).namespace == *namespace
*(*attr).namespace() == *namespace
}).and_then(|attr| {
let attr = attr.unsafe_get();
(*attr).value_atom_forever()
@ -263,7 +299,7 @@ impl LayoutElementHelpers for JS<Element> {
}
let node: JS<Node> = self.transmute_copy();
let owner_doc = node.owner_doc_for_layout().unsafe_get();
(*owner_doc).is_html_document
(*owner_doc).is_html_document()
}
}
@ -355,7 +391,7 @@ pub trait AttributeHandlers {
impl<'a> AttributeHandlers for JSRef<'a, Element> {
fn get_attribute(self, namespace: Namespace, local_name: &str) -> Option<Temporary<Attr>> {
self.get_attributes(local_name).iter().map(|attr| attr.root())
.find(|attr| attr.namespace == namespace)
.find(|attr| *attr.namespace() == namespace)
.map(|x| Temporary::from_rooted(*x))
}
@ -491,7 +527,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
false => Atom::from_slice(name)
};
self.attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
*attr.local_name() == name && attr.namespace == ns!("")
*attr.local_name() == name && *attr.namespace() == ns!("")
})
}
@ -626,7 +662,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
let node: JSRef<Node> = NodeCast::from_ref(self);
node.owner_doc().root()
};
let window = doc.window.root();
let window = doc.window().root();
let list = NamedNodeMap::new(*window, self);
self.attr_list.assign(Some(list));
}
@ -679,7 +715,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
let name = Atom::from_slice(name.as_slice());
let value = self.parse_attribute(&ns!(""), &name, value);
self.do_set_attribute(name.clone(), value, name.clone(), ns!(""), None, |attr| {
attr.name.as_slice() == name.as_slice()
attr.name().as_slice() == name.as_slice()
});
Ok(())
}
@ -748,7 +784,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
namespace.clone(), prefix.map(|s| s.to_string()),
|attr| {
*attr.local_name() == local_name &&
attr.namespace == namespace
*attr.namespace() == namespace
});
Ok(())
}

View file

@ -49,21 +49,22 @@ pub enum EventCancelable {
#[jstraceable]
#[must_root]
#[privatize]
pub struct Event {
pub type_id: EventTypeId,
type_id: EventTypeId,
reflector_: Reflector,
pub current_target: MutNullableJS<EventTarget>,
pub target: MutNullableJS<EventTarget>,
current_target: MutNullableJS<EventTarget>,
target: MutNullableJS<EventTarget>,
type_: RefCell<DOMString>,
pub phase: Cell<EventPhase>,
pub canceled: Cell<bool>,
pub stop_propagation: Cell<bool>,
pub stop_immediate: Cell<bool>,
pub cancelable: Cell<bool>,
pub bubbles: Cell<bool>,
pub trusted: Cell<bool>,
pub dispatching: Cell<bool>,
pub initialized: Cell<bool>,
phase: Cell<EventPhase>,
canceled: Cell<bool>,
stop_propagation: Cell<bool>,
stop_immediate: Cell<bool>,
cancelable: Cell<bool>,
bubbles: Cell<bool>,
trusted: Cell<bool>,
dispatching: Cell<bool>,
initialized: Cell<bool>,
timestamp: u64,
}
@ -110,6 +111,61 @@ impl Event {
let cancelable = if init.cancelable { Cancelable } else { NotCancelable };
Ok(Event::new(global, type_, bubbles, cancelable))
}
#[inline]
pub fn type_id<'a>(&'a self) -> &'a EventTypeId {
&self.type_id
}
#[inline]
pub fn clear_current_target(&self) {
self.current_target.clear();
}
#[inline]
pub fn set_current_target(&self, val: JSRef<EventTarget>) {
self.current_target.assign(Some(val));
}
#[inline]
pub fn set_target(&self, val: JSRef<EventTarget>) {
self.target.assign(Some(val));
}
#[inline]
pub fn set_phase(&self, val: EventPhase) {
self.phase.set(val)
}
#[inline]
pub fn stop_propagation(&self) -> bool {
self.stop_propagation.get()
}
#[inline]
pub fn stop_immediate(&self) -> bool {
self.stop_immediate.get()
}
#[inline]
pub fn bubbles(&self) -> bool {
self.bubbles.get()
}
#[inline]
pub fn dispatching(&self) -> bool {
self.dispatching.get()
}
#[inline]
pub fn set_dispatching(&self, val: bool) {
self.dispatching.set(val)
}
#[inline]
pub fn initialized(&self) -> bool {
self.initialized.get()
}
}
impl<'a> EventMethods for JSRef<'a, Event> {

View file

@ -5,7 +5,7 @@
use dom::bindings::callback::ReportExceptions;
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, NodeDerived};
use dom::bindings::js::{JS, JSRef, OptionalSettable, OptionalRootable, Root};
use dom::bindings::js::{JS, JSRef, OptionalRootable, Root};
use dom::eventtarget::{Capturing, Bubbling, EventTarget};
use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing};
use dom::node::{Node, NodeHelpers};
@ -15,13 +15,13 @@ use dom::virtualmethods::vtable_for;
pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
pseudo_target: Option<JSRef<'b, EventTarget>>,
event: JSRef<Event>) -> bool {
assert!(!event.dispatching.get());
assert!(!event.dispatching());
event.target.assign(Some(match pseudo_target {
event.set_target(match pseudo_target {
Some(pseudo_target) => pseudo_target,
None => target.clone(),
}));
event.dispatching.set(true);
});
event.set_dispatching(true);
let type_ = event.Type();
@ -36,7 +36,7 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
vec!()
};
event.phase.set(PhaseCapturing);
event.set_phase(PhaseCapturing);
//FIXME: The "callback this value" should be currentTarget
@ -44,17 +44,17 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
for cur_target in chain.as_slice().iter().rev() {
let stopped = match cur_target.get_listeners_for(type_.as_slice(), Capturing) {
Some(listeners) => {
event.current_target.assign(Some(cur_target.deref().clone()));
event.set_current_target(cur_target.deref().clone());
for listener in listeners.iter() {
// Explicitly drop any exception on the floor.
let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
if event.stop_immediate.get() {
if event.stop_immediate() {
break;
}
}
event.stop_propagation.get()
event.stop_propagation()
}
None => false
};
@ -65,9 +65,9 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
}
/* at target */
if !event.stop_propagation.get() {
event.phase.set(PhaseAtTarget);
event.current_target.assign(Some(target.clone()));
if !event.stop_propagation() {
event.set_phase(PhaseAtTarget);
event.set_current_target(target.clone());
let opt_listeners = target.get_listeners(type_.as_slice());
for listeners in opt_listeners.iter() {
@ -75,7 +75,7 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
// Explicitly drop any exception on the floor.
let _ = listener.HandleEvent_(target, event, ReportExceptions);
if event.stop_immediate.get() {
if event.stop_immediate() {
break;
}
}
@ -83,23 +83,23 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
}
/* bubbling */
if event.bubbles.get() && !event.stop_propagation.get() {
event.phase.set(PhaseBubbling);
if event.bubbles() && !event.stop_propagation() {
event.set_phase(PhaseBubbling);
for cur_target in chain.iter() {
let stopped = match cur_target.get_listeners_for(type_.as_slice(), Bubbling) {
Some(listeners) => {
event.current_target.assign(Some(cur_target.deref().clone()));
event.set_current_target(cur_target.deref().clone());
for listener in listeners.iter() {
// Explicitly drop any exception on the floor.
let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
if event.stop_immediate.get() {
if event.stop_immediate() {
break;
}
}
event.stop_propagation.get()
event.stop_propagation()
}
None => false
};
@ -131,9 +131,9 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
let _ = chain.pop();
}
event.dispatching.set(false);
event.phase.set(PhaseNone);
event.current_target.clear();
event.set_dispatching(false);
event.set_phase(PhaseNone);
event.clear_current_target();
!event.DefaultPrevented()
}

View file

@ -59,15 +59,17 @@ impl EventListenerType {
#[deriving(PartialEq)]
#[jstraceable]
#[privatize]
pub struct EventListenerEntry {
pub phase: ListenerPhase,
pub listener: EventListenerType
phase: ListenerPhase,
listener: EventListenerType
}
#[jstraceable]
#[must_root]
#[privatize]
pub struct EventTarget {
pub type_id: EventTargetTypeId,
type_id: EventTargetTypeId,
reflector_: Reflector,
handlers: RefCell<HashMap<DOMString, Vec<EventListenerEntry>>>,
}
@ -94,6 +96,11 @@ impl EventTarget {
filtered.map(|entry| entry.listener.get_listener()).collect()
})
}
#[inline]
pub fn type_id<'a>(&'a self) -> &'a EventTargetTypeId {
&self.type_id
}
}
pub trait EventTargetHelpers {
@ -121,7 +128,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
fn dispatch_event_with_target(self,
target: Option<JSRef<EventTarget>>,
event: JSRef<Event>) -> Fallible<bool> {
if event.dispatching.get() || !event.initialized.get() {
if event.dispatching() || !event.initialized() {
return Err(InvalidState);
}
Ok(dispatch_event(self, target, event))

View file

@ -12,10 +12,11 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct File {
pub blob: Blob,
pub name: DOMString,
pub type_: BlobType
blob: Blob,
name: DOMString,
type_: BlobType
}
impl File {
@ -34,6 +35,10 @@ impl File {
global,
FileBinding::Wrap)
}
pub fn name<'a>(&'a self) -> &'a DOMString {
&self.name
}
}
impl<'a> FileMethods for JSRef<'a, File> {

View file

@ -27,6 +27,7 @@ pub enum FormDatum {
#[jstraceable]
#[must_root]
#[privatize]
pub struct FormData {
data: RefCell<HashMap<DOMString, Vec<FormDatum>>>,
reflector_: Reflector,
@ -112,7 +113,7 @@ impl PrivateFormDataHelpers for FormData {
fn get_file_from_blob(&self, value: JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> {
let global = self.global.root();
let f: Option<JSRef<File>> = FileCast::to_ref(value);
let name = filename.unwrap_or(f.map(|inner| inner.name.clone()).unwrap_or("blob".to_string()));
let name = filename.unwrap_or(f.map(|inner| inner.name().clone()).unwrap_or("blob".to_string()));
File::new(&global.root_ref(), value, name)
}
}

View file

@ -23,13 +23,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLAnchorElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLAnchorElementDerived for EventTarget {
fn is_htmlanchorelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAnchorElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAnchorElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLAppletElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLAppletElementDerived for EventTarget {
fn is_htmlappletelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAppletElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAppletElementTypeId))
}
}

View file

@ -16,13 +16,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLAreaElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLAreaElementDerived for EventTarget {
fn is_htmlareaelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAreaElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAreaElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLAudioElement {
pub htmlmediaelement: HTMLMediaElement
htmlmediaelement: HTMLMediaElement
}
impl HTMLAudioElementDerived for EventTarget {
fn is_htmlaudioelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAudioElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAudioElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLBaseElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLBaseElementDerived for EventTarget {
fn is_htmlbaseelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBaseElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLBaseElementTypeId))
}
}

View file

@ -22,13 +22,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLBodyElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLBodyElementDerived for EventTarget {
fn is_htmlbodyelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBodyElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLBodyElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLBRElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLBRElementDerived for EventTarget {
fn is_htmlbrelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBRElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLBRElementTypeId))
}
}

View file

@ -22,13 +22,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLButtonElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLButtonElementDerived for EventTarget {
fn is_htmlbuttonelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLButtonElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLButtonElementTypeId))
}
}

View file

@ -30,8 +30,9 @@ static DefaultHeight: u32 = 150;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLCanvasElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
context: MutNullableJS<CanvasRenderingContext2D>,
width: Cell<u32>,
height: Cell<u32>,
@ -39,7 +40,7 @@ pub struct HTMLCanvasElement {
impl HTMLCanvasElementDerived for EventTarget {
fn is_htmlcanvaselement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLCanvasElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLCanvasElementTypeId))
}
}

View file

@ -31,6 +31,7 @@ pub enum CollectionTypeId {
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLCollection {
collection: CollectionTypeId,
reflector_: Reflector,
@ -66,7 +67,7 @@ impl HTMLCollection {
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
match self.namespace_filter {
None => true,
Some(ref namespace) => elem.namespace == *namespace
Some(ref namespace) => *elem.namespace() == *namespace
}
}
}
@ -88,9 +89,9 @@ impl HTMLCollection {
impl CollectionFilter for TagNameFilter {
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
if elem.html_element_in_html_document() {
elem.local_name == self.ascii_lower_tag
*elem.local_name() == self.ascii_lower_tag
} else {
elem.local_name == self.tag
*elem.local_name() == self.tag
}
}
}
@ -120,11 +121,11 @@ impl HTMLCollection {
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
let ns_match = match self.namespace_filter {
Some(ref namespace) => {
elem.namespace == *namespace
*elem.namespace() == *namespace
},
None => true
};
ns_match && elem.local_name == self.tag
ns_match && *elem.local_name() == self.tag
}
}
let filter = TagNameNSFilter {

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLDataElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLDataElementDerived for EventTarget {
fn is_htmldataelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDataElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDataElementTypeId))
}
}

View file

@ -18,13 +18,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLDataListElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLDataListElementDerived for EventTarget {
fn is_htmldatalistelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDataListElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDataListElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLDirectoryElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLDirectoryElementDerived for EventTarget {
fn is_htmldirectoryelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDirectoryElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDirectoryElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLDivElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLDivElementDerived for EventTarget {
fn is_htmldivelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDivElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDivElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLDListElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLDListElementDerived for EventTarget {
fn is_htmldlistelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDListElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDListElementTypeId))
}
}

View file

@ -22,13 +22,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLElement {
pub element: Element
element: Element
}
impl HTMLElementDerived for EventTarget {
fn is_htmlelement(&self) -> bool {
match self.type_id {
match *self.type_id() {
NodeTargetTypeId(ElementNodeTypeId(ElementTypeId_)) => false,
NodeTargetTypeId(ElementNodeTypeId(_)) => true,
_ => false
@ -48,6 +49,11 @@ impl HTMLElement {
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, prefix, document);
Node::reflect_node(box element, document, HTMLElementBinding::Wrap)
}
#[inline]
pub fn element<'a>(&'a self) -> &'a Element {
&self.element
}
}
trait PrivateHTMLElementHelpers {

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLEmbedElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLEmbedElementDerived for EventTarget {
fn is_htmlembedelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLEmbedElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLEmbedElementTypeId))
}
}

View file

@ -23,13 +23,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLFieldSetElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLFieldSetElementDerived for EventTarget {
fn is_htmlfieldsetelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFieldSetElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFieldSetElementTypeId))
}
}
@ -57,7 +58,7 @@ impl<'a> HTMLFieldSetElementMethods for JSRef<'a, HTMLFieldSetElement> {
static tag_names: StaticStringVec = &["button", "fieldset", "input",
"keygen", "object", "output", "select", "textarea"];
let root: JSRef<Element> = ElementCast::to_ref(root).unwrap();
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.local_name.as_slice())
elem != root && tag_names.iter().any(|&tag_name| tag_name == elem.local_name().as_slice())
}
}
let node: JSRef<Node> = NodeCast::from_ref(self);

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLFontElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLFontElementDerived for EventTarget {
fn is_htmlfontelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFontElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFontElementTypeId))
}
}

View file

@ -31,13 +31,14 @@ use url::form_urlencoded::serialize;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLFormElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLFormElementDerived for EventTarget {
fn is_htmlformelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFormElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFormElementTypeId))
}
}
@ -217,8 +218,8 @@ impl<'a> HTMLFormElementHelpers for JSRef<'a, HTMLFormElement> {
}
// This is wrong. https://html.spec.whatwg.org/multipage/forms.html#planned-navigation
let ScriptChan(ref script_chan) = win.script_chan;
script_chan.send(TriggerLoadMsg(win.page.id, load_data));
let ScriptChan(ref script_chan) = *win.script_chan();
script_chan.send(TriggerLoadMsg(win.page().id, load_data));
}
fn get_form_dataset(self, _submitter: Option<FormSubmitter>) -> Vec<FormDatum> {

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLFrameElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLFrameElementDerived for EventTarget {
fn is_htmlframeelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLFrameSetElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLFrameSetElementDerived for EventTarget {
fn is_htmlframesetelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameSetElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameSetElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLHeadElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLHeadElementDerived for EventTarget {
fn is_htmlheadelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadElementTypeId))
}
}

View file

@ -25,14 +25,15 @@ pub enum HeadingLevel {
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLHeadingElement {
pub htmlelement: HTMLElement,
pub level: HeadingLevel,
htmlelement: HTMLElement,
level: HeadingLevel,
}
impl HTMLHeadingElementDerived for EventTarget {
fn is_htmlheadingelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadingElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadingElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLHRElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLHRElementDerived for EventTarget {
fn is_htmlhrelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHRElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHRElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLHtmlElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLHtmlElementDerived for EventTarget {
fn is_htmlhtmlelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHtmlElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHtmlElementTypeId))
}
}

View file

@ -41,22 +41,36 @@ enum SandboxAllowance {
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLIFrameElement {
pub htmlelement: HTMLElement,
pub size: Cell<Option<IFrameSize>>,
pub sandbox: Cell<Option<u8>>,
htmlelement: HTMLElement,
size: Cell<Option<IFrameSize>>,
sandbox: Cell<Option<u8>>,
}
impl HTMLIFrameElementDerived for EventTarget {
fn is_htmliframeelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLIFrameElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLIFrameElementTypeId))
}
}
#[jstraceable]
#[privatize]
pub struct IFrameSize {
pub pipeline_id: PipelineId,
pub subpage_id: SubpageId,
pipeline_id: PipelineId,
subpage_id: SubpageId,
}
impl IFrameSize {
#[inline]
pub fn pipeline_id<'a>(&'a self) -> &'a PipelineId {
&self.pipeline_id
}
#[inline]
pub fn subpage_id<'a>(&'a self) -> &'a SubpageId {
&self.subpage_id
}
}
pub trait HTMLIFrameElementHelpers {
@ -126,6 +140,11 @@ impl HTMLIFrameElement {
let element = HTMLIFrameElement::new_inherited(localName, prefix, document);
Node::reflect_node(box element, document, HTMLIFrameElementBinding::Wrap)
}
#[inline]
pub fn size(&self) -> Option<IFrameSize> {
self.size.get()
}
}
impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
@ -152,7 +171,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
fn GetContentWindow(self) -> Option<Temporary<Window>> {
self.size.get().and_then(|size| {
let window = window_from_node(self).root();
let children = window.page.children.borrow();
let children = window.page().children.borrow();
let child = children.iter().find(|child| {
child.subpage_id.unwrap() == size.subpage_id
});

View file

@ -26,14 +26,15 @@ use std::cell::RefCell;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLImageElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
image: RefCell<Option<Url>>,
}
impl HTMLImageElementDerived for EventTarget {
fn is_htmlimageelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLImageElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLImageElementTypeId))
}
}
@ -47,8 +48,8 @@ impl<'a> PrivateHTMLImageElementHelpers for JSRef<'a, HTMLImageElement> {
fn update_image(self, value: Option<(DOMString, &Url)>) {
let node: JSRef<Node> = NodeCast::from_ref(self);
let document = node.owner_doc().root();
let window = document.window.root();
let image_cache = &window.image_cache_task;
let window = document.window().root();
let image_cache = window.image_cache_task();
match value {
None => {
*self.image.borrow_mut() = None;

View file

@ -45,8 +45,9 @@ enum InputType {
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLInputElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
input_type: Cell<InputType>,
checked: Cell<bool>,
uncommitted_value: RefCell<Option<String>>,
@ -56,7 +57,7 @@ pub struct HTMLInputElement {
impl HTMLInputElementDerived for EventTarget {
fn is_htmlinputelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLInputElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLInputElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLLabelElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLLabelElementDerived for EventTarget {
fn is_htmllabelelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLabelElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLabelElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLLegendElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLLegendElementDerived for EventTarget {
fn is_htmllegendelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLegendElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLegendElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLLIElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLLIElementDerived for EventTarget {
fn is_htmllielement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLIElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLIElementTypeId))
}
}

View file

@ -23,13 +23,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLLinkElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLLinkElementDerived for EventTarget {
fn is_htmllinkelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLinkElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLinkElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLMapElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLMapElementDerived for EventTarget {
fn is_htmlmapelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLMapElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLMapElementTypeId))
}
}

View file

@ -14,13 +14,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLMediaElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLMediaElementDerived for EventTarget {
fn is_htmlmediaelement(&self) -> bool {
match self.type_id {
match *self.type_id() {
NodeTargetTypeId(ElementNodeTypeId(HTMLVideoElementTypeId)) |
NodeTargetTypeId(ElementNodeTypeId(HTMLAudioElementTypeId)) => true,
_ => false
@ -34,6 +35,11 @@ impl HTMLMediaElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, prefix, document)
}
}
#[inline]
pub fn htmlelement<'a>(&'a self) -> &'a HTMLElement {
&self.htmlelement
}
}
impl Reflectable for HTMLMediaElement {

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLMetaElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLMetaElementDerived for EventTarget {
fn is_htmlmetaelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLMetaElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLMetaElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLMeterElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLMeterElementDerived for EventTarget {
fn is_htmlmeterelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLMeterElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLMeterElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLModElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLModElementDerived for EventTarget {
fn is_htmlmodelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLModElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLModElementTypeId))
}
}

View file

@ -27,13 +27,14 @@ use url::Url;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLObjectElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLObjectElementDerived for EventTarget {
fn is_htmlobjectelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLObjectElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLObjectElementTypeId))
}
}
@ -108,7 +109,7 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLObjectElement> {
if "data" == name.as_slice() {
let window = window_from_node(*self).root();
self.process_data_url(window.image_cache_task.clone());
self.process_data_url(window.image_cache_task().clone());
}
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLOListElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLOListElementDerived for EventTarget {
fn is_htmlolistelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOListElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLOListElementTypeId))
}
}

View file

@ -20,13 +20,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLOptGroupElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLOptGroupElementDerived for EventTarget {
fn is_htmloptgroupelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOptGroupElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLOptGroupElementTypeId))
}
}

View file

@ -24,13 +24,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLOptionElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLOptionElementDerived for EventTarget {
fn is_htmloptionelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOptionElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLOptionElementTypeId))
}
}
@ -50,7 +51,7 @@ impl HTMLOptionElement {
fn collect_text(node: &JSRef<Node>, value: &mut DOMString) {
let elem: JSRef<Element> = ElementCast::to_ref(*node).unwrap();
let svg_script = elem.namespace == ns!(SVG) && elem.local_name.as_slice() == "script";
let svg_script = *elem.namespace() == ns!(SVG) && elem.local_name().as_slice() == "script";
let html_script = node.is_htmlscriptelement();
if svg_script || html_script {
return;

View file

@ -17,13 +17,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLOutputElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLOutputElementDerived for EventTarget {
fn is_htmloutputelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOutputElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLOutputElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLParagraphElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLParagraphElementDerived for EventTarget {
fn is_htmlparagraphelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLParagraphElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLParagraphElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLParamElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLParamElementDerived for EventTarget {
fn is_htmlparamelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLParamElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLParamElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLPreElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLPreElementDerived for EventTarget {
fn is_htmlpreelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLPreElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLPreElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLProgressElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLProgressElementDerived for EventTarget {
fn is_htmlprogresselement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLProgressElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLProgressElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLQuoteElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLQuoteElementDerived for EventTarget {
fn is_htmlquoteelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLQuoteElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLQuoteElementTypeId))
}
}

View file

@ -20,13 +20,14 @@ use servo_util::str::{DOMString, HTML_SPACE_CHARACTERS, StaticStringVec};
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLScriptElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLScriptElementDerived for EventTarget {
fn is_htmlscriptelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLScriptElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLScriptElementTypeId))
}
}

View file

@ -23,13 +23,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLSelectElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLSelectElementDerived for EventTarget {
fn is_htmlselectelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSelectElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLSelectElementTypeId))
}
}

View file

@ -69,7 +69,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
fn serialize_comment(comment: JSRef<Comment>, html: &mut String) {
html.push_str("<!--");
html.push_str(comment.characterdata.data.borrow().as_slice());
html.push_str(comment.characterdata().data().as_slice());
html.push_str("-->");
}
@ -78,49 +78,49 @@ fn serialize_text(text: JSRef<Text>, html: &mut String) {
match text_node.parent_node().map(|node| node.root()) {
Some(ref parent) if parent.is_element() => {
let elem: JSRef<Element> = ElementCast::to_ref(**parent).unwrap();
match elem.local_name.as_slice() {
match elem.local_name().as_slice() {
"style" | "script" | "xmp" | "iframe" |
"noembed" | "noframes" | "plaintext" |
"noscript" if elem.namespace == ns!(HTML)
=> html.push_str(text.characterdata.data.borrow().as_slice()),
_ => escape(text.characterdata.data.borrow().as_slice(), false, html)
"noscript" if *elem.namespace() == ns!(HTML)
=> html.push_str(text.characterdata().data().as_slice()),
_ => escape(text.characterdata().data().as_slice(), false, html)
}
}
_ => escape(text.characterdata.data.borrow().as_slice(), false, html)
_ => escape(text.characterdata().data().as_slice(), false, html)
}
}
fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInstruction>,
html: &mut String) {
html.push_str("<?");
html.push_str(processing_instruction.target.as_slice());
html.push_str(processing_instruction.target().as_slice());
html.push_char(' ');
html.push_str(processing_instruction.characterdata.data.borrow().as_slice());
html.push_str(processing_instruction.characterdata().data().as_slice());
html.push_str("?>");
}
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
html.push_str("<!DOCTYPE");
html.push_str(doctype.name.as_slice());
html.push_str(doctype.name().as_slice());
html.push_char('>');
}
fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) {
html.push_char('<');
html.push_str(elem.local_name.as_slice());
for attr in elem.attrs.borrow().iter() {
html.push_str(elem.local_name().as_slice());
for attr in elem.attrs().iter() {
let attr = attr.root();
serialize_attr(*attr, html);
};
html.push_char('>');
match elem.local_name.as_slice() {
"pre" | "listing" | "textarea" if elem.namespace == ns!(HTML) => {
match elem.local_name().as_slice() {
"pre" | "listing" | "textarea" if *elem.namespace() == ns!(HTML) => {
let node: JSRef<Node> = NodeCast::from_ref(elem);
match node.first_child().map(|child| child.root()) {
Some(ref child) if child.is_text() => {
let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
if text.data.borrow().len() > 0 && text.data.borrow().as_slice().char_at(0) == '\n' {
if text.data().len() > 0 && text.data().as_slice().char_at(0) == '\n' {
html.push_char('\x0A');
}
},
@ -131,26 +131,26 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
}
if !(elem.is_void()) {
open_elements.push(elem.local_name.as_slice().to_string());
open_elements.push(elem.local_name().as_slice().to_string());
}
}
fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
html.push_char(' ');
if attr.namespace == ns!(XML) {
if *attr.namespace() == ns!(XML) {
html.push_str("xml:");
html.push_str(attr.local_name().as_slice());
} else if attr.namespace == ns!(XMLNS) &&
} else if *attr.namespace() == ns!(XMLNS) &&
*attr.local_name() == Atom::from_slice("xmlns") {
html.push_str("xmlns");
} else if attr.namespace == ns!(XMLNS) {
} else if *attr.namespace() == ns!(XMLNS) {
html.push_str("xmlns:");
html.push_str(attr.local_name().as_slice());
} else if attr.namespace == ns!(XLink) {
} else if *attr.namespace() == ns!(XLink) {
html.push_str("xlink:");
html.push_str(attr.local_name().as_slice());
} else {
html.push_str(attr.name.as_slice());
html.push_str(attr.name().as_slice());
};
html.push_str("=\"");
escape(attr.value().as_slice(), true, html);

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLSourceElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLSourceElementDerived for EventTarget {
fn is_htmlsourceelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSourceElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLSourceElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLSpanElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLSpanElementDerived for EventTarget {
fn is_htmlspanelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSpanElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLSpanElementTypeId))
}
}

View file

@ -19,13 +19,14 @@ use style::Stylesheet;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLStyleElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLStyleElementDerived for EventTarget {
fn is_htmlstyleelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLStyleElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLStyleElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableCaptionElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLTableCaptionElementDerived for EventTarget {
fn is_htmltablecaptionelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableCaptionElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableCaptionElementTypeId))
}
}

View file

@ -14,13 +14,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableCellElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTableCellElementDerived for EventTarget {
fn is_htmltablecellelement(&self) -> bool {
match self.type_id {
match *self.type_id() {
NodeTargetTypeId(ElementNodeTypeId(HTMLTableDataCellElementTypeId)) |
NodeTargetTypeId(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId)) => true,
_ => false
@ -34,6 +35,11 @@ impl HTMLTableCellElement {
htmlelement: HTMLElement::new_inherited(type_id, tag_name, prefix, document)
}
}
#[inline]
pub fn htmlelement<'a>(&'a self) -> &'a HTMLElement {
&self.htmlelement
}
}
impl Reflectable for HTMLTableCellElement {

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableColElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTableColElementDerived for EventTarget {
fn is_htmltablecolelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableColElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableColElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableDataCellElement {
pub htmltablecellelement: HTMLTableCellElement,
htmltablecellelement: HTMLTableCellElement,
}
impl HTMLTableDataCellElementDerived for EventTarget {
fn is_htmltabledatacellelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableDataCellElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableDataCellElementTypeId))
}
}

View file

@ -19,13 +19,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTableElementDerived for EventTarget {
fn is_htmltableelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableHeaderCellElement {
pub htmltablecellelement: HTMLTableCellElement,
htmltablecellelement: HTMLTableCellElement,
}
impl HTMLTableHeaderCellElementDerived for EventTarget {
fn is_htmltableheadercellelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableRowElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTableRowElementDerived for EventTarget {
fn is_htmltablerowelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableRowElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableRowElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTableSectionElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTableSectionElementDerived for EventTarget {
fn is_htmltablesectionelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableSectionElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableSectionElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTemplateElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTemplateElementDerived for EventTarget {
fn is_htmltemplateelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTemplateElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTemplateElementTypeId))
}
}

View file

@ -20,13 +20,14 @@ use string_cache::Atom;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTextAreaElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTextAreaElementDerived for EventTarget {
fn is_htmltextareaelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTextAreaElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTextAreaElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTimeElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLTimeElementDerived for EventTarget {
fn is_htmltimeelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTimeElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTimeElementTypeId))
}
}

View file

@ -18,13 +18,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTitleElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTitleElementDerived for EventTarget {
fn is_htmltitleelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTitleElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTitleElementTypeId))
}
}
@ -50,7 +51,7 @@ impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
for child in node.children() {
let text: Option<JSRef<Text>> = TextCast::to_ref(child);
match text {
Some(text) => content.push_str(text.characterdata.data.borrow().as_slice()),
Some(text) => content.push_str(text.characterdata().data().as_slice()),
None => (),
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLTrackElement {
pub htmlelement: HTMLElement,
htmlelement: HTMLElement,
}
impl HTMLTrackElementDerived for EventTarget {
fn is_htmltrackelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTrackElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTrackElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLUListElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLUListElementDerived for EventTarget {
fn is_htmlulistelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLUListElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLUListElementTypeId))
}
}

View file

@ -15,13 +15,14 @@ use servo_util::str::DOMString;
#[jstraceable]
#[must_root]
#[privatize]
pub struct HTMLUnknownElement {
pub htmlelement: HTMLElement
htmlelement: HTMLElement
}
impl HTMLUnknownElementDerived for EventTarget {
fn is_htmlunknownelement(&self) -> bool {
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLUnknownElementTypeId))
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLUnknownElementTypeId))
}
}

Some files were not shown because too many files have changed in this diff Show more