mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-08 10:44:56 +00:00
Bug 1689745 - Throw ImageProcessingException in Image#getBitmap. r=aklotz,esawin
Differential Revision: https://phabricator.services.mozilla.com/D103527
This commit is contained in:
parent
4de0841b18
commit
227fa1abcd
@ -1341,6 +1341,10 @@ package org.mozilla.geckoview {
|
||||
method @NonNull public GeckoResult<Bitmap> getBitmap(int);
|
||||
}
|
||||
|
||||
public static class Image.ImageProcessingException extends RuntimeException {
|
||||
ctor public ImageProcessingException(String);
|
||||
}
|
||||
|
||||
@AnyThread public class MediaElement {
|
||||
method @Nullable public MediaElement.Delegate getDelegate();
|
||||
method public void pause();
|
||||
|
@ -18,6 +18,7 @@ import org.junit.runners.Parameterized
|
||||
import org.mozilla.geckoview.GeckoResult
|
||||
import org.mozilla.geckoview.GeckoSession
|
||||
import org.mozilla.geckoview.WebExtension
|
||||
import org.mozilla.geckoview.Image.ImageProcessingException
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule
|
||||
import org.mozilla.geckoview.test.rule.GeckoSessionTestRule.AssertCalled
|
||||
|
||||
@ -466,7 +467,9 @@ class ExtensionActionTest : BaseSessionTest() {
|
||||
action.icon!!.getBitmap(38).accept({
|
||||
error.completeExceptionally(RuntimeException("Should not succeed."))
|
||||
}, { exception ->
|
||||
assertTrue(exception is IllegalArgumentException)
|
||||
if (!(exception is ImageProcessingException)) {
|
||||
throw exception!!;
|
||||
}
|
||||
error.complete(null)
|
||||
})
|
||||
}
|
||||
|
@ -10,6 +10,7 @@ import android.graphics.Bitmap;
|
||||
import androidx.annotation.AnyThread;
|
||||
import androidx.annotation.NonNull;
|
||||
|
||||
import org.mozilla.gecko.annotation.WrapForJNI;
|
||||
import org.mozilla.gecko.util.GeckoBundle;
|
||||
import org.mozilla.gecko.util.ImageResource;
|
||||
|
||||
@ -37,9 +38,26 @@ public class Image {
|
||||
* @param size pixel size at which this image will be displayed at.
|
||||
*
|
||||
* @return A {@link GeckoResult} that resolves to the bitmap when ready.
|
||||
* Will resolve exceptionally to {@link ImageProcessingException} if the image
|
||||
* cannot be processed.
|
||||
*/
|
||||
@NonNull
|
||||
public GeckoResult<Bitmap> getBitmap(final int size) {
|
||||
return mCollection.getBitmap(size);
|
||||
}
|
||||
|
||||
/**
|
||||
* Thrown whenever an image cannot be processed by {@link #getBitmap}
|
||||
*/
|
||||
@WrapForJNI
|
||||
public static class ImageProcessingException extends RuntimeException {
|
||||
/**
|
||||
* Build an instance of this class.
|
||||
*
|
||||
* @param message description of the error.
|
||||
*/
|
||||
public ImageProcessingException(final String message) {
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -19,9 +19,14 @@ exclude: true
|
||||
- Added [`WebExtension.Download.Info`][87.2] interface that can be used to
|
||||
implement the WebExtension `downloads` API. This interface allows communicating
|
||||
download's state to Web Extension.
|
||||
- [`Image#getBitmap`][87.3] now throws [`ImageProcessingException`][87.4] if
|
||||
the image cannot be processed.
|
||||
([bug 1689745]({{bugzilla}}1689745))
|
||||
|
||||
[87.1]: {{javadoc_uri}}/WebExtension.DownloadInitData.html
|
||||
[87.2]: {{javadoc_uri}}/WebExtension.Download.Info.html
|
||||
[87.3]: {{javadoc_uri}}/Image.html#getBitmap-int-
|
||||
[87.4]: {{javadoc_uri}}/Image.ImageProcessingException.html
|
||||
|
||||
## v86
|
||||
- Removed deprecated [`ContentDelegate#onExternalResponse(GeckoSession, WebResponseInfo)`].
|
||||
@ -887,4 +892,4 @@ to allow adding gecko profiler markers.
|
||||
[65.24]: {{javadoc_uri}}/CrashReporter.html#sendCrashReport-android.content.Context-android.os.Bundle-java.lang.String-
|
||||
[65.25]: {{javadoc_uri}}/GeckoResult.html
|
||||
|
||||
[api-version]: d751d69857ce777d1cab63a431bd6d67dc8b2a48
|
||||
[api-version]: ea27a27d150b635b5e186efcf2770f9f76bd04aa
|
||||
|
@ -12,6 +12,7 @@
|
||||
#include "JavaExceptions.h"
|
||||
#include "mozilla/gfx/Point.h"
|
||||
#include "mozilla/gfx/Swizzle.h"
|
||||
#include "mozilla/java/ImageWrappers.h"
|
||||
#include "nsNetUtil.h"
|
||||
|
||||
namespace mozilla {
|
||||
@ -31,7 +32,7 @@ class ImageCallbackHelper : public imgIContainerCallback,
|
||||
|
||||
void CompleteExceptionally(const char* aMessage) {
|
||||
mResult->CompleteExceptionally(
|
||||
java::sdk::IllegalArgumentException::New(aMessage)
|
||||
java::Image::ImageProcessingException::New(aMessage)
|
||||
.Cast<jni::Throwable>());
|
||||
gDecodeRequests.remove(this);
|
||||
}
|
||||
@ -59,7 +60,8 @@ class ImageCallbackHelper : public imgIContainerCallback,
|
||||
MOZ_ALWAYS_TRUE(gDecodeRequests.putNew(this));
|
||||
|
||||
if (NS_FAILED(aStatus)) {
|
||||
CompleteExceptionally("Could not process image.");
|
||||
nsPrintfCString error("Could not process image: %d", aStatus);
|
||||
CompleteExceptionally(error.get());
|
||||
return aStatus;
|
||||
}
|
||||
|
||||
|
@ -61,6 +61,7 @@ classes_with_WrapForJNI = [
|
||||
"GeckoVideoInfo",
|
||||
"GeckoWebExecutor",
|
||||
"HardwareCodecCapabilityUtils",
|
||||
"Image",
|
||||
"ImageDecoder",
|
||||
"MediaDrmProxy",
|
||||
"PanZoomController",
|
||||
|
Loading…
Reference in New Issue
Block a user