Skip to content
Permalink
Browse files
WebKit does not support DOM 3 Events FocusEvent
https://bugs.webkit.org/show_bug.cgi?id=76216

Source/WebCore:

Created a new FocusEvent class (extends UIEvent) with a relatedTarget attribute.  Moved
the {Focus,Blur,FocusIn,FocusOut}EventDispatchMediator classes inside FocusEvent.  Now when
focusin or focusout events are dispatched, a FocusEvent is created with the relatedTarget
attribute set accordingly.  No other logic changes have been made besides adding the
FocusEvent class.

Patch by Terry Anderson <tdanderson@chromium.org> on 2012-02-16
Reviewed by Eric Seidel.

Test: fast/events/related-target-focusevent.html

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
    - Included mention of FocusEvent / JSFocusEvent in the above files to
      allow the patch to build on the different platforms
* dom/EventDispatchMediator.cpp:
* dom/EventDispatchMediator.h:
* dom/EventFactory.in:
* dom/FocusEvent.cpp: Added.
(WebCore):
(WebCore::FocusEvent::FocusEvent):
(WebCore::FocusEvent::~FocusEvent):
(WebCore::FocusEvent::initFocusEvent):
(WebCore::FocusEvent::interfaceName):
(WebCore::FocusInEventDispatchMediator::create):
(WebCore::FocusInEventDispatchMediator::FocusInEventDispatchMediator):
(WebCore::FocusInEventDispatchMediator::dispatchEvent):
(WebCore::FocusInEventDispatchMediator::event):
(WebCore::FocusOutEventDispatchMediator::create):
(WebCore::FocusOutEventDispatchMediator::FocusOutEventDispatchMediator):
(WebCore::FocusOutEventDispatchMediator::dispatchEvent):
(WebCore::FocusOutEventDispatchMediator::event):
(WebCore::FocusEventDispatchMediator::create):
(WebCore::FocusEventDispatchMediator::FocusEventDispatchMediator):
(WebCore::FocusEventDispatchMediator::dispatchEvent):
(WebCore::BlurEventDispatchMediator::create):
(WebCore::BlurEventDispatchMediator::BlurEventDispatchMediator):
(WebCore::BlurEventDispatchMediator::dispatchEvent):
* dom/FocusEvent.h: Copied from Source/WebCore/dom/EventDispatchMediator.h.
(WebCore):
(FocusEvent):
(WebCore::FocusEvent::create):
(WebCore::FocusEvent::relatedTarget):
(WebCore::FocusEvent::setRelatedTarget):
(FocusInEventDispatchMediator):
(FocusOutEventDispatchMediator):
(FocusEventDispatchMediator):
(BlurEventDispatchMediator):
* dom/FocusEvent.idl: Added.
* dom/Node.cpp:
(WebCore::Node::dispatchFocusInEvent):
(WebCore::Node::dispatchFocusOutEvent):
* dom/UIEvent.cpp:
* dom/UIEvent.h:
* page/DOMWindow.idl:

LayoutTests:

Patch by Terry Anderson <tdanderson@chromium.org> on 2012-02-16
Reviewed by Eric Seidel.

* fast/dom/shadow/shadow-boundary-events-expected.txt:
* fast/dom/shadow/shadow-boundary-events.html:
    - Changed the focusin/focusout parts of this layout test to include the
      relatedTarget attribute, which is now set on FocusEvent objects
* fast/events/event-creation-expected.txt:
* fast/events/event-creation.html:
    - Added the creation of FocusEvents to this layout test
* fast/events/related-target-focusevent-expected.txt: Added.
* fast/events/related-target-focusevent.html: Added.
    - This is a new layout test I created specifically for this patch

Canonical link: https://commits.webkit.org/95788@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@107952 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
tdanderson authored and webkit-commit-queue committed Feb 16, 2012
1 parent 4c86f57 commit 5e4056bd2f1b0594fca93685b1c03e3b865c7c5e
@@ -1,3 +1,21 @@
2012-02-16 Terry Anderson <tdanderson@chromium.org>

WebKit does not support DOM 3 Events FocusEvent
https://bugs.webkit.org/show_bug.cgi?id=76216

Reviewed by Eric Seidel.

* fast/dom/shadow/shadow-boundary-events-expected.txt:
* fast/dom/shadow/shadow-boundary-events.html:
- Changed the focusin/focusout parts of this layout test to include the
relatedTarget attribute, which is now set on FocusEvent objects
* fast/events/event-creation-expected.txt:
* fast/events/event-creation.html:
- Added the creation of FocusEvents to this layout test
* fast/events/related-target-focusevent-expected.txt: Added.
* fast/events/related-target-focusevent.html: Added.
- This is a new layout test I created specifically for this patch

2012-02-16 Philippe Normand <pnormand@igalia.com>

Unreviewed, GTK baselines for new SVG and fast/ tests.
@@ -61,13 +61,13 @@ PASS dispatchedEvent("mouseout") is ["divH(<-shadowK)(@divH)", "shadowG(<-shadow

Move focus from a node to its sibling node. All nodes are outside of shadow boundary.
Moving focus from divB to divC
PASS dispatchedEvent("focusin") is ["divC(@divC)", "divC(@divA)"]
PASS dispatchedEvent("focusout") is ["divB(@divB)", "divB(@divA)"]
PASS dispatchedEvent("focusin") is ["divC(<-divB)(@divC)", "divC(<-divB)(@divA)"]
PASS dispatchedEvent("focusout") is ["divB(<-divC)(@divB)", "divB(<-divC)(@divA)"]

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("focusin") is ["divL(@divL)", "shadowK(@shadowK)", "shadowK(@divJ)"]
PASS dispatchedEvent("focusout") is ["divH(@divH)", "shadowG(@shadowG)", "shadowF(@shadowF)", "shadowF(@divE)"]
PASS dispatchedEvent("focusin") is ["divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)", "shadowK(<-shadowF)(@divJ)"]
PASS dispatchedEvent("focusout") is ["divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)", "shadowF(<-shadowK)(@divE)"]

Move focus from a node to its sibling node. All nodes are outside of shadow boundary.
Moving focus from divB to divC
@@ -187,13 +187,13 @@
// Test for focusin/focusout events.
moveFocus('divB', 'divC',
'Move focus from a node to its sibling node. All nodes are outside of shadow boundary.');
shouldBe('dispatchedEvent("focusin")', '["divC(@divC)", "divC(@divA)"]');
shouldBe('dispatchedEvent("focusout")', '["divB(@divB)", "divB(@divA)"]');
shouldBe('dispatchedEvent("focusin")', '["divC(<-divB)(@divC)", "divC(<-divB)(@divA)"]');
shouldBe('dispatchedEvent("focusout")', '["divB(<-divC)(@divB)", "divB(<-divC)(@divA)"]');

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("focusin")', '["divL(@divL)", "shadowK(@shadowK)", "shadowK(@divJ)"]');
shouldBe('dispatchedEvent("focusout")', '["divH(@divH)", "shadowG(@shadowG)", "shadowF(@shadowF)", "shadowF(@divE)"]');
shouldBe('dispatchedEvent("focusin")', '["divL(<-shadowF)(@divL)", "shadowK(<-shadowF)(@shadowK)", "shadowK(<-shadowF)(@divJ)"]');
shouldBe('dispatchedEvent("focusout")', '["divH(<-shadowK)(@divH)", "shadowG(<-shadowK)(@shadowG)", "shadowF(<-shadowK)(@shadowF)", "shadowF(<-shadowK)(@divE)"]');

// Omitted test cases where either a oldFocusedNode or newFocusedNode is an ancestor of the other.
// Due to a focus transfer mechanism on shadow hosts, a focused node should be a leaf node in general.
@@ -21,6 +21,10 @@ PASS document.createEvent('CustomEvent').constructor === window.CustomEvent is t
PASS document.createEvent('ErrorEvent') instanceof window.ErrorEvent is true
PASS document.createEvent('ErrorEvent') instanceof window.Event is true
PASS document.createEvent('ErrorEvent').constructor === window.ErrorEvent is true
PASS document.createEvent('FocusEvent') instanceof window.FocusEvent is true
PASS document.createEvent('FocusEvent') instanceof window.UIEvent is true
PASS document.createEvent('FocusEvent') instanceof window.Event is true
PASS document.createEvent('FocusEvent').constructor === window.FocusEvent is true
PASS document.createEvent('HashChangeEvent') instanceof window.HashChangeEvent is true
PASS document.createEvent('HashChangeEvent') instanceof window.Event is true
PASS document.createEvent('HashChangeEvent').constructor === window.HashChangeEvent is true
@@ -37,6 +37,12 @@
shouldBeTrue("document.createEvent('ErrorEvent') instanceof window.Event");
shouldBeTrue("document.createEvent('ErrorEvent').constructor === window.ErrorEvent");

// FocusEvent
shouldBeTrue("document.createEvent('FocusEvent') instanceof window.FocusEvent");
shouldBeTrue("document.createEvent('FocusEvent') instanceof window.UIEvent");
shouldBeTrue("document.createEvent('FocusEvent') instanceof window.Event");
shouldBeTrue("document.createEvent('FocusEvent').constructor === window.FocusEvent");

// HashChangeEvent
shouldBeTrue("document.createEvent('HashChangeEvent') instanceof window.HashChangeEvent");
shouldBeTrue("document.createEvent('HashChangeEvent') instanceof window.Event");
@@ -0,0 +1,21 @@
Layout test for https://bugs.webkit.org/show_bug.cgi?id=76216. Checks that the relatedTarget attribute for FocusEvent objects is being set correctly when focusin/focusout events are dispatched. Press tab four times to dispatch a focusin and focusout event for each of the buttons below.

Meow Purr Fur! Done
Expected Result

Meow received focusin, its relatedTarget is null
Meow received focusout, its relatedTarget is Purr
Purr received focusin, its relatedTarget is Meow
Purr received focusout, its relatedTarget is Fur!
Fur! received focusin, its relatedTarget is Purr
Fur! received focusout, its relatedTarget is Done

Actual Result

Meow received focusin, its relatedTarget is null
Meow received focusout, its relatedTarget is Purr
Purr received focusin, its relatedTarget is Meow
Purr received focusout, its relatedTarget is Fur!
Fur! received focusin, its relatedTarget is Purr
Fur! received focusout, its relatedTarget is Done

@@ -0,0 +1,73 @@
<html>
<head>
<script>

function log(msg)
{
document.getElementById('log').appendChild(document.createTextNode(msg + '\n'));
}

function test()
{
if (window.layoutTestController)
layoutTestController.dumpAsText();

var INEVENT = "focusin";
var OUTEVENT = "focusout";

var b1 = document.getElementById('button1');
var b2 = document.getElementById('button2');
var b3 = document.getElementById('button3');

b1.addEventListener(INEVENT, TestInEvent, true);
b2.addEventListener(INEVENT, TestInEvent, true);
b3.addEventListener(INEVENT, TestInEvent, true);

b1.addEventListener(OUTEVENT, TestOutEvent, true);
b2.addEventListener(OUTEVENT, TestOutEvent, true);
b3.addEventListener(OUTEVENT, TestOutEvent, true);

if (!window.layoutTestController)
return;

for (var i = 0; i < 4; i++)
eventSender.keyDown('\t');
}

function TestInEvent(evt)
{
if (evt.relatedTarget)
log(evt.target.innerText + " received focusin, its relatedTarget is " + evt.relatedTarget.innerText);
else
log(evt.target.innerText + " received focusin, its relatedTarget is " + evt.relatedTarget);
}

function TestOutEvent(evt)
{
if (evt.relatedTarget)
log(evt.target.innerText + " received focusout, its relatedTarget is " + evt.relatedTarget.innerText);
else
log(evt.target.innerText + " received focusout, its relatedTarget is " + evt.relatedTarget);

}
</script>
</head>
<body onload="test()">
<p>Layout test for <a href="https://bugs.webkit.org/show_bug.cgi?id=76216" tabindex=-1>https://bugs.webkit.org/show_bug.cgi?id=76216</a>. Checks that the relatedTarget attribute for FocusEvent objects is being set correctly when focusin/focusout events are dispatched. <b>Press tab four times</b> to dispatch a focusin and focusout event for each of the buttons below.</p>
<button id="button1">Meow</button>
<button id="button2">Purr</button>
<button id="button3">Fur!</button>
<button id="inputdone">Done</button>
<p>Expected Result</p>
<pre>
Meow received focusin, its relatedTarget is null
Meow received focusout, its relatedTarget is Purr
Purr received focusin, its relatedTarget is Meow
Purr received focusout, its relatedTarget is Fur!
Fur! received focusin, its relatedTarget is Purr
Fur! received focusout, its relatedTarget is Done
</pre>
<p>Actual Result</p>
<pre id="log"></pre>
</body>
</html>
@@ -158,6 +158,7 @@ SET(WebCore_IDL_FILES
dom/ErrorEvent.idl
dom/EventException.idl
dom/Event.idl
dom/FocusEvent.idl
dom/HashChangeEvent.idl
dom/KeyboardEvent.idl
dom/MessageChannel.idl
@@ -558,6 +559,7 @@ SET(WebCore_SOURCES
dom/EventTarget.cpp
dom/ExceptionBase.cpp
dom/ExceptionCodePlaceholder.cpp
dom/FocusEvent.cpp
dom/GenericEventQueue.cpp
dom/IconURL.cpp
dom/KeyboardEvent.cpp
@@ -1,3 +1,70 @@
2012-02-16 Terry Anderson <tdanderson@chromium.org>

WebKit does not support DOM 3 Events FocusEvent
https://bugs.webkit.org/show_bug.cgi?id=76216

Created a new FocusEvent class (extends UIEvent) with a relatedTarget attribute. Moved
the {Focus,Blur,FocusIn,FocusOut}EventDispatchMediator classes inside FocusEvent. Now when
focusin or focusout events are dispatched, a FocusEvent is created with the relatedTarget
attribute set accordingly. No other logic changes have been made besides adding the
FocusEvent class.

Reviewed by Eric Seidel.

Test: fast/events/related-target-focusevent.html

* CMakeLists.txt:
* DerivedSources.cpp:
* DerivedSources.make:
* DerivedSources.pri:
* GNUmakefile.list.am:
* Target.pri:
* WebCore.gypi:
* WebCore.xcodeproj/project.pbxproj:
* dom/DOMAllInOne.cpp:
- Included mention of FocusEvent / JSFocusEvent in the above files to
allow the patch to build on the different platforms
* dom/EventDispatchMediator.cpp:
* dom/EventDispatchMediator.h:
* dom/EventFactory.in:
* dom/FocusEvent.cpp: Added.
(WebCore):
(WebCore::FocusEvent::FocusEvent):
(WebCore::FocusEvent::~FocusEvent):
(WebCore::FocusEvent::initFocusEvent):
(WebCore::FocusEvent::interfaceName):
(WebCore::FocusInEventDispatchMediator::create):
(WebCore::FocusInEventDispatchMediator::FocusInEventDispatchMediator):
(WebCore::FocusInEventDispatchMediator::dispatchEvent):
(WebCore::FocusInEventDispatchMediator::event):
(WebCore::FocusOutEventDispatchMediator::create):
(WebCore::FocusOutEventDispatchMediator::FocusOutEventDispatchMediator):
(WebCore::FocusOutEventDispatchMediator::dispatchEvent):
(WebCore::FocusOutEventDispatchMediator::event):
(WebCore::FocusEventDispatchMediator::create):
(WebCore::FocusEventDispatchMediator::FocusEventDispatchMediator):
(WebCore::FocusEventDispatchMediator::dispatchEvent):
(WebCore::BlurEventDispatchMediator::create):
(WebCore::BlurEventDispatchMediator::BlurEventDispatchMediator):
(WebCore::BlurEventDispatchMediator::dispatchEvent):
* dom/FocusEvent.h: Copied from Source/WebCore/dom/EventDispatchMediator.h.
(WebCore):
(FocusEvent):
(WebCore::FocusEvent::create):
(WebCore::FocusEvent::relatedTarget):
(WebCore::FocusEvent::setRelatedTarget):
(FocusInEventDispatchMediator):
(FocusOutEventDispatchMediator):
(FocusEventDispatchMediator):
(BlurEventDispatchMediator):
* dom/FocusEvent.idl: Added.
* dom/Node.cpp:
(WebCore::Node::dispatchFocusInEvent):
(WebCore::Node::dispatchFocusOutEvent):
* dom/UIEvent.cpp:
* dom/UIEvent.h:
* page/DOMWindow.idl:

2012-02-16 No'am Rosenthal <noam.rosenthal@nokia.com>

[Texmap] Improve the way we deal with BGRA extension
@@ -129,6 +129,7 @@
#include "JSFileWriterSync.cpp"
#include "JSFloat32Array.cpp"
#include "JSFloat64Array.cpp"
#include "JSFocusEvent.cpp"
#include "JSGeolocation.cpp"
#include "JSGeoposition.cpp"
#include "JSHashChangeEvent.cpp"
@@ -111,6 +111,7 @@ BINDING_IDLS = \
$(WebCore)/dom/EventException.idl \
$(WebCore)/dom/EventListener.idl \
$(WebCore)/dom/EventTarget.idl \
$(WebCore)/dom/FocusEvent.idl \
$(WebCore)/dom/HashChangeEvent.idl \
$(WebCore)/dom/KeyboardEvent.idl \
$(WebCore)/dom/MessageChannel.idl \
@@ -142,6 +142,7 @@ IDL_BINDINGS += \
$$PWD/dom/EventException.idl \
# $$PWD/dom/EventListener.idl \
# $$PWD/dom/EventTarget.idl \
$$PWD/dom/FocusEvent.idl \
$$PWD/dom/HashChangeEvent.idl \
$$PWD/dom/KeyboardEvent.idl \
$$PWD/dom/MouseEvent.idl \
@@ -183,6 +183,8 @@ webcore_built_sources += \
DerivedSources/WebCore/JSFloat32Array.h \
DerivedSources/WebCore/JSFloat64Array.cpp \
DerivedSources/WebCore/JSFloat64Array.h \
DerivedSources/WebCore/JSFocusEvent.cpp \
DerivedSources/WebCore/JSFocusEvent.h \
DerivedSources/WebCore/JSGeolocation.cpp \
DerivedSources/WebCore/JSGeolocation.h \
DerivedSources/WebCore/JSGeoposition.cpp \
@@ -703,6 +705,7 @@ dom_binding_idls += \
$(WebCore)/dom/ErrorEvent.idl \
$(WebCore)/dom/Event.idl \
$(WebCore)/dom/EventException.idl \
$(WebCore)/dom/FocusEvent.idl \
$(WebCore)/dom/HashChangeEvent.idl \
$(WebCore)/dom/KeyboardEvent.idl \
$(WebCore)/dom/MessageChannel.idl \
@@ -1569,6 +1572,8 @@ webcore_sources += \
Source/WebCore/dom/ExceptionCode.h \
Source/WebCore/dom/ExceptionCodePlaceholder.cpp \
Source/WebCore/dom/ExceptionCodePlaceholder.h \
Source/WebCore/dom/FocusEvent.cpp \
Source/WebCore/dom/FocusEvent.h \
Source/WebCore/dom/FragmentScriptingPermission.h \
Source/WebCore/dom/IgnoreDestructiveWriteCountIncrementer.h \
Source/WebCore/dom/ExceptionCodePlaceholder.h \
@@ -521,6 +521,7 @@ SOURCES += \
dom/EventTarget.cpp \
dom/ExceptionBase.cpp \
dom/ExceptionCodePlaceholder.cpp \
dom/FocusEvent.cpp \
dom/GenericEventQueue.cpp \
dom/IconURL.cpp \
dom/KeyboardEvent.cpp \
@@ -1635,6 +1636,7 @@ HEADERS += \
dom/EventTarget.h \
dom/ExceptionBase.h \
dom/ExceptionCode.h \
dom/FocusEvent.h \
dom/FragmentScriptingPermission.h \
dom/KeyboardEvent.h \
dom/MessageChannel.h \
@@ -600,6 +600,7 @@
'dom/EventTarget.h',
'dom/ExceptionCode.h',
'dom/ExceptionCodePlaceholder.h',
'dom/FocusEvent.h',
'dom/FragmentScriptingPermission.h',
'dom/KeyboardEvent.h',
'dom/MessagePort.h',
@@ -625,6 +626,7 @@
'dom/Text.h',
'dom/TextEventInputType.h',
'dom/UIEvent.h',
'dom/FocusEvent.h',
'dom/UIEventWithKeyState.h',
'dom/UserGestureIndicator.h',
'dom/UserTypingGestureIndicator.h',
@@ -784,6 +786,7 @@
'dom/EventException.idl',
'dom/EventListener.idl',
'dom/EventTarget.idl',
'dom/FocusEvent.idl',
'dom/HashChangeEvent.idl',
'dom/KeyboardEvent.idl',
'dom/MessageChannel.idl',
@@ -816,6 +819,7 @@
'dom/TouchList.idl',
'dom/TreeWalker.idl',
'dom/UIEvent.idl',
'dom/FocusEvent.idl',
'dom/WebKitAnimationEvent.idl',
'dom/WebKitMutationObserver.idl',
'dom/WebKitNamedFlow.idl',
@@ -5029,6 +5033,7 @@
'dom/ExceptionBase.cpp',
'dom/ExceptionBase.h',
'dom/ExceptionCodePlaceholder.cpp',
'dom/FocusEvent.cpp',
'dom/GenericEventQueue.cpp',
'dom/GenericEventQueue.h',
'dom/HashChangeEvent.h',
@@ -5145,6 +5150,7 @@
'dom/TreeWalker.cpp',
'dom/TreeWalker.h',
'dom/UIEvent.cpp',
'dom/FocusEvent.cpp',
'dom/UIEventWithKeyState.cpp',
'dom/UserGestureIndicator.cpp',
'dom/UserTypingGestureIndicator.cpp',
@@ -7158,6 +7164,8 @@
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSFileWriterSync.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSFloat32Array.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSFloat32Array.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSFocusEvent.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSFocusEvent.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSGeolocation.cpp',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSGeolocation.h',
'<(PRODUCT_DIR)/DerivedSources/WebCore/JSGeoposition.cpp',

0 comments on commit 5e4056b

Please sign in to comment.