Bug 1304767 - Deprecated ImageBitmapRenderingContext.transferImageBitmap. r=ehsan draft
authorMorris Tseng <mtseng@mozilla.com>
Fri, 07 Oct 2016 17:14:34 +0800
changeset 424016 2e6b812c71403bcddc6aeb3ba00cae31f98409c0
parent 423604 7ae377917236b7e6111146aa9fb4c073c0efc7f4
child 533574 836da75934b27cc54a725b12c7936f114de7164f
push id32044
push userbmo:mtseng@mozilla.com
push dateWed, 12 Oct 2016 03:20:08 +0000
reviewersehsan
bugs1304767
milestone52.0a1
Bug 1304767 - Deprecated ImageBitmapRenderingContext.transferImageBitmap. r=ehsan Deprecated ImageBitmapRenderingContext.transferImageBitmap and replaced it with ImageBitmapRenderingContext.transferFromImageBitmap. MozReview-Commit-ID: BbNgKrluhT7
dom/base/nsDeprecatedOperationList.h
dom/canvas/ImageBitmapRenderingContext.cpp
dom/canvas/ImageBitmapRenderingContext.h
dom/canvas/test/test_bitmaprenderer.html
dom/canvas/test/test_offscreencanvas_toimagebitmap.html
dom/locales/en-US/chrome/dom/dom.properties
dom/webidl/ImageBitmapRenderingContext.webidl
--- a/dom/base/nsDeprecatedOperationList.h
+++ b/dom/base/nsDeprecatedOperationList.h
@@ -44,8 +44,9 @@ DEPRECATED_OPERATION(PannerNodeDoppler)
 DEPRECATED_OPERATION(NavigatorGetUserMedia)
 DEPRECATED_OPERATION(WebrtcDeprecatedPrefix)
 DEPRECATED_OPERATION(RTCPeerConnectionGetStreams)
 DEPRECATED_OPERATION(AppCache)
 DEPRECATED_OPERATION(PrefixedImageSmoothingEnabled)
 DEPRECATED_OPERATION(PrefixedFullscreenAPI)
 DEPRECATED_OPERATION(LenientSetter)
 DEPRECATED_OPERATION(FileLastModifiedDate)
+DEPRECATED_OPERATION(ImageBitmapRenderingContext_TransferImageBitmap)
--- a/dom/canvas/ImageBitmapRenderingContext.cpp
+++ b/dom/canvas/ImageBitmapRenderingContext.cpp
@@ -46,16 +46,22 @@ ImageBitmapRenderingContext::ClipToIntri
   }
   result = new layers::SourceSurfaceImage(gfx::IntSize(mWidth, mHeight), surface);
   return result.forget();
 }
 
 void
 ImageBitmapRenderingContext::TransferImageBitmap(ImageBitmap& aImageBitmap)
 {
+  TransferFromImageBitmap(aImageBitmap);
+}
+
+void
+ImageBitmapRenderingContext::TransferFromImageBitmap(ImageBitmap& aImageBitmap)
+{
   Reset();
   mImage = aImageBitmap.TransferAsImage();
 
   if (!mImage) {
     return;
   }
 
   Redraw(gfxRect(0, 0, mWidth, mHeight));
--- a/dom/canvas/ImageBitmapRenderingContext.h
+++ b/dom/canvas/ImageBitmapRenderingContext.h
@@ -20,17 +20,17 @@ namespace layers {
 class Image;
 class ImageContainer;
 }
 
 namespace dom {
 
 /**
  * The purpose of ImageBitmapRenderingContext is to provide a faster and efficient
- * way to display ImageBitmap. Simply call TransferImageBitmap() then we'll transfer
+ * way to display ImageBitmap. Simply call TransferFromImageBitmap() then we'll transfer
  * the surface of ImageBitmap to this context and then to use it to display.
  *
  * See more details in spec: https://wiki.whatwg.org/wiki/OffscreenCanvas
  */
 class ImageBitmapRenderingContext final :
   public nsICanvasRenderingContextInternal,
   public nsWrapperCache
 {
@@ -42,16 +42,17 @@ public:
   virtual JSObject* WrapObject(JSContext* aCx, JS::Handle<JSObject*> aGivenProto) override;
 
   // nsISupports interface + CC
   NS_DECL_CYCLE_COLLECTING_ISUPPORTS
 
   NS_DECL_CYCLE_COLLECTION_SCRIPT_HOLDER_CLASS(ImageBitmapRenderingContext)
 
   void TransferImageBitmap(ImageBitmap& aImageBitmap);
+  void TransferFromImageBitmap(ImageBitmap& aImageBitmap);
 
   // nsICanvasRenderingContextInternal
   virtual int32_t GetWidth() const override;
   virtual int32_t GetHeight() const override;
 
   NS_IMETHOD SetDimensions(int32_t aWidth, int32_t aHeight) override;
 
   NS_IMETHOD InitializeWithDrawTarget(nsIDocShell* aDocShell,
--- a/dom/canvas/test/test_bitmaprenderer.html
+++ b/dom/canvas/test/test_bitmaprenderer.html
@@ -15,17 +15,17 @@ function ok(expect, msg) {
 onmessage = function(event) {
   var bitmap = event.data.bitmap;
   ok(!!bitmap, "Get the ImageBitmap from the main script.");
 
   var offscreenCanvas = new OffscreenCanvas(64, 64);
   var ctx = offscreenCanvas.getContext('bitmaprenderer');
   ok(!!ctx, "Get bitmaprenderer context on worker.");
 
-  ctx.transferImageBitmap(bitmap);
+  ctx.transferFromImageBitmap(bitmap);
   var resultBitmap = offscreenCanvas.transferToImageBitmap();
   postMessage({"type": "bitmap", bitmap: resultBitmap}, [resultBitmap]);
 }
 </script>
 <script>
 
 SimpleTest.waitForExplicitFinish();
 
@@ -52,17 +52,17 @@ function runTest(canvasWidth, canvasHeig
   ctx.fillStyle = "#00FF00";
   ctx.fillRect(0, 0, canvasWidth, canvasHeight);
 
   createImageBitmap(canvas1).then(function(bmp) {
     document.body.removeChild(canvas1);
 
     var canvas2 = createCanvas(90, 90);
     var ctx2 = canvas2.getContext("bitmaprenderer");
-    ctx2.transferImageBitmap(bmp);
+    ctx2.transferFromImageBitmap(bmp);
 
     ok(canvasRef.toDataURL() == canvas2.toDataURL(), "toDataURL should return same result.");
 
     // Exam render result
     canvasRef.style.display = "none";
     canvas2.style.display = "block";
     var snapshot = snapshotWindow(window);
 
@@ -104,28 +104,28 @@ function scaleTest() {
   var p2 = createImageBitmap(canvas2);
   Promise.all([p1, p2]).then(function(bitmaps) {
     document.body.removeChild(canvas1);
     document.body.removeChild(canvas2);
 
     // Create a large canvas then shrink.
     var canvas3 = createCanvas(128, 128);
     var ctx3 = canvas3.getContext("bitmaprenderer");
-    ctx3.transferImageBitmap(bitmaps[0]);
+    ctx3.transferFromImageBitmap(bitmaps[0]);
     var snapshotLargeRef = snapshotWindow(window);
 
     canvas3.width = 32;
     canvas3.height = 32;
     var snapshotSmall = snapshotWindow(window);
     document.body.removeChild(canvas3);
 
     // Create a small canvas then grow.
     var canvas4 = createCanvas(32, 32);
     var ctx4 = canvas4.getContext("bitmaprenderer");
-    ctx4.transferImageBitmap(bitmaps[1]);
+    ctx4.transferFromImageBitmap(bitmaps[1]);
     var snapshotSmallRef = snapshotWindow(window);
 
     canvas4.width = 128;
     canvas4.height = 128;
     var snapshotLarge = snapshotWindow(window);
     document.body.removeChild(canvas4);
 
     var resultsLarge = compareSnapshots(snapshotLarge, snapshotLargeRef, true);
@@ -150,17 +150,17 @@ function runTestOnWorker() {
   createImageBitmap(canvas1).then(function(bmp) {
     worker.postMessage({bitmap: bmp}, [bmp]);
     worker.onmessage = function(event) {
       if (event.data.type == "status") {
         ok(event.data.status, event.data.msg);
       } else if (event.data.type == "bitmap") {
         var canvas2 = createCanvas(64, 64);
         var ctx2 = canvas2.getContext('bitmaprenderer');
-        ctx2.transferImageBitmap(event.data.bitmap);
+        ctx2.transferFromImageBitmap(event.data.bitmap);
         ok(canvas1.toDataURL() == canvas2.toDataURL(), 'toDataURL should be the same');
         SimpleTest.finish();
       }
     }
   });
 }
 
 SpecialPowers.pushPrefEnv({'set': [
--- a/dom/canvas/test/test_offscreencanvas_toimagebitmap.html
+++ b/dom/canvas/test/test_offscreencanvas_toimagebitmap.html
@@ -30,27 +30,27 @@ function runTest() {
       var c = document.getElementById("c-ref");
       var ctx = c.getContext("2d");
       ctx.rect(0, 0, 64, 64);
       ctx.fillStyle = "#00FF00";
       ctx.fill();
 
       var htmlCanvas = document.getElementById("c");
       var bitmapRenderer = htmlCanvas.getContext("bitmaprenderer");
-      bitmapRenderer.transferImageBitmap(msg.bitmap);
+      bitmapRenderer.transferFromImageBitmap(msg.bitmap);
 
       ok(c.toDataURL() == htmlCanvas.toDataURL(),
          "imagebitmap should return a 64x64 green square");
 
       // The ownership of msg.bitmap should be transferred to canvas "c" when
-      // we called transferImageBitmap. So we test if the ownership is actually
+      // we called transferFromImageBitmap. So we test if the ownership is actually
       // transferred here.
       var htmlCanvas = document.getElementById("c2");
       var bitmapRenderer = htmlCanvas.getContext("bitmaprenderer");
-      bitmapRenderer.transferImageBitmap(msg.bitmap);
+      bitmapRenderer.transferFromImageBitmap(msg.bitmap);
 
       SimpleTest.doesThrow(
         function() { c2.toDataURL(); },
         "ImageBitmap has been transferred, toDataURL will throw.");
 
       worker.terminate();
       SimpleTest.finish();
     }
--- a/dom/locales/en-US/chrome/dom/dom.properties
+++ b/dom/locales/en-US/chrome/dom/dom.properties
@@ -289,16 +289,18 @@ PushMessageBadRecordSize=The ServiceWorker for scope ‘%1$S’ failed to decrypt a push message. The ‘rs‘ parameter of the ‘Encryption‘ header must be between %2$S and 2^36-31, or omitted entirely. See https://tools.ietf.org/html/draft-ietf-httpbis-encryption-encoding-02#section-3.1 for more information.
 PushMessageBadPaddingError=The ServiceWorker for scope ‘%1$S’ failed to decrypt a push message. A record in the encrypted message was not padded correctly. See https://tools.ietf.org/html/draft-ietf-httpbis-encryption-encoding-02#section-2 for more information.
 # LOCALIZATION NOTE: This error is reported when push message decryption fails
 # and no specific error info is available. Do not translate "ServiceWorker".
 # %1$S is the ServiceWorker scope URL.
 PushMessageBadCryptoError=The ServiceWorker for scope ‘%1$S’ failed to decrypt a push message. For help with encryption, please see https://developer.mozilla.org/docs/Web/API/Push_API/Using_the_Push_API#Encryption
 # LOCALIZATION NOTE: %1$S is the type of a DOM event. 'passive' is a literal parameter from the DOM spec.
 PreventDefaultFromPassiveListenerWarning=Ignoring ‘preventDefault()’ call on event of type ‘%1$S’ from a listener registered as ‘passive’.
 FileLastModifiedDateWarning=File.lastModifiedDate is deprecated. Use File.lastModified instead.
+# LOCALIZATION NOTE: 'ImageBitmapRenderingContext.transferImageBitmap' and 'ImageBitmapRenderingContext.transferFromImageBitmap' should not be translated
+ImageBitmapRenderingContext_TransferImageBitmap=ImageBitmapRenderingContext.transferImageBitmap is deprecated and will be removed soon. Use ImageBitmapRenderingContext.transferFromImageBitmap instead.
 ChromeScriptedDOMParserWithoutPrincipal=Creating DOMParser without a principal is deprecated.
 IIRFilterChannelCountChangeWarning=IIRFilterNode channel count changes may produce audio glitches.
 BiquadFilterChannelCountChangeWarning=BiquadFilterNode channel count changes may produce audio glitches.
 # LOCALIZATION NOTE: %1$S is the unanimatable paced property.
 UnanimatablePacedProperty=Paced property ‘%1$S’ is not an animatable property.
 # LOCALIZATION NOTE: Do not translate ".jpeg"
 GenericImageNameJPEG=image.jpeg
 # LOCALIZATION NOTE: Do not translate ".gif"
--- a/dom/webidl/ImageBitmapRenderingContext.webidl
+++ b/dom/webidl/ImageBitmapRenderingContext.webidl
@@ -27,10 +27,14 @@ interface ImageBitmapRenderingContext {
   // The ImageBitmap conceptually replaces the canvas's bitmap, but
   // it does not change the canvas's intrinsic width or height.
   //
   // The ImageBitmap, when displayed, is clipped to the rectangle
   // defined by the canvas's instrinsic width and height. Pixels that
   // would be covered by the canvas's bitmap which are not covered by
   // the supplied ImageBitmap are rendered transparent black. Any CSS
   // styles affecting the display of the canvas are applied as usual.
+  void transferFromImageBitmap(ImageBitmap bitmap);
+
+  // Deprecated version of transferFromImageBitmap
+  [Deprecated="ImageBitmapRenderingContext_TransferImageBitmap"]
   void transferImageBitmap(ImageBitmap bitmap);
 };