Bug 1601475 - Remove ImageContentLoaded event and ImageDocumentLoaded message handling code across the tree r=Gijs
☠☠ backed out by f96293f37fc3 ☠ ☠
authorTyler <staatsty@msu.edu>
Mon, 09 Dec 2019 10:18:25 +0000
changeset 568165 e65c1bcb013fb1d12cc3ae3b7474add9d0d52e3b
parent 568164 395fa0c936538965886f60b870d9f20eae4e3092
child 568166 111c247a2bca158383d6c142cc6c2209456aa637
push id12493
push userffxbld-merge
push dateMon, 06 Jan 2020 15:38:57 +0000
treeherdermozilla-beta@63ae456b848d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersGijs
bugs1601475
milestone73.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1601475 - Remove ImageContentLoaded event and ImageDocumentLoaded message handling code across the tree r=Gijs Differential Revision: https://phabricator.services.mozilla.com/D56051
devtools/client/responsive/browser/tunnel.js
dom/html/ImageDocument.cpp
image/test/mochitest/mochitest.ini
image/test/mochitest/test_ImageContentLoaded.html
toolkit/content/browser-child.js
toolkit/content/widgets/browser-custom-element.js
xpcom/ds/StaticAtoms.py
--- a/devtools/client/responsive/browser/tunnel.js
+++ b/devtools/client/responsive/browser/tunnel.js
@@ -25,17 +25,16 @@ function debug(msg) {
 const SWAPPED_BROWSER_STATE = [
   "_remoteFinder",
   "_securityUI",
   "_documentURI",
   "_documentContentType",
   "_contentTitle",
   "_characterSet",
   "_contentPrincipal",
-  "_imageDocument",
   "_isSyntheticDocument",
   "_innerWindowID",
 ];
 
 /**
  * Various parts of the Firefox code base expect to access properties on the browser
  * window in response to events (by reaching for the window via the event's target).
  *
@@ -99,17 +98,16 @@ function tunnelToInnerBrowser(outer, inn
 
     onLocationChange: (webProgress, request, location, flags) => {
       if (webProgress && webProgress.isTopLevel) {
         inner._documentURI = outer._documentURI;
         inner._documentContentType = outer._documentContentType;
         inner._contentTitle = outer._contentTitle;
         inner._characterSet = outer._characterSet;
         inner._contentPrincipal = outer._contentPrincipal;
-        inner._imageDocument = outer._imageDocument;
         inner._isSyntheticDocument = outer._isSyntheticDocument;
         inner._innerWindowID = outer._innerWindowID;
         inner._remoteWebNavigation._currentURI =
           outer._remoteWebNavigation._currentURI;
       }
     },
 
     // We do not need an onSecurityChange handler since the remote security UI
@@ -454,17 +452,16 @@ MessageManagerTunnel.prototype = {
   ],
 
   INNER_TO_OUTER_MESSAGES: [
     // Messages sent to browser.js
     "Browser:LoadURI",
     "PageStyle:StyleSheets",
     // Messages sent to browser.js
     "DOMTitleChanged",
-    "ImageDocumentLoaded",
     "InPermitUnload",
     "PermitUnload",
     // Messages sent to SessionStore.jsm
     "SessionStore:update",
     // Messages sent to BrowserTestUtils.jsm
     "browser-test-utils:loadEvent",
   ],
 
--- a/dom/html/ImageDocument.cpp
+++ b/dom/html/ImageDocument.cpp
@@ -121,25 +121,16 @@ ImageListener::OnStartRequest(nsIRequest
     imageLoader->AddNativeObserver(imgDoc);
     imgDoc->mObservingImageLoader = true;
     imageLoader->LoadImageWithChannel(channel, getter_AddRefs(mNextStream));
   }
 
   return MediaDocumentStreamListener::OnStartRequest(request);
 }
 
-NS_IMETHODIMP
-ImageListener::OnStopRequest(nsIRequest* aRequest, nsresult aStatus) {
-  ImageDocument* imgDoc = static_cast<ImageDocument*>(mDocument.get());
-  nsContentUtils::DispatchChromeEvent(imgDoc, ToSupports(imgDoc),
-                                      NS_LITERAL_STRING("ImageContentLoaded"),
-                                      CanBubble::eYes, Cancelable::eYes);
-  return MediaDocumentStreamListener::OnStopRequest(aRequest, aStatus);
-}
-
 ImageDocument::ImageDocument()
     : MediaDocument(),
       mVisibleWidth(0.0),
       mVisibleHeight(0.0),
       mImageWidth(0),
       mImageHeight(0),
       mResizeImageByDefault(false),
       mClickResizingEnabled(false),
--- a/image/test/mochitest/mochitest.ini
+++ b/image/test/mochitest/mochitest.ini
@@ -132,17 +132,16 @@ skip-if = verify
 [test_bullet_animation.html]
 [test_changeOfSource.html]
 [test_changeOfSource2.html]
 [test_discardAnimatedImage.html]
 [test_discardFramesAnimatedImage.html]
 [test_drawDiscardedImage.html]
 [test_error_events.html]
 [test_image_crossorigin_data_url.html]
-[test_ImageContentLoaded.html]
 [test_has_transparency.html]
 [test_net_failedtoprocess.html]
 skip-if = verify
 [test_removal_ondecode.html]
 [test_removal_onload.html]
 [test_short_gif_header.html]
 [test_staticClone.html]
 [test_svg_animatedGIF.html]
deleted file mode 100644
--- a/image/test/mochitest/test_ImageContentLoaded.html
+++ /dev/null
@@ -1,28 +0,0 @@
-<!DOCTYPE HTML>
-<html>
-<!--
-https://bugzilla.mozilla.org/show_bug.cgi?id=691610
--->
-<head>
-<title>Test for Bug 691610</title>
-<script src="/tests/SimpleTest/SimpleTest.js"></script>
-<script src="/tests/SimpleTest/EventUtils.js"></script>
-</head>
-<body>
-<script type="text/javascript">
-    SimpleTest.waitForExplicitFinish()
-
-    SpecialPowers.addChromeEventListener("ImageContentLoaded", function () {
-       ok(true, "chrome listener was invoked");
-       SimpleTest.finish();
-    }, true);
-
-    var iframe = document.createElement("iframe");
-    iframe.src = "damon.jpg"
-    document.body.appendChild(iframe);
-    iframe.contentDocument.defaultView.addEventListener("ImageContentLoaded", function () {
-        ok(false, "should not invoke event");
-    }, true);
-</script>
-</body>
-</html>
--- a/toolkit/content/browser-child.js
+++ b/toolkit/content/browser-child.js
@@ -47,33 +47,16 @@ addEventListener(
     ) {
       return;
     }
     sendAsyncMessage("DOMTitleChanged", { title: content.document.title });
   },
   false
 );
 
-addEventListener(
-  "ImageContentLoaded",
-  function(aEvent) {
-    if (content.document instanceof Ci.nsIImageDocument) {
-      let req = content.document.imageRequest;
-      if (!req.image) {
-        return;
-      }
-      sendAsyncMessage("ImageDocumentLoaded", {
-        width: req.image.width,
-        height: req.image.height,
-      });
-    }
-  },
-  false
-);
-
 // This is here for now until we find a better way of forcing an about:blank load
 // with a particular principal that doesn't involve the message manager. We can't
 // do this with JS Window Actors for now because JS Window Actors are tied to the
 // document principals themselves, so forcing the load with a new principal is
 // self-destructive in that case.
 addMessageListener("BrowserElement:CreateAboutBlank", message => {
   if (!content.document || content.document.documentURI != "about:blank") {
     throw new Error("Can't create a content viewer unless on about:blank");
--- a/toolkit/content/widgets/browser-custom-element.js
+++ b/toolkit/content/widgets/browser-custom-element.js
@@ -286,18 +286,16 @@
        * Weak reference to an optional frame loader that can be used to influence
        * process selection for this browser.
        * See nsIBrowser.sameProcessAsFrameLoader.
        */
       this._sameProcessAsFrameLoader = null;
 
       this._loadContext = null;
 
-      this._imageDocument = null;
-
       this._webBrowserFind = null;
 
       this._finder = null;
 
       this._remoteFinder = null;
 
       this._fastFind = null;
 
@@ -562,34 +560,16 @@
           return frameLoader.remoteTab.hasLayers;
         }
         return false;
       }
 
       return this.docShellIsActive;
     }
 
-    get imageDocument() {
-      if (this.isRemoteBrowser) {
-        return this._imageDocument;
-      }
-      var document = this.contentDocument;
-      if (!document || !(document instanceof Ci.nsIImageDocument)) {
-        return null;
-      }
-
-      try {
-        return {
-          width: document.imageRequest.image.width,
-          height: document.imageRequest.image.height,
-        };
-      } catch (e) {}
-      return null;
-    }
-
     get isRemoteBrowser() {
       return this.getAttribute("remote") == "true";
     }
 
     get remoteType() {
       if (!this.isRemoteBrowser || !this.messageManager) {
         return null;
       }
@@ -1258,17 +1238,16 @@
           this.loadContext
         );
         // CSP for about:blank is null; if we ever change _contentPrincipal above,
         // we should re-evaluate the CSP here.
         this._csp = null;
 
         this.messageManager.addMessageListener("Browser:Init", this);
         this.messageManager.addMessageListener("DOMTitleChanged", this);
-        this.messageManager.addMessageListener("ImageDocumentLoaded", this);
 
         let jsm = "resource://gre/modules/RemoteWebProgress.jsm";
         let { RemoteWebProgressManager } = ChromeUtils.import(jsm, {});
 
         let oldManager = this._remoteWebProgressManager;
         this._remoteWebProgressManager = new RemoteWebProgressManager(this);
         if (oldManager) {
           // We're transitioning from one remote type to another. This means that
@@ -1491,22 +1470,16 @@
       let data = aMessage.data;
       switch (aMessage.name) {
         case "Browser:Init":
           this._outerWindowID = data.outerWindowID;
           break;
         case "DOMTitleChanged":
           this._contentTitle = data.title;
           break;
-        case "ImageDocumentLoaded":
-          this._imageDocument = {
-            width: data.width,
-            height: data.height,
-          };
-          break;
         default:
           return this._receiveMessage(aMessage);
       }
       return undefined;
     }
 
     enableDisableCommandsRemoteOnly(
       aAction,
@@ -1596,17 +1569,16 @@
 
         if (aContentType != null) {
           this._documentContentType = aContentType;
         }
 
         this._remoteWebNavigation._currentURI = aLocation;
         this._documentURI = aDocumentURI;
         this._contentTitle = aTitle;
-        this._imageDocument = null;
         this._contentPrincipal = aContentPrincipal;
         this._contentStoragePrincipal = aContentStoragePrincipal;
         this._contentBlockingAllowListPrincipal = aContentBlockingAllowListPrincipal;
         this._csp = aCSP;
         this._referrerInfo = aReferrerInfo;
         this._isSyntheticDocument = aIsSynthetic;
         this._innerWindowID = aInnerWindowID;
         this._contentRequestContextID = aHaveRequestContextID
@@ -1946,17 +1918,16 @@
             "_documentContentType",
             "_contentTitle",
             "_characterSet",
             "_mayEnableCharacterEncodingMenu",
             "_charsetAutodetected",
             "_contentPrincipal",
             "_contentStoragePrincipal",
             "_contentBlockingAllowListPrincipal",
-            "_imageDocument",
             "_fullZoom",
             "_textZoom",
             "_isSyntheticDocument",
             "_innerWindowID",
           ]
         );
       }
 
--- a/xpcom/ds/StaticAtoms.py
+++ b/xpcom/ds/StaticAtoms.py
@@ -1908,17 +1908,16 @@ STATIC_ATOMS = [
     Atom("onDOMPopupBlocked", "onDOMPopupBlocked"),
     Atom("onDOMTitleChanged", "onDOMTitleChanged"),
     Atom("onDOMWindowClose", "onDOMWindowClose"),
     Atom("onDOMWindowCreated", "onDOMWindowCreated"),
     Atom("onDOMWindowFocus", "onDOMWindowFocus"),
     Atom("onFullZoomChange", "onFullZoomChange"),
     Atom("onGloballyAutoplayBlocked", "onGloballyAutoplayBlocked"),
     Atom("onHiddenPlugin", "onHiddenPlugin"),
-    Atom("onImageContentLoaded", "onImageContentLoaded"),
     Atom("onMozApplicationManifest", "onMozApplicationManifest"),
     Atom("onMozDOMFullscreen_Entered", "onMozDOMFullscreen:Entered"),
     Atom("onMozDOMFullscreen_Exit", "onMozDOMFullscreen:Exit"),
     Atom("onMozDOMFullscreen_Exited", "onMozDOMFullscreen:Exited"),
     Atom("onMozDOMFullscreen_NewOrigin", "onMozDOMFullscreen:NewOrigin"),
     Atom("onMozDOMFullscreen_Request", "onMozDOMFullscreen:Request"),
     Atom("onMozDOMPointerLock_Entered", "onMozDOMPointerLock:Entered"),
     Atom("onMozDOMPointerLock_Exited", "onMozDOMPointerLock:Exited"),