WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
WIP
bug-136051-20140926134159.patch (text/plain), 31.42 KB, created by
Brian Burg
on 2014-09-26 13:42:12 PDT
(
hide
)
Description:
WIP
Filename:
MIME Type:
Creator:
Brian Burg
Created:
2014-09-26 13:42:12 PDT
Size:
31.42 KB
patch
obsolete
>Subversion Revision: 173802 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 16cbdcfadb25008d4f0b89a0ee33603acc520118..24e562d7f6dbdf64cd03744ed276cd968a92e04e 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,70 @@ >+2014-08-18 Brian J. Burg <burg@cs.washington.edu> >+ >+ Web Replay: EventSender dispatches should be deterministic and per-Document >+ https://bugs.webkit.org/show_bug.cgi?id=136051 >+ >+ EventSender uses a Timer to asynchronously dispatch the same event to multiple >+ elements of the same type on a future run loop. This is nondeterministic because >+ static instances are shared between all Documents in the same process. >+ >+ This patch shares EventSender instances among elements in the same Document. >+ The event dispatching is made deterministic by using a ReplayableTimer. >+ >+ Normal (non-replay) functionality is covered by existing tests. >+ >+ * WebCore.xcodeproj/project.pbxproj: >+ * dom/Document.cpp: >+ (WebCore::Document::Document): >+ (WebCore::Document::implicitClose): Dispatch pending events for this document only. >+ * dom/Document.h: >+ (WebCore::Document::sharedEventSenders): >+ * dom/EventSender.h: Keep a Document reference around for firing the timer. >+ (WebCore::EventSender::EventSender): >+ (WebCore::EventSender::hasPendingEvents): >+ (WebCore::EventSender::timerFired): >+ (WebCore::EventSender<T>::dispatchEventSoon): >+ (WebCore::EventSender<T>::cancelEvent): >+ (WebCore::EventSender<T>::dispatchPendingEvents): >+ (WebCore::EventSender<T>::EventSender): Deleted. The type argument was not necessary. >+ >+ * dom/SharedEventSenders.cpp: Added. Lazily creates event senders as they are requested. >+ (WebCore::SharedEventSenders::linkLoadEventSender): >+ (WebCore::SharedEventSenders::styleLoadEventSender): >+ (WebCore::SharedEventSenders::imageBeforeloadEventSender): >+ (WebCore::SharedEventSenders::imageLoadEventSender): >+ (WebCore::SharedEventSenders::imageErrorEventSender): >+ * dom/SharedEventSenders.h: Added. >+ (WebCore::SharedEventSenders::SharedEventSenders): >+ * html/HTMLLinkElement.cpp: >+ (WebCore::HTMLLinkElement::linkLoadEventSender): >+ (WebCore::HTMLLinkElement::dispatchPendingEvent): >+ (WebCore::linkLoadEventSender): Deleted. >+ (WebCore::HTMLLinkElement::dispatchPendingLoadEvents): Deleted. >+ * html/HTMLLinkElement.h: >+ * html/HTMLStyleElement.cpp: >+ (WebCore::HTMLStyleElement::styleLoadEventSender): >+ (WebCore::HTMLStyleElement::dispatchPendingEvent): >+ (WebCore::styleLoadEventSender): Deleted. >+ (WebCore::HTMLStyleElement::dispatchPendingLoadEvents): Deleted. >+ * html/HTMLStyleElement.h: >+ * loader/ImageLoader.cpp: >+ (WebCore::ImageLoader::beforeLoadEventSender): >+ (WebCore::ImageLoader::loadEventSender): >+ (WebCore::ImageLoader::errorEventSender): >+ (WebCore::ImageLoader::dispatchPendingEvent): >+ (WebCore::beforeLoadEventSender): Deleted. >+ (WebCore::loadEventSender): Deleted. >+ (WebCore::errorEventSender): Deleted. >+ (WebCore::ImageLoader::dispatchPendingBeforeLoadEvents): Deleted. >+ (WebCore::ImageLoader::dispatchPendingLoadEvents): Deleted. >+ (WebCore::ImageLoader::dispatchPendingErrorEvents): Deleted. >+ * loader/ImageLoader.h: >+ >+ * xml/parser/XMLDocumentParser.cpp: >+ (WebCore::XMLDocumentParser::append): Remove an early call to the EventSender for image beforeload >+ events. This was a performance optimization, but is no longer safe since the document (and thus >+ the event sender) may not be available in a synchronous document write. >+ > 2014-07-15 Brian J. Burg <burg@cs.washington.edu> > > Web Replay: make calls into FrameLoader::checkLoadComplete() deterministic >diff --git a/Source/WebCore/WebCore.xcodeproj/project.pbxproj b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >index 8bf4f3537b605bb22d50e4d2d890916c66365ef8..24f72a6bb9eb4517d44035d014dc47ea262d759c 100644 >--- a/Source/WebCore/WebCore.xcodeproj/project.pbxproj >+++ b/Source/WebCore/WebCore.xcodeproj/project.pbxproj >@@ -5510,6 +5510,9 @@ > C3CF17A615B0063F00276D39 /* IdTargetObserverRegistry.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C3CF17A215B0063F00276D39 /* IdTargetObserverRegistry.cpp */; }; > C3CF17A715B0063F00276D39 /* IdTargetObserverRegistry.h in Headers */ = {isa = PBXBuildFile; fileRef = C3CF17A315B0063F00276D39 /* IdTargetObserverRegistry.h */; settings = {ATTRIBUTES = (Private, ); }; }; > C400D10918F1C8F60090D863 /* EventLoopInput.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C400D10818F1C8F60090D863 /* EventLoopInput.cpp */; }; >+ C49474A119A2847C009B3DE8 /* SharedEventSenders.h in Headers */ = {isa = PBXBuildFile; fileRef = C49474A019A2847C009B3DE8 /* SharedEventSenders.h */; }; >+ C49474A819A2D612009B3DE8 /* EventSender.h in Headers */ = {isa = PBXBuildFile; fileRef = CE5CB1B314EDAB6F00BB2795 /* EventSender.h */; }; >+ C49474AA19A2E2E5009B3DE8 /* SharedEventSenders.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C49474A919A2E2E5009B3DE8 /* SharedEventSenders.cpp */; }; > C4CD629A18383766007EBAF1 /* FrameSnapshotting.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C4CD629818383766007EBAF1 /* FrameSnapshotting.cpp */; }; > C4CD629B18383766007EBAF1 /* FrameSnapshotting.h in Headers */ = {isa = PBXBuildFile; fileRef = C4CD629918383766007EBAF1 /* FrameSnapshotting.h */; settings = {ATTRIBUTES = (Private, ); }; }; > C4D4F52B1975C88B003EF5BC /* ReplayableTimer.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C4D4F5271975C88B003EF5BC /* ReplayableTimer.cpp */; }; >@@ -12925,6 +12928,8 @@ > C3CF17A315B0063F00276D39 /* IdTargetObserverRegistry.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = IdTargetObserverRegistry.h; sourceTree = "<group>"; }; > C3E61C653A64807A83E76FB8 /* MathMLMencloseElement.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = MathMLMencloseElement.cpp; sourceTree = "<group>"; }; > C400D10818F1C8F60090D863 /* EventLoopInput.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = EventLoopInput.cpp; sourceTree = "<group>"; }; >+ C49474A019A2847C009B3DE8 /* SharedEventSenders.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SharedEventSenders.h; sourceTree = "<group>"; }; >+ C49474A919A2E2E5009B3DE8 /* SharedEventSenders.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = SharedEventSenders.cpp; sourceTree = "<group>"; }; > C4CD629818383766007EBAF1 /* FrameSnapshotting.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = FrameSnapshotting.cpp; sourceTree = "<group>"; }; > C4CD629918383766007EBAF1 /* FrameSnapshotting.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = FrameSnapshotting.h; sourceTree = "<group>"; }; > C4D4F5271975C88B003EF5BC /* ReplayableTimer.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = ReplayableTimer.cpp; sourceTree = "<group>"; }; >@@ -22775,6 +22780,8 @@ > E45322AA140CE267005A0F92 /* SelectorQuery.h */, > A6D169611346B49B000EB770 /* ShadowRoot.cpp */, > A6D169631346B4C1000EB770 /* ShadowRoot.h */, >+ C49474A919A2E2E5009B3DE8 /* SharedEventSenders.cpp */, >+ C49474A019A2847C009B3DE8 /* SharedEventSenders.h */, > 31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */, > D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */, > D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */, >@@ -23368,6 +23375,7 @@ > 070363E0181A1CDC00C074A5 /* AVAudioCaptureSource.h in Headers */, > 070363E2181A1CDC00C074A5 /* AVCaptureDeviceManager.h in Headers */, > 070363E4181A1CDC00C074A5 /* AVMediaCaptureSource.h in Headers */, >+ C49474A819A2D612009B3DE8 /* EventSender.h in Headers */, > CD336F6217F9F64700DDDCD0 /* AVTrackPrivateAVFObjCImpl.h in Headers */, > 070363E6181A1CDC00C074A5 /* AVVideoCaptureSource.h in Headers */, > 29A812380FBB9C1D00510293 /* AXObjectCache.h in Headers */, >@@ -26405,6 +26413,7 @@ > 85031B4F0A44EFC700F992E0 /* UIEventWithKeyState.h in Headers */, > AA4739D21757AFEC00E76767 /* UIRequestEvent.h in Headers */, > 9B2D8A7914997CCF00ECEF3E /* UndoStep.h in Headers */, >+ C49474A119A2847C009B3DE8 /* SharedEventSenders.h in Headers */, > A863E2011343412000274926 /* UnicodeBidi.h in Headers */, > E4AFCFA50DAF29A300F5F55C /* UnitBezier.h in Headers */, > D086FE9809D53AAB005BC74D /* UnlinkCommand.h in Headers */, >@@ -28070,6 +28079,7 @@ > 8931DE5B14C44C44000DC9D2 /* JSBlobCustom.cpp in Sources */, > 1449E287107D4DB400B5793F /* JSCallbackData.cpp in Sources */, > 65DF323909D1DE65000BE325 /* JSCanvasGradient.cpp in Sources */, >+ C49474AA19A2E2E5009B3DE8 /* SharedEventSenders.cpp in Sources */, > 65DF323B09D1DE65000BE325 /* JSCanvasPattern.cpp in Sources */, > 49EED1421051969400099FAB /* JSCanvasRenderingContext.cpp in Sources */, > 49EED1441051969400099FAB /* JSCanvasRenderingContext2D.cpp in Sources */, >diff --git a/Source/WebCore/dom/Document.cpp b/Source/WebCore/dom/Document.cpp >index d8513afd8429333bbae029c4503a994a812eb3e7..70d5846714c7f6b5906f8567b399ce352a0b4ae3 100644 >--- a/Source/WebCore/dom/Document.cpp >+++ b/Source/WebCore/dom/Document.cpp >@@ -138,6 +138,7 @@ > #include "SelectorQuery.h" > #include "Settings.h" > #include "ShadowRoot.h" >+#include "SharedEventSenders.h" > #include "StyleProperties.h" > #include "StyleResolver.h" > #include "StyleSheetContents.h" >@@ -472,6 +473,7 @@ Document::Document(Frame* frame, const URL& url, unsigned documentClasses, unsig > , m_sawElementsInKnownNamespaces(false) > , m_isSrcdocDocument(false) > , m_eventQueue(*this) >+ , m_sharedEventSenders(std::make_unique<SharedEventSenders>(*this)) > , m_weakFactory(this) > #if ENABLE(FULLSCREEN_API) > , m_areKeysEnabledInFullScreen(0) >@@ -2383,17 +2385,15 @@ void Document::implicitClose() > if (f) { > f->loader().icon().startLoader(); > f->animation().startAnimationsIfNotSuspended(this); >- >- // FIXME: We shouldn't be dispatching pending events globally on all Documents here. >- // For now, only do this when there is a Frame, otherwise this could cause JS reentrancy >- // below SVG font parsing, for example. <https://webkit.org/b/136269> >- ImageLoader::dispatchPendingBeforeLoadEvents(); >- ImageLoader::dispatchPendingLoadEvents(); >- ImageLoader::dispatchPendingErrorEvents(); >- HTMLLinkElement::dispatchPendingLoadEvents(); >- HTMLStyleElement::dispatchPendingLoadEvents(); > } > >+ sharedEventSenders().imageBeforeloadEventSender().dispatchPendingEvents(); >+ sharedEventSenders().imageLoadEventSender().dispatchPendingEvents(); >+ sharedEventSenders().imageErrorEventSender().dispatchPendingEvents(); >+ >+ sharedEventSenders().linkLoadEventSender().dispatchPendingEvents(); >+ sharedEventSenders().styleLoadEventSender().dispatchPendingEvents(); >+ > // To align the HTML load event and the SVGLoad event for the outermost <svg> element, fire it from > // here, instead of doing it from SVGElement::finishedParsingChildren (if externalResourcesRequired="false", > // which is the default, for ='true' its fired at a later time, once all external resources finished loading). >diff --git a/Source/WebCore/dom/Document.h b/Source/WebCore/dom/Document.h >index f754bc460f00ab824726932243e6e7f2c5b7cbd3..5973b330d141231c70cb2c29bc9df0e2a7c708a3 100644 >--- a/Source/WebCore/dom/Document.h >+++ b/Source/WebCore/dom/Document.h >@@ -145,6 +145,7 @@ class SelectorQueryCache; > class SerializedScriptValue; > class SegmentedString; > class Settings; >+class SharedEventSenders; > class StyleResolver; > class StyleSheet; > class StyleSheetContents; >@@ -1123,6 +1124,8 @@ public: > void enqueuePopstateEvent(PassRefPtr<SerializedScriptValue> stateObject); > virtual DocumentEventQueue& eventQueue() const override { return m_eventQueue; } > >+ SharedEventSenders& sharedEventSenders() const { return *m_sharedEventSenders; } >+ > WEBCORE_EXPORT void addMediaCanStartListener(MediaCanStartListener*); > WEBCORE_EXPORT void removeMediaCanStartListener(MediaCanStartListener*); > MediaCanStartListener* takeAnyMediaCanStartListener(); >@@ -1570,6 +1573,8 @@ private: > RenderPtr<RenderView> m_renderView; > mutable DocumentEventQueue m_eventQueue; > >+ const std::unique_ptr<SharedEventSenders> m_sharedEventSenders; >+ > WeakPtrFactory<Document> m_weakFactory; > > HashSet<MediaCanStartListener*> m_mediaCanStartListeners; >diff --git a/Source/WebCore/dom/EventSender.h b/Source/WebCore/dom/EventSender.h >index 04fe258f722e28ad4f6ce1a3e46a813b1c4d5129..3bd21dd386535d4d0c312f8051cd300270262774 100644 >--- a/Source/WebCore/dom/EventSender.h >+++ b/Source/WebCore/dom/EventSender.h >@@ -1,5 +1,6 @@ > /* > * Copyright (C) 2012 Apple Inc. All rights reserved. >+ * Copyright (C) 2014 University of Washington. All rights reserved. > * > * Redistribution and use in source and binary forms, with or without > * modification, are permitted provided that the following conditions >@@ -26,15 +27,23 @@ > #ifndef EventSender_h > #define EventSender_h > >-#include "Timer.h" >+#include "ReplayableTimer.h" > #include <wtf/Vector.h> > > namespace WebCore { > >-template<typename T> class EventSender { >+class Document; >+ >+template <typename T> >+class EventSender { > WTF_MAKE_NONCOPYABLE(EventSender); WTF_MAKE_FAST_ALLOCATED; > public: >- explicit EventSender(const AtomicString& eventType); >+ EventSender(Document& document, const AtomicString& eventType) >+ : m_document(document) >+ , m_eventType(eventType) >+ , m_timer(this, &EventSender::timerFired) >+ { >+ } > > const AtomicString& eventType() const { return m_eventType; } > void dispatchEventSoon(T&); >@@ -42,49 +51,47 @@ public: > void dispatchPendingEvents(); > > #ifndef NDEBUG >- bool hasPendingEvents(T& sender) const >+ bool hasPendingEvents(T& client) const > { >- return m_dispatchSoonList.find(&sender) != notFound || m_dispatchingList.find(&sender) != notFound; >+ return m_dispatchSoonList.find(&client) != notFound || m_dispatchingList.find(&client) != notFound; > } > #endif > > private: >- void timerFired(Timer<EventSender<T>>&) { dispatchPendingEvents(); } >+ void timerFired(ReplayableTimer<EventSender<T>>&) { dispatchPendingEvents(); } > >+ Document& m_document; > AtomicString m_eventType; >- Timer<EventSender<T>> m_timer; >+ ReplayableTimer<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& client) > { >-} >- >-template<typename T> void EventSender<T>::dispatchEventSoon(T& sender) >-{ >- m_dispatchSoonList.append(&sender); >+ m_dispatchSoonList.append(&client); > if (!m_timer.isActive()) >- m_timer.startOneShot(0); >+ m_timer.startOneShot(0, &m_document); > } > >-template<typename T> void EventSender<T>::cancelEvent(T& sender) >+template<typename T> >+void EventSender<T>::cancelEvent(T& client) > { >- // Remove instances of this sender from both lists. >+ // Remove instances of this client from both lists. > // Use loops because we allow multiple instances to get into the lists. > for (auto& event : m_dispatchSoonList) { >- if (event == &sender) >+ if (event == &client) > event = nullptr; > } > for (auto& event : m_dispatchingList) { >- if (event == &sender) >+ if (event == &client) > event = nullptr; > } > } > >-template<typename T> void EventSender<T>::dispatchPendingEvents() >+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 >@@ -94,13 +101,11 @@ template<typename T> void EventSender<T>::dispatchPendingEvents() > > m_timer.stop(); > >- m_dispatchSoonList.checkConsistency(); >- > m_dispatchingList.swap(m_dispatchSoonList); > for (auto& event : m_dispatchingList) { >- if (T* sender = event) { >+ if (T* client = event) { > event = nullptr; >- sender->dispatchPendingEvent(this); >+ client->dispatchPendingEvent(*this); > } > } > m_dispatchingList.clear(); >diff --git a/Source/WebCore/dom/SharedEventSenders.cpp b/Source/WebCore/dom/SharedEventSenders.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..5c749013928b30f530b81e2516a6426f443dbe49 >--- /dev/null >+++ b/Source/WebCore/dom/SharedEventSenders.cpp >@@ -0,0 +1,75 @@ >+/* >+ * Copyright (C) 2014 University of Washington. 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. >+ */ >+ >+#include "config.h" >+#include "SharedEventSenders.h" >+ >+#include "HTMLLinkElement.h" >+#include "HTMLStyleElement.h" >+#include "ImageLoader.h" >+ >+namespace WebCore { >+ >+EventSender<HTMLLinkElement>& SharedEventSenders::linkLoadEventSender() >+{ >+ if (!m_linkLoadEventSender) >+ m_linkLoadEventSender = std::make_unique<EventSender<HTMLLinkElement>>(m_document, eventNames().loadEvent); >+ >+ return *m_linkLoadEventSender; >+} >+ >+EventSender<HTMLStyleElement>& SharedEventSenders::styleLoadEventSender() >+{ >+ if (!m_styleLoadEventSender) >+ m_styleLoadEventSender = std::make_unique<EventSender<HTMLStyleElement>>(m_document, eventNames().loadEvent); >+ >+ return *m_styleLoadEventSender; >+} >+ >+EventSender<ImageLoader>& SharedEventSenders::imageBeforeloadEventSender() >+{ >+ if (!m_imageBeforeloadEventSender) >+ m_imageBeforeloadEventSender = std::make_unique<EventSender<ImageLoader>>(m_document, eventNames().beforeloadEvent); >+ >+ return *m_imageBeforeloadEventSender; >+} >+ >+EventSender<ImageLoader>& SharedEventSenders::imageLoadEventSender() >+{ >+ if (!m_imageLoadEventSender) >+ m_imageLoadEventSender = std::make_unique<EventSender<ImageLoader>>(m_document, eventNames().loadEvent); >+ >+ return *m_imageLoadEventSender; >+} >+ >+EventSender<ImageLoader>& SharedEventSenders::imageErrorEventSender() >+{ >+ if (!m_imageErrorEventSender) >+ m_imageErrorEventSender = std::make_unique<EventSender<ImageLoader>>(m_document, eventNames().errorEvent); >+ >+ return *m_imageErrorEventSender; >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/dom/SharedEventSenders.h b/Source/WebCore/dom/SharedEventSenders.h >new file mode 100644 >index 0000000000000000000000000000000000000000..c9d3a94207f32a324fd82379e32eec5973c64b80 >--- /dev/null >+++ b/Source/WebCore/dom/SharedEventSenders.h >@@ -0,0 +1,62 @@ >+/* >+ * Copyright (C) 2014 University of Washington. 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 SharedEventSenders_h >+#define SharedEventSenders_h >+ >+#include "EventNames.h" >+#include "EventSender.h" >+ >+namespace WebCore { >+ >+class HTMLLinkElement; >+class HTMLStyleElement; >+class ImageLoader; >+ >+class SharedEventSenders { >+ WTF_MAKE_NONCOPYABLE(SharedEventSenders); WTF_MAKE_FAST_ALLOCATED; >+public: >+ explicit SharedEventSenders(Document& document) >+ : m_document(document) >+ { >+ } >+ >+ EventSender<HTMLLinkElement>& linkLoadEventSender(); >+ EventSender<HTMLStyleElement>& styleLoadEventSender(); >+ EventSender<ImageLoader>& imageBeforeloadEventSender(); >+ EventSender<ImageLoader>& imageLoadEventSender(); >+ EventSender<ImageLoader>& imageErrorEventSender(); >+private: >+ Document& m_document; >+ std::unique_ptr<EventSender<HTMLLinkElement>> m_linkLoadEventSender; >+ std::unique_ptr<EventSender<HTMLStyleElement>> m_styleLoadEventSender; >+ std::unique_ptr<EventSender<ImageLoader>> m_imageBeforeloadEventSender; >+ std::unique_ptr<EventSender<ImageLoader>> m_imageLoadEventSender; >+ std::unique_ptr<EventSender<ImageLoader>> m_imageErrorEventSender; >+}; >+ >+} // namespace WebCore >+ >+#endif // SharedEventSenders_h >diff --git a/Source/WebCore/html/HTMLLinkElement.cpp b/Source/WebCore/html/HTMLLinkElement.cpp >index dd6f9878452ff40cba0517b9afd21dcca7d0f961..0f9a3020b717c8a91cc99fd9b3441175f4ed2f4b 100644 >--- a/Source/WebCore/html/HTMLLinkElement.cpp >+++ b/Source/WebCore/html/HTMLLinkElement.cpp >@@ -47,6 +47,7 @@ > #include "RenderStyle.h" > #include "SecurityOrigin.h" > #include "Settings.h" >+#include "SharedEventSenders.h" > #include "StyleInheritedData.h" > #include "StyleResolveForDocument.h" > #include "StyleSheetContents.h" >@@ -57,10 +58,9 @@ namespace WebCore { > > using namespace HTMLNames; > >-static LinkEventSender& linkLoadEventSender() >+LinkEventSender& HTMLLinkElement::linkLoadEventSender() const > { >- DEPRECATED_DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (eventNames().loadEvent)); >- return sharedLoadEventSender; >+ return document().sharedEventSenders().linkLoadEventSender(); > } > > inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document& document, bool createdByParser) >@@ -361,14 +361,9 @@ bool HTMLLinkElement::sheetLoaded() > return false; > } > >-void HTMLLinkElement::dispatchPendingLoadEvents() >+void HTMLLinkElement::dispatchPendingEvent(LinkEventSender& eventSender) > { >- linkLoadEventSender().dispatchPendingEvents(); >-} >- >-void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender) >-{ >- ASSERT_UNUSED(eventSender, eventSender == &linkLoadEventSender()); >+ ASSERT_UNUSED(eventSender, &eventSender == &linkLoadEventSender()); > if (m_loadedSheet) > linkLoaded(); > else >diff --git a/Source/WebCore/html/HTMLLinkElement.h b/Source/WebCore/html/HTMLLinkElement.h >index 49701f86fe4e7e43b11c24bd77595a70c4f6fc83..bfb695db3ceb1b8f167b5972113a79f2aaed43b1 100644 >--- a/Source/WebCore/html/HTMLLinkElement.h >+++ b/Source/WebCore/html/HTMLLinkElement.h >@@ -68,8 +68,8 @@ public: > void setSizes(const String&); > DOMSettableTokenList* sizes() const; > >- void dispatchPendingEvent(LinkEventSender*); >- static void dispatchPendingLoadEvents(); >+ void dispatchPendingEvent(LinkEventSender&); >+ LinkEventSender& linkLoadEventSender() const; > > private: > virtual void parseAttribute(const QualifiedName&, const AtomicString&) override; >diff --git a/Source/WebCore/html/HTMLStyleElement.cpp b/Source/WebCore/html/HTMLStyleElement.cpp >index 6806494928dc831c87d89d18e97ff8592a061b9d..d5986e5839d022e9d1e0bbb5f303d4ab19a9d1c2 100644 >--- a/Source/WebCore/html/HTMLStyleElement.cpp >+++ b/Source/WebCore/html/HTMLStyleElement.cpp >@@ -33,16 +33,16 @@ > #include "RuntimeEnabledFeatures.h" > #include "ScriptableDocumentParser.h" > #include "ShadowRoot.h" >+#include "SharedEventSenders.h" > #include "StyleSheetContents.h" > > namespace WebCore { > > using namespace HTMLNames; > >-static StyleEventSender& styleLoadEventSender() >+StyleEventSender& HTMLStyleElement::styleLoadEventSender() const > { >- DEPRECATED_DEFINE_STATIC_LOCAL(StyleEventSender, sharedLoadEventSender, (eventNames().loadEvent)); >- return sharedLoadEventSender; >+ return document().sharedEventSenders().styleLoadEventSender(); > } > > inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document& document, bool createdByParser) >@@ -114,14 +114,9 @@ void HTMLStyleElement::childrenChanged(const ChildChange& change) > m_styleSheetOwner.childrenChanged(*this); > } > >-void HTMLStyleElement::dispatchPendingLoadEvents() >+void HTMLStyleElement::dispatchPendingEvent(StyleEventSender& eventSender) > { >- styleLoadEventSender().dispatchPendingEvents(); >-} >- >-void HTMLStyleElement::dispatchPendingEvent(StyleEventSender* eventSender) >-{ >- ASSERT_UNUSED(eventSender, eventSender == &styleLoadEventSender()); >+ ASSERT_UNUSED(eventSender, &eventSender == &styleLoadEventSender()); > if (m_loadedSheet) > dispatchEvent(Event::create(eventNames().loadEvent, false, false)); > else >diff --git a/Source/WebCore/html/HTMLStyleElement.h b/Source/WebCore/html/HTMLStyleElement.h >index 9957ba50702821abaef68d0722fe7d56f1644380..2d7eaa9b5d2c7645207347f5ed0ec1cee34974a2 100644 >--- a/Source/WebCore/html/HTMLStyleElement.h >+++ b/Source/WebCore/html/HTMLStyleElement.h >@@ -44,8 +44,9 @@ public: > bool disabled() const; > void setDisabled(bool); > >- void dispatchPendingEvent(StyleEventSender*); >- static void dispatchPendingLoadEvents(); >+ void dispatchPendingEvent(StyleEventSender&); >+ >+ StyleEventSender& styleLoadEventSender() const; > > private: > HTMLStyleElement(const QualifiedName&, Document&, bool createdByParser); >diff --git a/Source/WebCore/loader/ImageLoader.cpp b/Source/WebCore/loader/ImageLoader.cpp >index 9bad9b47e4c6ff5eb96f8abaef92a72f56f42541..ea340f9331ec0dc0ac90980b8e8173ffeb54c419 100644 >--- a/Source/WebCore/loader/ImageLoader.cpp >+++ b/Source/WebCore/loader/ImageLoader.cpp >@@ -38,6 +38,7 @@ > #include "RenderImage.h" > #include "RenderSVGImage.h" > #include "SecurityOrigin.h" >+#include "SharedEventSenders.h" > #include <wtf/NeverDestroyed.h> > > #if ENABLE(VIDEO) >@@ -63,22 +64,19 @@ template<> struct ValueCheck<WebCore::ImageLoader*> { > > namespace WebCore { > >-static ImageEventSender& beforeLoadEventSender() >+ImageEventSender& ImageLoader::beforeLoadEventSender() const > { >- static NeverDestroyed<ImageEventSender> sender(eventNames().beforeloadEvent); >- return sender; >+ return m_element.document().sharedEventSenders().imageBeforeloadEventSender(); > } > >-static ImageEventSender& loadEventSender() >+ImageEventSender& ImageLoader::loadEventSender() const > { >- static NeverDestroyed<ImageEventSender> sender(eventNames().loadEvent); >- return sender; >+ return m_element.document().sharedEventSenders().imageLoadEventSender(); > } > >-static ImageEventSender& errorEventSender() >+ImageEventSender& ImageLoader::errorEventSender() const > { >- static NeverDestroyed<ImageEventSender> sender(eventNames().errorEvent); >- return sender; >+ return m_element.document().sharedEventSenders().imageErrorEventSender(); > } > > static inline bool pageIsBeingDismissed(Document& document) >@@ -379,10 +377,10 @@ void ImageLoader::timerFired(Timer<ImageLoader>&) > element().deref(); > } > >-void ImageLoader::dispatchPendingEvent(ImageEventSender* eventSender) >+void ImageLoader::dispatchPendingEvent(ImageEventSender& eventSender) > { >- ASSERT(eventSender == &beforeLoadEventSender() || eventSender == &loadEventSender() || eventSender == &errorEventSender()); >- const AtomicString& eventType = eventSender->eventType(); >+ ASSERT(&eventSender == &beforeLoadEventSender() || &eventSender == &loadEventSender() || &eventSender == &errorEventSender()); >+ const AtomicString& eventType = eventSender.eventType(); > if (eventType == eventNames().beforeloadEvent) > dispatchPendingBeforeLoadEvent(); > if (eventType == eventNames().loadEvent) >@@ -448,21 +446,6 @@ void ImageLoader::dispatchPendingErrorEvent() > updatedHasPendingEvent(); > } > >-void ImageLoader::dispatchPendingBeforeLoadEvents() >-{ >- beforeLoadEventSender().dispatchPendingEvents(); >-} >- >-void ImageLoader::dispatchPendingLoadEvents() >-{ >- loadEventSender().dispatchPendingEvents(); >-} >- >-void ImageLoader::dispatchPendingErrorEvents() >-{ >- errorEventSender().dispatchPendingEvents(); >-} >- > void ImageLoader::elementDidMoveToNewDocument() > { > clearFailedLoadURL(); >diff --git a/Source/WebCore/loader/ImageLoader.h b/Source/WebCore/loader/ImageLoader.h >index 5f3724ccabb65efa78bfdf867da1f278d4ddd73d..36ba58e8c44ed36bd12481ad40db6512fb4bed1f 100644 >--- a/Source/WebCore/loader/ImageLoader.h >+++ b/Source/WebCore/loader/ImageLoader.h >@@ -65,11 +65,11 @@ public: > bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; } > bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent; } > >- void dispatchPendingEvent(ImageEventSender*); >+ void dispatchPendingEvent(ImageEventSender&); > >- static void dispatchPendingBeforeLoadEvents(); >- static void dispatchPendingLoadEvents(); >- static void dispatchPendingErrorEvents(); >+ ImageEventSender& beforeLoadEventSender() const; >+ ImageEventSender& loadEventSender() const; >+ ImageEventSender& errorEventSender() const; > > protected: > explicit ImageLoader(Element&); >diff --git a/Source/WebCore/xml/parser/XMLDocumentParser.cpp b/Source/WebCore/xml/parser/XMLDocumentParser.cpp >index 11e347e03a5bf30e233e263600a5e9321653a533..45ea995ceef7300e4c0cc4e726fb797968c2d8e8 100644 >--- a/Source/WebCore/xml/parser/XMLDocumentParser.cpp >+++ b/Source/WebCore/xml/parser/XMLDocumentParser.cpp >@@ -48,6 +48,7 @@ > #include "SVGStyleElement.h" > #include "ScriptElement.h" > #include "ScriptSourceCode.h" >+#include "SharedEventSenders.h" > #include "TextResourceDecoder.h" > #include "TreeDepthLimit.h" > #include <wtf/Ref.h> >@@ -120,9 +121,6 @@ void XMLDocumentParser::append(PassRefPtr<StringImpl> inputSource) > } > > doWrite(source.toString()); >- >- // After parsing, go ahead and dispatch image beforeload events. >- ImageLoader::dispatchPendingBeforeLoadEvents(); > } > > void XMLDocumentParser::handleError(XMLErrors::ErrorType type, const char* m, TextPosition position)
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 136051
:
236793
|
238735
|
238741
|
239062