mirror of
https://github.com/servo/servo.git
synced 2025-08-06 06:00:15 +01:00
Remove doublepointer in VirtualMethods, and from_borrowed_ref
Most of the heavy lifting done by: ``` $ ls *rs | xargs gawk -i inplace '/let .*: &&.*from_borrowed_ref/{sub("&&", "\\&");sub("_borrowed_","_");} {print $0}' $ ls *rs | xargs gawk -i inplace "/impl.*VirtualMethods/{in_vm=1; sub(/<'a>/,\"\");sub(/&'a /,\"\")} /^}\$/{in_vm=0;} in_vm{\$0=gensub(/\\*self([^.])/,\"self\\\1\",\"g\"); sub(/from_borrowed_ref/,\"from_ref\")} {print}" ```
This commit is contained in:
parent
5e83a3f0a3
commit
b33c5427bc
34 changed files with 159 additions and 164 deletions
|
@ -1543,9 +1543,9 @@ impl<'a> ElementMethods for &'a Element {
|
|||
}
|
||||
}
|
||||
|
||||
impl<'a> VirtualMethods for &'a Element {
|
||||
impl VirtualMethods for Element {
|
||||
fn super_type<'b>(&'b self) -> Option<&'b VirtualMethods> {
|
||||
let node: &&Node = NodeCast::from_borrowed_ref(self);
|
||||
let node: &Node = NodeCast::from_ref(self);
|
||||
Some(node as &VirtualMethods)
|
||||
}
|
||||
|
||||
|
@ -1554,11 +1554,11 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
s.after_set_attr(attr);
|
||||
}
|
||||
|
||||
let node = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(self);
|
||||
match attr.local_name() {
|
||||
&atom!("style") => {
|
||||
// Modifying the `style` attribute might change style.
|
||||
let doc = document_from_node(*self);
|
||||
let doc = document_from_node(self);
|
||||
let base_url = doc.r().base_url();
|
||||
let value = attr.value();
|
||||
let style = Some(parse_style_attribute(&value, &base_url));
|
||||
|
@ -1571,7 +1571,7 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
&atom!("class") => {
|
||||
// Modifying a class can change style.
|
||||
if node.is_in_doc() {
|
||||
let document = document_from_node(*self);
|
||||
let document = document_from_node(self);
|
||||
document.r().content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
}
|
||||
|
@ -1579,10 +1579,10 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
// Modifying an ID might change style.
|
||||
let value = attr.value();
|
||||
if node.is_in_doc() {
|
||||
let doc = document_from_node(*self);
|
||||
let doc = document_from_node(self);
|
||||
if !value.is_empty() {
|
||||
let value = value.atom().unwrap().clone();
|
||||
doc.r().register_named_element(*self, value);
|
||||
doc.r().register_named_element(self, value);
|
||||
}
|
||||
doc.r().content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
|
@ -1590,7 +1590,7 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
_ => {
|
||||
// Modifying any other attribute might change arbitrary things.
|
||||
if node.is_in_doc() {
|
||||
let document = document_from_node(*self);
|
||||
let document = document_from_node(self);
|
||||
document.r().content_changed(node, NodeDamage::OtherNodeDamage);
|
||||
}
|
||||
}
|
||||
|
@ -1602,14 +1602,14 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
s.before_remove_attr(attr);
|
||||
}
|
||||
|
||||
let node = NodeCast::from_ref(*self);
|
||||
let node = NodeCast::from_ref(self);
|
||||
match attr.local_name() {
|
||||
&atom!("style") => {
|
||||
// Modifying the `style` attribute might change style.
|
||||
*self.style_attribute.borrow_mut() = None;
|
||||
|
||||
if node.is_in_doc() {
|
||||
let doc = document_from_node(*self);
|
||||
let doc = document_from_node(self);
|
||||
doc.r().content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
}
|
||||
|
@ -1617,10 +1617,10 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
// Modifying an ID can change style.
|
||||
let value = attr.value();
|
||||
if node.is_in_doc() {
|
||||
let doc = document_from_node(*self);
|
||||
let doc = document_from_node(self);
|
||||
if !value.is_empty() {
|
||||
let value = value.atom().unwrap().clone();
|
||||
doc.r().unregister_named_element(*self, value);
|
||||
doc.r().unregister_named_element(self, value);
|
||||
}
|
||||
doc.r().content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
|
@ -1628,14 +1628,14 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
&atom!("class") => {
|
||||
// Modifying a class can change style.
|
||||
if node.is_in_doc() {
|
||||
let document = document_from_node(*self);
|
||||
let document = document_from_node(self);
|
||||
document.r().content_changed(node, NodeDamage::NodeStyleDamaged);
|
||||
}
|
||||
}
|
||||
_ => {
|
||||
// Modifying any other attribute might change arbitrary things.
|
||||
if node.is_in_doc() {
|
||||
let doc = document_from_node(*self);
|
||||
let doc = document_from_node(self);
|
||||
doc.r().content_changed(node, NodeDamage::OtherNodeDamage);
|
||||
}
|
||||
}
|
||||
|
@ -1658,11 +1658,11 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
if !tree_in_doc { return; }
|
||||
|
||||
if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("id")) {
|
||||
let doc = document_from_node(*self);
|
||||
let doc = document_from_node(self);
|
||||
let value = attr.r().Value();
|
||||
if !value.is_empty() {
|
||||
let value = Atom::from_slice(&value);
|
||||
doc.r().register_named_element(*self, value);
|
||||
doc.r().register_named_element(self, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1675,11 +1675,11 @@ impl<'a> VirtualMethods for &'a Element {
|
|||
if !tree_in_doc { return; }
|
||||
|
||||
if let Some(ref attr) = self.get_attribute(&ns!(""), &atom!("id")) {
|
||||
let doc = document_from_node(*self);
|
||||
let doc = document_from_node(self);
|
||||
let value = attr.r().Value();
|
||||
if !value.is_empty() {
|
||||
let value = Atom::from_slice(&value);
|
||||
doc.r().unregister_named_element(*self, value);
|
||||
doc.r().unregister_named_element(self, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue