mirror of
https://github.com/servo/servo.git
synced 2025-08-03 12:40:06 +01:00
Introduce HTMLImageElement::new.
This commit is contained in:
parent
7c17970c21
commit
c9bc5f6409
2 changed files with 19 additions and 3 deletions
|
@ -2,9 +2,12 @@
|
|||
* License, v. 2.0. If a copy of the MPL was not distributed with this
|
||||
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
|
||||
|
||||
use dom::bindings::codegen::HTMLImageElementBinding;
|
||||
use dom::bindings::utils::{DOMString, ErrorResult, null_str_as_empty};
|
||||
use dom::document::AbstractDocument;
|
||||
use dom::element::HTMLImageElementTypeId;
|
||||
use dom::htmlelement::HTMLElement;
|
||||
use dom::node::{ScriptView, AbstractNode};
|
||||
use dom::node::{AbstractNode, Node, ScriptView};
|
||||
use extra::url::Url;
|
||||
use servo_util::geometry::to_px;
|
||||
use layout_interface::{ContentBoxQuery, ContentBoxResponse};
|
||||
|
@ -18,6 +21,20 @@ pub struct HTMLImageElement {
|
|||
image: Option<Url>,
|
||||
}
|
||||
|
||||
impl HTMLImageElement {
|
||||
pub fn new_inherited(localName: ~str, document: AbstractDocument) -> HTMLImageElement {
|
||||
HTMLImageElement {
|
||||
htmlelement: HTMLElement::new(HTMLImageElementTypeId, localName, document),
|
||||
image: None,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new(localName: ~str, document: AbstractDocument) -> AbstractNode<ScriptView> {
|
||||
let element = HTMLImageElement::new_inherited(localName, document);
|
||||
Node::reflect_node(@mut element, document, HTMLImageElementBinding::Wrap)
|
||||
}
|
||||
}
|
||||
|
||||
impl HTMLImageElement {
|
||||
/// Makes the local `image` member match the status of the `src` attribute and starts
|
||||
/// prefetching the image. This method must be called after `src` is changed.
|
||||
|
|
|
@ -270,8 +270,6 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum
|
|||
handle_element!(cx, document, tag, "track", HTMLTrackElementTypeId, HTMLTrackElement, []);
|
||||
handle_element!(cx, document, tag, "ul", HTMLUListElementTypeId, HTMLUListElement, []);
|
||||
|
||||
handle_element!(cx, document, tag, "img", HTMLImageElementTypeId, HTMLImageElement, [(image: None)]);
|
||||
|
||||
handle_htmlelement!(cx, document, tag, "aside", HTMLElementTypeId, HTMLElement);
|
||||
handle_htmlelement!(cx, document, tag, "b", HTMLElementTypeId, HTMLElement);
|
||||
handle_htmlelement!(cx, document, tag, "i", HTMLElementTypeId, HTMLElement);
|
||||
|
@ -286,6 +284,7 @@ pub fn build_element_from_tag(cx: *JSContext, tag: &str, document: AbstractDocum
|
|||
handle_newable_element!(document, tag, "h5", HTMLHeadingElement, Heading5);
|
||||
handle_newable_element!(document, tag, "h6", HTMLHeadingElement, Heading6);
|
||||
handle_newable_element!(document, tag, "iframe", HTMLIFrameElement);
|
||||
handle_newable_element!(document, tag, "img", HTMLImageElement);
|
||||
handle_newable_element!(document, tag, "td", HTMLTableDataCellElement);
|
||||
handle_newable_element!(document, tag, "th", HTMLTableHeaderCellElement);
|
||||
handle_newable_element!(document, tag, "video", HTMLVideoElement);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue