aboutsummaryrefslogtreecommitdiffstats
path: root/components/script/dom/htmlelement.rs
diff options
context:
space:
mode:
authorAnthony Ramine <n.oxyde@gmail.com>2015-08-27 01:22:42 +0200
committerAnthony Ramine <n.oxyde@gmail.com>2015-08-27 16:59:02 +0200
commitc831c2c0a528b6a04b355cc51169023f8c29b761 (patch)
treed443f7075709bdb222163aecc8ce1c3b81e107b9 /components/script/dom/htmlelement.rs
parent1384ff5e9f4d98630d4ec1206049c8fb6d96f187 (diff)
downloadservo-c831c2c0a528b6a04b355cc51169023f8c29b761.tar.gz
servo-c831c2c0a528b6a04b355cc51169023f8c29b761.zip
Remove helper traits
Now that JSRef<T> is gone, there is no need to have helper traits. On components/script/*.rs: # Remove imports. /^ *use dom::[a-z]+::\{.*Helpers/ { s/\{(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers, /\{/ s/, (Raw[^L]|[^L][^a])[a-zA-Z]+Helpers([,}])/\2/g s/\{([a-zA-Z]+)\}/\1/ /\{\}/d s/::self;$/;/ } /^ *use dom::[a-z]+::\{?(Raw[^L]|[^L][^a])[a-zA-Z]+Helpers\}?;$/d On components/script/dom/*.rs: # Ignore layout things. /^(pub )?(impl|trait).*Layout.* \{/,/^}$/ { P; D; } # Delete helpers traits. /^(pub )?trait ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? \{$/,/^\}$/D # Patch private helpers. /^impl.*Private.*Helpers/,/^\}$/ { s/^impl<'a> Private([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for &'a ([^ ]+) \{$/impl \3 {/ /^ *(unsafe )?fn .*\(self.*[<&]'a/ { s/&'a /\&/g s/<'a, /</g } /^ *(unsafe )?fn /s/\(self([,)])/\(\&self\1/ } # Patch public helpers. /^impl.*Helpers/,/^\}$/ { s/^impl(<'a>)? ([^L][^ ]|L[^a])[^ ]+Helpers(<'a>)? for (&'a )?([^ ]+) \{$/impl \5 {/ /^ *(unsafe )?fn .*\(self.*[<&]'a/ { s/&'a /\&/g s/<'a, /</g } /^ *(unsafe )?fn .*\(&?self[,)]/s/(unsafe )?fn/pub &/ /^ *pub (unsafe )?fn /s/\(self([,)])/\(\&self\1/ } The few error cases were then fixed by hand.
Diffstat (limited to 'components/script/dom/htmlelement.rs')
-rw-r--r--components/script/dom/htmlelement.rs33
1 files changed, 11 insertions, 22 deletions
diff --git a/components/script/dom/htmlelement.rs b/components/script/dom/htmlelement.rs
index 01b222fd539..2d50a215edd 100644
--- a/components/script/dom/htmlelement.rs
+++ b/components/script/dom/htmlelement.rs
@@ -3,7 +3,6 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
use dom::attr::Attr;
-use dom::attr::AttrHelpers;
use dom::attr::AttrValue;
use dom::bindings::codegen::Bindings::EventHandlerBinding::EventHandlerNonNull;
use dom::bindings::codegen::Bindings::HTMLElementBinding;
@@ -18,16 +17,15 @@ use dom::bindings::error::ErrorResult;
use dom::bindings::js::{JS, MutNullableHeap, Root};
use dom::bindings::utils::Reflectable;
use dom::cssstyledeclaration::{CSSStyleDeclaration, CSSModificationAccess};
-use dom::document::{Document, DocumentHelpers};
+use dom::document::Document;
use dom::domstringmap::DOMStringMap;
-use dom::element::{Element, ElementTypeId, ActivationElementHelpers, AttributeHandlers};
-use dom::eventtarget::{EventTarget, EventTargetHelpers, EventTargetTypeId};
+use dom::element::{Element, ElementTypeId, AttributeHandlers};
+use dom::eventtarget::{EventTarget, EventTargetTypeId};
use dom::htmlinputelement::HTMLInputElement;
use dom::htmlmediaelement::HTMLMediaElementTypeId;
use dom::htmltablecellelement::HTMLTableCellElementTypeId;
-use dom::node::{Node, NodeHelpers, NodeTypeId, document_from_node, window_from_node, SEQUENTIALLY_FOCUSABLE};
+use dom::node::{Node, NodeTypeId, document_from_node, window_from_node, SEQUENTIALLY_FOCUSABLE};
use dom::virtualmethods::VirtualMethods;
-use dom::window::WindowHelpers;
use msg::constellation_msg::FocusType;
use util::str::DOMString;
@@ -81,18 +79,14 @@ impl HTMLElement {
}
}
-trait PrivateHTMLElementHelpers {
- fn is_body_or_frameset(self) -> bool;
- fn update_sequentially_focusable_status(self);
-}
-impl<'a> PrivateHTMLElementHelpers for &'a HTMLElement {
- fn is_body_or_frameset(self) -> bool {
+impl HTMLElement {
+ fn is_body_or_frameset(&self) -> bool {
let eventtarget = EventTargetCast::from_ref(self);
eventtarget.is_htmlbodyelement() || eventtarget.is_htmlframesetelement()
}
- fn update_sequentially_focusable_status(self) {
+ fn update_sequentially_focusable_status(&self) {
let element = ElementCast::from_ref(self);
let node = NodeCast::from_ref(self);
if element.has_attribute(&atom!("tabindex")) {
@@ -276,11 +270,6 @@ impl<'a> HTMLElementMethods for &'a HTMLElement {
}
// https://html.spec.whatwg.org/#attr-data-*
-pub trait HTMLElementCustomAttributeHelpers {
- fn set_custom_attr(self, name: DOMString, value: DOMString) -> ErrorResult;
- fn get_custom_attr(self, name: DOMString) -> Option<DOMString>;
- fn delete_custom_attr(self, name: DOMString);
-}
fn to_snake_case(name: DOMString) -> DOMString {
let mut attr_name = "data-".to_owned();
@@ -295,8 +284,8 @@ fn to_snake_case(name: DOMString) -> DOMString {
attr_name
}
-impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
- fn set_custom_attr(self, name: DOMString, value: DOMString) -> ErrorResult {
+impl HTMLElement {
+ pub fn set_custom_attr(&self, name: DOMString, value: DOMString) -> ErrorResult {
if name.chars()
.skip_while(|&ch| ch != '\u{2d}')
.nth(1).map_or(false, |ch| ch >= 'a' && ch <= 'z') {
@@ -306,7 +295,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
element.set_custom_attribute(to_snake_case(name), value)
}
- fn get_custom_attr(self, local_name: DOMString) -> Option<DOMString> {
+ pub fn get_custom_attr(&self, local_name: DOMString) -> Option<DOMString> {
let element = ElementCast::from_ref(self);
let local_name = Atom::from_slice(&to_snake_case(local_name));
element.get_attribute(&ns!(""), &local_name).map(|attr| {
@@ -314,7 +303,7 @@ impl<'a> HTMLElementCustomAttributeHelpers for &'a HTMLElement {
})
}
- fn delete_custom_attr(self, local_name: DOMString) {
+ pub fn delete_custom_attr(&self, local_name: DOMString) {
let element = ElementCast::from_ref(self);
let local_name = Atom::from_slice(&to_snake_case(local_name));
element.remove_attribute(&ns!(""), &local_name);