MediaQueryList.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. /*
  2. * Copyright (c) 2021, Linus Groh <linusg@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibWeb/Bindings/MediaQueryListWrapper.h>
  7. #include <LibWeb/CSS/MediaQueryList.h>
  8. #include <LibWeb/DOM/Document.h>
  9. #include <LibWeb/DOM/EventDispatcher.h>
  10. namespace Web::CSS {
  11. MediaQueryList::MediaQueryList(DOM::Document& document, String media)
  12. : DOM::EventTarget(static_cast<Bindings::ScriptExecutionContext&>(document))
  13. , m_document(document)
  14. , m_media(move(media))
  15. {
  16. }
  17. MediaQueryList::~MediaQueryList()
  18. {
  19. }
  20. // https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-media
  21. String MediaQueryList::media() const
  22. {
  23. // TODO: Replace this with a "media query list" and serialize on demand
  24. return m_media;
  25. }
  26. // https://drafts.csswg.org/cssom-view/#dom-mediaquerylist-matches
  27. bool MediaQueryList::matches() const
  28. {
  29. // TODO: Implement me :^)
  30. return false;
  31. }
  32. bool MediaQueryList::dispatch_event(NonnullRefPtr<DOM::Event> event)
  33. {
  34. return DOM::EventDispatcher::dispatch(*this, event);
  35. }
  36. JS::Object* MediaQueryList::create_wrapper(JS::GlobalObject& global_object)
  37. {
  38. return wrap(global_object, *this);
  39. }
  40. }