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