From c6fa24ff07b892160a5dc366354145e6c9860cd9 Mon Sep 17 00:00:00 2001 From: "hayato@chromium.org" Date: Tue, 17 Jan 2012 03:56:16 +0000 Subject: [PATCH] Implement multiple AT_TARGET event dispatching in regard to shadow tree. https://bugs.webkit.org/show_bug.cgi?id=76217 Reviewed by Dimitri Glazkov. The original motivation is to fix the regression: Event.eventPhase is not set to 2 (at target) when handling dblclick event in element. Since the issue is not specific to element, but general one, this patch fixes the regression by adapting a living draft spec of shadow DOM. This won't break a compatibility if there is no shadow boundaries in event dispatching. See the following shadow dom spec how multiple AT_TARGET events work. http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#event-dispatch Source/WebCore: * dom/EventContext.cpp: (WebCore::EventContext::handleLocalEvents): LayoutTests: * fast/dom/shadow/shadow-boundary-events-expected.txt: * fast/dom/shadow/shadow-boundary-events.html: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@105123 268f45cc-cd09-0410-ab3c-d52691b4dbfc --- LayoutTests/ChangeLog | 18 ++++++++++++++++++ .../dom/shadow/shadow-boundary-events-expected.txt | 4 ++-- .../fast/dom/shadow/shadow-boundary-events.html | 6 ++++-- Source/WebCore/ChangeLog | 18 ++++++++++++++++++ Source/WebCore/dom/EventContext.cpp | 7 +++++++ 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog index 8db3ced..7311624 100644 --- a/LayoutTests/ChangeLog +++ b/LayoutTests/ChangeLog @@ -1,3 +1,21 @@ +2012-01-16 Hayato Ito + + Implement multiple AT_TARGET event dispatching in regard to shadow tree. + https://bugs.webkit.org/show_bug.cgi?id=76217 + + Reviewed by Dimitri Glazkov. + + The original motivation is to fix the regression: Event.eventPhase is not set to 2 + (at target) when handling dblclick event in element. + Since the issue is not specific to element, but general one, this patch fixes + the regression by adapting a living draft spec of shadow DOM. + This won't break a compatibility if there is no shadow boundaries in event dispatching. + See the following shadow dom spec how multiple AT_TARGET events work. + http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#event-dispatch + + * fast/dom/shadow/shadow-boundary-events-expected.txt: + * fast/dom/shadow/shadow-boundary-events.html: + 2012-01-16 Robert Hogan Heap-use-after-free in WebCore::RenderBlock::selectionGaps diff --git a/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt b/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt index 6c465ca..9a5f9db 100644 --- a/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt +++ b/LayoutTests/fast/dom/shadow/shadow-boundary-events-expected.txt @@ -76,8 +76,8 @@ PASS dispatchedEvent("blur") is ["divB(@divA)(capturing phase)", "divB(@divB)"] Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary. Moving focus from shadowD/shadowF/shadowG/divH to shadowD/shadowK/divL -PASS dispatchedEvent("focus") is ["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)(capturing phase)", "divL(@divL)"] -PASS dispatchedEvent("blur") is ["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)(capturing phase)", "shadowG(@shadowG)(capturing phase)", "divH(@divH)"] +PASS dispatchedEvent("focus") is ["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)", "divL(@divL)"] +PASS dispatchedEvent("blur") is ["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)", "shadowG(@shadowG)", "divH(@divH)"] PASS successfullyParsed is true TEST COMPLETE diff --git a/LayoutTests/fast/dom/shadow/shadow-boundary-events.html b/LayoutTests/fast/dom/shadow/shadow-boundary-events.html index da62efd..f0630c7 100644 --- a/LayoutTests/fast/dom/shadow/shadow-boundary-events.html +++ b/LayoutTests/fast/dom/shadow/shadow-boundary-events.html @@ -59,6 +59,8 @@ function recordEvent(event) eventString += '(@' + event.currentTarget.id + ')'; if (event.eventPhase == 1) eventString += '(capturing phase)'; + if (event.target && event.currentTarget && event.target.id == event.currentTarget.id) + shouldBe("event.eventPhase", "2", true); eventRecords[eventType].push(eventString); } @@ -204,8 +206,8 @@ function test() moveFocus('shadowD/shadowF/shadowG/divH', 'shadowD/shadowK/divL', 'Old focused node and new focused node exist in separated subtrees, crossing shadow boundaries. Making sure that an event is not dispatched beyond the lowest common boundary.'); - shouldBe('dispatchedEvent("focus")', '["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)(capturing phase)", "divL(@divL)"]'); - shouldBe('dispatchedEvent("blur")', '["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)(capturing phase)", "shadowG(@shadowG)(capturing phase)", "divH(@divH)"]'); + shouldBe('dispatchedEvent("focus")', '["shadowK(@divJ)(capturing phase)", "shadowK(@shadowK)", "divL(@divL)"]'); + shouldBe('dispatchedEvent("blur")', '["shadowF(@divE)(capturing phase)", "shadowF(@shadowF)", "shadowG(@shadowG)", "divH(@divH)"]'); } test(); diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog index 02e0d70..0a3648a 100644 --- a/Source/WebCore/ChangeLog +++ b/Source/WebCore/ChangeLog @@ -1,3 +1,21 @@ +2012-01-16 Hayato Ito + + Implement multiple AT_TARGET event dispatching in regard to shadow tree. + https://bugs.webkit.org/show_bug.cgi?id=76217 + + Reviewed by Dimitri Glazkov. + + The original motivation is to fix the regression: Event.eventPhase is not set to 2 + (at target) when handling dblclick event in element. + Since the issue is not specific to element, but general one, this patch fixes + the regression by adapting a living draft spec of shadow DOM. + This won't break a compatibility if there is no shadow boundaries in event dispatching. + See the following shadow dom spec how multiple AT_TARGET events work. + http://dvcs.w3.org/hg/webcomponents/raw-file/tip/spec/shadow/index.html#event-dispatch + + * dom/EventContext.cpp: + (WebCore::EventContext::handleLocalEvents): + 2012-01-16 Jason Liu platformRequest(QNX) need to get the conditional information from ResourceRequest. diff --git a/Source/WebCore/dom/EventContext.cpp b/Source/WebCore/dom/EventContext.cpp index 2a5c521..dba46af 100644 --- a/Source/WebCore/dom/EventContext.cpp +++ b/Source/WebCore/dom/EventContext.cpp @@ -43,9 +43,16 @@ EventContext::EventContext(PassRefPtr node, PassRefPtr curren void EventContext::handleLocalEvents(Event* event) const { + unsigned short eventPhase = event->eventPhase(); + if (m_target.get() == m_currentTarget.get()) { + if (eventPhase == Event::CAPTURING_PHASE && event->bubbles()) + return; + event->setEventPhase(Event::AT_TARGET); + } event->setTarget(m_target.get()); event->setCurrentTarget(m_currentTarget.get()); m_node->handleLocalEvents(event); + event->setEventPhase(eventPhase); } } -- 2.7.4