CssMediaQueryList
Represents the class implementing a media query list for notifications.
using AngleSharp.Dom.Events;
using AngleSharp.Html;
namespace AngleSharp.Dom.Css
{
internal sealed class CssMediaQueryList : EventTarget, IMediaQueryList, IEventTarget
{
private readonly IMediaList _media;
private bool _matched;
public string MediaText => _media.MediaText;
public IMediaList Media => _media;
public bool IsMatched => _matched;
public event DomEventHandler Changed {
add {
AddEventListener(EventNames.Change, value, false);
}
remove {
RemoveEventListener(EventNames.Change, value, false);
}
}
public CssMediaQueryList(IWindow window, IMediaList media)
{
_media = media;
_matched = ComputeMatched(window);
window.Resized += Resized;
}
private bool ComputeMatched(IWindow window)
{
return false;
}
private void Resized(object sender, Event ev)
{
IWindow window = (IWindow)sender;
bool flag = ComputeMatched(window);
if (flag != _matched) {
MediaQueryListEvent ev2 = new MediaQueryListEvent(EventNames.Change, false, false, _media.MediaText, flag);
Dispatch(ev2);
}
_matched = flag;
}
}
}