mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Ensure that Reflectors are the first field
This commit is contained in:
parent
d761877ef6
commit
21a888341d
14 changed files with 146 additions and 21 deletions
|
@ -62,15 +62,15 @@ impl DOMErrorName {
|
|||
|
||||
#[dom_struct]
|
||||
pub struct DOMException {
|
||||
reflector_: Reflector,
|
||||
code: DOMErrorName,
|
||||
reflector_: Reflector
|
||||
}
|
||||
|
||||
impl DOMException {
|
||||
fn new_inherited(code: DOMErrorName) -> DOMException {
|
||||
DOMException {
|
||||
reflector_: Reflector::new(),
|
||||
code: code,
|
||||
reflector_: Reflector::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -27,15 +27,15 @@ use servo_util::str::DOMString;
|
|||
|
||||
#[dom_struct]
|
||||
pub struct DOMImplementation {
|
||||
document: JS<Document>,
|
||||
reflector_: Reflector,
|
||||
document: JS<Document>,
|
||||
}
|
||||
|
||||
impl DOMImplementation {
|
||||
fn new_inherited(document: JSRef<Document>) -> DOMImplementation {
|
||||
DOMImplementation {
|
||||
document: JS::from_rooted(document),
|
||||
reflector_: Reflector::new(),
|
||||
document: JS::from_rooted(document),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -19,15 +19,15 @@ use servo_util::str::DOMString;
|
|||
|
||||
#[dom_struct]
|
||||
pub struct DOMParser {
|
||||
reflector_: Reflector,
|
||||
window: JS<Window>, //XXXjdm Document instead?
|
||||
reflector_: Reflector
|
||||
}
|
||||
|
||||
impl DOMParser {
|
||||
fn new_inherited(window: JSRef<Window>) -> DOMParser {
|
||||
DOMParser {
|
||||
reflector_: Reflector::new(),
|
||||
window: JS::from_rooted(window),
|
||||
reflector_: Reflector::new()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -51,8 +51,8 @@ pub enum EventCancelable {
|
|||
|
||||
#[dom_struct]
|
||||
pub struct Event {
|
||||
type_id: EventTypeId,
|
||||
reflector_: Reflector,
|
||||
type_id: EventTypeId,
|
||||
current_target: MutNullableJS<EventTarget>,
|
||||
target: MutNullableJS<EventTarget>,
|
||||
type_: DOMRefCell<DOMString>,
|
||||
|
@ -71,8 +71,8 @@ pub struct Event {
|
|||
impl Event {
|
||||
pub fn new_inherited(type_id: EventTypeId) -> Event {
|
||||
Event {
|
||||
type_id: type_id,
|
||||
reflector_: Reflector::new(),
|
||||
type_id: type_id,
|
||||
current_target: Default::default(),
|
||||
target: Default::default(),
|
||||
phase: Cell::new(EventPhase::None),
|
||||
|
|
|
@ -72,16 +72,16 @@ pub struct EventListenerEntry {
|
|||
|
||||
#[dom_struct]
|
||||
pub struct EventTarget {
|
||||
type_id: EventTargetTypeId,
|
||||
reflector_: Reflector,
|
||||
type_id: EventTargetTypeId,
|
||||
handlers: DOMRefCell<HashMap<DOMString, Vec<EventListenerEntry>, FnvHasher>>,
|
||||
}
|
||||
|
||||
impl EventTarget {
|
||||
pub fn new_inherited(type_id: EventTargetTypeId) -> EventTarget {
|
||||
EventTarget {
|
||||
type_id: type_id,
|
||||
reflector_: Reflector::new(),
|
||||
type_id: type_id,
|
||||
handlers: DOMRefCell::new(HashMap::with_hasher(FnvHasher)),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -29,8 +29,8 @@ pub enum FormDatum {
|
|||
|
||||
#[dom_struct]
|
||||
pub struct FormData {
|
||||
data: DOMRefCell<HashMap<DOMString, Vec<FormDatum>>>,
|
||||
reflector_: Reflector,
|
||||
data: DOMRefCell<HashMap<DOMString, Vec<FormDatum>>>,
|
||||
global: GlobalField,
|
||||
form: Option<JS<HTMLFormElement>>
|
||||
}
|
||||
|
@ -38,8 +38,8 @@ pub struct FormData {
|
|||
impl FormData {
|
||||
fn new_inherited(form: Option<JSRef<HTMLFormElement>>, global: &GlobalRef) -> FormData {
|
||||
FormData {
|
||||
data: DOMRefCell::new(HashMap::new()),
|
||||
reflector_: Reflector::new(),
|
||||
data: DOMRefCell::new(HashMap::new()),
|
||||
global: GlobalField::from_rooted(global),
|
||||
form: form.map(|f| JS::from_rooted(f)),
|
||||
}
|
||||
|
|
|
@ -32,15 +32,15 @@ pub enum CollectionTypeId {
|
|||
|
||||
#[dom_struct]
|
||||
pub struct HTMLCollection {
|
||||
collection: CollectionTypeId,
|
||||
reflector_: Reflector,
|
||||
collection: CollectionTypeId,
|
||||
}
|
||||
|
||||
impl HTMLCollection {
|
||||
fn new_inherited(collection: CollectionTypeId) -> HTMLCollection {
|
||||
HTMLCollection {
|
||||
collection: collection,
|
||||
reflector_: Reflector::new(),
|
||||
collection: collection,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -50,3 +50,46 @@ impl HTMLTableRowElement {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
pub trait HTMLTableRowElementHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
}
|
||||
|
||||
impl HTMLTableRowElementHelpers for HTMLTableRowElement {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLTableRowElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
|
||||
Some(htmlelement as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||
match self.super_type() {
|
||||
Some(ref s) => s.after_set_attr(attr),
|
||||
_ => ()
|
||||
}
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("bgcolor") => {
|
||||
self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok())
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||
match self.super_type() {
|
||||
Some(ref s) => s.before_remove_attr(attr),
|
||||
_ => ()
|
||||
}
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("bgcolor") => self.background_color.set(None),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -49,3 +49,45 @@ impl HTMLTableSectionElement {
|
|||
}
|
||||
}
|
||||
|
||||
pub trait HTMLTableSectionElementHelpers {
|
||||
fn get_background_color(&self) -> Option<RGBA>;
|
||||
}
|
||||
|
||||
impl HTMLTableSectionElementHelpers for HTMLTableSectionElement {
|
||||
fn get_background_color(&self) -> Option<RGBA> {
|
||||
self.background_color.get()
|
||||
}
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLTableSectionElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
|
||||
Some(htmlelement as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, attr: JSRef<Attr>) {
|
||||
match self.super_type() {
|
||||
Some(ref s) => s.after_set_attr(attr),
|
||||
_ => ()
|
||||
}
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("bgcolor") => {
|
||||
self.background_color.set(str::parse_legacy_color(attr.value().as_slice()).ok())
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn before_remove_attr(&self, attr: JSRef<Attr>) {
|
||||
match self.super_type() {
|
||||
Some(ref s) => s.before_remove_attr(attr),
|
||||
_ => ()
|
||||
}
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("bgcolor") => self.background_color.set(None),
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -329,3 +329,20 @@ impl<'a> VirtualMethods for JSRef<'a, HTMLTextAreaElement> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> FormControl<'a> for JSRef<'a, HTMLTextAreaElement> {
|
||||
fn to_element(self) -> JSRef<'a, Element> {
|
||||
ElementCast::from_ref(self)
|
||||
}
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#concept-fe-mutable
|
||||
fn mutable(self) -> bool {
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-fe-mutable
|
||||
!(self.Disabled() || self.ReadOnly())
|
||||
}
|
||||
|
||||
fn reset(self) {
|
||||
// https://html.spec.whatwg.org/multipage/forms.html#the-textarea-element:concept-form-reset-control
|
||||
self.SetValue(self.DefaultValue());
|
||||
self.value_changed.set(false);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,3 +64,17 @@ impl<'a> HTMLTitleElementMethods for JSRef<'a, HTMLTitleElement> {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for JSRef<'a, HTMLTitleElement> {
|
||||
fn super_type<'a>(&'a self) -> Option<&'a VirtualMethods> {
|
||||
let htmlelement: &JSRef<HTMLElement> = HTMLElementCast::from_borrowed_ref(self);
|
||||
Some(htmlelement as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn bind_to_tree(&self, is_in_doc: bool) {
|
||||
let node: JSRef<Node> = NodeCast::from_ref(*self);
|
||||
if is_in_doc {
|
||||
let document = node.owner_doc().root();
|
||||
document.send_title_to_compositor()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,15 +19,15 @@ pub enum NodeListType {
|
|||
|
||||
#[dom_struct]
|
||||
pub struct NodeList {
|
||||
list_type: NodeListType,
|
||||
reflector_: Reflector,
|
||||
list_type: NodeListType,
|
||||
}
|
||||
|
||||
impl NodeList {
|
||||
fn new_inherited(list_type: NodeListType) -> NodeList {
|
||||
NodeList {
|
||||
list_type: list_type,
|
||||
reflector_: Reflector::new(),
|
||||
list_type: list_type,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -24,15 +24,15 @@ use std::ascii::OwnedAsciiExt;
|
|||
|
||||
#[dom_struct]
|
||||
pub struct URLSearchParams {
|
||||
data: DOMRefCell<HashMap<DOMString, Vec<DOMString>>>,
|
||||
reflector_: Reflector,
|
||||
data: DOMRefCell<HashMap<DOMString, Vec<DOMString>>>,
|
||||
}
|
||||
|
||||
impl URLSearchParams {
|
||||
fn new_inherited() -> URLSearchParams {
|
||||
URLSearchParams {
|
||||
data: DOMRefCell::new(HashMap::new()),
|
||||
reflector_: Reflector::new(),
|
||||
data: DOMRefCell::new(HashMap::new()),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue