Diff
Modified: trunk/Source/WebCore/ChangeLog (108560 => 108561)
--- trunk/Source/WebCore/ChangeLog 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/ChangeLog 2012-02-22 23:28:15 UTC (rev 108561)
@@ -1,3 +1,38 @@
+2012-02-22 Daniel Bates <[email protected]>
+
+ Abstract ImageEventSender into a general purpose EventSender
+ https://bugs.webkit.org/show_bug.cgi?id=78840
+
+ Reviewed by Adam Barth.
+
+ Abstract the functionality in ImageEventSender so that it can be used again.
+ This functionality may be useful in fixing WebKit Bug #38995.
+
+ No functionality was changed; no new tests.
+
+ * GNUmakefile.list.am: Added EventSender.h.
+ * Target.pri: Ditto.
+ * WebCore.gypi: Ditto.
+ * WebCore.vcproj/WebCore.vcproj: Ditto.
+ * WebCore.xcodeproj/project.pbxproj: Ditto.
+ * dom/EventSender.h: Added.
+ (WebCore):
+ (EventSender):
+ (WebCore::EventSender::eventType):
+ (WebCore::EventSender::hasPendingEvents):
+ (WebCore::EventSender::timerFired):
+ (WebCore::::EventSender):
+ (WebCore::::dispatchEventSoon):
+ (WebCore::::cancelEvent):
+ (WebCore::::dispatchPendingEvents):
+ * loader/ImageLoader.cpp: Modified to use EventSender.
+ (WebCore):
+ (WebCore::ImageLoader::dispatchPendingEvent): Added; called by EventSender when the ImageLoader
+ should dispatch a pending BeforeLoad or Load event.
+ * loader/ImageLoader.h:
+ (WebCore):
+ (ImageLoader):
+
2012-02-22 Max Vujovic <[email protected]>
Paddings and borders on root SVG element with viewbox causes child SVG elements to be rendered with the incorrect size
Modified: trunk/Source/WebCore/GNUmakefile.list.am (108560 => 108561)
--- trunk/Source/WebCore/GNUmakefile.list.am 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/GNUmakefile.list.am 2012-02-22 23:28:15 UTC (rev 108561)
@@ -1578,6 +1578,7 @@
Source/WebCore/dom/EventTarget.cpp \
Source/WebCore/dom/EventTarget.h \
Source/WebCore/dom/EventQueue.h \
+ Source/WebCore/dom/EventSender.h \
Source/WebCore/dom/ExceptionBase.cpp \
Source/WebCore/dom/ExceptionBase.h \
Source/WebCore/dom/ExceptionCode.h \
Modified: trunk/Source/WebCore/Target.pri (108560 => 108561)
--- trunk/Source/WebCore/Target.pri 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/Target.pri 2012-02-22 23:28:15 UTC (rev 108561)
@@ -1647,6 +1647,7 @@
dom/EventListenerMap.h \
dom/EventNames.h \
dom/EventQueue.h \
+ dom/EventSender.h \
dom/EventTarget.h \
dom/ExceptionBase.h \
dom/ExceptionCode.h \
Modified: trunk/Source/WebCore/WebCore.gypi (108560 => 108561)
--- trunk/Source/WebCore/WebCore.gypi 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/WebCore.gypi 2012-02-22 23:28:15 UTC (rev 108561)
@@ -5048,6 +5048,7 @@
'dom/EventListenerMap.cpp',
'dom/EventNames.cpp',
'dom/EventQueue.h',
+ 'dom/EventSender.h',
'dom/EventTarget.cpp',
'dom/ExceptionBase.cpp',
'dom/ExceptionBase.h',
Modified: trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj (108560 => 108561)
--- trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/WebCore.vcproj/WebCore.vcproj 2012-02-22 23:28:15 UTC (rev 108561)
@@ -48770,6 +48770,10 @@
>
</File>
<File
+ RelativePath="..\dom\EventSender.h"
+ >
+ </File>
+ <File
RelativePath="..\dom\EventTarget.cpp"
>
<FileConfiguration
Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (108560 => 108561)
--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj 2012-02-22 23:28:15 UTC (rev 108561)
@@ -12637,6 +12637,7 @@
CE057FA31220731100A476D5 /* DocumentMarkerController.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DocumentMarkerController.cpp; sourceTree = "<group>"; };
CE057FA41220731100A476D5 /* DocumentMarkerController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DocumentMarkerController.h; sourceTree = "<group>"; };
CE54FD371016D9A6008B44C8 /* ScriptSourceProvider.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ScriptSourceProvider.h; sourceTree = "<group>"; };
+ CE5CB1B314EDAB6F00BB2795 /* EventSender.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = EventSender.h; sourceTree = "<group>"; };
CEA3949A11D45CDA003094CF /* StaticHashSetNodeList.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = StaticHashSetNodeList.cpp; sourceTree = "<group>"; };
CEA3949B11D45CDA003094CF /* StaticHashSetNodeList.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = StaticHashSetNodeList.h; sourceTree = "<group>"; };
CECCFC3A141973D5002A0AC1 /* DecodeEscapeSequences.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DecodeEscapeSequences.h; sourceTree = "<group>"; };
@@ -20699,6 +20700,7 @@
939885C108B7E3D100E707C4 /* EventNames.cpp */,
939885C208B7E3D100E707C4 /* EventNames.h */,
8F6756191288B17B0047ACA3 /* EventQueue.h */,
+ CE5CB1B314EDAB6F00BB2795 /* EventSender.h */,
E12EDBE90B308E0B002704B6 /* EventTarget.cpp */,
E12EDB7A0B308A78002704B6 /* EventTarget.h */,
85AFA7420AAF298400E84305 /* EventTarget.idl */,
Added: trunk/Source/WebCore/dom/EventSender.h (0 => 108561)
--- trunk/Source/WebCore/dom/EventSender.h (rev 0)
+++ trunk/Source/WebCore/dom/EventSender.h 2012-02-22 23:28:15 UTC (rev 108561)
@@ -0,0 +1,114 @@
+/*
+ * Copyright (C) 2012 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#ifndef EventSender_h
+#define EventSender_h
+
+#include "Timer.h"
+#include <wtf/Vector.h>
+
+namespace WebCore {
+
+template<typename T> class EventSender {
+ WTF_MAKE_NONCOPYABLE(EventSender); WTF_MAKE_FAST_ALLOCATED;
+public:
+ explicit EventSender(const AtomicString& eventType);
+
+ const AtomicString& eventType() const { return m_eventType; }
+ void dispatchEventSoon(T*);
+ void cancelEvent(T*);
+ void dispatchPendingEvents();
+
+#ifndef NDEBUG
+ bool hasPendingEvents(T* sender) const
+ {
+ return m_dispatchSoonList.find(sender) != notFound || m_dispatchingList.find(sender) != notFound;
+ }
+#endif
+
+private:
+ void timerFired(Timer<EventSender<T> >*) { dispatchPendingEvents(); }
+
+ AtomicString m_eventType;
+ Timer<EventSender<T> > m_timer;
+ Vector<T*> m_dispatchSoonList;
+ Vector<T*> m_dispatchingList;
+};
+
+template<typename T> EventSender<T>::EventSender(const AtomicString& eventType)
+ : m_eventType(eventType)
+ , m_timer(this, &EventSender::timerFired)
+{
+}
+
+template<typename T> void EventSender<T>::dispatchEventSoon(T* sender)
+{
+ m_dispatchSoonList.append(sender);
+ if (!m_timer.isActive())
+ m_timer.startOneShot(0);
+}
+
+template<typename T> void EventSender<T>::cancelEvent(T* sender)
+{
+ // Remove instances of this sender from both lists.
+ // Use loops because we allow multiple instances to get into the lists.
+ size_t size = m_dispatchSoonList.size();
+ for (size_t i = 0; i < size; ++i) {
+ if (m_dispatchSoonList[i] == sender)
+ m_dispatchSoonList[i] = 0;
+ }
+ size = m_dispatchingList.size();
+ for (size_t i = 0; i < size; ++i) {
+ if (m_dispatchingList[i] == sender)
+ m_dispatchingList[i] = 0;
+ }
+}
+
+template<typename T> void EventSender<T>::dispatchPendingEvents()
+{
+ // Need to avoid re-entering this function; if new dispatches are
+ // scheduled before the parent finishes processing the list, they
+ // will set a timer and eventually be processed.
+ if (!m_dispatchingList.isEmpty())
+ return;
+
+ m_timer.stop();
+
+ m_dispatchSoonList.checkConsistency();
+
+ m_dispatchingList.swap(m_dispatchSoonList);
+ size_t size = m_dispatchingList.size();
+ for (size_t i = 0; i < size; ++i) {
+ if (T* sender = m_dispatchingList[i]) {
+ m_dispatchingList[i] = 0;
+ sender->dispatchPendingEvent(this);
+ }
+ }
+ m_dispatchingList.clear();
+}
+
+} // namespace WebCore
+
+#endif // EventSender_h
Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (108560 => 108561)
--- trunk/Source/WebCore/loader/ImageLoader.cpp 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp 2012-02-22 23:28:15 UTC (rev 108561)
@@ -28,6 +28,7 @@
#include "Document.h"
#include "Element.h"
#include "Event.h"
+#include "EventSender.h"
#include "HTMLNames.h"
#include "HTMLObjectElement.h"
#include "HTMLParserIdioms.h"
@@ -62,32 +63,6 @@
namespace WebCore {
-class ImageEventSender {
- WTF_MAKE_NONCOPYABLE(ImageEventSender); WTF_MAKE_FAST_ALLOCATED;
-public:
- ImageEventSender(const AtomicString& eventType);
-
- void dispatchEventSoon(ImageLoader*);
- void cancelEvent(ImageLoader*);
-
- void dispatchPendingEvents();
-
-#ifndef NDEBUG
- bool hasPendingEvents(ImageLoader* loader) const
- {
- return m_dispatchSoonList.find(loader) != notFound || m_dispatchingList.find(loader) != notFound;
- }
-#endif
-
-private:
- void timerFired(Timer<ImageEventSender>*);
-
- AtomicString m_eventType;
- Timer<ImageEventSender> m_timer;
- Vector<ImageLoader*> m_dispatchSoonList;
- Vector<ImageLoader*> m_dispatchingList;
-};
-
static ImageEventSender& beforeLoadEventSender()
{
DEFINE_STATIC_LOCAL(ImageEventSender, sender, (eventNames().beforeloadEvent));
@@ -302,6 +277,16 @@
imageResource->setCachedImage(m_image.get());
}
+void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender)
+{
+ ASSERT(eventSender == &beforeLoadEventSender() || eventSender == &loadEventSender());
+ const AtomicString& eventType = eventSender->eventType();
+ if (eventType == eventNames().beforeloadEvent)
+ dispatchPendingBeforeLoadEvent();
+ if (eventType == eventNames().loadEvent)
+ dispatchPendingLoadEvent();
+}
+
void ImageLoader::dispatchPendingBeforeLoadEvent()
{
if (m_firedBeforeLoad)
@@ -354,66 +339,4 @@
setImage(0);
}
-ImageEventSender::ImageEventSender(const AtomicString& eventType)
- : m_eventType(eventType)
- , m_timer(this, &ImageEventSender::timerFired)
-{
}
-
-void ImageEventSender::dispatchEventSoon(ImageLoader* loader)
-{
- m_dispatchSoonList.append(loader);
- if (!m_timer.isActive())
- m_timer.startOneShot(0);
-}
-
-void ImageEventSender::cancelEvent(ImageLoader* loader)
-{
- // Remove instances of this loader from both lists.
- // Use loops because we allow multiple instances to get into the lists.
- size_t size = m_dispatchSoonList.size();
- for (size_t i = 0; i < size; ++i) {
- if (m_dispatchSoonList[i] == loader)
- m_dispatchSoonList[i] = 0;
- }
- size = m_dispatchingList.size();
- for (size_t i = 0; i < size; ++i) {
- if (m_dispatchingList[i] == loader)
- m_dispatchingList[i] = 0;
- }
- if (m_dispatchSoonList.isEmpty())
- m_timer.stop();
-}
-
-void ImageEventSender::dispatchPendingEvents()
-{
- // Need to avoid re-entering this function; if new dispatches are
- // scheduled before the parent finishes processing the list, they
- // will set a timer and eventually be processed.
- if (!m_dispatchingList.isEmpty())
- return;
-
- m_timer.stop();
-
- m_dispatchSoonList.checkConsistency();
-
- m_dispatchingList.swap(m_dispatchSoonList);
- size_t size = m_dispatchingList.size();
- for (size_t i = 0; i < size; ++i) {
- if (ImageLoader* loader = m_dispatchingList[i]) {
- m_dispatchingList[i] = 0;
- if (m_eventType == eventNames().beforeloadEvent)
- loader->dispatchPendingBeforeLoadEvent();
- else
- loader->dispatchPendingLoadEvent();
- }
- }
- m_dispatchingList.clear();
-}
-
-void ImageEventSender::timerFired(Timer<ImageEventSender>*)
-{
- dispatchPendingEvents();
-}
-
-}
Modified: trunk/Source/WebCore/loader/ImageLoader.h (108560 => 108561)
--- trunk/Source/WebCore/loader/ImageLoader.h 2012-02-22 23:23:44 UTC (rev 108560)
+++ trunk/Source/WebCore/loader/ImageLoader.h 2012-02-22 23:28:15 UTC (rev 108561)
@@ -30,9 +30,12 @@
namespace WebCore {
class Element;
-class ImageLoadEventSender;
+class ImageLoader;
class RenderImageResource;
+template<typename T> class EventSender;
+typedef EventSender<ImageLoader> ImageEventSender;
+
class ImageLoader : public CachedImageClient {
public:
ImageLoader(Element*);
@@ -59,6 +62,8 @@
bool haveFiredBeforeLoadEvent() const { return m_firedBeforeLoad; }
bool haveFiredLoadEvent() const { return m_firedLoad; }
+ void dispatchPendingEvent(ImageEventSender*);
+
static void dispatchPendingBeforeLoadEvents();
static void dispatchPendingLoadEvents();
@@ -69,7 +74,6 @@
virtual void dispatchLoadEvent() = 0;
virtual String sourceURI(const AtomicString&) const = 0;
- friend class ImageEventSender;
void dispatchPendingBeforeLoadEvent();
void dispatchPendingLoadEvent();