HTMLBlinkElement.cpp 827 B

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <LibCore/Timer.h>
  7. #include <LibWeb/CSS/StyleProperties.h>
  8. #include <LibWeb/CSS/StyleValue.h>
  9. #include <LibWeb/HTML/HTMLBlinkElement.h>
  10. #include <LibWeb/Layout/Node.h>
  11. namespace Web::HTML {
  12. HTMLBlinkElement::HTMLBlinkElement(DOM::Document& document, QualifiedName qualified_name)
  13. : HTMLElement(document, move(qualified_name))
  14. , m_timer(Core::Timer::construct())
  15. {
  16. m_timer->set_interval(500);
  17. m_timer->on_timeout = [this] { blink(); };
  18. m_timer->start();
  19. }
  20. HTMLBlinkElement::~HTMLBlinkElement()
  21. {
  22. }
  23. void HTMLBlinkElement::blink()
  24. {
  25. if (!layout_node())
  26. return;
  27. layout_node()->set_visible(!layout_node()->is_visible());
  28. layout_node()->set_needs_display();
  29. }
  30. }