AngleSharp by Florian Rappl

<PackageReference Include="AngleSharp" Version="0.8.5" />

.NET API 1,113,600 bytes

 HtmlIFrameElement

Represents the HTML iframe element.
using AngleSharp.Dom.Collections; using AngleSharp.Dom.Css; using AngleSharp.Extensions; using AngleSharp.Html; using AngleSharp.Network; using System.Threading; using System.Threading.Tasks; namespace AngleSharp.Dom.Html { internal sealed class HtmlIFrameElement : HtmlFrameElementBase, IHtmlInlineFrameElement, IHtmlElement, IElement, INode, IEventTarget, IMarkupFormattable, IParentNode, IChildNode, INonDocumentTypeChildNode, IElementCssInlineStyle { private readonly IBrowsingContext _context; private SettableTokenList _sandbox; private Task _current; public Alignment Align { get { return GetOwnAttribute(AttributeNames.Align).ToEnum(Alignment.Bottom); } set { SetOwnAttribute(AttributeNames.Align, value.ToString()); } } public string ContentHtml { get { return GetOwnAttribute(AttributeNames.SrcDoc); } set { SetOwnAttribute(AttributeNames.SrcDoc, value); } } public ISettableTokenList Sandbox { get { if (_sandbox == null) { _sandbox = new SettableTokenList(GetOwnAttribute(AttributeNames.Sandbox)); _sandbox.Changed += delegate { UpdateAttribute(AttributeNames.Sandbox, _sandbox.Value); }; } return _sandbox; } } public bool IsSeamless { get { return GetOwnAttribute(AttributeNames.SrcDoc) != null; } set { SetOwnAttribute(AttributeNames.SrcDoc, value ? string.Empty : null); } } public bool IsFullscreenAllowed { get { return GetOwnAttribute(AttributeNames.AllowFullscreen) != null; } set { SetOwnAttribute(AttributeNames.AllowFullscreen, value ? string.Empty : null); } } public IWindow ContentWindow => _context.Current; public HtmlIFrameElement(Document owner, string prefix = null) : base(owner, Tags.Iframe, prefix, NodeFlags.LiteralText) { _context = owner.NewChildContext(Sandboxes.None); RegisterAttributeObserver(AttributeNames.Src, UpdateSource); } private void UpdateSource(string src) { base.Owner.Tasks.Cancel(_current); if (!string.IsNullOrEmpty(src)) { Url target = this.HyperReference(src); DocumentRequest request = new DocumentRequest(target) { Source = this, Referer = base.Owner.DocumentUri }; _current = base.Owner.Tasks.Add((CancellationToken cancel) => _context.OpenAsync(request, cancel)); _current.ContinueWith((Task m) => this.FireSimpleEvent(EventNames.Load, false, false)); } } } }