HTMLBlinkElement.cpp 755 B

1234567891011121314151617181920212223242526272829303132333435
  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, 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()
  19. {
  20. }
  21. void HTMLBlinkElement::blink()
  22. {
  23. if (!layout_node())
  24. return;
  25. layout_node()->set_visible(!layout_node()->is_visible());
  26. layout_node()->set_needs_display();
  27. }
  28. }