mirror of
https://github.com/servo/servo.git
synced 2025-08-02 12:10:29 +01:00
Implement the Image NamedConstructor for HTMLImageElement
This commit is contained in:
parent
012be81eab
commit
d33579183a
6 changed files with 53 additions and 53 deletions
|
@ -7,8 +7,10 @@ use dom::attr::{AttrHelpers, AttrValue};
|
|||
use dom::bindings::cell::DOMRefCell;
|
||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding;
|
||||
use dom::bindings::codegen::Bindings::HTMLImageElementBinding::HTMLImageElementMethods;
|
||||
use dom::bindings::codegen::Bindings::WindowBinding::WindowMethods;
|
||||
use dom::bindings::codegen::InheritTypes::{NodeCast, ElementCast, EventTargetCast, HTMLElementCast,
|
||||
HTMLImageElementDerived};
|
||||
use dom::bindings::error::Fallible;
|
||||
use dom::bindings::global::GlobalRef;
|
||||
use dom::bindings::js::{LayoutJS, Root};
|
||||
use dom::bindings::refcounted::Trusted;
|
||||
|
@ -151,6 +153,21 @@ impl HTMLImageElement {
|
|||
let element = HTMLImageElement::new_inherited(localName, prefix, document);
|
||||
Node::reflect_node(box element, document, HTMLImageElementBinding::Wrap)
|
||||
}
|
||||
|
||||
pub fn Image(global: GlobalRef,
|
||||
width: Option<u32>,
|
||||
height: Option<u32>) -> Fallible<Root<HTMLImageElement>> {
|
||||
let document = global.as_window().Document();
|
||||
let image = HTMLImageElement::new("img".to_owned(), None, document.r());
|
||||
if let Some(w) = width {
|
||||
image.SetWidth(w);
|
||||
}
|
||||
if let Some(h) = height {
|
||||
image.SetHeight(h);
|
||||
}
|
||||
|
||||
Ok(image)
|
||||
}
|
||||
}
|
||||
|
||||
pub trait LayoutHTMLImageElementHelpers {
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
// https://www.whatwg.org/html/#htmlimageelement
|
||||
//[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
|
||||
[NamedConstructor=Image(optional unsigned long width, optional unsigned long height)]
|
||||
interface HTMLImageElement : HTMLElement {
|
||||
attribute DOMString alt;
|
||||
attribute DOMString src;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue