Skip to content

Commit

Permalink
Mark nullsafe fixmes in views/text/frescosupport
Browse files Browse the repository at this point in the history
Differential Revision: D67992721
  • Loading branch information
Thomas Nardone authored and facebook-github-bot committed Jan 10, 2025
1 parent d01bd2f commit 114c9a2
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import com.facebook.common.logging.FLog;
import com.facebook.common.util.UriUtil;
import com.facebook.drawee.controller.AbstractDraweeControllerBuilder;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.Dynamic;
import com.facebook.react.bridge.ReadableArray;
import com.facebook.react.bridge.ReadableMap;
Expand All @@ -27,9 +28,11 @@
import java.util.Locale;

/** Shadow node that represents an inline image. Loading is done using Fresco. */
@Nullsafe(Nullsafe.Mode.LOCAL)
class FrescoBasedReactTextInlineImageShadowNode extends ReactTextInlineImageShadowNode {

private @Nullable Uri mUri;
// NULLSAFE_FIXME[Field Not Initialized]
private ReadableMap mHeaders;
private final AbstractDraweeControllerBuilder mDraweeControllerBuilder;
private final @Nullable Object mCallerContext;
Expand All @@ -47,6 +50,7 @@ public FrescoBasedReactTextInlineImageShadowNode(
@ReactProp(name = "src")
public void setSource(@Nullable ReadableArray sources) {
final String source =
// NULLSAFE_FIXME[Nullable Dereference]
(sources == null || sources.size() == 0) ? null : sources.getMap(0).getString("uri");
Uri uri = null;
if (source != null) {
Expand Down Expand Up @@ -145,6 +149,7 @@ public TextInlineImageSpan buildInlineImageSpan() {
getHeaders(),
getDraweeControllerBuilder(),
getCallerContext(),
// NULLSAFE_FIXME[Parameter Not Nullable]
mResizeMode);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import com.facebook.drawee.view.DraweeHolder;
import com.facebook.imagepipeline.request.ImageRequest;
import com.facebook.imagepipeline.request.ImageRequestBuilder;
import com.facebook.infer.annotation.Nullsafe;
import com.facebook.react.bridge.ReadableMap;
import com.facebook.react.modules.fresco.ReactNetworkImageRequest;
import com.facebook.react.uimanager.PixelUtil;
Expand All @@ -40,6 +41,7 @@
* <p>Note: It borrows code from DynamicDrawableSpan and if that code updates how it computes size
* or draws, we need to update this as well.
*/
@Nullsafe(Nullsafe.Mode.LOCAL)
class FrescoBasedReactTextInlineImageSpan extends TextInlineImageSpan {

private @Nullable Drawable mDrawable;
Expand Down Expand Up @@ -116,6 +118,7 @@ public int getSize(Paint paint, CharSequence text, int start, int end, Paint.Fon
return mWidth;
}

// NULLSAFE_FIXME[Inconsistent Subclass Parameter Annotation]
public void setTextView(TextView textView) {
mTextView = textView;
}
Expand All @@ -140,17 +143,21 @@ public void draw(
mDraweeControllerBuilder
.reset()
.setOldController(mDraweeHolder.getController())
// NULLSAFE_FIXME[Parameter Not Nullable]
.setCallerContext(mCallerContext)
.setImageRequest(imageRequest)
.build();
mDraweeHolder.setController(draweeController);
mDraweeControllerBuilder.reset();

mDrawable = mDraweeHolder.getTopLevelDrawable();
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.setBounds(0, 0, mWidth, mHeight);
if (mTintColor != 0) {
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.setColorFilter(mTintColor, PorterDuff.Mode.SRC_IN);
}
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.setCallback(mTextView);
}

Expand All @@ -161,9 +168,11 @@ public void draw(
// Align to center
int fontHeight = (int) (paint.descent() - paint.ascent());
int centerY = y + (int) paint.descent() - fontHeight / 2;
// NULLSAFE_FIXME[Nullable Dereference]
int transY = centerY - (mDrawable.getBounds().bottom - mDrawable.getBounds().top) / 2;

canvas.translate(x, transY);
// NULLSAFE_FIXME[Nullable Dereference]
mDrawable.draw(canvas);
canvas.restore();
}
Expand Down

0 comments on commit 114c9a2

Please sign in to comment.