mirror of
https://github.com/servo/servo.git
synced 2025-08-03 04:30:10 +01:00
Auto merge of #7452 - nox:cleanup-attributes, r=nox
Introduce VirtualMethods::attribute_mutated() <!-- Reviewable:start --> [<img src="https://reviewable.io/review_button.png" height=40 alt="Review on Reviewable"/>](https://reviewable.io/reviews/servo/servo/7452) <!-- Reviewable:end -->
This commit is contained in:
commit
eaf90c0b1c
33 changed files with 634 additions and 943 deletions
|
@ -8,7 +8,7 @@ use dom::bindings::codegen::Bindings::HTMLFontElementBinding::HTMLFontElementMet
|
|||
use dom::bindings::codegen::InheritTypes::{HTMLElementCast, HTMLFontElementDerived};
|
||||
use dom::bindings::js::Root;
|
||||
use dom::document::Document;
|
||||
use dom::element::ElementTypeId;
|
||||
use dom::element::{AttributeMutation, ElementTypeId};
|
||||
use dom::eventtarget::{EventTarget, EventTargetTypeId};
|
||||
use dom::htmlelement::{HTMLElement, HTMLElementTypeId};
|
||||
use dom::node::{Node, NodeTypeId};
|
||||
|
@ -63,27 +63,15 @@ impl VirtualMethods for HTMLFontElement {
|
|||
Some(htmlelement as &VirtualMethods)
|
||||
}
|
||||
|
||||
fn after_set_attr(&self, attr: &Attr) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
s.after_set_attr(attr);
|
||||
}
|
||||
|
||||
fn attribute_mutated(&self, attr: &Attr, mutation: AttributeMutation) {
|
||||
self.super_type().unwrap().attribute_mutated(attr, mutation);
|
||||
match attr.local_name() {
|
||||
&atom!("color") => {
|
||||
self.color.set(str::parse_legacy_color(&attr.value()).ok())
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn before_remove_attr(&self, attr: &Attr) {
|
||||
if let Some(ref s) = self.super_type() {
|
||||
s.before_remove_attr(attr);
|
||||
}
|
||||
|
||||
match attr.local_name() {
|
||||
&atom!("color") => self.color.set(None),
|
||||
_ => ()
|
||||
&atom!(color) => {
|
||||
self.color.set(mutation.new_value(attr).and_then(|value| {
|
||||
str::parse_legacy_color(&value).ok()
|
||||
}));
|
||||
},
|
||||
_ => {},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue