1//
2// Event.cpp
3//
4// Library: XML
5// Package: DOM
6// Module: DOMEvents
7//
8// Copyright (c) 2004-2006, Applied Informatics Software Engineering GmbH.
9// and Contributors.
10//
11// SPDX-License-Identifier: BSL-1.0
12//
13
14
15#include "Poco/DOM/Event.h"
16#include "Poco/DOM/Document.h"
17
18
19namespace Poco {
20namespace XML {
21
22
23Event::Event(Document* pOwnerDocument, const XMLString& type):
24 _pOwner(pOwnerDocument),
25 _type(type),
26 _pTarget(0),
27 _pCurrentTarget(0),
28 _currentPhase(CAPTURING_PHASE),
29 _bubbles(true),
30 _cancelable(true),
31 _canceled(false),
32 _stopped(false)
33{
34}
35
36
37Event::Event(Document* pOwnerDocument, const XMLString& type, EventTarget* pTarget, bool canBubble, bool isCancelable):
38 _pOwner(pOwnerDocument),
39 _type(type),
40 _pTarget(pTarget),
41 _pCurrentTarget(0),
42 _currentPhase(CAPTURING_PHASE),
43 _bubbles(canBubble),
44 _cancelable(isCancelable),
45 _canceled(false),
46 _stopped(false)
47{
48}
49
50
51Event::~Event()
52{
53}
54
55
56void Event::stopPropagation()
57{
58 _stopped = true;
59}
60
61
62void Event::preventDefault()
63{
64 _canceled = true;
65}
66
67
68void Event::initEvent(const XMLString& eventType, bool canBubble, bool isCancelable)
69{
70 _type = eventType;
71 _bubbles = canBubble;
72 _cancelable = isCancelable;
73 _canceled = false;
74 _stopped = false;
75}
76
77
78void Event::setTarget(EventTarget* pTarget)
79{
80 _pTarget = pTarget;
81}
82
83
84void Event::setCurrentPhase(PhaseType phase)
85{
86 _currentPhase = phase;
87}
88
89
90void Event::setCurrentTarget(EventTarget* pTarget)
91{
92 _pCurrentTarget = pTarget;
93}
94
95
96void Event::autoRelease()
97{
98 _pOwner->autoReleasePool().add(this);
99}
100
101
102} } // namespace Poco::XML
103