Title: [148072] trunk
- Revision
- 148072
- Author
- [email protected]
- Date
- 2013-04-09 18:11:50 -0700 (Tue, 09 Apr 2013)
Log Message
Update Document's event listener type bitfield when adopting a Node
https://bugs.webkit.org/show_bug.cgi?id=114322
Reviewed by Darin Adler.
Source/WebCore:
Without this, moving a Node between documents can silently deactivate
an event listener, if it's one of the types that whose creation is
optimized away by Document::hasListenerType.
An alternate approach would be to simply copy the old document's
bitfield over. It's a tradeoff between making adoption fast and making
the operation of any operation depending on these event types fast.
The latter seems like the right optimization given that adoption
doesn't happen very often.
Test: fast/events/event-listener-moving-documents.html
* dom/Node.cpp:
(WebCore::Node::didMoveToNewDocument): For each event listener type on the adopted node, update the new document's list of listener types.
LayoutTests:
* fast/events/event-listener-moving-documents-expected.txt: Added.
* fast/events/event-listener-moving-documents.html: Added.
Modified Paths
Added Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (148071 => 148072)
--- trunk/LayoutTests/ChangeLog 2013-04-10 00:57:52 UTC (rev 148071)
+++ trunk/LayoutTests/ChangeLog 2013-04-10 01:11:50 UTC (rev 148072)
@@ -1,3 +1,13 @@
+2013-04-09 Adam Klein <[email protected]>
+
+ Update Document's event listener type bitfield when adopting a Node
+ https://bugs.webkit.org/show_bug.cgi?id=114322
+
+ Reviewed by Darin Adler.
+
+ * fast/events/event-listener-moving-documents-expected.txt: Added.
+ * fast/events/event-listener-moving-documents.html: Added.
+
2013-04-09 Dongwoo Joshua Im <[email protected]>
[CSS3] Parsing the property, text-justify.
Added: trunk/LayoutTests/fast/events/event-listener-moving-documents-expected.txt (0 => 148072)
--- trunk/LayoutTests/fast/events/event-listener-moving-documents-expected.txt (rev 0)
+++ trunk/LayoutTests/fast/events/event-listener-moving-documents-expected.txt 2013-04-10 01:11:50 UTC (rev 148072)
@@ -0,0 +1,12 @@
+Moving an event listener between documents should keep it active
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS addedCalls is 1
+PASS addedCalls is 2
+PASS removedCalls is 1
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
Added: trunk/LayoutTests/fast/events/event-listener-moving-documents.html (0 => 148072)
--- trunk/LayoutTests/fast/events/event-listener-moving-documents.html (rev 0)
+++ trunk/LayoutTests/fast/events/event-listener-moving-documents.html 2013-04-10 01:11:50 UTC (rev 148072)
@@ -0,0 +1,21 @@
+<!DOCTYPE html>
+<body>
+<script src=""
+<script>
+description('Moving an event listener between documents should keep it active');
+
+var doc = document.implementation.createHTMLDocument('');
+var div = doc.createElement('div');
+var addedCalls = 0;
+var removedCalls = 0;
+div.addEventListener('DOMNodeInserted', function() { addedCalls++ });
+div.addEventListener('DOMNodeRemoved', function() { removedCalls++ });
+document.body.appendChild(div);
+shouldBe('addedCalls', '1');
+div.appendChild(document.createElement('span'));
+shouldBe('addedCalls', '2');
+div.removeChild(div.firstChild);
+shouldBe('removedCalls', '1');
+</script>
+<script src=""
+</body>
Modified: trunk/Source/WebCore/ChangeLog (148071 => 148072)
--- trunk/Source/WebCore/ChangeLog 2013-04-10 00:57:52 UTC (rev 148071)
+++ trunk/Source/WebCore/ChangeLog 2013-04-10 01:11:50 UTC (rev 148072)
@@ -1,3 +1,25 @@
+2013-04-09 Adam Klein <[email protected]>
+
+ Update Document's event listener type bitfield when adopting a Node
+ https://bugs.webkit.org/show_bug.cgi?id=114322
+
+ Reviewed by Darin Adler.
+
+ Without this, moving a Node between documents can silently deactivate
+ an event listener, if it's one of the types that whose creation is
+ optimized away by Document::hasListenerType.
+
+ An alternate approach would be to simply copy the old document's
+ bitfield over. It's a tradeoff between making adoption fast and making
+ the operation of any operation depending on these event types fast.
+ The latter seems like the right optimization given that adoption
+ doesn't happen very often.
+
+ Test: fast/events/event-listener-moving-documents.html
+
+ * dom/Node.cpp:
+ (WebCore::Node::didMoveToNewDocument): For each event listener type on the adopted node, update the new document's list of listener types.
+
2013-04-09 Dean Jackson <[email protected]>
Add logging channel for animations
Modified: trunk/Source/WebCore/dom/Node.cpp (148071 => 148072)
--- trunk/Source/WebCore/dom/Node.cpp 2013-04-10 00:57:52 UTC (rev 148071)
+++ trunk/Source/WebCore/dom/Node.cpp 2013-04-10 01:11:50 UTC (rev 148072)
@@ -2152,12 +2152,19 @@
{
TreeScopeAdopter::ensureDidMoveToNewDocumentWasCalled(oldDocument);
+ if (const EventTargetData* eventTargetData = this->eventTargetData()) {
+ const EventListenerMap& listenerMap = eventTargetData->eventListenerMap;
+ if (!listenerMap.isEmpty()) {
+ Vector<AtomicString> types = listenerMap.eventTypes();
+ for (unsigned i = 0; i < types.size(); ++i)
+ document()->addListenerTypeIfNeeded(types[i]);
+ }
+ }
+
if (AXObjectCache::accessibilityEnabled() && oldDocument)
if (AXObjectCache* cache = oldDocument->existingAXObjectCache())
cache->remove(this);
- // FIXME: Event listener types for this node should be set on the new owner document here.
-
const EventListenerVector& wheelListeners = getEventListeners(eventNames().mousewheelEvent);
for (size_t i = 0; i < wheelListeners.size(); ++i) {
oldDocument->didRemoveWheelEventHandler();
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes