mirror of
https://github.com/servo/servo.git
synced 2025-08-05 13:40:08 +01:00
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:
commit
f350879574
131 changed files with 803 additions and 381 deletions
|
@ -78,20 +78,20 @@ pub trait LayoutDataAccess {
|
||||||
impl<'ln> LayoutDataAccess for LayoutNode<'ln> {
|
impl<'ln> LayoutDataAccess for LayoutNode<'ln> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
unsafe fn borrow_layout_data_unchecked(&self) -> *const Option<LayoutDataWrapper> {
|
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)]
|
#[inline(always)]
|
||||||
fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.get().layout_data.borrow())
|
mem::transmute(self.get().layout_data())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.get().layout_data.borrow_mut())
|
mem::transmute(self.get().layout_data_mut())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -116,8 +116,8 @@ pub trait TLayoutNode {
|
||||||
fail!("not an iframe element!")
|
fail!("not an iframe element!")
|
||||||
}
|
}
|
||||||
let iframe_element: JS<HTMLIFrameElement> = self.get_jsmanaged().transmute_copy();
|
let iframe_element: JS<HTMLIFrameElement> = self.get_jsmanaged().transmute_copy();
|
||||||
let size = (*iframe_element.unsafe_get()).size.get().unwrap();
|
let size = (*iframe_element.unsafe_get()).size().unwrap();
|
||||||
(size.pipeline_id, size.subpage_id)
|
(*size.pipeline_id(), *size.subpage_id())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -189,7 +189,7 @@ impl<'ln> TLayoutNode for LayoutNode<'ln> {
|
||||||
unsafe {
|
unsafe {
|
||||||
if self.get().is_text() {
|
if self.get().is_text() {
|
||||||
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
|
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() {
|
} else if self.get().is_htmlinputelement() {
|
||||||
let input: JS<HTMLInputElement> = self.get_jsmanaged().transmute_copy();
|
let input: JS<HTMLInputElement> = self.get_jsmanaged().transmute_copy();
|
||||||
input.get_value_for_layout()
|
input.get_value_for_layout()
|
||||||
|
@ -425,7 +425,7 @@ pub struct LayoutElement<'le> {
|
||||||
impl<'le> LayoutElement<'le> {
|
impl<'le> LayoutElement<'le> {
|
||||||
pub fn style_attribute(&self) -> &'le Option<PropertyDeclarationBlock> {
|
pub fn style_attribute(&self) -> &'le Option<PropertyDeclarationBlock> {
|
||||||
let style: &Option<PropertyDeclarationBlock> = unsafe {
|
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>
|
// cast to the direct reference to T placed on the head of RefCell<T>
|
||||||
mem::transmute(style)
|
mem::transmute(style)
|
||||||
};
|
};
|
||||||
|
@ -436,12 +436,12 @@ impl<'le> LayoutElement<'le> {
|
||||||
impl<'le> TElement<'le> for LayoutElement<'le> {
|
impl<'le> TElement<'le> for LayoutElement<'le> {
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_local_name(self) -> &'le Atom {
|
fn get_local_name(self) -> &'le Atom {
|
||||||
&self.element.local_name
|
self.element.local_name()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn get_namespace(self) -> &'le Namespace {
|
fn get_namespace(self) -> &'le Namespace {
|
||||||
&self.element.namespace
|
self.element.namespace()
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -456,7 +456,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
|
||||||
|
|
||||||
fn get_link(self) -> Option<&'le str> {
|
fn get_link(self) -> Option<&'le str> {
|
||||||
// FIXME: This is HTML only.
|
// 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#
|
// http://www.whatwg.org/specs/web-apps/current-work/multipage/selectors.html#
|
||||||
// selector-link
|
// selector-link
|
||||||
ElementNodeTypeId(HTMLAnchorElementTypeId) |
|
ElementNodeTypeId(HTMLAnchorElementTypeId) |
|
||||||
|
@ -470,7 +470,7 @@ impl<'le> TElement<'le> for LayoutElement<'le> {
|
||||||
|
|
||||||
fn get_hover_state(self) -> bool {
|
fn get_hover_state(self) -> bool {
|
||||||
unsafe {
|
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 {
|
fn get_disabled_state(self) -> bool {
|
||||||
unsafe {
|
unsafe {
|
||||||
self.element.node.get_disabled_state_for_layout()
|
self.element.node().get_disabled_state_for_layout()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_enabled_state(self) -> bool {
|
fn get_enabled_state(self) -> bool {
|
||||||
unsafe {
|
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)]
|
#[inline(always)]
|
||||||
pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
pub fn borrow_layout_data<'a>(&'a self) -> Ref<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
unsafe {
|
||||||
mem::transmute(self.get().layout_data.borrow())
|
mem::transmute(self.get().layout_data())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -729,7 +729,7 @@ impl<'ln> ThreadSafeLayoutNode<'ln> {
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
pub fn mutate_layout_data<'a>(&'a self) -> RefMut<'a,Option<LayoutDataWrapper>> {
|
||||||
unsafe {
|
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) => {
|
Some(TextNodeTypeId) => {
|
||||||
unsafe {
|
unsafe {
|
||||||
let text: JS<Text> = self.get_jsmanaged().transmute_copy();
|
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
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,6 +27,7 @@ mod jstraceable;
|
||||||
pub fn plugin_registrar(reg: &mut Registry) {
|
pub fn plugin_registrar(reg: &mut Registry) {
|
||||||
reg.register_lint_pass(box lints::TransmutePass as LintPassObject);
|
reg.register_lint_pass(box lints::TransmutePass as LintPassObject);
|
||||||
reg.register_lint_pass(box lints::UnrootedPass 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))
|
reg.register_syntax_extension(intern("jstraceable"), Decorator(box jstraceable::expand_jstraceable))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
* 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/. */
|
* 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 syntax::attr::AttrMetaMethods;
|
||||||
use rustc::lint::{Context, LintPass, LintArray};
|
use rustc::lint::{Context, LintPass, LintArray};
|
||||||
use rustc::middle::ty::expr_ty;
|
use rustc::middle::ty::expr_ty;
|
||||||
|
@ -14,9 +15,12 @@ declare_lint!(TRANSMUTE_TYPE_LINT, Allow,
|
||||||
"Warn and report types being transmuted")
|
"Warn and report types being transmuted")
|
||||||
declare_lint!(UNROOTED_MUST_ROOT, Deny,
|
declare_lint!(UNROOTED_MUST_ROOT, Deny,
|
||||||
"Warn and report usage of unrooted jsmanaged objects")
|
"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 TransmutePass;
|
||||||
pub struct UnrootedPass;
|
pub struct UnrootedPass;
|
||||||
|
pub struct PrivatizePass;
|
||||||
|
|
||||||
impl LintPass for TransmutePass {
|
impl LintPass for TransmutePass {
|
||||||
fn get_lints(&self) -> LintArray {
|
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());
|
||||||
|
}
|
||||||
|
_ => {}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -72,13 +72,14 @@ impl Str for AttrValue {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct Attr {
|
pub struct Attr {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
local_name: Atom,
|
local_name: Atom,
|
||||||
value: RefCell<AttrValue>,
|
value: RefCell<AttrValue>,
|
||||||
pub name: Atom,
|
name: Atom,
|
||||||
pub namespace: Namespace,
|
namespace: Namespace,
|
||||||
pub prefix: Option<DOMString>,
|
prefix: Option<DOMString>,
|
||||||
|
|
||||||
/// the element that owns this attribute.
|
/// the element that owns this attribute.
|
||||||
owner: JS<Element>,
|
owner: JS<Element>,
|
||||||
|
@ -111,6 +112,21 @@ impl Attr {
|
||||||
reflect_dom_object(box Attr::new_inherited(local_name, value, name, namespace, prefix, owner),
|
reflect_dom_object(box Attr::new_inherited(local_name, value, name, namespace, prefix, owner),
|
||||||
&global::Window(window), AttrBinding::Wrap)
|
&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> {
|
impl<'a> AttrMethods for JSRef<'a, Attr> {
|
||||||
|
|
|
@ -5452,7 +5452,7 @@ class GlobalGenRoots():
|
||||||
protoDescriptor = config.getDescriptor(protoName)
|
protoDescriptor = config.getDescriptor(protoName)
|
||||||
delegate = string.Template('''impl ${selfName} for ${baseName} {
|
delegate = string.Template('''impl ${selfName} for ${baseName} {
|
||||||
fn ${fname}(&self) -> bool {
|
fn ${fname}(&self) -> bool {
|
||||||
self.${parentName}.${fname}()
|
self.${parentName}().${fname}()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
''').substitute({'fname': 'is_' + name.lower(),
|
''').substitute({'fname': 'is_' + name.lower(),
|
||||||
|
|
|
@ -83,7 +83,7 @@ impl<'a> GlobalRef<'a> {
|
||||||
/// thread.
|
/// thread.
|
||||||
pub fn script_chan<'b>(&'b self) -> &'b ScriptChan {
|
pub fn script_chan<'b>(&'b self) -> &'b ScriptChan {
|
||||||
match *self {
|
match *self {
|
||||||
Window(ref window) => &window.script_chan,
|
Window(ref window) => window.script_chan(),
|
||||||
Worker(ref worker) => worker.script_chan(),
|
Worker(ref worker) => worker.script_chan(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -660,7 +660,7 @@ pub extern fn outerize_global(_cx: *mut JSContext, obj: JSHandleObject) -> *mut
|
||||||
IDLInterface::get_prototype_depth(None::<window::Window>))
|
IDLInterface::get_prototype_depth(None::<window::Window>))
|
||||||
.unwrap()
|
.unwrap()
|
||||||
.root();
|
.root();
|
||||||
win.browser_context.borrow().as_ref().unwrap().window_proxy()
|
win.browser_context().as_ref().unwrap().window_proxy()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,6 +17,7 @@ pub enum BlobType {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct Blob {
|
pub struct Blob {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
type_: BlobType
|
type_: BlobType
|
||||||
|
|
|
@ -15,6 +15,7 @@ use std::ptr;
|
||||||
|
|
||||||
#[allow(raw_pointer_deriving)]
|
#[allow(raw_pointer_deriving)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
|
#[privatize]
|
||||||
pub struct BrowserContext {
|
pub struct BrowserContext {
|
||||||
history: Vec<SessionHistoryEntry>,
|
history: Vec<SessionHistoryEntry>,
|
||||||
active_index: uint,
|
active_index: uint,
|
||||||
|
@ -38,7 +39,7 @@ impl BrowserContext {
|
||||||
|
|
||||||
pub fn active_window(&self) -> Temporary<Window> {
|
pub fn active_window(&self) -> Temporary<Window> {
|
||||||
let doc = self.active_document().root();
|
let doc = self.active_document().root();
|
||||||
Temporary::new(doc.window.clone())
|
Temporary::new(doc.window().clone())
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn window_proxy(&self) -> *mut JSObject {
|
pub fn window_proxy(&self) -> *mut JSObject {
|
||||||
|
@ -66,6 +67,7 @@ impl BrowserContext {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct SessionHistoryEntry {
|
pub struct SessionHistoryEntry {
|
||||||
document: JS<Document>,
|
document: JS<Document>,
|
||||||
children: Vec<BrowserContext>
|
children: Vec<BrowserContext>
|
||||||
|
|
|
@ -17,6 +17,7 @@ use canvas::canvas_render_task::{CanvasMsg, CanvasRenderTask, ClearRect, Close,
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct CanvasRenderingContext2D {
|
pub struct CanvasRenderingContext2D {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
global: GlobalField,
|
global: GlobalField,
|
||||||
|
|
|
@ -14,18 +14,19 @@ use dom::eventtarget::{EventTarget, NodeTargetTypeId};
|
||||||
use dom::node::{CommentNodeTypeId, Node, NodeTypeId, TextNodeTypeId, ProcessingInstructionNodeTypeId, NodeHelpers};
|
use dom::node::{CommentNodeTypeId, Node, NodeTypeId, TextNodeTypeId, ProcessingInstructionNodeTypeId, NodeHelpers};
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
use std::cell::RefCell;
|
use std::cell::{Ref, RefCell};
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct CharacterData {
|
pub struct CharacterData {
|
||||||
pub node: Node,
|
node: Node,
|
||||||
pub data: RefCell<DOMString>,
|
data: RefCell<DOMString>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CharacterDataDerived for EventTarget {
|
impl CharacterDataDerived for EventTarget {
|
||||||
fn is_characterdata(&self) -> bool {
|
fn is_characterdata(&self) -> bool {
|
||||||
match self.type_id {
|
match *self.type_id() {
|
||||||
NodeTargetTypeId(TextNodeTypeId) |
|
NodeTargetTypeId(TextNodeTypeId) |
|
||||||
NodeTargetTypeId(CommentNodeTypeId) |
|
NodeTargetTypeId(CommentNodeTypeId) |
|
||||||
NodeTargetTypeId(ProcessingInstructionNodeTypeId) => true,
|
NodeTargetTypeId(ProcessingInstructionNodeTypeId) => true,
|
||||||
|
@ -41,6 +42,21 @@ impl CharacterData {
|
||||||
data: RefCell::new(data),
|
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> {
|
impl<'a> CharacterDataMethods for JSRef<'a, CharacterData> {
|
||||||
|
|
|
@ -18,13 +18,14 @@ use servo_util::str::DOMString;
|
||||||
/// An HTML comment.
|
/// An HTML comment.
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct Comment {
|
pub struct Comment {
|
||||||
pub characterdata: CharacterData,
|
characterdata: CharacterData,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl CommentDerived for EventTarget {
|
impl CommentDerived for EventTarget {
|
||||||
fn is_comment(&self) -> bool {
|
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();
|
let document = global.as_window().Document().root();
|
||||||
Ok(Comment::new(data, *document))
|
Ok(Comment::new(data, *document))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn characterdata<'a>(&'a self) -> &'a CharacterData {
|
||||||
|
&self.characterdata
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Reflectable for Comment {
|
impl Reflectable for Comment {
|
||||||
|
|
|
@ -11,8 +11,9 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct Console {
|
pub struct Console {
|
||||||
pub reflector_: Reflector
|
reflector_: Reflector
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Console {
|
impl Console {
|
||||||
|
|
|
@ -19,6 +19,7 @@ use std::cell::Cell;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct CustomEvent {
|
pub struct CustomEvent {
|
||||||
event: Event,
|
event: Event,
|
||||||
detail: Cell<JSVal>,
|
detail: Cell<JSVal>,
|
||||||
|
@ -26,7 +27,7 @@ pub struct CustomEvent {
|
||||||
|
|
||||||
impl CustomEventDerived for Event {
|
impl CustomEventDerived for Event {
|
||||||
fn is_customevent(&self) -> bool {
|
fn is_customevent(&self) -> bool {
|
||||||
self.type_id == CustomEventTypeId
|
*self.type_id() == CustomEventTypeId
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -37,6 +37,7 @@ use url::Url;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DedicatedWorkerGlobalScope {
|
pub struct DedicatedWorkerGlobalScope {
|
||||||
workerglobalscope: WorkerGlobalScope,
|
workerglobalscope: WorkerGlobalScope,
|
||||||
receiver: Receiver<ScriptMsg>,
|
receiver: Receiver<ScriptMsg>,
|
||||||
|
@ -192,7 +193,7 @@ impl Reflectable for DedicatedWorkerGlobalScope {
|
||||||
|
|
||||||
impl DedicatedWorkerGlobalScopeDerived for EventTarget {
|
impl DedicatedWorkerGlobalScopeDerived for EventTarget {
|
||||||
fn is_dedicatedworkerglobalscope(&self) -> bool {
|
fn is_dedicatedworkerglobalscope(&self) -> bool {
|
||||||
match self.type_id {
|
match *self.type_id() {
|
||||||
WorkerGlobalScopeTypeId(DedicatedGlobalScope) => true,
|
WorkerGlobalScopeTypeId(DedicatedGlobalScope) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
|
|
@ -62,7 +62,7 @@ use url::Url;
|
||||||
|
|
||||||
use std::collections::hashmap::HashMap;
|
use std::collections::hashmap::HashMap;
|
||||||
use std::ascii::StrAsciiExt;
|
use std::ascii::StrAsciiExt;
|
||||||
use std::cell::{Cell, RefCell};
|
use std::cell::{Cell, Ref, RefCell};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use time;
|
use time;
|
||||||
|
|
||||||
|
@ -75,16 +75,17 @@ pub enum IsHTMLDocument {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct Document {
|
pub struct Document {
|
||||||
pub node: Node,
|
node: Node,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
pub window: JS<Window>,
|
window: JS<Window>,
|
||||||
idmap: RefCell<HashMap<Atom, Vec<JS<Element>>>>,
|
idmap: RefCell<HashMap<Atom, Vec<JS<Element>>>>,
|
||||||
implementation: MutNullableJS<DOMImplementation>,
|
implementation: MutNullableJS<DOMImplementation>,
|
||||||
content_type: DOMString,
|
content_type: DOMString,
|
||||||
last_modified: RefCell<Option<DOMString>>,
|
last_modified: RefCell<Option<DOMString>>,
|
||||||
pub encoding_name: RefCell<DOMString>,
|
encoding_name: RefCell<DOMString>,
|
||||||
pub is_html_document: bool,
|
is_html_document: bool,
|
||||||
url: Url,
|
url: Url,
|
||||||
quirks_mode: Cell<QuirksMode>,
|
quirks_mode: Cell<QuirksMode>,
|
||||||
images: MutNullableJS<HTMLCollection>,
|
images: MutNullableJS<HTMLCollection>,
|
||||||
|
@ -98,7 +99,7 @@ pub struct Document {
|
||||||
|
|
||||||
impl DocumentDerived for EventTarget {
|
impl DocumentDerived for EventTarget {
|
||||||
fn is_document(&self) -> bool {
|
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);
|
node.set_owner_doc(*document);
|
||||||
Temporary::from_rooted(*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 {
|
impl Reflectable for Document {
|
||||||
|
@ -641,7 +657,7 @@ impl<'a> DocumentMethods for JSRef<'a, Document> {
|
||||||
for child in title_elem.children() {
|
for child in title_elem.children() {
|
||||||
if child.is_text() {
|
if child.is_text() {
|
||||||
let text: JSRef<Text> = TextCast::to_ref(child).unwrap();
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
|
@ -20,13 +20,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DocumentFragment {
|
pub struct DocumentFragment {
|
||||||
pub node: Node,
|
node: Node,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentFragmentDerived for EventTarget {
|
impl DocumentFragmentDerived for EventTarget {
|
||||||
fn is_documentfragment(&self) -> bool {
|
fn is_documentfragment(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(DocumentFragmentNodeTypeId)
|
*self.type_id() == NodeTargetTypeId(DocumentFragmentNodeTypeId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,16 +15,17 @@ use servo_util::str::DOMString;
|
||||||
/// The `DOCTYPE` tag.
|
/// The `DOCTYPE` tag.
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DocumentType {
|
pub struct DocumentType {
|
||||||
pub node: Node,
|
node: Node,
|
||||||
pub name: DOMString,
|
name: DOMString,
|
||||||
pub public_id: DOMString,
|
public_id: DOMString,
|
||||||
pub system_id: DOMString,
|
system_id: DOMString,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DocumentTypeDerived for EventTarget {
|
impl DocumentTypeDerived for EventTarget {
|
||||||
fn is_documenttype(&self) -> bool {
|
fn is_documenttype(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(DoctypeNodeTypeId)
|
*self.type_id() == NodeTargetTypeId(DoctypeNodeTypeId)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,6 +54,21 @@ impl DocumentType {
|
||||||
document);
|
document);
|
||||||
Node::reflect_node(box documenttype, document, DocumentTypeBinding::Wrap)
|
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> {
|
impl<'a> DocumentTypeMethods for JSRef<'a, DocumentType> {
|
||||||
|
|
|
@ -62,9 +62,10 @@ impl DOMErrorName {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DOMException {
|
pub struct DOMException {
|
||||||
pub code: DOMErrorName,
|
code: DOMErrorName,
|
||||||
pub reflector_: Reflector
|
reflector_: Reflector
|
||||||
}
|
}
|
||||||
|
|
||||||
impl DOMException {
|
impl DOMException {
|
||||||
|
|
|
@ -24,6 +24,7 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DOMImplementation {
|
pub struct DOMImplementation {
|
||||||
document: JS<Document>,
|
document: JS<Document>,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
@ -38,7 +39,7 @@ impl DOMImplementation {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn new(document: JSRef<Document>) -> Temporary<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),
|
reflect_dom_object(box DOMImplementation::new_inherited(document),
|
||||||
&Window(*window),
|
&Window(*window),
|
||||||
DOMImplementationBinding::Wrap)
|
DOMImplementationBinding::Wrap)
|
||||||
|
@ -72,7 +73,7 @@ impl<'a> DOMImplementationMethods for JSRef<'a, DOMImplementation> {
|
||||||
fn CreateDocument(self, namespace: Option<DOMString>, qname: DOMString,
|
fn CreateDocument(self, namespace: Option<DOMString>, qname: DOMString,
|
||||||
maybe_doctype: Option<JSRef<DocumentType>>) -> Fallible<Temporary<Document>> {
|
maybe_doctype: Option<JSRef<DocumentType>>) -> Fallible<Temporary<Document>> {
|
||||||
let doc = self.document.root();
|
let doc = self.document.root();
|
||||||
let win = doc.window.root();
|
let win = doc.window().root();
|
||||||
|
|
||||||
// Step 1.
|
// Step 1.
|
||||||
let doc = Document::new(*win, None, NonHTMLDocument, None).root();
|
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
|
// http://dom.spec.whatwg.org/#dom-domimplementation-createhtmldocument
|
||||||
fn CreateHTMLDocument(self, title: Option<DOMString>) -> Temporary<Document> {
|
fn CreateHTMLDocument(self, title: Option<DOMString>) -> Temporary<Document> {
|
||||||
let document = self.document.root();
|
let document = self.document.root();
|
||||||
let win = document.window.root();
|
let win = document.window().root();
|
||||||
|
|
||||||
// Step 1-2.
|
// Step 1-2.
|
||||||
let doc = Document::new(*win, None, HTMLDocument, None).root();
|
let doc = Document::new(*win, None, HTMLDocument, None).root();
|
||||||
|
|
|
@ -16,6 +16,7 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DOMParser {
|
pub struct DOMParser {
|
||||||
window: JS<Window>, //XXXjdm Document instead?
|
window: JS<Window>, //XXXjdm Document instead?
|
||||||
reflector_: Reflector
|
reflector_: Reflector
|
||||||
|
|
|
@ -12,6 +12,7 @@ use servo_util::geometry::Au;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DOMRect {
|
pub struct DOMRect {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
top: f32,
|
top: f32,
|
||||||
|
|
|
@ -12,6 +12,7 @@ use dom::window::Window;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DOMRectList {
|
pub struct DOMRectList {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
rects: Vec<JS<DOMRect>>,
|
rects: Vec<JS<DOMRect>>,
|
||||||
|
|
|
@ -17,6 +17,7 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct DOMTokenList {
|
pub struct DOMTokenList {
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
element: JS<Element>,
|
element: JS<Element>,
|
||||||
|
|
|
@ -35,7 +35,7 @@ use servo_util::namespace;
|
||||||
use servo_util::str::DOMString;
|
use servo_util::str::DOMString;
|
||||||
|
|
||||||
use std::ascii::StrAsciiExt;
|
use std::ascii::StrAsciiExt;
|
||||||
use std::cell::RefCell;
|
use std::cell::{Ref, RefMut, RefCell};
|
||||||
use std::default::Default;
|
use std::default::Default;
|
||||||
use std::mem;
|
use std::mem;
|
||||||
use std::slice::Items;
|
use std::slice::Items;
|
||||||
|
@ -44,20 +44,21 @@ use url::UrlParser;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct Element {
|
pub struct Element {
|
||||||
pub node: Node,
|
node: Node,
|
||||||
pub local_name: Atom,
|
local_name: Atom,
|
||||||
pub namespace: Namespace,
|
namespace: Namespace,
|
||||||
pub prefix: Option<DOMString>,
|
prefix: Option<DOMString>,
|
||||||
pub attrs: RefCell<Vec<JS<Attr>>>,
|
attrs: RefCell<Vec<JS<Attr>>>,
|
||||||
pub style_attribute: RefCell<Option<style::PropertyDeclarationBlock>>,
|
style_attribute: RefCell<Option<style::PropertyDeclarationBlock>>,
|
||||||
pub attr_list: MutNullableJS<NamedNodeMap>,
|
attr_list: MutNullableJS<NamedNodeMap>,
|
||||||
class_list: MutNullableJS<DOMTokenList>,
|
class_list: MutNullableJS<DOMTokenList>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ElementDerived for EventTarget {
|
impl ElementDerived for EventTarget {
|
||||||
fn is_element(&self) -> bool {
|
fn is_element(&self) -> bool {
|
||||||
match self.type_id {
|
match *self.type_id() {
|
||||||
NodeTargetTypeId(ElementNodeTypeId(_)) => true,
|
NodeTargetTypeId(ElementNodeTypeId(_)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
}
|
}
|
||||||
|
@ -166,6 +167,41 @@ impl Element {
|
||||||
Node::reflect_node(box Element::new_inherited(ElementTypeId_, local_name, namespace, prefix, document),
|
Node::reflect_node(box Element::new_inherited(ElementTypeId_, local_name, namespace, prefix, document),
|
||||||
document, ElementBinding::Wrap)
|
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 {
|
pub trait RawLayoutElementHelpers {
|
||||||
|
@ -186,7 +222,7 @@ impl RawLayoutElementHelpers for Element {
|
||||||
(*attrs).iter().find(|attr: & &JS<Attr>| {
|
(*attrs).iter().find(|attr: & &JS<Attr>| {
|
||||||
let attr = attr.unsafe_get();
|
let attr = attr.unsafe_get();
|
||||||
name == (*attr).local_name_atom_forever().as_slice() &&
|
name == (*attr).local_name_atom_forever().as_slice() &&
|
||||||
(*attr).namespace == *namespace
|
*(*attr).namespace() == *namespace
|
||||||
}).map(|attr| {
|
}).map(|attr| {
|
||||||
let attr = attr.unsafe_get();
|
let attr = attr.unsafe_get();
|
||||||
(*attr).value_ref_forever()
|
(*attr).value_ref_forever()
|
||||||
|
@ -217,7 +253,7 @@ impl RawLayoutElementHelpers for Element {
|
||||||
(*attrs).iter().find(|attr: & &JS<Attr>| {
|
(*attrs).iter().find(|attr: & &JS<Attr>| {
|
||||||
let attr = attr.unsafe_get();
|
let attr = attr.unsafe_get();
|
||||||
name == (*attr).local_name_atom_forever().as_slice() &&
|
name == (*attr).local_name_atom_forever().as_slice() &&
|
||||||
(*attr).namespace == *namespace
|
*(*attr).namespace() == *namespace
|
||||||
}).and_then(|attr| {
|
}).and_then(|attr| {
|
||||||
let attr = attr.unsafe_get();
|
let attr = attr.unsafe_get();
|
||||||
(*attr).value_atom_forever()
|
(*attr).value_atom_forever()
|
||||||
|
@ -263,7 +299,7 @@ impl LayoutElementHelpers for JS<Element> {
|
||||||
}
|
}
|
||||||
let node: JS<Node> = self.transmute_copy();
|
let node: JS<Node> = self.transmute_copy();
|
||||||
let owner_doc = node.owner_doc_for_layout().unsafe_get();
|
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> {
|
impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
fn get_attribute(self, namespace: Namespace, local_name: &str) -> Option<Temporary<Attr>> {
|
fn get_attribute(self, namespace: Namespace, local_name: &str) -> Option<Temporary<Attr>> {
|
||||||
self.get_attributes(local_name).iter().map(|attr| attr.root())
|
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))
|
.map(|x| Temporary::from_rooted(*x))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -491,7 +527,7 @@ impl<'a> AttributeHandlers for JSRef<'a, Element> {
|
||||||
false => Atom::from_slice(name)
|
false => Atom::from_slice(name)
|
||||||
};
|
};
|
||||||
self.attrs.borrow().iter().map(|attr| attr.root()).any(|attr| {
|
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);
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
node.owner_doc().root()
|
node.owner_doc().root()
|
||||||
};
|
};
|
||||||
let window = doc.window.root();
|
let window = doc.window().root();
|
||||||
let list = NamedNodeMap::new(*window, self);
|
let list = NamedNodeMap::new(*window, self);
|
||||||
self.attr_list.assign(Some(list));
|
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 name = Atom::from_slice(name.as_slice());
|
||||||
let value = self.parse_attribute(&ns!(""), &name, value);
|
let value = self.parse_attribute(&ns!(""), &name, value);
|
||||||
self.do_set_attribute(name.clone(), value, name.clone(), ns!(""), None, |attr| {
|
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(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
@ -748,7 +784,7 @@ impl<'a> ElementMethods for JSRef<'a, Element> {
|
||||||
namespace.clone(), prefix.map(|s| s.to_string()),
|
namespace.clone(), prefix.map(|s| s.to_string()),
|
||||||
|attr| {
|
|attr| {
|
||||||
*attr.local_name() == local_name &&
|
*attr.local_name() == local_name &&
|
||||||
attr.namespace == namespace
|
*attr.namespace() == namespace
|
||||||
});
|
});
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
|
@ -49,21 +49,22 @@ pub enum EventCancelable {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct Event {
|
pub struct Event {
|
||||||
pub type_id: EventTypeId,
|
type_id: EventTypeId,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
pub current_target: MutNullableJS<EventTarget>,
|
current_target: MutNullableJS<EventTarget>,
|
||||||
pub target: MutNullableJS<EventTarget>,
|
target: MutNullableJS<EventTarget>,
|
||||||
type_: RefCell<DOMString>,
|
type_: RefCell<DOMString>,
|
||||||
pub phase: Cell<EventPhase>,
|
phase: Cell<EventPhase>,
|
||||||
pub canceled: Cell<bool>,
|
canceled: Cell<bool>,
|
||||||
pub stop_propagation: Cell<bool>,
|
stop_propagation: Cell<bool>,
|
||||||
pub stop_immediate: Cell<bool>,
|
stop_immediate: Cell<bool>,
|
||||||
pub cancelable: Cell<bool>,
|
cancelable: Cell<bool>,
|
||||||
pub bubbles: Cell<bool>,
|
bubbles: Cell<bool>,
|
||||||
pub trusted: Cell<bool>,
|
trusted: Cell<bool>,
|
||||||
pub dispatching: Cell<bool>,
|
dispatching: Cell<bool>,
|
||||||
pub initialized: Cell<bool>,
|
initialized: Cell<bool>,
|
||||||
timestamp: u64,
|
timestamp: u64,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,6 +111,61 @@ impl Event {
|
||||||
let cancelable = if init.cancelable { Cancelable } else { NotCancelable };
|
let cancelable = if init.cancelable { Cancelable } else { NotCancelable };
|
||||||
Ok(Event::new(global, type_, bubbles, cancelable))
|
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> {
|
impl<'a> EventMethods for JSRef<'a, Event> {
|
||||||
|
|
|
@ -5,7 +5,7 @@
|
||||||
use dom::bindings::callback::ReportExceptions;
|
use dom::bindings::callback::ReportExceptions;
|
||||||
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
use dom::bindings::codegen::Bindings::EventBinding::EventMethods;
|
||||||
use dom::bindings::codegen::InheritTypes::{EventTargetCast, NodeCast, NodeDerived};
|
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::eventtarget::{Capturing, Bubbling, EventTarget};
|
||||||
use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing};
|
use dom::event::{Event, PhaseAtTarget, PhaseNone, PhaseBubbling, PhaseCapturing};
|
||||||
use dom::node::{Node, NodeHelpers};
|
use dom::node::{Node, NodeHelpers};
|
||||||
|
@ -15,13 +15,13 @@ use dom::virtualmethods::vtable_for;
|
||||||
pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
|
pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
|
||||||
pseudo_target: Option<JSRef<'b, EventTarget>>,
|
pseudo_target: Option<JSRef<'b, EventTarget>>,
|
||||||
event: JSRef<Event>) -> bool {
|
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,
|
Some(pseudo_target) => pseudo_target,
|
||||||
None => target.clone(),
|
None => target.clone(),
|
||||||
}));
|
});
|
||||||
event.dispatching.set(true);
|
event.set_dispatching(true);
|
||||||
|
|
||||||
let type_ = event.Type();
|
let type_ = event.Type();
|
||||||
|
|
||||||
|
@ -36,7 +36,7 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
|
||||||
vec!()
|
vec!()
|
||||||
};
|
};
|
||||||
|
|
||||||
event.phase.set(PhaseCapturing);
|
event.set_phase(PhaseCapturing);
|
||||||
|
|
||||||
//FIXME: The "callback this value" should be currentTarget
|
//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() {
|
for cur_target in chain.as_slice().iter().rev() {
|
||||||
let stopped = match cur_target.get_listeners_for(type_.as_slice(), Capturing) {
|
let stopped = match cur_target.get_listeners_for(type_.as_slice(), Capturing) {
|
||||||
Some(listeners) => {
|
Some(listeners) => {
|
||||||
event.current_target.assign(Some(cur_target.deref().clone()));
|
event.set_current_target(cur_target.deref().clone());
|
||||||
for listener in listeners.iter() {
|
for listener in listeners.iter() {
|
||||||
// Explicitly drop any exception on the floor.
|
// Explicitly drop any exception on the floor.
|
||||||
let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
|
let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
|
||||||
|
|
||||||
if event.stop_immediate.get() {
|
if event.stop_immediate() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.stop_propagation.get()
|
event.stop_propagation()
|
||||||
}
|
}
|
||||||
None => false
|
None => false
|
||||||
};
|
};
|
||||||
|
@ -65,9 +65,9 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* at target */
|
/* at target */
|
||||||
if !event.stop_propagation.get() {
|
if !event.stop_propagation() {
|
||||||
event.phase.set(PhaseAtTarget);
|
event.set_phase(PhaseAtTarget);
|
||||||
event.current_target.assign(Some(target.clone()));
|
event.set_current_target(target.clone());
|
||||||
|
|
||||||
let opt_listeners = target.get_listeners(type_.as_slice());
|
let opt_listeners = target.get_listeners(type_.as_slice());
|
||||||
for listeners in opt_listeners.iter() {
|
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.
|
// Explicitly drop any exception on the floor.
|
||||||
let _ = listener.HandleEvent_(target, event, ReportExceptions);
|
let _ = listener.HandleEvent_(target, event, ReportExceptions);
|
||||||
|
|
||||||
if event.stop_immediate.get() {
|
if event.stop_immediate() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -83,23 +83,23 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* bubbling */
|
/* bubbling */
|
||||||
if event.bubbles.get() && !event.stop_propagation.get() {
|
if event.bubbles() && !event.stop_propagation() {
|
||||||
event.phase.set(PhaseBubbling);
|
event.set_phase(PhaseBubbling);
|
||||||
|
|
||||||
for cur_target in chain.iter() {
|
for cur_target in chain.iter() {
|
||||||
let stopped = match cur_target.get_listeners_for(type_.as_slice(), Bubbling) {
|
let stopped = match cur_target.get_listeners_for(type_.as_slice(), Bubbling) {
|
||||||
Some(listeners) => {
|
Some(listeners) => {
|
||||||
event.current_target.assign(Some(cur_target.deref().clone()));
|
event.set_current_target(cur_target.deref().clone());
|
||||||
for listener in listeners.iter() {
|
for listener in listeners.iter() {
|
||||||
// Explicitly drop any exception on the floor.
|
// Explicitly drop any exception on the floor.
|
||||||
let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
|
let _ = listener.HandleEvent_(**cur_target, event, ReportExceptions);
|
||||||
|
|
||||||
if event.stop_immediate.get() {
|
if event.stop_immediate() {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
event.stop_propagation.get()
|
event.stop_propagation()
|
||||||
}
|
}
|
||||||
None => false
|
None => false
|
||||||
};
|
};
|
||||||
|
@ -131,9 +131,9 @@ pub fn dispatch_event<'a, 'b>(target: JSRef<'a, EventTarget>,
|
||||||
let _ = chain.pop();
|
let _ = chain.pop();
|
||||||
}
|
}
|
||||||
|
|
||||||
event.dispatching.set(false);
|
event.set_dispatching(false);
|
||||||
event.phase.set(PhaseNone);
|
event.set_phase(PhaseNone);
|
||||||
event.current_target.clear();
|
event.clear_current_target();
|
||||||
|
|
||||||
!event.DefaultPrevented()
|
!event.DefaultPrevented()
|
||||||
}
|
}
|
||||||
|
|
|
@ -59,15 +59,17 @@ impl EventListenerType {
|
||||||
|
|
||||||
#[deriving(PartialEq)]
|
#[deriving(PartialEq)]
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
|
#[privatize]
|
||||||
pub struct EventListenerEntry {
|
pub struct EventListenerEntry {
|
||||||
pub phase: ListenerPhase,
|
phase: ListenerPhase,
|
||||||
pub listener: EventListenerType
|
listener: EventListenerType
|
||||||
}
|
}
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct EventTarget {
|
pub struct EventTarget {
|
||||||
pub type_id: EventTargetTypeId,
|
type_id: EventTargetTypeId,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
handlers: RefCell<HashMap<DOMString, Vec<EventListenerEntry>>>,
|
handlers: RefCell<HashMap<DOMString, Vec<EventListenerEntry>>>,
|
||||||
}
|
}
|
||||||
|
@ -94,6 +96,11 @@ impl EventTarget {
|
||||||
filtered.map(|entry| entry.listener.get_listener()).collect()
|
filtered.map(|entry| entry.listener.get_listener()).collect()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn type_id<'a>(&'a self) -> &'a EventTargetTypeId {
|
||||||
|
&self.type_id
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub trait EventTargetHelpers {
|
pub trait EventTargetHelpers {
|
||||||
|
@ -121,7 +128,7 @@ impl<'a> EventTargetHelpers for JSRef<'a, EventTarget> {
|
||||||
fn dispatch_event_with_target(self,
|
fn dispatch_event_with_target(self,
|
||||||
target: Option<JSRef<EventTarget>>,
|
target: Option<JSRef<EventTarget>>,
|
||||||
event: JSRef<Event>) -> Fallible<bool> {
|
event: JSRef<Event>) -> Fallible<bool> {
|
||||||
if event.dispatching.get() || !event.initialized.get() {
|
if event.dispatching() || !event.initialized() {
|
||||||
return Err(InvalidState);
|
return Err(InvalidState);
|
||||||
}
|
}
|
||||||
Ok(dispatch_event(self, target, event))
|
Ok(dispatch_event(self, target, event))
|
||||||
|
|
|
@ -12,10 +12,11 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct File {
|
pub struct File {
|
||||||
pub blob: Blob,
|
blob: Blob,
|
||||||
pub name: DOMString,
|
name: DOMString,
|
||||||
pub type_: BlobType
|
type_: BlobType
|
||||||
}
|
}
|
||||||
|
|
||||||
impl File {
|
impl File {
|
||||||
|
@ -34,6 +35,10 @@ impl File {
|
||||||
global,
|
global,
|
||||||
FileBinding::Wrap)
|
FileBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn name<'a>(&'a self) -> &'a DOMString {
|
||||||
|
&self.name
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> FileMethods for JSRef<'a, File> {
|
impl<'a> FileMethods for JSRef<'a, File> {
|
||||||
|
|
|
@ -27,6 +27,7 @@ pub enum FormDatum {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct FormData {
|
pub struct FormData {
|
||||||
data: RefCell<HashMap<DOMString, Vec<FormDatum>>>,
|
data: RefCell<HashMap<DOMString, Vec<FormDatum>>>,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
@ -112,7 +113,7 @@ impl PrivateFormDataHelpers for FormData {
|
||||||
fn get_file_from_blob(&self, value: JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> {
|
fn get_file_from_blob(&self, value: JSRef<Blob>, filename: Option<DOMString>) -> Temporary<File> {
|
||||||
let global = self.global.root();
|
let global = self.global.root();
|
||||||
let f: Option<JSRef<File>> = FileCast::to_ref(value);
|
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)
|
File::new(&global.root_ref(), value, name)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,13 +23,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLAnchorElement {
|
pub struct HTMLAnchorElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLAnchorElementDerived for EventTarget {
|
impl HTMLAnchorElementDerived for EventTarget {
|
||||||
fn is_htmlanchorelement(&self) -> bool {
|
fn is_htmlanchorelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAnchorElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAnchorElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLAppletElement {
|
pub struct HTMLAppletElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLAppletElementDerived for EventTarget {
|
impl HTMLAppletElementDerived for EventTarget {
|
||||||
fn is_htmlappletelement(&self) -> bool {
|
fn is_htmlappletelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAppletElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAppletElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -16,13 +16,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLAreaElement {
|
pub struct HTMLAreaElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLAreaElementDerived for EventTarget {
|
impl HTMLAreaElementDerived for EventTarget {
|
||||||
fn is_htmlareaelement(&self) -> bool {
|
fn is_htmlareaelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAreaElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAreaElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLAudioElement {
|
pub struct HTMLAudioElement {
|
||||||
pub htmlmediaelement: HTMLMediaElement
|
htmlmediaelement: HTMLMediaElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLAudioElementDerived for EventTarget {
|
impl HTMLAudioElementDerived for EventTarget {
|
||||||
fn is_htmlaudioelement(&self) -> bool {
|
fn is_htmlaudioelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLAudioElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLAudioElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLBaseElement {
|
pub struct HTMLBaseElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLBaseElementDerived for EventTarget {
|
impl HTMLBaseElementDerived for EventTarget {
|
||||||
fn is_htmlbaseelement(&self) -> bool {
|
fn is_htmlbaseelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBaseElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLBaseElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLBodyElement {
|
pub struct HTMLBodyElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLBodyElementDerived for EventTarget {
|
impl HTMLBodyElementDerived for EventTarget {
|
||||||
fn is_htmlbodyelement(&self) -> bool {
|
fn is_htmlbodyelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBodyElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLBodyElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLBRElement {
|
pub struct HTMLBRElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLBRElementDerived for EventTarget {
|
impl HTMLBRElementDerived for EventTarget {
|
||||||
fn is_htmlbrelement(&self) -> bool {
|
fn is_htmlbrelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLBRElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLBRElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLButtonElement {
|
pub struct HTMLButtonElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLButtonElementDerived for EventTarget {
|
impl HTMLButtonElementDerived for EventTarget {
|
||||||
fn is_htmlbuttonelement(&self) -> bool {
|
fn is_htmlbuttonelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLButtonElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLButtonElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -30,8 +30,9 @@ static DefaultHeight: u32 = 150;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLCanvasElement {
|
pub struct HTMLCanvasElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
context: MutNullableJS<CanvasRenderingContext2D>,
|
context: MutNullableJS<CanvasRenderingContext2D>,
|
||||||
width: Cell<u32>,
|
width: Cell<u32>,
|
||||||
height: Cell<u32>,
|
height: Cell<u32>,
|
||||||
|
@ -39,7 +40,7 @@ pub struct HTMLCanvasElement {
|
||||||
|
|
||||||
impl HTMLCanvasElementDerived for EventTarget {
|
impl HTMLCanvasElementDerived for EventTarget {
|
||||||
fn is_htmlcanvaselement(&self) -> bool {
|
fn is_htmlcanvaselement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLCanvasElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLCanvasElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ pub enum CollectionTypeId {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLCollection {
|
pub struct HTMLCollection {
|
||||||
collection: CollectionTypeId,
|
collection: CollectionTypeId,
|
||||||
reflector_: Reflector,
|
reflector_: Reflector,
|
||||||
|
@ -66,7 +67,7 @@ impl HTMLCollection {
|
||||||
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
|
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
|
||||||
match self.namespace_filter {
|
match self.namespace_filter {
|
||||||
None => true,
|
None => true,
|
||||||
Some(ref namespace) => elem.namespace == *namespace
|
Some(ref namespace) => *elem.namespace() == *namespace
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -88,9 +89,9 @@ impl HTMLCollection {
|
||||||
impl CollectionFilter for TagNameFilter {
|
impl CollectionFilter for TagNameFilter {
|
||||||
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
|
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
|
||||||
if elem.html_element_in_html_document() {
|
if elem.html_element_in_html_document() {
|
||||||
elem.local_name == self.ascii_lower_tag
|
*elem.local_name() == self.ascii_lower_tag
|
||||||
} else {
|
} 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 {
|
fn filter(&self, elem: JSRef<Element>, _root: JSRef<Node>) -> bool {
|
||||||
let ns_match = match self.namespace_filter {
|
let ns_match = match self.namespace_filter {
|
||||||
Some(ref namespace) => {
|
Some(ref namespace) => {
|
||||||
elem.namespace == *namespace
|
*elem.namespace() == *namespace
|
||||||
},
|
},
|
||||||
None => true
|
None => true
|
||||||
};
|
};
|
||||||
ns_match && elem.local_name == self.tag
|
ns_match && *elem.local_name() == self.tag
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
let filter = TagNameNSFilter {
|
let filter = TagNameNSFilter {
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLDataElement {
|
pub struct HTMLDataElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLDataElementDerived for EventTarget {
|
impl HTMLDataElementDerived for EventTarget {
|
||||||
fn is_htmldataelement(&self) -> bool {
|
fn is_htmldataelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDataElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDataElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLDataListElement {
|
pub struct HTMLDataListElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLDataListElementDerived for EventTarget {
|
impl HTMLDataListElementDerived for EventTarget {
|
||||||
fn is_htmldatalistelement(&self) -> bool {
|
fn is_htmldatalistelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDataListElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDataListElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLDirectoryElement {
|
pub struct HTMLDirectoryElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLDirectoryElementDerived for EventTarget {
|
impl HTMLDirectoryElementDerived for EventTarget {
|
||||||
fn is_htmldirectoryelement(&self) -> bool {
|
fn is_htmldirectoryelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDirectoryElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDirectoryElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLDivElement {
|
pub struct HTMLDivElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLDivElementDerived for EventTarget {
|
impl HTMLDivElementDerived for EventTarget {
|
||||||
fn is_htmldivelement(&self) -> bool {
|
fn is_htmldivelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDivElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDivElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLDListElement {
|
pub struct HTMLDListElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLDListElementDerived for EventTarget {
|
impl HTMLDListElementDerived for EventTarget {
|
||||||
fn is_htmldlistelement(&self) -> bool {
|
fn is_htmldlistelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLDListElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLDListElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,13 +22,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLElement {
|
pub struct HTMLElement {
|
||||||
pub element: Element
|
element: Element
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLElementDerived for EventTarget {
|
impl HTMLElementDerived for EventTarget {
|
||||||
fn is_htmlelement(&self) -> bool {
|
fn is_htmlelement(&self) -> bool {
|
||||||
match self.type_id {
|
match *self.type_id() {
|
||||||
NodeTargetTypeId(ElementNodeTypeId(ElementTypeId_)) => false,
|
NodeTargetTypeId(ElementNodeTypeId(ElementTypeId_)) => false,
|
||||||
NodeTargetTypeId(ElementNodeTypeId(_)) => true,
|
NodeTargetTypeId(ElementNodeTypeId(_)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -48,6 +49,11 @@ impl HTMLElement {
|
||||||
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, prefix, document);
|
let element = HTMLElement::new_inherited(HTMLElementTypeId, localName, prefix, document);
|
||||||
Node::reflect_node(box element, document, HTMLElementBinding::Wrap)
|
Node::reflect_node(box element, document, HTMLElementBinding::Wrap)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
pub fn element<'a>(&'a self) -> &'a Element {
|
||||||
|
&self.element
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
trait PrivateHTMLElementHelpers {
|
trait PrivateHTMLElementHelpers {
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLEmbedElement {
|
pub struct HTMLEmbedElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLEmbedElementDerived for EventTarget {
|
impl HTMLEmbedElementDerived for EventTarget {
|
||||||
fn is_htmlembedelement(&self) -> bool {
|
fn is_htmlembedelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLEmbedElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLEmbedElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLFieldSetElement {
|
pub struct HTMLFieldSetElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLFieldSetElementDerived for EventTarget {
|
impl HTMLFieldSetElementDerived for EventTarget {
|
||||||
fn is_htmlfieldsetelement(&self) -> bool {
|
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",
|
static tag_names: StaticStringVec = &["button", "fieldset", "input",
|
||||||
"keygen", "object", "output", "select", "textarea"];
|
"keygen", "object", "output", "select", "textarea"];
|
||||||
let root: JSRef<Element> = ElementCast::to_ref(root).unwrap();
|
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);
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLFontElement {
|
pub struct HTMLFontElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLFontElementDerived for EventTarget {
|
impl HTMLFontElementDerived for EventTarget {
|
||||||
fn is_htmlfontelement(&self) -> bool {
|
fn is_htmlfontelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFontElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFontElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -31,13 +31,14 @@ use url::form_urlencoded::serialize;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLFormElement {
|
pub struct HTMLFormElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLFormElementDerived for EventTarget {
|
impl HTMLFormElementDerived for EventTarget {
|
||||||
fn is_htmlformelement(&self) -> bool {
|
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
|
// This is wrong. https://html.spec.whatwg.org/multipage/forms.html#planned-navigation
|
||||||
let ScriptChan(ref script_chan) = win.script_chan;
|
let ScriptChan(ref script_chan) = *win.script_chan();
|
||||||
script_chan.send(TriggerLoadMsg(win.page.id, load_data));
|
script_chan.send(TriggerLoadMsg(win.page().id, load_data));
|
||||||
}
|
}
|
||||||
|
|
||||||
fn get_form_dataset(self, _submitter: Option<FormSubmitter>) -> Vec<FormDatum> {
|
fn get_form_dataset(self, _submitter: Option<FormSubmitter>) -> Vec<FormDatum> {
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLFrameElement {
|
pub struct HTMLFrameElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLFrameElementDerived for EventTarget {
|
impl HTMLFrameElementDerived for EventTarget {
|
||||||
fn is_htmlframeelement(&self) -> bool {
|
fn is_htmlframeelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLFrameSetElement {
|
pub struct HTMLFrameSetElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLFrameSetElementDerived for EventTarget {
|
impl HTMLFrameSetElementDerived for EventTarget {
|
||||||
fn is_htmlframesetelement(&self) -> bool {
|
fn is_htmlframesetelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameSetElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLFrameSetElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLHeadElement {
|
pub struct HTMLHeadElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLHeadElementDerived for EventTarget {
|
impl HTMLHeadElementDerived for EventTarget {
|
||||||
fn is_htmlheadelement(&self) -> bool {
|
fn is_htmlheadelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -25,14 +25,15 @@ pub enum HeadingLevel {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLHeadingElement {
|
pub struct HTMLHeadingElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
pub level: HeadingLevel,
|
level: HeadingLevel,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLHeadingElementDerived for EventTarget {
|
impl HTMLHeadingElementDerived for EventTarget {
|
||||||
fn is_htmlheadingelement(&self) -> bool {
|
fn is_htmlheadingelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadingElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHeadingElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLHRElement {
|
pub struct HTMLHRElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLHRElementDerived for EventTarget {
|
impl HTMLHRElementDerived for EventTarget {
|
||||||
fn is_htmlhrelement(&self) -> bool {
|
fn is_htmlhrelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHRElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHRElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLHtmlElement {
|
pub struct HTMLHtmlElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLHtmlElementDerived for EventTarget {
|
impl HTMLHtmlElementDerived for EventTarget {
|
||||||
fn is_htmlhtmlelement(&self) -> bool {
|
fn is_htmlhtmlelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLHtmlElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLHtmlElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -41,22 +41,36 @@ enum SandboxAllowance {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLIFrameElement {
|
pub struct HTMLIFrameElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
pub size: Cell<Option<IFrameSize>>,
|
size: Cell<Option<IFrameSize>>,
|
||||||
pub sandbox: Cell<Option<u8>>,
|
sandbox: Cell<Option<u8>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLIFrameElementDerived for EventTarget {
|
impl HTMLIFrameElementDerived for EventTarget {
|
||||||
fn is_htmliframeelement(&self) -> bool {
|
fn is_htmliframeelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLIFrameElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLIFrameElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
|
#[privatize]
|
||||||
pub struct IFrameSize {
|
pub struct IFrameSize {
|
||||||
pub pipeline_id: PipelineId,
|
pipeline_id: PipelineId,
|
||||||
pub subpage_id: SubpageId,
|
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 {
|
pub trait HTMLIFrameElementHelpers {
|
||||||
|
@ -126,6 +140,11 @@ impl HTMLIFrameElement {
|
||||||
let element = HTMLIFrameElement::new_inherited(localName, prefix, document);
|
let element = HTMLIFrameElement::new_inherited(localName, prefix, document);
|
||||||
Node::reflect_node(box element, document, HTMLIFrameElementBinding::Wrap)
|
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> {
|
impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
|
@ -152,7 +171,7 @@ impl<'a> HTMLIFrameElementMethods for JSRef<'a, HTMLIFrameElement> {
|
||||||
fn GetContentWindow(self) -> Option<Temporary<Window>> {
|
fn GetContentWindow(self) -> Option<Temporary<Window>> {
|
||||||
self.size.get().and_then(|size| {
|
self.size.get().and_then(|size| {
|
||||||
let window = window_from_node(self).root();
|
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| {
|
let child = children.iter().find(|child| {
|
||||||
child.subpage_id.unwrap() == size.subpage_id
|
child.subpage_id.unwrap() == size.subpage_id
|
||||||
});
|
});
|
||||||
|
|
|
@ -26,14 +26,15 @@ use std::cell::RefCell;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLImageElement {
|
pub struct HTMLImageElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
image: RefCell<Option<Url>>,
|
image: RefCell<Option<Url>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLImageElementDerived for EventTarget {
|
impl HTMLImageElementDerived for EventTarget {
|
||||||
fn is_htmlimageelement(&self) -> bool {
|
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)>) {
|
fn update_image(self, value: Option<(DOMString, &Url)>) {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(self);
|
let node: JSRef<Node> = NodeCast::from_ref(self);
|
||||||
let document = node.owner_doc().root();
|
let document = node.owner_doc().root();
|
||||||
let window = document.window.root();
|
let window = document.window().root();
|
||||||
let image_cache = &window.image_cache_task;
|
let image_cache = window.image_cache_task();
|
||||||
match value {
|
match value {
|
||||||
None => {
|
None => {
|
||||||
*self.image.borrow_mut() = None;
|
*self.image.borrow_mut() = None;
|
||||||
|
|
|
@ -45,8 +45,9 @@ enum InputType {
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLInputElement {
|
pub struct HTMLInputElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
input_type: Cell<InputType>,
|
input_type: Cell<InputType>,
|
||||||
checked: Cell<bool>,
|
checked: Cell<bool>,
|
||||||
uncommitted_value: RefCell<Option<String>>,
|
uncommitted_value: RefCell<Option<String>>,
|
||||||
|
@ -56,7 +57,7 @@ pub struct HTMLInputElement {
|
||||||
|
|
||||||
impl HTMLInputElementDerived for EventTarget {
|
impl HTMLInputElementDerived for EventTarget {
|
||||||
fn is_htmlinputelement(&self) -> bool {
|
fn is_htmlinputelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLInputElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLInputElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLLabelElement {
|
pub struct HTMLLabelElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLLabelElementDerived for EventTarget {
|
impl HTMLLabelElementDerived for EventTarget {
|
||||||
fn is_htmllabelelement(&self) -> bool {
|
fn is_htmllabelelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLabelElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLabelElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLLegendElement {
|
pub struct HTMLLegendElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLLegendElementDerived for EventTarget {
|
impl HTMLLegendElementDerived for EventTarget {
|
||||||
fn is_htmllegendelement(&self) -> bool {
|
fn is_htmllegendelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLegendElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLegendElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLLIElement {
|
pub struct HTMLLIElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLLIElementDerived for EventTarget {
|
impl HTMLLIElementDerived for EventTarget {
|
||||||
fn is_htmllielement(&self) -> bool {
|
fn is_htmllielement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLIElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLIElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLLinkElement {
|
pub struct HTMLLinkElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLLinkElementDerived for EventTarget {
|
impl HTMLLinkElementDerived for EventTarget {
|
||||||
fn is_htmllinkelement(&self) -> bool {
|
fn is_htmllinkelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLLinkElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLLinkElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLMapElement {
|
pub struct HTMLMapElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLMapElementDerived for EventTarget {
|
impl HTMLMapElementDerived for EventTarget {
|
||||||
fn is_htmlmapelement(&self) -> bool {
|
fn is_htmlmapelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLMapElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLMapElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLMediaElement {
|
pub struct HTMLMediaElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLMediaElementDerived for EventTarget {
|
impl HTMLMediaElementDerived for EventTarget {
|
||||||
fn is_htmlmediaelement(&self) -> bool {
|
fn is_htmlmediaelement(&self) -> bool {
|
||||||
match self.type_id {
|
match *self.type_id() {
|
||||||
NodeTargetTypeId(ElementNodeTypeId(HTMLVideoElementTypeId)) |
|
NodeTargetTypeId(ElementNodeTypeId(HTMLVideoElementTypeId)) |
|
||||||
NodeTargetTypeId(ElementNodeTypeId(HTMLAudioElementTypeId)) => true,
|
NodeTargetTypeId(ElementNodeTypeId(HTMLAudioElementTypeId)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -34,6 +35,11 @@ impl HTMLMediaElement {
|
||||||
htmlelement: HTMLElement::new_inherited(type_id, tag_name, prefix, document)
|
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 {
|
impl Reflectable for HTMLMediaElement {
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLMetaElement {
|
pub struct HTMLMetaElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLMetaElementDerived for EventTarget {
|
impl HTMLMetaElementDerived for EventTarget {
|
||||||
fn is_htmlmetaelement(&self) -> bool {
|
fn is_htmlmetaelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLMetaElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLMetaElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLMeterElement {
|
pub struct HTMLMeterElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLMeterElementDerived for EventTarget {
|
impl HTMLMeterElementDerived for EventTarget {
|
||||||
fn is_htmlmeterelement(&self) -> bool {
|
fn is_htmlmeterelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLMeterElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLMeterElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLModElement {
|
pub struct HTMLModElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLModElementDerived for EventTarget {
|
impl HTMLModElementDerived for EventTarget {
|
||||||
fn is_htmlmodelement(&self) -> bool {
|
fn is_htmlmodelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLModElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLModElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -27,13 +27,14 @@ use url::Url;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLObjectElement {
|
pub struct HTMLObjectElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLObjectElementDerived for EventTarget {
|
impl HTMLObjectElementDerived for EventTarget {
|
||||||
fn is_htmlobjectelement(&self) -> bool {
|
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() {
|
if "data" == name.as_slice() {
|
||||||
let window = window_from_node(*self).root();
|
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLOListElement {
|
pub struct HTMLOListElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLOListElementDerived for EventTarget {
|
impl HTMLOListElementDerived for EventTarget {
|
||||||
fn is_htmlolistelement(&self) -> bool {
|
fn is_htmlolistelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOListElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLOListElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLOptGroupElement {
|
pub struct HTMLOptGroupElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLOptGroupElementDerived for EventTarget {
|
impl HTMLOptGroupElementDerived for EventTarget {
|
||||||
fn is_htmloptgroupelement(&self) -> bool {
|
fn is_htmloptgroupelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOptGroupElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLOptGroupElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,13 +24,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLOptionElement {
|
pub struct HTMLOptionElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLOptionElementDerived for EventTarget {
|
impl HTMLOptionElementDerived for EventTarget {
|
||||||
fn is_htmloptionelement(&self) -> bool {
|
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) {
|
fn collect_text(node: &JSRef<Node>, value: &mut DOMString) {
|
||||||
let elem: JSRef<Element> = ElementCast::to_ref(*node).unwrap();
|
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();
|
let html_script = node.is_htmlscriptelement();
|
||||||
if svg_script || html_script {
|
if svg_script || html_script {
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -17,13 +17,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLOutputElement {
|
pub struct HTMLOutputElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLOutputElementDerived for EventTarget {
|
impl HTMLOutputElementDerived for EventTarget {
|
||||||
fn is_htmloutputelement(&self) -> bool {
|
fn is_htmloutputelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLOutputElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLOutputElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLParagraphElement {
|
pub struct HTMLParagraphElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLParagraphElementDerived for EventTarget {
|
impl HTMLParagraphElementDerived for EventTarget {
|
||||||
fn is_htmlparagraphelement(&self) -> bool {
|
fn is_htmlparagraphelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLParagraphElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLParagraphElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLParamElement {
|
pub struct HTMLParamElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLParamElementDerived for EventTarget {
|
impl HTMLParamElementDerived for EventTarget {
|
||||||
fn is_htmlparamelement(&self) -> bool {
|
fn is_htmlparamelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLParamElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLParamElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLPreElement {
|
pub struct HTMLPreElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLPreElementDerived for EventTarget {
|
impl HTMLPreElementDerived for EventTarget {
|
||||||
fn is_htmlpreelement(&self) -> bool {
|
fn is_htmlpreelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLPreElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLPreElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLProgressElement {
|
pub struct HTMLProgressElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLProgressElementDerived for EventTarget {
|
impl HTMLProgressElementDerived for EventTarget {
|
||||||
fn is_htmlprogresselement(&self) -> bool {
|
fn is_htmlprogresselement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLProgressElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLProgressElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLQuoteElement {
|
pub struct HTMLQuoteElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLQuoteElementDerived for EventTarget {
|
impl HTMLQuoteElementDerived for EventTarget {
|
||||||
fn is_htmlquoteelement(&self) -> bool {
|
fn is_htmlquoteelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLQuoteElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLQuoteElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,14 @@ use servo_util::str::{DOMString, HTML_SPACE_CHARACTERS, StaticStringVec};
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLScriptElement {
|
pub struct HTMLScriptElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLScriptElementDerived for EventTarget {
|
impl HTMLScriptElementDerived for EventTarget {
|
||||||
fn is_htmlscriptelement(&self) -> bool {
|
fn is_htmlscriptelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLScriptElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLScriptElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -23,13 +23,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLSelectElement {
|
pub struct HTMLSelectElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLSelectElementDerived for EventTarget {
|
impl HTMLSelectElementDerived for EventTarget {
|
||||||
fn is_htmlselectelement(&self) -> bool {
|
fn is_htmlselectelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSelectElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLSelectElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ pub fn serialize(iterator: &mut NodeIterator) -> String {
|
||||||
|
|
||||||
fn serialize_comment(comment: JSRef<Comment>, html: &mut String) {
|
fn serialize_comment(comment: JSRef<Comment>, html: &mut String) {
|
||||||
html.push_str("<!--");
|
html.push_str("<!--");
|
||||||
html.push_str(comment.characterdata.data.borrow().as_slice());
|
html.push_str(comment.characterdata().data().as_slice());
|
||||||
html.push_str("-->");
|
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()) {
|
match text_node.parent_node().map(|node| node.root()) {
|
||||||
Some(ref parent) if parent.is_element() => {
|
Some(ref parent) if parent.is_element() => {
|
||||||
let elem: JSRef<Element> = ElementCast::to_ref(**parent).unwrap();
|
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" |
|
"style" | "script" | "xmp" | "iframe" |
|
||||||
"noembed" | "noframes" | "plaintext" |
|
"noembed" | "noframes" | "plaintext" |
|
||||||
"noscript" if elem.namespace == ns!(HTML)
|
"noscript" if *elem.namespace() == ns!(HTML)
|
||||||
=> html.push_str(text.characterdata.data.borrow().as_slice()),
|
=> html.push_str(text.characterdata().data().as_slice()),
|
||||||
_ => escape(text.characterdata.data.borrow().as_slice(), false, html)
|
_ => 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>,
|
fn serialize_processing_instruction(processing_instruction: JSRef<ProcessingInstruction>,
|
||||||
html: &mut String) {
|
html: &mut String) {
|
||||||
html.push_str("<?");
|
html.push_str("<?");
|
||||||
html.push_str(processing_instruction.target.as_slice());
|
html.push_str(processing_instruction.target().as_slice());
|
||||||
html.push_char(' ');
|
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("?>");
|
html.push_str("?>");
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
|
fn serialize_doctype(doctype: JSRef<DocumentType>, html: &mut String) {
|
||||||
html.push_str("<!DOCTYPE");
|
html.push_str("<!DOCTYPE");
|
||||||
html.push_str(doctype.name.as_slice());
|
html.push_str(doctype.name().as_slice());
|
||||||
html.push_char('>');
|
html.push_char('>');
|
||||||
}
|
}
|
||||||
|
|
||||||
fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) {
|
fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &mut String) {
|
||||||
html.push_char('<');
|
html.push_char('<');
|
||||||
html.push_str(elem.local_name.as_slice());
|
html.push_str(elem.local_name().as_slice());
|
||||||
for attr in elem.attrs.borrow().iter() {
|
for attr in elem.attrs().iter() {
|
||||||
let attr = attr.root();
|
let attr = attr.root();
|
||||||
serialize_attr(*attr, html);
|
serialize_attr(*attr, html);
|
||||||
};
|
};
|
||||||
html.push_char('>');
|
html.push_char('>');
|
||||||
|
|
||||||
match elem.local_name.as_slice() {
|
match elem.local_name().as_slice() {
|
||||||
"pre" | "listing" | "textarea" if elem.namespace == ns!(HTML) => {
|
"pre" | "listing" | "textarea" if *elem.namespace() == ns!(HTML) => {
|
||||||
let node: JSRef<Node> = NodeCast::from_ref(elem);
|
let node: JSRef<Node> = NodeCast::from_ref(elem);
|
||||||
match node.first_child().map(|child| child.root()) {
|
match node.first_child().map(|child| child.root()) {
|
||||||
Some(ref child) if child.is_text() => {
|
Some(ref child) if child.is_text() => {
|
||||||
let text: JSRef<CharacterData> = CharacterDataCast::to_ref(**child).unwrap();
|
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');
|
html.push_char('\x0A');
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -131,26 +131,26 @@ fn serialize_elem(elem: JSRef<Element>, open_elements: &mut Vec<String>, html: &
|
||||||
}
|
}
|
||||||
|
|
||||||
if !(elem.is_void()) {
|
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) {
|
fn serialize_attr(attr: JSRef<Attr>, html: &mut String) {
|
||||||
html.push_char(' ');
|
html.push_char(' ');
|
||||||
if attr.namespace == ns!(XML) {
|
if *attr.namespace() == ns!(XML) {
|
||||||
html.push_str("xml:");
|
html.push_str("xml:");
|
||||||
html.push_str(attr.local_name().as_slice());
|
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") {
|
*attr.local_name() == Atom::from_slice("xmlns") {
|
||||||
html.push_str("xmlns");
|
html.push_str("xmlns");
|
||||||
} else if attr.namespace == ns!(XMLNS) {
|
} else if *attr.namespace() == ns!(XMLNS) {
|
||||||
html.push_str("xmlns:");
|
html.push_str("xmlns:");
|
||||||
html.push_str(attr.local_name().as_slice());
|
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("xlink:");
|
||||||
html.push_str(attr.local_name().as_slice());
|
html.push_str(attr.local_name().as_slice());
|
||||||
} else {
|
} else {
|
||||||
html.push_str(attr.name.as_slice());
|
html.push_str(attr.name().as_slice());
|
||||||
};
|
};
|
||||||
html.push_str("=\"");
|
html.push_str("=\"");
|
||||||
escape(attr.value().as_slice(), true, html);
|
escape(attr.value().as_slice(), true, html);
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLSourceElement {
|
pub struct HTMLSourceElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLSourceElementDerived for EventTarget {
|
impl HTMLSourceElementDerived for EventTarget {
|
||||||
fn is_htmlsourceelement(&self) -> bool {
|
fn is_htmlsourceelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSourceElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLSourceElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLSpanElement {
|
pub struct HTMLSpanElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLSpanElementDerived for EventTarget {
|
impl HTMLSpanElementDerived for EventTarget {
|
||||||
fn is_htmlspanelement(&self) -> bool {
|
fn is_htmlspanelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLSpanElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLSpanElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,14 @@ use style::Stylesheet;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLStyleElement {
|
pub struct HTMLStyleElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLStyleElementDerived for EventTarget {
|
impl HTMLStyleElementDerived for EventTarget {
|
||||||
fn is_htmlstyleelement(&self) -> bool {
|
fn is_htmlstyleelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLStyleElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLStyleElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableCaptionElement {
|
pub struct HTMLTableCaptionElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableCaptionElementDerived for EventTarget {
|
impl HTMLTableCaptionElementDerived for EventTarget {
|
||||||
fn is_htmltablecaptionelement(&self) -> bool {
|
fn is_htmltablecaptionelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableCaptionElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableCaptionElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -14,13 +14,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableCellElement {
|
pub struct HTMLTableCellElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableCellElementDerived for EventTarget {
|
impl HTMLTableCellElementDerived for EventTarget {
|
||||||
fn is_htmltablecellelement(&self) -> bool {
|
fn is_htmltablecellelement(&self) -> bool {
|
||||||
match self.type_id {
|
match *self.type_id() {
|
||||||
NodeTargetTypeId(ElementNodeTypeId(HTMLTableDataCellElementTypeId)) |
|
NodeTargetTypeId(ElementNodeTypeId(HTMLTableDataCellElementTypeId)) |
|
||||||
NodeTargetTypeId(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId)) => true,
|
NodeTargetTypeId(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId)) => true,
|
||||||
_ => false
|
_ => false
|
||||||
|
@ -34,6 +35,11 @@ impl HTMLTableCellElement {
|
||||||
htmlelement: HTMLElement::new_inherited(type_id, tag_name, prefix, document)
|
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 {
|
impl Reflectable for HTMLTableCellElement {
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableColElement {
|
pub struct HTMLTableColElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableColElementDerived for EventTarget {
|
impl HTMLTableColElementDerived for EventTarget {
|
||||||
fn is_htmltablecolelement(&self) -> bool {
|
fn is_htmltablecolelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableColElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableColElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableDataCellElement {
|
pub struct HTMLTableDataCellElement {
|
||||||
pub htmltablecellelement: HTMLTableCellElement,
|
htmltablecellelement: HTMLTableCellElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableDataCellElementDerived for EventTarget {
|
impl HTMLTableDataCellElementDerived for EventTarget {
|
||||||
fn is_htmltabledatacellelement(&self) -> bool {
|
fn is_htmltabledatacellelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableDataCellElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableDataCellElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -19,13 +19,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableElement {
|
pub struct HTMLTableElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableElementDerived for EventTarget {
|
impl HTMLTableElementDerived for EventTarget {
|
||||||
fn is_htmltableelement(&self) -> bool {
|
fn is_htmltableelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableHeaderCellElement {
|
pub struct HTMLTableHeaderCellElement {
|
||||||
pub htmltablecellelement: HTMLTableCellElement,
|
htmltablecellelement: HTMLTableCellElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableHeaderCellElementDerived for EventTarget {
|
impl HTMLTableHeaderCellElementDerived for EventTarget {
|
||||||
fn is_htmltableheadercellelement(&self) -> bool {
|
fn is_htmltableheadercellelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableHeaderCellElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableRowElement {
|
pub struct HTMLTableRowElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableRowElementDerived for EventTarget {
|
impl HTMLTableRowElementDerived for EventTarget {
|
||||||
fn is_htmltablerowelement(&self) -> bool {
|
fn is_htmltablerowelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableRowElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableRowElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTableSectionElement {
|
pub struct HTMLTableSectionElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTableSectionElementDerived for EventTarget {
|
impl HTMLTableSectionElementDerived for EventTarget {
|
||||||
fn is_htmltablesectionelement(&self) -> bool {
|
fn is_htmltablesectionelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTableSectionElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTableSectionElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTemplateElement {
|
pub struct HTMLTemplateElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTemplateElementDerived for EventTarget {
|
impl HTMLTemplateElementDerived for EventTarget {
|
||||||
fn is_htmltemplateelement(&self) -> bool {
|
fn is_htmltemplateelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTemplateElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTemplateElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -20,13 +20,14 @@ use string_cache::Atom;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTextAreaElement {
|
pub struct HTMLTextAreaElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTextAreaElementDerived for EventTarget {
|
impl HTMLTextAreaElementDerived for EventTarget {
|
||||||
fn is_htmltextareaelement(&self) -> bool {
|
fn is_htmltextareaelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTextAreaElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTextAreaElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTimeElement {
|
pub struct HTMLTimeElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTimeElementDerived for EventTarget {
|
impl HTMLTimeElementDerived for EventTarget {
|
||||||
fn is_htmltimeelement(&self) -> bool {
|
fn is_htmltimeelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTimeElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTimeElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -18,13 +18,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTitleElement {
|
pub struct HTMLTitleElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTitleElementDerived for EventTarget {
|
impl HTMLTitleElementDerived for EventTarget {
|
||||||
fn is_htmltitleelement(&self) -> bool {
|
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() {
|
for child in node.children() {
|
||||||
let text: Option<JSRef<Text>> = TextCast::to_ref(child);
|
let text: Option<JSRef<Text>> = TextCast::to_ref(child);
|
||||||
match text {
|
match text {
|
||||||
Some(text) => content.push_str(text.characterdata.data.borrow().as_slice()),
|
Some(text) => content.push_str(text.characterdata().data().as_slice()),
|
||||||
None => (),
|
None => (),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLTrackElement {
|
pub struct HTMLTrackElement {
|
||||||
pub htmlelement: HTMLElement,
|
htmlelement: HTMLElement,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLTrackElementDerived for EventTarget {
|
impl HTMLTrackElementDerived for EventTarget {
|
||||||
fn is_htmltrackelement(&self) -> bool {
|
fn is_htmltrackelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLTrackElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLTrackElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLUListElement {
|
pub struct HTMLUListElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLUListElementDerived for EventTarget {
|
impl HTMLUListElementDerived for EventTarget {
|
||||||
fn is_htmlulistelement(&self) -> bool {
|
fn is_htmlulistelement(&self) -> bool {
|
||||||
self.type_id == NodeTargetTypeId(ElementNodeTypeId(HTMLUListElementTypeId))
|
*self.type_id() == NodeTargetTypeId(ElementNodeTypeId(HTMLUListElementTypeId))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,13 +15,14 @@ use servo_util::str::DOMString;
|
||||||
|
|
||||||
#[jstraceable]
|
#[jstraceable]
|
||||||
#[must_root]
|
#[must_root]
|
||||||
|
#[privatize]
|
||||||
pub struct HTMLUnknownElement {
|
pub struct HTMLUnknownElement {
|
||||||
pub htmlelement: HTMLElement
|
htmlelement: HTMLElement
|
||||||
}
|
}
|
||||||
|
|
||||||
impl HTMLUnknownElementDerived for EventTarget {
|
impl HTMLUnknownElementDerived for EventTarget {
|
||||||
fn is_htmlunknownelement(&self) -> bool {
|
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
Loading…
Add table
Add a link
Reference in a new issue