HTMLImageElement
Represents the image element.
namespace AngleSharp.DOM.Html
{
[DOM("HTMLImageElement")]
public sealed class HTMLImageElement : HTMLElement
{
internal const string Tag = "img";
internal const string FalseTag = "image";
private uint _imageWidth;
private uint _imageHeight;
private bool _loaded;
[DOM("src")]
public string Src {
get {
return GetAttribute("src");
}
set {
SetAttribute("src", value);
}
}
[DOM("alt")]
public string Alt {
get {
return GetAttribute("alt");
}
set {
SetAttribute("alt", value);
}
}
[DOM("crossOrigin")]
public string CrossOrigin {
get {
return GetAttribute("crossorigin");
}
set {
SetAttribute("crossorigin", value);
}
}
[DOM("useMap")]
public string UseMap {
get {
return GetAttribute("usemap");
}
set {
SetAttribute("usemap", value);
}
}
[DOM("width")]
public uint Width {
get {
return Element.ToInteger(GetAttribute("width"), _imageWidth);
}
set {
SetAttribute("width", value.ToString());
}
}
[DOM("height")]
public uint Height {
get {
return Element.ToInteger(GetAttribute("height"), _imageHeight);
}
set {
SetAttribute("height", value.ToString());
}
}
[DOM("naturalWidth")]
public uint NaturalWidth {
get {
return _imageWidth;
}
}
[DOM("naturalHeight")]
public uint NaturalHeight {
get {
return _imageHeight;
}
}
[DOM("complete")]
public bool Complete {
get {
return _loaded;
}
}
[DOM("isMap")]
public bool IsMap {
get {
return GetAttribute("ismap") != null;
}
set {
SetAttribute("ismap", value ? string.Empty : null);
}
}
protected internal override bool IsSpecial => true;
internal HTMLImageElement()
{
_loaded = true;
_name = "img";
_imageHeight = 0;
_imageWidth = 0;
}
protected override void Register(Document document)
{
if (document is HTMLDocument)
((HTMLDocument)document).Images.Add(this);
}
protected override void Unregister(Document document)
{
if (document is HTMLDocument)
((HTMLDocument)document).Images.Remove(this);
}
}
}