ladybird/Userland/Libraries/LibWeb/DOM/Event.cpp
Brian Gianforcaro 1682f0b760 Everything: Move to SPDX license identifiers in all files.
SPDX License Identifiers are a more compact / standardized
way of representing file license information.

See: https://spdx.dev/resources/use/#identifiers

This was done with the `ambr` search and replace tool.

 ambr --no-parent-ignore --key-from-file --rep-from-file key.txt rep.txt *
2021-04-22 11:22:27 +02:00

62 lines
1.9 KiB
C++

/*
* Copyright (c) 2020, the SerenityOS developers.
*
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <AK/Assertions.h>
#include <AK/TypeCasts.h>
#include <LibWeb/DOM/Event.h>
#include <LibWeb/DOM/Node.h>
#include <LibWeb/DOM/ShadowRoot.h>
namespace Web::DOM {
void Event::append_to_path(EventTarget& invocation_target, RefPtr<EventTarget> shadow_adjusted_target, RefPtr<EventTarget> related_target, TouchTargetList& touch_targets, bool slot_in_closed_tree)
{
bool invocation_target_in_shadow_tree = false;
bool root_of_closed_tree = false;
if (is<Node>(invocation_target)) {
auto& invocation_target_node = downcast<Node>(invocation_target);
if (is<ShadowRoot>(invocation_target_node.root()))
invocation_target_in_shadow_tree = true;
if (is<ShadowRoot>(invocation_target_node)) {
auto& invocation_target_shadow_root = downcast<ShadowRoot>(invocation_target_node);
root_of_closed_tree = invocation_target_shadow_root.closed();
}
}
m_path.append({ invocation_target, invocation_target_in_shadow_tree, shadow_adjusted_target, related_target, touch_targets, root_of_closed_tree, slot_in_closed_tree, m_path.size() });
}
void Event::set_cancelled_flag()
{
if (m_cancelable && !m_in_passive_listener)
m_cancelled = true;
}
// https://dom.spec.whatwg.org/#concept-event-initialize
void Event::initialize(const String& type, bool bubbles, bool cancelable)
{
m_initialized = true;
m_stop_propagation = false;
m_stop_immediate_propagation = false;
m_cancelled = false;
m_is_trusted = false;
m_target = nullptr;
m_type = type;
m_bubbles = bubbles;
m_cancelable = cancelable;
}
// https://dom.spec.whatwg.org/#dom-event-initevent
void Event::init_event(const String& type, bool bubbles, bool cancelable)
{
if (m_dispatch)
return;
initialize(type, bubbles, cancelable);
}
}