jezhiggins/arabica — pull request #1 by sradomski (2012-12-30 00:24:53+00:00)
Title: First signs of DOM Level2 Events

Hey Jez,

as discussed per mail, I started to implement DOM Level2 events. The implementation is still rather pragmatic and incomplete and I don't expect you to accept the pull request.

But please have a look at what I did with regard to the class structure and tell me what you'd like to change in order to fit into arabica. I tried to stick to the idioms established in the DocumentTraversal class. The API is something like this for now:

// instantiate an eventtarget from a dom node
Arabica::DOM::Events::EventTarget<std::string> evTarget =
Arabica::DOM::Events::EventTarget<std::string>(someNode);
evTarget.addEventListener("DOMSubtreeModified", *this, true);

// another one from the nodes parent
Arabica::DOM::Events::EventTarget<std::string> evTarget2 =
Arabica::DOM::Events::EventTarget<std::string>(someNode.getParentNode());
evTarget2.addEventListener("DOMSubtreeModified", *this, true);

// create a MutationEvent
Arabica::DOM::Events::MutationEvent<std::string>
me(someNode.getOwnerDocument().createEvent("MutationEvent"));
me.initMutationEvent("DOMSubtreeModified", true, false, Arabica::DOM::Node<std::string>(),
"", "", "", Arabica::DOM::Events::MutationEvent<std::string>::MODIFICATION);

// dispatch the event on the first event target
evTarget.dispatchEvent(me);

I am sure I missed quite a few things and it is not yet anywhere near standard compliant, but please have a look at the class structure.
Stefan