Commit 4f575515 authored by hayato@chromium.org's avatar hayato@chromium.org

Don't emptify event.path after dispatching an event.

BUG=402749

Review URL: https://codereview.chromium.org/473833002

git-svn-id: svn://svn.chromium.org/blink/trunk@180284 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 16417ad1
Makes sure that event.path is empty before dispatching the event.
length: 0
#b, #a, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], length: 5
Makes sure that event.path returns static NodeList.
#b, #a, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], length: 5
Makes sure that event.path isn't emptified after dispatching the event.
#b, #a, [object HTMLBodyElement], [object HTMLHtmlElement], [object HTMLDocument], length: 5
PASS successfullyParsed is true
TEST COMPLETE
......
......@@ -24,8 +24,12 @@ b.addEventListener('click', function(event) {
debug(dumpNodeList(event.path));
});
var clickEvent = document.createEvent("MouseEvents");
debug("Makes sure that event.path is empty before dispatching the event.");
debug(dumpNodeList(clickEvent.path));
clickEvent.initMouseEvent('click', true, false, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
b.dispatchEvent(clickEvent);
debug("Makes sure that event.path isn't emptified after dispatching the event.");
debug(dumpNodeList(clickEvent.path));
</script>
</body>
</html>
......@@ -224,7 +224,17 @@ EventPath& Event::ensureEventPath()
PassRefPtrWillBeRawPtr<StaticNodeList> Event::path() const
{
if (!m_currentTarget || !m_currentTarget->toNode())
if (!m_currentTarget) {
ASSERT(m_eventPhase == PhaseType::NONE);
if (!m_eventPath) {
// Before dispatching the event
return StaticNodeList::createEmpty();
}
ASSERT(!m_eventPath->isEmpty());
// After dispatching the event
return m_eventPath->last().treeScopeEventContext().ensureEventPath(*m_eventPath);
}
if (!m_currentTarget->toNode())
return StaticNodeList::createEmpty();
Node* node = m_currentTarget->toNode();
// FIXME: Support SVG Elements.
......
......@@ -55,7 +55,7 @@ public:
NodeEventContext& operator[](size_t index) { return m_nodeEventContexts[index]; }
const NodeEventContext& operator[](size_t index) const { return m_nodeEventContexts[index]; }
const NodeEventContext& last() const { return m_nodeEventContexts[size() - 1]; }
NodeEventContext& last() { return m_nodeEventContexts[size() - 1]; }
bool isEmpty() const { return m_nodeEventContexts.isEmpty(); }
size_t size() const { return m_nodeEventContexts.size(); }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment