Title: [174278] trunk/Source/WebCore

Diff

Modified: trunk/Source/WebCore/CMakeLists.txt (174277 => 174278)


--- trunk/Source/WebCore/CMakeLists.txt	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/CMakeLists.txt	2014-10-03 20:08:32 UTC (rev 174278)
@@ -1437,7 +1437,6 @@
     dom/SecurityContext.cpp
     dom/SelectorQuery.cpp
     dom/ShadowRoot.cpp
-    dom/SharedEventSenders.cpp
     dom/SpaceSplitString.cpp
     dom/StaticNodeList.cpp
     dom/StringCallback.cpp

Modified: trunk/Source/WebCore/ChangeLog (174277 => 174278)


--- trunk/Source/WebCore/ChangeLog	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/ChangeLog	2014-10-03 20:08:32 UTC (rev 174278)
@@ -1,3 +1,16 @@
+2014-10-03  Commit Queue  <[email protected]>
+
+        Unreviewed, rolling out r174270.
+        https://bugs.webkit.org/show_bug.cgi?id=137397
+
+        crashes on the bots (Requested by dethbakin on #webkit).
+
+        Reverted changeset:
+
+        "EventSender dispatches should be per-Document"
+        https://bugs.webkit.org/show_bug.cgi?id=136051
+        http://trac.webkit.org/changeset/174270
+
 2014-10-03  Jer Noble  <[email protected]>
 
         [iOS] Back-to-back fullscreen videos result in incorrectly sized videos

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj (174277 => 174278)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj	2014-10-03 20:08:32 UTC (rev 174278)
@@ -13778,20 +13778,6 @@
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
     </ClCompile>
-    <ClCompile Include="..\dom\SharedEventSenders.cpp">
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='DebugSuffix|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Release_WinCairo|x64'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|Win32'">true</ExcludedFromBuild>
-      <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Production|x64'">true</ExcludedFromBuild>
-    </ClCompile>
     <ClCompile Include="..\dom\SpaceSplitString.cpp">
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">true</ExcludedFromBuild>
       <ExcludedFromBuild Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">true</ExcludedFromBuild>
@@ -20597,7 +20583,6 @@
     <ClInclude Include="..\dom\SecurityContext.h" />
     <ClInclude Include="..\dom\SelectorQuery.h" />
     <ClInclude Include="..\dom\SimulatedClickOptions.h" />
-    <ClInclude Include="..\dom\SharedEventSenders.h" />
     <ClInclude Include="..\dom\SpaceSplitString.h" />
     <ClInclude Include="..\dom\StaticHashSetNodeList.h" />
     <ClInclude Include="..\dom\StaticNodeList.h" />

Modified: trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters (174277 => 174278)


--- trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/WebCore.vcxproj/WebCore.vcxproj.filters	2014-10-03 20:08:32 UTC (rev 174278)
@@ -3354,9 +3354,6 @@
     <ClCompile Include="..\dom\SelectorQuery.cpp">
       <Filter>dom</Filter>
     </ClCompile>
-    <ClCompile Include="..\dom\SharedEventSenders.cpp">
-      <Filter>dom</Filter>
-    </ClCompile>
     <ClCompile Include="..\dom\SpaceSplitString.cpp">
       <Filter>dom</Filter>
     </ClCompile>
@@ -10455,9 +10452,6 @@
     <ClInclude Include="..\dom\SelectorQuery.h">
       <Filter>dom</Filter>
     </ClInclude>
-    <ClInclude Include="..\dom\SharedEventSenders.h">
-      <Filter>dom</Filter>
-    </ClInclude>
     <ClInclude Include="..\dom\SimulatedClickOptions.h">
       <Filter>dom</Filter>
     </ClInclude>

Modified: trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj (174277 => 174278)


--- trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/WebCore.xcodeproj/project.pbxproj	2014-10-03 20:08:32 UTC (rev 174278)
@@ -5517,9 +5517,6 @@
 		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, ); }; };
 		C50B561612119D23008B46E0 /* GroupSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C50B561412119D23008B46E0 /* GroupSettings.cpp */; };
@@ -12938,8 +12935,6 @@
 		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>"; };
 		C50B561412119D23008B46E0 /* GroupSettings.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = GroupSettings.cpp; sourceTree = "<group>"; };
@@ -22797,8 +22792,6 @@
 				E45322AA140CE267005A0F92 /* SelectorQuery.h */,
 				A6D169611346B49B000EB770 /* ShadowRoot.cpp */,
 				A6D169631346B4C1000EB770 /* ShadowRoot.h */,
-				C49474A919A2E2E5009B3DE8 /* SharedEventSenders.cpp */,
-				C49474A019A2847C009B3DE8 /* SharedEventSenders.h */,
 				31741AAB16635E45008A5B7E /* SimulatedClickOptions.h */,
 				D01A27AB10C9BFD800026A42 /* SpaceSplitString.cpp */,
 				D01A27AC10C9BFD800026A42 /* SpaceSplitString.h */,
@@ -23393,7 +23386,6 @@
 				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 */,
@@ -26433,7 +26425,6 @@
 				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 */,
@@ -28100,7 +28091,6 @@
 				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 */,

Modified: trunk/Source/WebCore/dom/DOMAllInOne.cpp (174277 => 174278)


--- trunk/Source/WebCore/dom/DOMAllInOne.cpp	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/dom/DOMAllInOne.cpp	2014-10-03 20:08:32 UTC (rev 174278)
@@ -124,7 +124,6 @@
 #include "SecurityContext.cpp"
 #include "SelectorQuery.cpp"
 #include "ShadowRoot.cpp"
-#include "SharedEventSenders.cpp"
 #include "SpaceSplitString.cpp"
 #include "StaticNodeList.cpp"
 #include "StyledElement.cpp"

Modified: trunk/Source/WebCore/dom/Document.cpp (174277 => 174278)


--- trunk/Source/WebCore/dom/Document.cpp	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/dom/Document.cpp	2014-10-03 20:08:32 UTC (rev 174278)
@@ -138,7 +138,6 @@
 #include "SelectorQuery.h"
 #include "Settings.h"
 #include "ShadowRoot.h"
-#include "SharedEventSenders.h"
 #include "StyleProperties.h"
 #include "StyleResolver.h"
 #include "StyleSheetContents.h"
@@ -472,7 +471,6 @@
     , m_sawElementsInKnownNamespaces(false)
     , m_isSrcdocDocument(false)
     , m_eventQueue(*this)
-    , m_sharedEventSenders(std::make_unique<SharedEventSenders>())
     , m_weakFactory(this)
 #if ENABLE(FULLSCREEN_API)
     , m_areKeysEnabledInFullScreen(0)
@@ -2424,19 +2422,21 @@
     //  -When any new HTMLLinkElement is inserted into the document
     // But those add a dynamic component to the favicon that has UI 
     // ramifications, and we need to decide what is the Right Thing To Do(tm)
-    Frame* frame = this->frame();
-    if (frame) {
-        frame->loader().icon().startLoader();
-        frame->animation().startAnimationsIfNotSuspended(this);
+    Frame* f = frame();
+    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 ='' its fired at a later time, once all external resources finished loading).
@@ -2447,15 +2447,15 @@
     enqueuePageshowEvent(PageshowEventNotPersisted);
     enqueuePopstateEvent(m_pendingStateObject ? m_pendingStateObject.release() : SerializedScriptValue::nullValue());
     
-    if (frame)
-        frame->loader().handledOnloadEvents();
+    if (f)
+        f->loader().handledOnloadEvents();
 #ifdef INSTRUMENT_LAYOUT_SCHEDULING
     if (!ownerElement())
         printf("onload fired at %lld\n", elapsedTime().count());
 #endif
 
     // An event handler may have removed the frame
-    if (!this->frame()) {
+    if (!frame()) {
         m_processingLoadEvent = false;
         return;
     }
@@ -2464,7 +2464,7 @@
     // fires. This will improve onload scores, and other browsers do it.
     // If they wanna cheat, we can too. -dwh
 
-    if (this->frame()->navigationScheduler().locationChangePending() && elapsedTime() < settings()->layoutInterval()) {
+    if (frame()->navigationScheduler().locationChangePending() && elapsedTime() < settings()->layoutInterval()) {
         // Just bail out. Before or during the onload we were shifted to another page.
         // The old i-Bench suite does this. When this happens don't bother painting or laying out.        
         m_processingLoadEvent = false;
@@ -2472,7 +2472,7 @@
         return;
     }
 
-    this->frame()->loader().checkCallImplicitClose();
+    frame()->loader().checkCallImplicitClose();
     
     // We used to force a synchronous display and flush here.  This really isn't
     // necessary and can in fact be actively harmful if pages are loading at a rate of > 60fps
@@ -2489,7 +2489,7 @@
     m_processingLoadEvent = false;
 
 #if PLATFORM(COCOA) || PLATFORM(WIN) || PLATFORM(GTK) || PLATFORM(EFL)
-    if (frame && hasLivingRenderTree() && AXObjectCache::accessibilityEnabled()) {
+    if (f && hasLivingRenderTree() && AXObjectCache::accessibilityEnabled()) {
         // The AX cache may have been cleared at this point, but we need to make sure it contains an
         // AX object to send the notification to. getOrCreate will make sure that an valid AX object
         // exists in the cache (we ignore the return value because we don't need it here). This is 

Modified: trunk/Source/WebCore/dom/Document.h (174277 => 174278)


--- trunk/Source/WebCore/dom/Document.h	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/dom/Document.h	2014-10-03 20:08:32 UTC (rev 174278)
@@ -144,7 +144,6 @@
 class SerializedScriptValue;
 class SegmentedString;
 class Settings;
-class SharedEventSenders;
 class StyleResolver;
 class StyleSheet;
 class StyleSheetContents;
@@ -1120,8 +1119,6 @@
     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();
@@ -1579,8 +1576,6 @@
     RenderPtr<RenderView> m_renderView;
     mutable DocumentEventQueue m_eventQueue;
 
-    const std::unique_ptr<SharedEventSenders> m_sharedEventSenders;
-
     WeakPtrFactory<Document> m_weakFactory;
 
     HashSet<MediaCanStartListener*> m_mediaCanStartListeners;

Modified: trunk/Source/WebCore/dom/EventSender.h (174277 => 174278)


--- trunk/Source/WebCore/dom/EventSender.h	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/dom/EventSender.h	2014-10-03 20:08:32 UTC (rev 174278)
@@ -1,6 +1,5 @@
 /*
  * 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
@@ -32,15 +31,10 @@
 
 namespace WebCore {
 
-template <typename T>
-class EventSender {
+template<typename T> class EventSender {
     WTF_MAKE_NONCOPYABLE(EventSender); WTF_MAKE_FAST_ALLOCATED;
 public:
-    EventSender(const AtomicString& eventType)
-        : m_eventType(eventType)
-        , m_timer(this, &EventSender::timerFired)
-    {
-    }
+    explicit EventSender(const AtomicString& eventType);
 
     const AtomicString& eventType() const { return m_eventType; }
     void dispatchEventSoon(T&);
@@ -48,9 +42,9 @@
     void dispatchPendingEvents();
 
 #ifndef NDEBUG
-    bool hasPendingEvents(T& client) const
+    bool hasPendingEvents(T& sender) const
     {
-        return m_dispatchSoonList.find(&client) != notFound || m_dispatchingList.find(&client) != notFound;
+        return m_dispatchSoonList.find(&sender) != notFound || m_dispatchingList.find(&sender) != notFound;
     }
 #endif
 
@@ -63,31 +57,34 @@
     Vector<T*> m_dispatchingList;
 };
 
-template <typename T>
-void EventSender<T>::dispatchEventSoon(T& client)
+template<typename T> EventSender<T>::EventSender(const AtomicString& eventType)
+    : m_eventType(eventType)
+    , m_timer(this, &EventSender::timerFired)
 {
-    m_dispatchSoonList.append(&client);
+}
+
+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& client)
+template<typename T> void EventSender<T>::cancelEvent(T& sender)
 {
-    // Remove instances of this client from both lists.
+    // Remove instances of this sender from both lists.
     // Use loops because we allow multiple instances to get into the lists.
     for (auto& event : m_dispatchSoonList) {
-        if (event == &client)
+        if (event == &sender)
             event = nullptr;
     }
     for (auto& event : m_dispatchingList) {
-        if (event == &client)
+        if (event == &sender)
             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
@@ -97,11 +94,13 @@
 
     m_timer.stop();
 
+    m_dispatchSoonList.checkConsistency();
+
     m_dispatchingList.swap(m_dispatchSoonList);
     for (auto& event : m_dispatchingList) {
-        if (T* client = event) {
+        if (T* sender = event) {
             event = nullptr;
-            client->dispatchPendingEvent(*this);
+            sender->dispatchPendingEvent(this);
         }
     }
     m_dispatchingList.clear();

Deleted: trunk/Source/WebCore/dom/SharedEventSenders.cpp (174277 => 174278)


--- trunk/Source/WebCore/dom/SharedEventSenders.cpp	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/dom/SharedEventSenders.cpp	2014-10-03 20:08:32 UTC (rev 174278)
@@ -1,75 +0,0 @@
-/*
- * 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>>(eventNames().loadEvent);
-
-    return *m_linkLoadEventSender;
-}
-
-EventSender<HTMLStyleElement>& SharedEventSenders::styleLoadEventSender()
-{
-    if (!m_styleLoadEventSender)
-        m_styleLoadEventSender = std::make_unique<EventSender<HTMLStyleElement>>(eventNames().loadEvent);
-
-    return *m_styleLoadEventSender;
-}
-
-EventSender<ImageLoader>& SharedEventSenders::imageBeforeloadEventSender()
-{
-    if (!m_imageBeforeloadEventSender)
-        m_imageBeforeloadEventSender = std::make_unique<EventSender<ImageLoader>>(eventNames().beforeloadEvent);
-
-    return *m_imageBeforeloadEventSender;
-}
-
-EventSender<ImageLoader>& SharedEventSenders::imageLoadEventSender()
-{
-    if (!m_imageLoadEventSender)
-        m_imageLoadEventSender = std::make_unique<EventSender<ImageLoader>>(eventNames().loadEvent);
-
-    return *m_imageLoadEventSender;
-}
-
-EventSender<ImageLoader>& SharedEventSenders::imageErrorEventSender()
-{
-    if (!m_imageErrorEventSender)
-        m_imageErrorEventSender = std::make_unique<EventSender<ImageLoader>>(eventNames().errorEvent);
-
-    return *m_imageErrorEventSender;
-}
-
-} // namespace WebCore

Deleted: trunk/Source/WebCore/dom/SharedEventSenders.h (174277 => 174278)


--- trunk/Source/WebCore/dom/SharedEventSenders.h	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/dom/SharedEventSenders.h	2014-10-03 20:08:32 UTC (rev 174278)
@@ -1,58 +0,0 @@
-/*
- * 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() { }
-
-    EventSender<HTMLLinkElement>& linkLoadEventSender();
-    EventSender<HTMLStyleElement>& styleLoadEventSender();
-    EventSender<ImageLoader>& imageBeforeloadEventSender();
-    EventSender<ImageLoader>& imageLoadEventSender();
-    EventSender<ImageLoader>& imageErrorEventSender();
-private:
-    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

Modified: trunk/Source/WebCore/html/HTMLLinkElement.cpp (174277 => 174278)


--- trunk/Source/WebCore/html/HTMLLinkElement.cpp	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/html/HTMLLinkElement.cpp	2014-10-03 20:08:32 UTC (rev 174278)
@@ -33,6 +33,7 @@
 #include "Document.h"
 #include "DocumentStyleSheetCollection.h"
 #include "Event.h"
+#include "EventSender.h"
 #include "Frame.h"
 #include "FrameLoader.h"
 #include "FrameLoaderClient.h"
@@ -46,7 +47,6 @@
 #include "RenderStyle.h"
 #include "SecurityOrigin.h"
 #include "Settings.h"
-#include "SharedEventSenders.h"
 #include "StyleInheritedData.h"
 #include "StyleResolveForDocument.h"
 #include "StyleSheetContents.h"
@@ -57,6 +57,12 @@
 
 using namespace HTMLNames;
 
+static LinkEventSender& linkLoadEventSender()
+{
+    DEPRECATED_DEFINE_STATIC_LOCAL(LinkEventSender, sharedLoadEventSender, (eventNames().loadEvent));
+    return sharedLoadEventSender;
+}
+
 inline HTMLLinkElement::HTMLLinkElement(const QualifiedName& tagName, Document& document, bool createdByParser)
     : HTMLElement(tagName, document)
     , m_linkLoader(this)
@@ -88,7 +94,7 @@
     if (inDocument())
         document().styleSheetCollection().removeStyleSheetCandidateNode(*this);
 
-    document().sharedEventSenders().linkLoadEventSender().cancelEvent(*this);
+    linkLoadEventSender().cancelEvent(*this);
 }
 
 void HTMLLinkElement::setDisabledState(bool disabled)
@@ -355,10 +361,14 @@
     return false;
 }
 
-void HTMLLinkElement::dispatchPendingEvent(EventSender<HTMLLinkElement>& eventSender)
+void HTMLLinkElement::dispatchPendingLoadEvents()
 {
-    ASSERT_UNUSED(eventSender, &eventSender == &document().sharedEventSenders().linkLoadEventSender());
+    linkLoadEventSender().dispatchPendingEvents();
+}
 
+void HTMLLinkElement::dispatchPendingEvent(LinkEventSender* eventSender)
+{
+    ASSERT_UNUSED(eventSender, eventSender == &linkLoadEventSender());
     if (m_loadedSheet)
         linkLoaded();
     else
@@ -370,7 +380,7 @@
     if (m_firedLoad)
         return;
     m_loadedSheet = !errorOccurred;
-    document().sharedEventSenders().linkLoadEventSender().dispatchEventSoon(*this);
+    linkLoadEventSender().dispatchEventSoon(*this);
     m_firedLoad = true;
 }
 

Modified: trunk/Source/WebCore/html/HTMLLinkElement.h (174277 => 174278)


--- trunk/Source/WebCore/html/HTMLLinkElement.h	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/html/HTMLLinkElement.h	2014-10-03 20:08:32 UTC (rev 174278)
@@ -40,6 +40,7 @@
 class URL;
 
 template<typename T> class EventSender;
+typedef EventSender<HTMLLinkElement> LinkEventSender;
 
 class HTMLLinkElement final : public HTMLElement, public CachedStyleSheetClient, public LinkLoaderClient {
 public:
@@ -67,7 +68,8 @@
     void setSizes(const String&);
     DOMSettableTokenList* sizes() const;
 
-    void dispatchPendingEvent(EventSender<HTMLLinkElement>&);
+    void dispatchPendingEvent(LinkEventSender*);
+    static void dispatchPendingLoadEvents();
 
 private:
     virtual void parseAttribute(const QualifiedName&, const AtomicString&) override;

Modified: trunk/Source/WebCore/html/HTMLStyleElement.cpp (174277 => 174278)


--- trunk/Source/WebCore/html/HTMLStyleElement.cpp	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/html/HTMLStyleElement.cpp	2014-10-03 20:08:32 UTC (rev 174278)
@@ -27,18 +27,23 @@
 #include "Attribute.h"
 #include "Document.h"
 #include "Event.h"
+#include "EventSender.h"
 #include "HTMLNames.h"
 #include "MediaList.h"
 #include "RuntimeEnabledFeatures.h"
 #include "ScriptableDocumentParser.h"
 #include "ShadowRoot.h"
-#include "SharedEventSenders.h"
 #include "StyleSheetContents.h"
 
 namespace WebCore {
 
 using namespace HTMLNames;
 
+static StyleEventSender& styleLoadEventSender()
+{
+    DEPRECATED_DEFINE_STATIC_LOCAL(StyleEventSender, sharedLoadEventSender, (eventNames().loadEvent));
+    return sharedLoadEventSender;
+}
 
 inline HTMLStyleElement::HTMLStyleElement(const QualifiedName& tagName, Document& document, bool createdByParser)
     : HTMLElement(tagName, document)
@@ -55,7 +60,7 @@
     // Therefore we can't ASSERT(m_scopedStyleRegistrationState == NotRegistered).
     m_styleSheetOwner.clearDocumentData(document(), *this);
 
-    document().sharedEventSenders().styleLoadEventSender().cancelEvent(*this);
+    styleLoadEventSender().cancelEvent(*this);
 }
 
 PassRefPtr<HTMLStyleElement> HTMLStyleElement::create(const QualifiedName& tagName, Document& document, bool createdByParser)
@@ -109,10 +114,14 @@
     m_styleSheetOwner.childrenChanged(*this);
 }
 
-void HTMLStyleElement::dispatchPendingEvent(EventSender<HTMLStyleElement>& eventSender)
+void HTMLStyleElement::dispatchPendingLoadEvents()
 {
-    ASSERT_UNUSED(eventSender, &eventSender == &document().sharedEventSenders().styleLoadEventSender());
+    styleLoadEventSender().dispatchPendingEvents();
+}
 
+void HTMLStyleElement::dispatchPendingEvent(StyleEventSender* eventSender)
+{
+    ASSERT_UNUSED(eventSender, eventSender == &styleLoadEventSender());
     if (m_loadedSheet)
         dispatchEvent(Event::create(eventNames().loadEvent, false, false));
     else
@@ -124,7 +133,7 @@
     if (m_firedLoad)
         return;
     m_loadedSheet = !errorOccurred;
-    document().sharedEventSenders().styleLoadEventSender().dispatchEventSoon(*this);
+    styleLoadEventSender().dispatchEventSoon(*this);
     m_firedLoad = true;
 }
 

Modified: trunk/Source/WebCore/html/HTMLStyleElement.h (174277 => 174278)


--- trunk/Source/WebCore/html/HTMLStyleElement.h	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/html/HTMLStyleElement.h	2014-10-03 20:08:32 UTC (rev 174278)
@@ -32,6 +32,7 @@
 class StyleSheet;
 
 template<typename T> class EventSender;
+typedef EventSender<HTMLStyleElement> StyleEventSender;
 
 class HTMLStyleElement final : public HTMLElement {
 public:
@@ -43,7 +44,8 @@
     bool disabled() const;
     void setDisabled(bool);
 
-    void dispatchPendingEvent(EventSender<HTMLStyleElement>&);
+    void dispatchPendingEvent(StyleEventSender*);
+    static void dispatchPendingLoadEvents();
 
 private:
     HTMLStyleElement(const QualifiedName&, Document&, bool createdByParser);

Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (174277 => 174278)


--- trunk/Source/WebCore/loader/ImageLoader.cpp	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp	2014-10-03 20:08:32 UTC (rev 174278)
@@ -29,6 +29,7 @@
 #include "Document.h"
 #include "Element.h"
 #include "Event.h"
+#include "EventSender.h"
 #include "Frame.h"
 #include "HTMLNames.h"
 #include "HTMLObjectElement.h"
@@ -37,7 +38,6 @@
 #include "RenderImage.h"
 #include "RenderSVGImage.h"
 #include "SecurityOrigin.h"
-#include "SharedEventSenders.h"
 #include <wtf/NeverDestroyed.h>
 
 #if ENABLE(VIDEO)
@@ -63,19 +63,22 @@
 
 namespace WebCore {
 
-EventSender<ImageLoader>& ImageLoader::beforeLoadEventSender() const
+static ImageEventSender& beforeLoadEventSender()
 {
-    return m_element.document().sharedEventSenders().imageBeforeloadEventSender();
+    static NeverDestroyed<ImageEventSender> sender(eventNames().beforeloadEvent);
+    return sender;
 }
 
-EventSender<ImageLoader>& ImageLoader::loadEventSender() const
+static ImageEventSender& loadEventSender()
 {
-    return m_element.document().sharedEventSenders().imageLoadEventSender();
+    static NeverDestroyed<ImageEventSender> sender(eventNames().loadEvent);
+    return sender;
 }
 
-EventSender<ImageLoader>& ImageLoader::errorEventSender() const
+static ImageEventSender& errorEventSender()
 {
-    return m_element.document().sharedEventSenders().imageErrorEventSender();
+    static NeverDestroyed<ImageEventSender> sender(eventNames().errorEvent);
+    return sender;
 }
 
 static inline bool pageIsBeingDismissed(Document& document)
@@ -376,10 +379,10 @@
     element().deref();
 }
 
-void ImageLoader::dispatchPendingEvent(EventSender<ImageLoader>& 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)
@@ -445,6 +448,21 @@
     updatedHasPendingEvent();
 }
 
+void ImageLoader::dispatchPendingBeforeLoadEvents()
+{
+    beforeLoadEventSender().dispatchPendingEvents();
+}
+
+void ImageLoader::dispatchPendingLoadEvents()
+{
+    loadEventSender().dispatchPendingEvents();
+}
+
+void ImageLoader::dispatchPendingErrorEvents()
+{
+    errorEventSender().dispatchPendingEvents();
+}
+
 void ImageLoader::elementDidMoveToNewDocument()
 {
     clearFailedLoadURL();

Modified: trunk/Source/WebCore/loader/ImageLoader.h (174277 => 174278)


--- trunk/Source/WebCore/loader/ImageLoader.h	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/loader/ImageLoader.h	2014-10-03 20:08:32 UTC (rev 174278)
@@ -35,6 +35,7 @@
 class RenderImageResource;
 
 template<typename T> class EventSender;
+typedef EventSender<ImageLoader> ImageEventSender;
 
 class ImageLoader : public CachedImageClient {
     WTF_MAKE_FAST_ALLOCATED;
@@ -64,11 +65,11 @@
     bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; }
     bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent; }
 
-    void dispatchPendingEvent(EventSender<ImageLoader>&);
+    void dispatchPendingEvent(ImageEventSender*);
 
-    EventSender<ImageLoader>& beforeLoadEventSender() const;
-    EventSender<ImageLoader>& loadEventSender() const;
-    EventSender<ImageLoader>& errorEventSender() const;
+    static void dispatchPendingBeforeLoadEvents();
+    static void dispatchPendingLoadEvents();
+    static void dispatchPendingErrorEvents();
 
 protected:
     explicit ImageLoader(Element&);

Modified: trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp (174277 => 174278)


--- trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2014-10-03 20:07:01 UTC (rev 174277)
+++ trunk/Source/WebCore/xml/parser/XMLDocumentParser.cpp	2014-10-03 20:08:32 UTC (rev 174278)
@@ -120,6 +120,9 @@
     }
 
     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)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to