- Revision
- 88980
- Author
- simon.fra...@apple.com
- Date
- 2011-06-15 16:02:48 -0700 (Wed, 15 Jun 2011)
Log Message
2011-06-15 Simon Fraser <simon.fra...@apple.com>
Reviewed by Dan Bernstein.
Have Document keep track of whether scroll listeners are registered
https://bugs.webkit.org/show_bug.cgi?id=62757
To avoid extra work dispatching scroll events when there are no listeners,
have Document keep track of whether any scroll listeners are registered,
just like it does for some other event types.
* dom/Document.cpp:
(WebCore::Document::addListenerTypeIfNeeded):
* dom/Document.h:
* dom/EventQueue.cpp:
(WebCore::EventQueue::enqueueOrDispatchScrollEvent):
Modified Paths
Diff
Modified: trunk/LayoutTests/ChangeLog (88979 => 88980)
--- trunk/LayoutTests/ChangeLog 2011-06-15 22:35:50 UTC (rev 88979)
+++ trunk/LayoutTests/ChangeLog 2011-06-15 23:02:48 UTC (rev 88980)
@@ -1,3 +1,17 @@
+2011-06-15 Simon Fraser <simon.fra...@apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Have Document keep track of whether scroll listeners are registered
+ https://bugs.webkit.org/show_bug.cgi?id=62757
+
+ This test relied on the fact that, with async scroll event dispatch,
+ an element would get a scroll event even if the listener is registered
+ after the scroll happens. Fix the test to register the listener before
+ the first scroll.
+
+ * fast/events/remove-child-onscroll.html:
+
2011-06-15 Stephen White <senorbla...@chromium.org>
Unreviewed; test expectations cleanup.
Modified: trunk/LayoutTests/fast/events/remove-child-onscroll.html (88979 => 88980)
--- trunk/LayoutTests/fast/events/remove-child-onscroll.html 2011-06-15 22:35:50 UTC (rev 88979)
+++ trunk/LayoutTests/fast/events/remove-child-onscroll.html 2011-06-15 23:02:48 UTC (rev 88980)
@@ -10,8 +10,6 @@
{
if (window.eventSender && window.layoutTestController) {
layoutTestController.waitUntilDone();
- eventSender.mouseMoveTo(100, 100);
- eventSender.mouseScrollBy(0, -1);
var scrollCount = 0;
document.getElementById('dv').addEventListener(
'scroll',
@@ -24,6 +22,9 @@
layoutTestController.notifyDone();
},
false);
+
+ eventSender.mouseMoveTo(100, 100);
+ eventSender.mouseScrollBy(0, -1);
}
}
</script>
Modified: trunk/Source/WebCore/ChangeLog (88979 => 88980)
--- trunk/Source/WebCore/ChangeLog 2011-06-15 22:35:50 UTC (rev 88979)
+++ trunk/Source/WebCore/ChangeLog 2011-06-15 23:02:48 UTC (rev 88980)
@@ -1,3 +1,20 @@
+2011-06-15 Simon Fraser <simon.fra...@apple.com>
+
+ Reviewed by Dan Bernstein.
+
+ Have Document keep track of whether scroll listeners are registered
+ https://bugs.webkit.org/show_bug.cgi?id=62757
+
+ To avoid extra work dispatching scroll events when there are no listeners,
+ have Document keep track of whether any scroll listeners are registered,
+ just like it does for some other event types.
+
+ * dom/Document.cpp:
+ (WebCore::Document::addListenerTypeIfNeeded):
+ * dom/Document.h:
+ * dom/EventQueue.cpp:
+ (WebCore::EventQueue::enqueueOrDispatchScrollEvent):
+
2011-06-15 Dimitri Glazkov <dglaz...@chromium.org>
Reviewed by Adam Barth.
Modified: trunk/Source/WebCore/dom/Document.cpp (88979 => 88980)
--- trunk/Source/WebCore/dom/Document.cpp 2011-06-15 22:35:50 UTC (rev 88979)
+++ trunk/Source/WebCore/dom/Document.cpp 2011-06-15 23:02:48 UTC (rev 88980)
@@ -3524,6 +3524,8 @@
page->chrome()->client()->needTouchEvents(true);
}
#endif
+ else if (eventType == eventNames().scrollEvent)
+ addListenerType(SCROLL_LISTENER);
}
CSSStyleDeclaration* Document::getOverrideStyle(Element*, const String&)
Modified: trunk/Source/WebCore/dom/Document.h (88979 => 88980)
--- trunk/Source/WebCore/dom/Document.h 2011-06-15 22:35:50 UTC (rev 88979)
+++ trunk/Source/WebCore/dom/Document.h 2011-06-15 23:02:48 UTC (rev 88980)
@@ -758,7 +758,8 @@
TRANSITIONEND_LISTENER = 0x800,
BEFORELOAD_LISTENER = 0x1000,
TOUCH_LISTENER = 0x2000,
- BEFOREPROCESS_LISTENER = 0x4000
+ BEFOREPROCESS_LISTENER = 0x4000,
+ SCROLL_LISTENER = 0x8000
};
bool hasListenerType(ListenerType listenerType) const { return (m_listenerTypes & listenerType); }
Modified: trunk/Source/WebCore/dom/EventQueue.cpp (88979 => 88980)
--- trunk/Source/WebCore/dom/EventQueue.cpp 2011-06-15 22:35:50 UTC (rev 88979)
+++ trunk/Source/WebCore/dom/EventQueue.cpp 2011-06-15 23:02:48 UTC (rev 88980)
@@ -117,6 +117,9 @@
void EventQueue::enqueueOrDispatchScrollEvent(PassRefPtr<Node> target, ScrollEventTargetType targetType)
{
+ if (!target->document()->hasListenerType(Document::SCROLL_LISTENER))
+ return;
+
// Per the W3C CSSOM View Module, scroll events fired at the document should bubble, others should not.
bool canBubble = targetType == ScrollEventDocumentTarget;
RefPtr<Event> scrollEvent = Event::create(eventNames().scrollEvent, canBubble, false /* non cancelleable */);