HTMLBlinkElement.cpp 767 B

123456789101112131415161718192021222324252627282930313233
  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/StyleValue.h>
  8. #include <LibWeb/HTML/HTMLBlinkElement.h>
  9. namespace Web::HTML {
  10. HTMLBlinkElement::HTMLBlinkElement(DOM::Document& document, DOM::QualifiedName qualified_name)
  11. : HTMLElement(document, move(qualified_name))
  12. , m_timer(Core::Timer::construct())
  13. {
  14. m_timer->set_interval(500);
  15. m_timer->on_timeout = [this] { blink(); };
  16. m_timer->start();
  17. }
  18. HTMLBlinkElement::~HTMLBlinkElement() = default;
  19. void HTMLBlinkElement::blink()
  20. {
  21. if (!layout_node())
  22. return;
  23. layout_node()->set_visible(!layout_node()->is_visible());
  24. layout_node()->set_needs_display();
  25. }
  26. }