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);
|
||||
}
|
||||
|
|
|
@ -40,6 +40,7 @@ use crate::dom::htmlobjectelement::HTMLObjectElement;
|
|||
use crate::dom::htmloptgroupelement::HTMLOptGroupElement;
|
||||
use crate::dom::htmloptionelement::HTMLOptionElement;
|
||||
use crate::dom::htmloutputelement::HTMLOutputElement;
|
||||
use crate::dom::htmlpreelement::HTMLPreElement;
|
||||
use crate::dom::htmlscriptelement::HTMLScriptElement;
|
||||
use crate::dom::htmlselectelement::HTMLSelectElement;
|
||||
use crate::dom::htmlsourceelement::HTMLSourceElement;
|
||||
|
@ -233,6 +234,9 @@ pub fn vtable_for(node: &Node) -> &dyn VirtualMethods {
|
|||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLOutputElement)) => {
|
||||
node.downcast::<HTMLOutputElement>().unwrap() as &dyn VirtualMethods
|
||||
},
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLPreElement)) => {
|
||||
node.downcast::<HTMLPreElement>().unwrap() as &dyn VirtualMethods
|
||||
},
|
||||
NodeTypeId::Element(ElementTypeId::HTMLElement(HTMLElementTypeId::HTMLScriptElement)) => {
|
||||
node.downcast::<HTMLScriptElement>().unwrap() as &dyn VirtualMethods
|
||||
},
|
||||
|
|
|
@ -12,6 +12,5 @@ interface HTMLPreElement : HTMLElement {
|
|||
|
||||
// https://html.spec.whatwg.org/multipage/#HTMLPreElement-partial
|
||||
partial interface HTMLPreElement {
|
||||
// [CEReactions]
|
||||
// attribute long width;
|
||||
[CEReactions] attribute long width;
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue