Rabbit-R1/android (non root)/java/sources/androidx/compose/foundation/text/modifiers/TextStringSimpleNode.java

321 lines
22 KiB
Java
Raw Normal View History

2024-05-21 21:08:36 +00:00
package androidx.compose.foundation.text.modifiers;
import androidx.compose.ui.Modifier;
import androidx.compose.ui.geometry.Offset;
import androidx.compose.ui.geometry.Rect;
import androidx.compose.ui.geometry.RectKt;
import androidx.compose.ui.geometry.SizeKt;
import androidx.compose.ui.graphics.Brush;
import androidx.compose.ui.graphics.Canvas;
import androidx.compose.ui.graphics.Color;
import androidx.compose.ui.graphics.ColorProducer;
import androidx.compose.ui.graphics.Shadow;
import androidx.compose.ui.graphics.drawscope.ContentDrawScope;
import androidx.compose.ui.graphics.drawscope.DrawStyle;
import androidx.compose.ui.graphics.drawscope.Fill;
import androidx.compose.ui.layout.AlignmentLine;
import androidx.compose.ui.layout.AlignmentLineKt;
import androidx.compose.ui.layout.IntrinsicMeasurable;
import androidx.compose.ui.layout.IntrinsicMeasureScope;
import androidx.compose.ui.layout.Measurable;
import androidx.compose.ui.layout.MeasureResult;
import androidx.compose.ui.layout.MeasureScope;
import androidx.compose.ui.layout.Placeable;
import androidx.compose.ui.node.DrawModifierNode;
import androidx.compose.ui.node.DrawModifierNodeKt;
import androidx.compose.ui.node.LayoutModifierNode;
import androidx.compose.ui.node.LayoutModifierNodeKt;
import androidx.compose.ui.node.SemanticsModifierNode;
import androidx.compose.ui.node.SemanticsModifierNodeKt;
import androidx.compose.ui.semantics.SemanticsPropertiesKt;
import androidx.compose.ui.semantics.SemanticsPropertyReceiver;
import androidx.compose.ui.text.AnnotatedString;
import androidx.compose.ui.text.Paragraph;
import androidx.compose.ui.text.TextLayoutResult;
import androidx.compose.ui.text.TextStyle;
import androidx.compose.ui.text.font.FontFamily;
import androidx.compose.ui.text.style.TextDecoration;
import androidx.compose.ui.text.style.TextOverflow;
import androidx.compose.ui.unit.Constraints;
import androidx.compose.ui.unit.Density;
import androidx.compose.ui.unit.IntSize;
import io.sentry.protocol.ViewHierarchyNode;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import kotlin.Metadata;
import kotlin.Unit;
import kotlin.jvm.functions.Function1;
import kotlin.jvm.internal.DefaultConstructorMarker;
import kotlin.jvm.internal.Intrinsics;
import kotlin.math.MathKt;
/* compiled from: TextStringSimpleNode.kt */
@Metadata(d1 = {"\u0000¤\u0001\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000e\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u000b\n\u0000\n\u0002\u0010\b\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0002\b\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010%\n\u0002\u0018\u0002\n\u0002\b\u0005\n\u0002\u0018\u0002\n\u0002\u0010!\n\u0002\u0018\u0002\n\u0000\n\u0002\u0010\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\b\u0007\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0004\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0002\u0018\u0002\n\u0000\n\u0002\u0018\u0002\n\u0002\b\u0005\b\u0000\u0018\u00002\u00020\u00012\u00020\u00022\u00020\u00032\u00020\u0004BT\u0012\u0006\u0010\u0005\u001a\u00020\u0006\u0012\u0006\u0010\u0007\u001a\u00020\b\u0012\u0006\u0010\t\u001a\u00020\n\u0012\b\b\u0002\u0010\u000b\u001a\u00020\f\u0012\b\b\u0002\u0010\r\u001a\u00020\u000e\u0012\b\b\u0002\u0010\u000f\u001a\u00020\u0010\u0012\b\b\u0002\u0010\u0011\u001a\u00020\u0010\u0012\n\b\u0002\u0010\u0012\u001a\u0004\u0018\u00010\u0013ø\u0001\u0000¢\u0006\u0002\u0010\u0014J\u001e\u0010\"\u001a\u00020#2\u0006\u0010$\u001a\u00020\u000e2\u0006\u0010%\u001a\u00020\u000e2\u0006\u0010&\u001a\u00020\u000eJ\u0010\u0010\u001b\u001a\u00020\u00162\u0006\u0010'\u001a\u00020(H\u0002J\u0018\u0010)\u001a\u00020\u000e2\b\u0010*\u001a\u0004\u0018\u00010\u00132\u0006\u0010\u0007\u001a\u00020\bJC\u0010+\u001a\u00020\u000e2\u0006\u0010\u0007\u001a\u00020\b2\u0006\u0010\u0011\u001a\u00020\u00102\u0006\u0010\u000f\u001a\u00020\u00102\u0006\u0010\r\u001a\u00020\u000e2\u0006\u0010\t\u001a\u00020\n2\u0006\u0010\u000b\u001a\u00020\\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b,\u0010-J\u000e\u0010.\u001a\u00020\u000e2\u0006\u0010\u0005\u001a\u00020\u0006J\f\u0010/\u001a\u00020#*\u000200H\u0016J\f\u00101\u001a\u00020#*\u000202H\u0016J\u001c\u00103\u001a\u00020\u0010*\u0002042\u0006\u00105\u001a\u0002062\u0006\u00107\u001a\u00020\u0010H\u0016J\u001c\u00108\u001a\u00020\u0010*\u0002042\u0006\u00105\u001a\u0002062\u0006\u00109\u001a\u00020\u0010H\u0016J)\u0010:\u001a\u00020;*\u00020<2\u0006\u00105\u001a\u00020=2\u0006\u0010>\u001a\u00020?H\u0016ø\u0001\u0001ø\u0001\u0000¢\u0006\u0004\b@\u0010AJ\u001c\u0010B\u001a\u00020\u0010*\u0002042\u0006\u00105\u001a\u0002062\u0006\u00107\u001a\u00020\u0010H\u0016J\u001c\u0010C\u001a\u00020\u0010*\u0002042\u0006\u00105\u001a\u0002062\u0006\u00109\u001a\u00020\u0010H\u0016R\u0010\u0010\u0015\u001a\u0004\u0018\u00010\u0016X\u0082\u000e¢\u0006\u0002\n\u0000R\u001c\u0010\u0017\u001a\u0010\u0012\u0004\u0012\u00020\u0019\u0012\u0004\u0012\u00020\u0010\u0018\u00010\u0018X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\t\u001a\u00020\nX\u0082\u000e¢\u0006\u0002\n\u0000R\u0014\u0010\u001a\u001a\u00020\u00168BX\u0082\u0004¢\u0006\u0006\u001a\u0004\b\u001b\u0010\u001cR\u000e\u0010\u000f\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0011\u001a\u00020\u0010X\u0082\u000e¢\u0006\u0002\n\u0000R\u0019\u0010\u000b\u001a\u00020\fX\u0082\u000eø\u0001\u0000ø\u0001\u0001ø\u0001\u0002¢\u0006\u0004\n\u0002\u0010\u001dR\u0010\u0010\u0012\u001a\u0004\u0018\u00010\u0013X\u0082\u000e¢\u0006\u0002\n\u0000R\"\u0010\u001e\u001a\u0016\u0012\n\u0012\b\u0012\u0004\u0012\u00020!0 \u0012\u0004\u0012\u00020\u000e\u0018\u00010\u001fX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\r\u001a\u00020\u000eX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0007\u001a\u00020\bX\u0082\u000e¢\u0006\u0002\n\u0000R\u000e\u0010\u0005\u001a\u00020\u0006X\u0082\u000e¢\u0006\u0002\n\u0000\u0082\u0002\u000f\n\u0002\b\u0019\n\u0005\\u001e0\u0001\n\u0002\b!¨\u0006D"}, d2 = {"Landroidx/compose/foundation/text/modifiers/TextStringSimpleNode;", "Landroidx/compose/ui/Modifier$Node;", "Landroidx/compose/ui/node/LayoutModifierNode;", "Landroidx/compose/ui/node/DrawModifierNode;", "Landroidx/compose/ui/node/SemanticsModifierNode;", "text", "", "style", "Landroidx/compose
/* loaded from: classes.dex */
public final class TextStringSimpleNode extends Modifier.Node implements LayoutModifierNode, DrawModifierNode, SemanticsModifierNode {
private ParagraphLayoutCache _layoutCache;
private Map<AlignmentLine, Integer> baselineCache;
private FontFamily.Resolver fontFamilyResolver;
private int maxLines;
private int minLines;
private int overflow;
private ColorProducer overrideColor;
private Function1<? super List<TextLayoutResult>, Boolean> semanticsTextLayoutResult;
private boolean softWrap;
private TextStyle style;
private String text;
public /* synthetic */ TextStringSimpleNode(String str, TextStyle textStyle, FontFamily.Resolver resolver, int i, boolean z, int i2, int i3, ColorProducer colorProducer, DefaultConstructorMarker defaultConstructorMarker) {
this(str, textStyle, resolver, i, z, i2, i3, colorProducer);
}
public /* synthetic */ TextStringSimpleNode(String str, TextStyle textStyle, FontFamily.Resolver resolver, int i, boolean z, int i2, int i3, ColorProducer colorProducer, int i4, DefaultConstructorMarker defaultConstructorMarker) {
this(str, textStyle, resolver, (i4 & 8) != 0 ? TextOverflow.INSTANCE.m4824getClipgIe3tQ8() : i, (i4 & 16) != 0 ? true : z, (i4 & 32) != 0 ? Integer.MAX_VALUE : i2, (i4 & 64) != 0 ? 1 : i3, (i4 & 128) != 0 ? null : colorProducer, null);
}
private TextStringSimpleNode(String text, TextStyle style, FontFamily.Resolver fontFamilyResolver, int i, boolean z, int i2, int i3, ColorProducer colorProducer) {
Intrinsics.checkNotNullParameter(text, "text");
Intrinsics.checkNotNullParameter(style, "style");
Intrinsics.checkNotNullParameter(fontFamilyResolver, "fontFamilyResolver");
this.text = text;
this.style = style;
this.fontFamilyResolver = fontFamilyResolver;
this.overflow = i;
this.softWrap = z;
this.maxLines = i2;
this.minLines = i3;
this.overrideColor = colorProducer;
}
/* JADX INFO: Access modifiers changed from: private */
public final ParagraphLayoutCache getLayoutCache() {
if (this._layoutCache == null) {
this._layoutCache = new ParagraphLayoutCache(this.text, this.style, this.fontFamilyResolver, this.overflow, this.softWrap, this.maxLines, this.minLines, null);
}
ParagraphLayoutCache paragraphLayoutCache = this._layoutCache;
Intrinsics.checkNotNull(paragraphLayoutCache);
return paragraphLayoutCache;
}
private final ParagraphLayoutCache getLayoutCache(Density density) {
ParagraphLayoutCache layoutCache = getLayoutCache();
layoutCache.setDensity$foundation_release(density);
return layoutCache;
}
public final boolean updateDraw(ColorProducer color, TextStyle style) {
Intrinsics.checkNotNullParameter(style, "style");
boolean z = !Intrinsics.areEqual(color, this.overrideColor);
this.overrideColor = color;
return z || !style.hasSameDrawAffectingAttributes(this.style);
}
public final boolean updateText(String text) {
Intrinsics.checkNotNullParameter(text, "text");
if (Intrinsics.areEqual(this.text, text)) {
return false;
}
this.text = text;
return true;
}
/* renamed from: updateLayoutRelatedArgs-HuAbxIM, reason: not valid java name */
public final boolean m878updateLayoutRelatedArgsHuAbxIM(TextStyle style, int minLines, int maxLines, boolean softWrap, FontFamily.Resolver fontFamilyResolver, int overflow) {
Intrinsics.checkNotNullParameter(style, "style");
Intrinsics.checkNotNullParameter(fontFamilyResolver, "fontFamilyResolver");
boolean z = !this.style.hasSameLayoutAffectingAttributes(style);
this.style = style;
if (this.minLines != minLines) {
this.minLines = minLines;
z = true;
}
if (this.maxLines != maxLines) {
this.maxLines = maxLines;
z = true;
}
if (this.softWrap != softWrap) {
this.softWrap = softWrap;
z = true;
}
if (!Intrinsics.areEqual(this.fontFamilyResolver, fontFamilyResolver)) {
this.fontFamilyResolver = fontFamilyResolver;
z = true;
}
if (TextOverflow.m4817equalsimpl0(this.overflow, overflow)) {
return z;
}
this.overflow = overflow;
return true;
}
public final void doInvalidations(boolean drawChanged, boolean textChanged, boolean layoutChanged) {
if (textChanged) {
SemanticsModifierNodeKt.invalidateSemantics(this);
}
if (textChanged || layoutChanged) {
getLayoutCache().m865updateL6sJoHM(this.text, this.style, this.fontFamilyResolver, this.overflow, this.softWrap, this.maxLines, this.minLines);
LayoutModifierNodeKt.invalidateMeasurement(this);
DrawModifierNodeKt.invalidateDraw(this);
}
if (drawChanged) {
DrawModifierNodeKt.invalidateDraw(this);
}
}
@Override // androidx.compose.ui.node.SemanticsModifierNode
public void applySemantics(SemanticsPropertyReceiver semanticsPropertyReceiver) {
Intrinsics.checkNotNullParameter(semanticsPropertyReceiver, "<this>");
Function1<? super List<TextLayoutResult>, Boolean> function1 = this.semanticsTextLayoutResult;
if (function1 == null) {
function1 = new Function1<List<TextLayoutResult>, Boolean>() { // from class: androidx.compose.foundation.text.modifiers.TextStringSimpleNode$applySemantics$1
/* JADX INFO: Access modifiers changed from: package-private */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public final Boolean invoke(List<TextLayoutResult> textLayoutResult) {
ParagraphLayoutCache layoutCache;
Intrinsics.checkNotNullParameter(textLayoutResult, "textLayoutResult");
layoutCache = TextStringSimpleNode.this.getLayoutCache();
TextLayoutResult slowCreateTextLayoutResultOrNull = layoutCache.slowCreateTextLayoutResultOrNull();
if (slowCreateTextLayoutResultOrNull != null) {
textLayoutResult.add(slowCreateTextLayoutResultOrNull);
}
return false;
}
};
this.semanticsTextLayoutResult = function1;
}
SemanticsPropertiesKt.setText(semanticsPropertyReceiver, new AnnotatedString(this.text, null, null, 6, null));
SemanticsPropertiesKt.getTextLayoutResult$default(semanticsPropertyReceiver, null, function1, 1, null);
}
@Override // androidx.compose.ui.node.LayoutModifierNode
/* renamed from: measure-3p2s80s */
public MeasureResult mo247measure3p2s80s(MeasureScope measure, Measurable measurable, long j) {
Intrinsics.checkNotNullParameter(measure, "$this$measure");
Intrinsics.checkNotNullParameter(measurable, "measurable");
ParagraphLayoutCache layoutCache = getLayoutCache(measure);
boolean m863layoutWithConstraintsK40F9xA = layoutCache.m863layoutWithConstraintsK40F9xA(j, measure.getLayoutDirection());
layoutCache.getObserveFontChanges$foundation_release();
Paragraph paragraph = layoutCache.getParagraph();
Intrinsics.checkNotNull(paragraph);
long layoutSize = layoutCache.getLayoutSize();
if (m863layoutWithConstraintsK40F9xA) {
LayoutModifierNodeKt.invalidateLayer(this);
LinkedHashMap linkedHashMap = this.baselineCache;
if (linkedHashMap == null) {
linkedHashMap = new LinkedHashMap(2);
}
linkedHashMap.put(AlignmentLineKt.getFirstBaseline(), Integer.valueOf(MathKt.roundToInt(paragraph.getFirstBaseline())));
linkedHashMap.put(AlignmentLineKt.getLastBaseline(), Integer.valueOf(MathKt.roundToInt(paragraph.getLastBaseline())));
this.baselineCache = linkedHashMap;
}
final Placeable mo3876measureBRTryo0 = measurable.mo3876measureBRTryo0(Constraints.INSTANCE.m4847fixedJhjzzOo(IntSize.m5043getWidthimpl(layoutSize), IntSize.m5042getHeightimpl(layoutSize)));
int m5043getWidthimpl = IntSize.m5043getWidthimpl(layoutSize);
int m5042getHeightimpl = IntSize.m5042getHeightimpl(layoutSize);
Map<AlignmentLine, Integer> map = this.baselineCache;
Intrinsics.checkNotNull(map);
return measure.layout(m5043getWidthimpl, m5042getHeightimpl, map, new Function1<Placeable.PlacementScope, Unit>() { // from class: androidx.compose.foundation.text.modifiers.TextStringSimpleNode$measure$1
/* JADX INFO: Access modifiers changed from: package-private */
{
super(1);
}
@Override // kotlin.jvm.functions.Function1
public /* bridge */ /* synthetic */ Unit invoke(Placeable.PlacementScope placementScope) {
invoke2(placementScope);
return Unit.INSTANCE;
}
/* renamed from: invoke, reason: avoid collision after fix types in other method */
public final void invoke2(Placeable.PlacementScope layout) {
Intrinsics.checkNotNullParameter(layout, "$this$layout");
Placeable.PlacementScope.place$default(layout, Placeable.this, 0, 0, 0.0f, 4, null);
}
});
}
@Override // androidx.compose.ui.node.LayoutModifierNode
public int minIntrinsicWidth(IntrinsicMeasureScope intrinsicMeasureScope, IntrinsicMeasurable measurable, int i) {
Intrinsics.checkNotNullParameter(intrinsicMeasureScope, "<this>");
Intrinsics.checkNotNullParameter(measurable, "measurable");
return getLayoutCache(intrinsicMeasureScope).minIntrinsicWidth(intrinsicMeasureScope.getLayoutDirection());
}
@Override // androidx.compose.ui.node.LayoutModifierNode
public int minIntrinsicHeight(IntrinsicMeasureScope intrinsicMeasureScope, IntrinsicMeasurable measurable, int i) {
Intrinsics.checkNotNullParameter(intrinsicMeasureScope, "<this>");
Intrinsics.checkNotNullParameter(measurable, "measurable");
return getLayoutCache(intrinsicMeasureScope).intrinsicHeight(i, intrinsicMeasureScope.getLayoutDirection());
}
@Override // androidx.compose.ui.node.LayoutModifierNode
public int maxIntrinsicWidth(IntrinsicMeasureScope intrinsicMeasureScope, IntrinsicMeasurable measurable, int i) {
Intrinsics.checkNotNullParameter(intrinsicMeasureScope, "<this>");
Intrinsics.checkNotNullParameter(measurable, "measurable");
return getLayoutCache(intrinsicMeasureScope).maxIntrinsicWidth(intrinsicMeasureScope.getLayoutDirection());
}
@Override // androidx.compose.ui.node.LayoutModifierNode
public int maxIntrinsicHeight(IntrinsicMeasureScope intrinsicMeasureScope, IntrinsicMeasurable measurable, int i) {
Intrinsics.checkNotNullParameter(intrinsicMeasureScope, "<this>");
Intrinsics.checkNotNullParameter(measurable, "measurable");
return getLayoutCache(intrinsicMeasureScope).intrinsicHeight(i, intrinsicMeasureScope.getLayoutDirection());
}
@Override // androidx.compose.ui.node.DrawModifierNode
public void draw(ContentDrawScope contentDrawScope) {
Intrinsics.checkNotNullParameter(contentDrawScope, "<this>");
Paragraph paragraph = getLayoutCache().getParagraph();
if (paragraph == null) {
throw new IllegalArgumentException("Required value was null.".toString());
}
Canvas canvas = contentDrawScope.getDrawContext().getCanvas();
boolean didOverflow = getLayoutCache().getDidOverflow();
if (didOverflow) {
Rect m2440Recttz77jQw = RectKt.m2440Recttz77jQw(Offset.INSTANCE.m2416getZeroF1C5BW0(), SizeKt.Size(IntSize.m5043getWidthimpl(getLayoutCache().getLayoutSize()), IntSize.m5042getHeightimpl(getLayoutCache().getLayoutSize())));
canvas.save();
Canvas.m2612clipRectmtrdDE$default(canvas, m2440Recttz77jQw, 0, 2, null);
}
try {
TextDecoration textDecoration = this.style.getTextDecoration();
if (textDecoration == null) {
textDecoration = TextDecoration.INSTANCE.getNone();
}
TextDecoration textDecoration2 = textDecoration;
Shadow shadow = this.style.getShadow();
if (shadow == null) {
shadow = Shadow.INSTANCE.getNone();
}
Shadow shadow2 = shadow;
Fill drawStyle = this.style.getDrawStyle();
if (drawStyle == null) {
drawStyle = Fill.INSTANCE;
}
DrawStyle drawStyle2 = drawStyle;
Brush brush = this.style.getBrush();
if (brush != null) {
Paragraph.m4309painthn5TExg$default(paragraph, canvas, brush, this.style.getAlpha(), shadow2, textDecoration2, drawStyle2, 0, 64, null);
} else {
ColorProducer colorProducer = this.overrideColor;
long m2716invoke0d7_KjU = colorProducer != null ? colorProducer.m2716invoke0d7_KjU() : Color.INSTANCE.m2675getUnspecified0d7_KjU();
if (m2716invoke0d7_KjU == Color.INSTANCE.m2675getUnspecified0d7_KjU()) {
if (this.style.m4435getColor0d7_KjU() != Color.INSTANCE.m2675getUnspecified0d7_KjU()) {
m2716invoke0d7_KjU = this.style.m4435getColor0d7_KjU();
} else {
m2716invoke0d7_KjU = Color.INSTANCE.m2665getBlack0d7_KjU();
}
}
Paragraph.m4307paintLG529CI$default(paragraph, canvas, m2716invoke0d7_KjU, shadow2, textDecoration2, drawStyle2, 0, 32, null);
}
} finally {
if (didOverflow) {
canvas.restore();
}
}
}
}