HtmlObjectElement
sealed class HtmlObjectElement : HtmlFormControlElement, IHtmlObjectElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle, IGlobalEventHandlers, IValidation, ILoadableElement
Represents the HTML object element.
using AngleSharp.Dom.Css;
using AngleSharp.Dom.Events;
using AngleSharp.Extensions;
using AngleSharp.Html;
using AngleSharp.Network;
using AngleSharp.Network.RequestProcessors;
namespace AngleSharp.Dom.Html
{
internal sealed class HtmlObjectElement : HtmlFormControlElement, IHtmlObjectElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle, IGlobalEventHandlers, IValidation, ILoadableElement
{
private readonly ObjectRequestProcessor _request;
public IDownload CurrentDownload => _request?.Download;
public string Source {
get {
return this.GetUrlAttribute(AttributeNames.Data);
}
set {
this.SetOwnAttribute(AttributeNames.Data, value, false);
}
}
public string Type {
get {
return this.GetOwnAttribute(AttributeNames.Type);
}
set {
this.SetOwnAttribute(AttributeNames.Type, value, false);
}
}
public bool TypeMustMatch {
get {
return this.GetBoolAttribute(AttributeNames.TypeMustMatch);
}
set {
this.SetBoolAttribute(AttributeNames.TypeMustMatch, value);
}
}
public string UseMap {
get {
return this.GetOwnAttribute(AttributeNames.UseMap);
}
set {
this.SetOwnAttribute(AttributeNames.UseMap, value, false);
}
}
public int DisplayWidth {
get {
return this.GetOwnAttribute(AttributeNames.Width).ToInteger(OriginalWidth);
}
set {
this.SetOwnAttribute(AttributeNames.Width, value.ToString(), false);
}
}
public int DisplayHeight {
get {
return this.GetOwnAttribute(AttributeNames.Height).ToInteger(OriginalHeight);
}
set {
this.SetOwnAttribute(AttributeNames.Height, value.ToString(), false);
}
}
public int OriginalWidth => _request?.Width ?? 0;
public int OriginalHeight => _request?.Height ?? 0;
public IDocument ContentDocument => null;
public IWindow ContentWindow => null;
public HtmlObjectElement(Document owner, string prefix = null)
: base(owner, TagNames.Object, prefix, NodeFlags.Scoped)
{
_request = ObjectRequestProcessor.Create(this);
}
protected override bool CanBeValidated()
{
return false;
}
internal override void SetupElement()
{
base.SetupElement();
string ownAttribute = this.GetOwnAttribute(AttributeNames.Data);
if (ownAttribute != null)
UpdateSource(ownAttribute);
}
internal void UpdateSource(string value)
{
Url url = new Url(Source);
this.Process(_request, url);
}
}
}