HTMLImageElement
sealed class HTMLImageElement : HTMLElement, IHtmlImageElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
Represents the image element.
using AngleSharp.DOM.Css;
namespace AngleSharp.DOM.Html
{
internal sealed class HTMLImageElement : HTMLElement, IHtmlImageElement, IHtmlElement, IElement, INode, IEventTarget, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle
{
private int _imageWidth;
private int _imageHeight;
private bool _loaded;
public string Source {
get {
return GetAttribute(AttributeNames.Src);
}
set {
SetAttribute(AttributeNames.Src, value);
}
}
public string AlternativeText {
get {
return GetAttribute(AttributeNames.Alt);
}
set {
SetAttribute(AttributeNames.Alt, value);
}
}
public string CrossOrigin {
get {
return GetAttribute(AttributeNames.CrossOrigin);
}
set {
SetAttribute(AttributeNames.CrossOrigin, value);
}
}
public string UseMap {
get {
return GetAttribute(AttributeNames.UseMap);
}
set {
SetAttribute(AttributeNames.UseMap, value);
}
}
public int DisplayWidth {
get {
return GetAttribute(AttributeNames.Width).ToInteger(_imageWidth);
}
set {
SetAttribute(AttributeNames.Width, value.ToString());
}
}
public int DisplayHeight {
get {
return GetAttribute(AttributeNames.Height).ToInteger(_imageHeight);
}
set {
SetAttribute(AttributeNames.Height, value.ToString());
}
}
public int OriginalWidth => _imageWidth;
public int OriginalHeight => _imageHeight;
public bool IsCompleted => _loaded;
public bool IsMap {
get {
return GetAttribute(AttributeNames.IsMap) != null;
}
set {
SetAttribute(AttributeNames.IsMap, value ? string.Empty : null);
}
}
internal HTMLImageElement()
: base(Tags.Img, NodeFlags.SelfClosing | NodeFlags.Special)
{
_loaded = true;
_imageHeight = 0;
_imageWidth = 0;
}
}
}