Title: [274199] trunk
Revision
274199
Author
[email protected]
Date
2021-03-09 22:39:48 -0800 (Tue, 09 Mar 2021)

Log Message

Unreviewed, reverting r274054.

Broke http/tests/misc/empty-urls.html

Reverted changeset:

"Use counters for pending events"
https://bugs.webkit.org/show_bug.cgi?id=218556
https://commits.webkit.org/r274054

Modified Paths

Diff

Modified: trunk/LayoutTests/ChangeLog (274198 => 274199)


--- trunk/LayoutTests/ChangeLog	2021-03-10 06:20:46 UTC (rev 274198)
+++ trunk/LayoutTests/ChangeLog	2021-03-10 06:39:48 UTC (rev 274199)
@@ -1,3 +1,15 @@
+2021-03-09  Ryosuke Niwa  <[email protected]>
+
+        Unreviewed, reverting r274054.
+
+        Broke http/tests/misc/empty-urls.html
+
+        Reverted changeset:
+
+        "Use counters for pending events"
+        https://bugs.webkit.org/show_bug.cgi?id=218556
+        https://commits.webkit.org/r274054
+
 2021-03-09  Ryan Haddad  <[email protected]>
 
         Resync web-platform-tests/dom tests from upstream

Modified: trunk/LayoutTests/fast/dom/modify-node-and-while-in-the-callback-too-crash.html (274198 => 274199)


--- trunk/LayoutTests/fast/dom/modify-node-and-while-in-the-callback-too-crash.html	2021-03-10 06:20:46 UTC (rev 274198)
+++ trunk/LayoutTests/fast/dom/modify-node-and-while-in-the-callback-too-crash.html	2021-03-10 06:39:48 UTC (rev 274199)
@@ -15,8 +15,7 @@
         var container = document.getElementById('container');
 
         img._onerror_ = function() { 
-            if (container.parentNode)
-                container.parentNode.removeChild(container);
+            container.parentNode.removeChild(container);
         }
         
         container.appendChild(img);

Modified: trunk/Source/WebCore/ChangeLog (274198 => 274199)


--- trunk/Source/WebCore/ChangeLog	2021-03-10 06:20:46 UTC (rev 274198)
+++ trunk/Source/WebCore/ChangeLog	2021-03-10 06:39:48 UTC (rev 274199)
@@ -1,3 +1,15 @@
+2021-03-09  Ryosuke Niwa  <[email protected]>
+
+        Unreviewed, reverting r274054.
+
+        Broke http/tests/misc/empty-urls.html
+
+        Reverted changeset:
+
+        "Use counters for pending events"
+        https://bugs.webkit.org/show_bug.cgi?id=218556
+        https://commits.webkit.org/r274054
+
 2021-03-09  Antoine Quint  <[email protected]>
 
         Correctly blend the flex-basis CSS property

Modified: trunk/Source/WebCore/loader/ImageLoader.cpp (274198 => 274199)


--- trunk/Source/WebCore/loader/ImageLoader.cpp	2021-03-10 06:20:46 UTC (rev 274198)
+++ trunk/Source/WebCore/loader/ImageLoader.cpp	2021-03-10 06:39:48 UTC (rev 274199)
@@ -98,6 +98,9 @@
     : m_element(element)
     , m_image(nullptr)
     , m_derefElementTimer(*this, &ImageLoader::timerFired)
+    , m_hasPendingBeforeLoadEvent(false)
+    , m_hasPendingLoadEvent(false)
+    , m_hasPendingErrorEvent(false)
     , m_imageComplete(true)
     , m_loadManually(false)
     , m_elementIsProtected(false)
@@ -109,16 +112,16 @@
     if (m_image)
         m_image->removeClient(*this);
 
-    ASSERT(m_pendingBeforeLoadEventCount || !beforeLoadEventSender().hasPendingEvents(*this));
-    if (m_pendingBeforeLoadEventCount)
+    ASSERT(m_hasPendingBeforeLoadEvent || !beforeLoadEventSender().hasPendingEvents(*this));
+    if (m_hasPendingBeforeLoadEvent)
         beforeLoadEventSender().cancelEvent(*this);
 
-    ASSERT(m_pendingLoadEventCount || !loadEventSender().hasPendingEvents(*this));
-    if (m_pendingLoadEventCount)
+    ASSERT(m_hasPendingLoadEvent || !loadEventSender().hasPendingEvents(*this));
+    if (m_hasPendingLoadEvent)
         loadEventSender().cancelEvent(*this);
 
-    ASSERT(m_pendingErrorEventCount || !errorEventSender().hasPendingEvents(*this));
-    if (m_pendingErrorEventCount)
+    ASSERT(m_hasPendingErrorEvent || !errorEventSender().hasPendingEvents(*this));
+    if (m_hasPendingErrorEvent)
         errorEventSender().cancelEvent(*this);
 }
 
@@ -137,17 +140,17 @@
     CachedImage* oldImage = m_image.get();
     if (oldImage) {
         m_image = nullptr;
-        if (m_pendingBeforeLoadEventCount) {
+        if (m_hasPendingBeforeLoadEvent) {
             beforeLoadEventSender().cancelEvent(*this);
-            m_pendingBeforeLoadEventCount--;
+            m_hasPendingBeforeLoadEvent = false;
         }
-        if (m_pendingLoadEventCount) {
+        if (m_hasPendingLoadEvent) {
             loadEventSender().cancelEvent(*this);
-            m_pendingLoadEventCount--;
+            m_hasPendingLoadEvent = false;
         }
-        if (m_pendingErrorEventCount) {
+        if (m_hasPendingErrorEvent) {
             errorEventSender().cancelEvent(*this);
-            m_pendingErrorEventCount--;
+            m_hasPendingErrorEvent = false;
         }
         m_imageComplete = true;
         if (oldImage)
@@ -221,7 +224,7 @@
         // error event if the page is not being dismissed.
         if (!newImage && !pageIsBeingDismissed(document)) {
             m_failedLoadURL = attr;
-            m_pendingErrorEventCount++;
+            m_hasPendingErrorEvent = true;
             errorEventSender().dispatchEventSoon(*this);
         } else
             clearFailedLoadURL();
@@ -228,19 +231,19 @@
     } else if (!attr.isNull()) {
         // Fire an error event if the url is empty.
         m_failedLoadURL = attr;
-        m_pendingErrorEventCount++;
+        m_hasPendingErrorEvent = true;
         errorEventSender().dispatchEventSoon(*this);
     }
 
     CachedImage* oldImage = m_image.get();
     if (newImage != oldImage || relevantMutation == RelevantMutation::Yes) {
-        if (m_pendingBeforeLoadEventCount) {
+        if (m_hasPendingBeforeLoadEvent) {
             beforeLoadEventSender().cancelEvent(*this);
-            m_pendingBeforeLoadEventCount--;
+            m_hasPendingBeforeLoadEvent = false;
         }
-        if (m_pendingLoadEventCount) {
+        if (m_hasPendingLoadEvent) {
             loadEventSender().cancelEvent(*this);
-            m_pendingLoadEventCount--;
+            m_hasPendingLoadEvent = false;
         }
 
         // Cancel error events that belong to the previous load, which is now cancelled by changing the src attribute.
@@ -247,16 +250,14 @@
         // If newImage is null and m_hasPendingErrorEvent is true, we know the error event has been just posted by
         // this load and we should not cancel the event.
         // FIXME: If both previous load and this one got blocked with an error, we can receive one error event instead of two.
-        if (m_pendingErrorEventCount && newImage) {
+        if (m_hasPendingErrorEvent && newImage) {
             errorEventSender().cancelEvent(*this);
-            m_pendingErrorEventCount--;
+            m_hasPendingErrorEvent = false;
         }
 
         m_image = newImage;
-        if (!document.isImageDocument() && newImage)
-            m_pendingBeforeLoadEventCount++;
-        if (newImage)
-            m_pendingLoadEventCount++;
+        m_hasPendingBeforeLoadEvent = !document.isImageDocument() && newImage;
+        m_hasPendingLoadEvent = newImage;
         m_imageComplete = !newImage;
 
         if (newImage) {
@@ -337,7 +338,7 @@
     if (!hasPendingBeforeLoadEvent())
         updateRenderer();
 
-    if (!m_pendingLoadEventCount)
+    if (!m_hasPendingLoadEvent)
         return;
 
     if (m_image->resourceError().isAccessControl()) {
@@ -345,7 +346,7 @@
 
         clearImageWithoutConsideringPendingLoadEvent();
 
-        m_pendingErrorEventCount++;
+        m_hasPendingErrorEvent = true;
         errorEventSender().dispatchEventSoon(*this);
 
         auto message = makeString("Cannot load image ", imageURL.string(), " due to access control checks.");
@@ -354,7 +355,7 @@
         if (hasPendingDecodePromises())
             rejectDecodePromises("Access control error.");
         
-        ASSERT(!m_pendingLoadEventCount);
+        ASSERT(!m_hasPendingLoadEvent);
 
         // Only consider updating the protection ref-count of the Element immediately before returning
         // from this function as doing so might result in the destruction of this ImageLoader.
@@ -365,8 +366,7 @@
     if (m_image->wasCanceled()) {
         if (hasPendingDecodePromises())
             rejectDecodePromises("Loading was canceled.");
-        ASSERT(m_pendingLoadEventCount);
-        m_pendingLoadEventCount--;
+        m_hasPendingLoadEvent = false;
         // Only consider updating the protection ref-count of the Element immediately before returning
         // from this function as doing so might result in the destruction of this ImageLoader.
         updatedHasPendingEvent();
@@ -422,7 +422,7 @@
     // destroyed by DOM manipulation or garbage collection.
     // If such an Element wishes for the load to stop when removed from the DOM it needs to stop the ImageLoader explicitly.
     bool wasProtected = m_elementIsProtected;
-    m_elementIsProtected = m_pendingLoadEventCount || m_pendingErrorEventCount;
+    m_elementIsProtected = m_hasPendingLoadEvent || m_hasPendingErrorEvent;
     if (wasProtected == m_elementIsProtected)
         return;
 
@@ -501,13 +501,13 @@
 
 void ImageLoader::dispatchPendingBeforeLoadEvent()
 {
-    if (!m_pendingBeforeLoadEventCount)
+    if (!m_hasPendingBeforeLoadEvent)
         return;
     if (!m_image)
         return;
     if (!element().document().hasLivingRenderTree())
         return;
-    m_pendingBeforeLoadEventCount--;
+    m_hasPendingBeforeLoadEvent = false;
     Ref<Document> originalDocument = element().document();
     if (element().dispatchBeforeLoadEvent(m_image->url().string())) {
         bool didEventListenerDisconnectThisElement = !element().isConnected() || &element().document() != originalDocument.ptr();
@@ -523,8 +523,7 @@
     }
 
     loadEventSender().cancelEvent(*this);
-    ASSERT(m_pendingLoadEventCount);
-    m_pendingLoadEventCount--;
+    m_hasPendingLoadEvent = false;
     
     if (is<HTMLObjectElement>(element()))
         downcast<HTMLObjectElement>(element()).renderFallbackContent();
@@ -536,11 +535,11 @@
 
 void ImageLoader::dispatchPendingLoadEvent()
 {
-    if (!m_pendingLoadEventCount)
+    if (!m_hasPendingLoadEvent)
         return;
     if (!m_image)
         return;
-    m_pendingLoadEventCount--;
+    m_hasPendingLoadEvent = false;
     if (element().document().hasLivingRenderTree())
         dispatchLoadEvent();
 
@@ -551,9 +550,9 @@
 
 void ImageLoader::dispatchPendingErrorEvent()
 {
-    if (!m_pendingErrorEventCount)
+    if (!m_hasPendingErrorEvent)
         return;
-    m_pendingErrorEventCount--;
+    m_hasPendingErrorEvent = false;
     if (element().document().hasLivingRenderTree())
         element().dispatchEvent(Event::create(eventNames().errorEvent, Event::CanBubble::No, Event::IsCancelable::No));
 

Modified: trunk/Source/WebCore/loader/ImageLoader.h (274198 => 274199)


--- trunk/Source/WebCore/loader/ImageLoader.h	2021-03-10 06:20:46 UTC (rev 274198)
+++ trunk/Source/WebCore/loader/ImageLoader.h	2021-03-10 06:39:48 UTC (rev 274199)
@@ -70,8 +70,8 @@
 
     void setLoadManually(bool loadManually) { m_loadManually = loadManually; }
 
-    bool hasPendingBeforeLoadEvent() const { return m_pendingBeforeLoadEventCount; }
-    bool hasPendingActivity() const { return m_pendingLoadEventCount || m_pendingErrorEventCount; }
+    bool hasPendingBeforeLoadEvent() const { return m_hasPendingBeforeLoadEvent; }
+    bool hasPendingActivity() const { return m_hasPendingLoadEvent || m_hasPendingErrorEvent; }
 
     void dispatchPendingEvent(ImageEventSender*);
 
@@ -123,9 +123,9 @@
     RefPtr<Element> m_protectedElement;
     AtomString m_failedLoadURL;
     Vector<RefPtr<DeferredPromise>> m_decodingPromises;
-    unsigned m_pendingBeforeLoadEventCount { 0 };
-    unsigned m_pendingErrorEventCount { 0 };
-    unsigned m_pendingLoadEventCount { 0 };
+    bool m_hasPendingBeforeLoadEvent : 1;
+    bool m_hasPendingLoadEvent : 1;
+    bool m_hasPendingErrorEvent : 1;
     bool m_imageComplete : 1;
     bool m_loadManually : 1;
     bool m_elementIsProtected : 1;
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to