mirror of
https://github.com/servo/servo.git
synced 2025-08-06 14:10:11 +01:00
script: Add pre element obsolete width attribute support (#31792)
This commit is contained in:
parent
bd39e03eeb
commit
97144ddf71
7 changed files with 35 additions and 543 deletions
|
@ -3,13 +3,18 @@
|
|||
* file, You can obtain one at https://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom_struct::dom_struct;
|
||||
use html5ever::{LocalName, Prefix};
|
||||
use html5ever::{local_name, LocalName, Prefix};
|
||||
use js::rust::HandleObject;
|
||||
use style::attr::AttrValue;
|
||||
|
||||
use crate::dom::bindings::codegen::Bindings::HTMLPreElementBinding::HTMLPreElementMethods;
|
||||
use crate::dom::bindings::inheritance::Castable;
|
||||
use crate::dom::bindings::root::DomRoot;
|
||||
use crate::dom::bindings::str::DOMString;
|
||||
use crate::dom::document::Document;
|
||||
use crate::dom::htmlelement::HTMLElement;
|
||||
use crate::dom::node::Node;
|
||||
use crate::dom::virtualmethods::VirtualMethods;
|
||||
|
||||
#[dom_struct]
|
||||
pub struct HTMLPreElement {
|
||||
|
@ -41,3 +46,27 @@ impl HTMLPreElement {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
impl VirtualMethods for HTMLPreElement {
|
||||
fn super_type(&self) -> Option<&dyn VirtualMethods> {
|
||||
Some(self.upcast::<HTMLElement>() as &dyn VirtualMethods)
|
||||
}
|
||||
|
||||
fn parse_plain_attribute(&self, name: &LocalName, value: DOMString) -> AttrValue {
|
||||
match *name {
|
||||
local_name!("width") => AttrValue::from_limited_i32(value.into(), 0),
|
||||
_ => self
|
||||
.super_type()
|
||||
.unwrap()
|
||||
.parse_plain_attribute(name, value),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLPreElementMethods for HTMLPreElement {
|
||||
// https://html.spec.whatwg.org/multipage/#dom-pre-width
|
||||
make_int_getter!(Width, "width", 0);
|
||||
|
||||
// https://html.spec.whatwg.org/multipage/#dom-pre-width
|
||||
make_int_setter!(SetWidth, "width", 0);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue