mirror of
https://github.com/VibedByKaKi/alexandroid.git
synced 2026-11-13 09:27:16 +01:00
1492 lines
58 KiB
Java
1492 lines
58 KiB
Java
package com.caverock.androidsvg;
|
|
|
|
import android.util.Log;
|
|
import androidx.biometric.ErrorUtils$$ExternalSyntheticOutline0;
|
|
import com.amazon.alexa.ra.core.ui.markdown.parser.formatter.MarkdownConstants;
|
|
import com.amazon.deecomms.common.metrics.MetricKeys;
|
|
import com.caverock.androidsvg.SVG;
|
|
import com.caverock.androidsvg.SVGParser;
|
|
import defpackage.a$$ExternalSyntheticOutline0;
|
|
import java.util.ArrayList;
|
|
import java.util.HashMap;
|
|
import java.util.Iterator;
|
|
import java.util.List;
|
|
import java.util.Locale;
|
|
import java.util.Map;
|
|
import kotlinx.serialization.json.internal.AbstractJsonLexerKt;
|
|
import org.objectweb.asm.signature.SignatureVisitor;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* loaded from: classes6.dex */
|
|
class CSSParser {
|
|
private static final String CLASS = "class";
|
|
static final String CSS_MIME_TYPE = "text/css";
|
|
private static final String ID = "id";
|
|
private static final int SPECIFICITY_ATTRIBUTE_OR_PSEUDOCLASS = 1000;
|
|
private static final int SPECIFICITY_ELEMENT_OR_PSEUDOELEMENT = 1;
|
|
private static final int SPECIFICITY_ID_ATTRIBUTE = 1000000;
|
|
private static final String TAG = "CSSParser";
|
|
private MediaType deviceMediaType;
|
|
private boolean inMediaRule;
|
|
private Source source;
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
/* renamed from: com.caverock.androidsvg.CSSParser$1, reason: invalid class name */
|
|
public static /* synthetic */ class AnonymousClass1 {
|
|
static final /* synthetic */ int[] $SwitchMap$com$caverock$androidsvg$CSSParser$AttribOp;
|
|
static final /* synthetic */ int[] $SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents;
|
|
|
|
static {
|
|
int[] iArr = new int[PseudoClassIdents.values().length];
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents = iArr;
|
|
try {
|
|
iArr[PseudoClassIdents.first_child.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.last_child.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused2) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.only_child.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused3) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.first_of_type.ordinal()] = 4;
|
|
} catch (NoSuchFieldError unused4) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.last_of_type.ordinal()] = 5;
|
|
} catch (NoSuchFieldError unused5) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.only_of_type.ordinal()] = 6;
|
|
} catch (NoSuchFieldError unused6) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.root.ordinal()] = 7;
|
|
} catch (NoSuchFieldError unused7) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.empty.ordinal()] = 8;
|
|
} catch (NoSuchFieldError unused8) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.nth_child.ordinal()] = 9;
|
|
} catch (NoSuchFieldError unused9) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.nth_last_child.ordinal()] = 10;
|
|
} catch (NoSuchFieldError unused10) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.nth_of_type.ordinal()] = 11;
|
|
} catch (NoSuchFieldError unused11) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.nth_last_of_type.ordinal()] = 12;
|
|
} catch (NoSuchFieldError unused12) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.not.ordinal()] = 13;
|
|
} catch (NoSuchFieldError unused13) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.target.ordinal()] = 14;
|
|
} catch (NoSuchFieldError unused14) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.lang.ordinal()] = 15;
|
|
} catch (NoSuchFieldError unused15) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.link.ordinal()] = 16;
|
|
} catch (NoSuchFieldError unused16) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.visited.ordinal()] = 17;
|
|
} catch (NoSuchFieldError unused17) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.hover.ordinal()] = 18;
|
|
} catch (NoSuchFieldError unused18) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.active.ordinal()] = 19;
|
|
} catch (NoSuchFieldError unused19) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.focus.ordinal()] = 20;
|
|
} catch (NoSuchFieldError unused20) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.enabled.ordinal()] = 21;
|
|
} catch (NoSuchFieldError unused21) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.disabled.ordinal()] = 22;
|
|
} catch (NoSuchFieldError unused22) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.checked.ordinal()] = 23;
|
|
} catch (NoSuchFieldError unused23) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[PseudoClassIdents.indeterminate.ordinal()] = 24;
|
|
} catch (NoSuchFieldError unused24) {
|
|
}
|
|
int[] iArr2 = new int[AttribOp.values().length];
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$AttribOp = iArr2;
|
|
try {
|
|
iArr2[AttribOp.EQUALS.ordinal()] = 1;
|
|
} catch (NoSuchFieldError unused25) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$AttribOp[AttribOp.INCLUDES.ordinal()] = 2;
|
|
} catch (NoSuchFieldError unused26) {
|
|
}
|
|
try {
|
|
$SwitchMap$com$caverock$androidsvg$CSSParser$AttribOp[AttribOp.DASHMATCH.ordinal()] = 3;
|
|
} catch (NoSuchFieldError unused27) {
|
|
}
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class Attrib {
|
|
public final String name;
|
|
final AttribOp operation;
|
|
public final String value;
|
|
|
|
public Attrib(String str, AttribOp attribOp, String str2) {
|
|
this.name = str;
|
|
this.operation = attribOp;
|
|
this.value = str2;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum AttribOp {
|
|
EXISTS,
|
|
EQUALS,
|
|
INCLUDES,
|
|
DASHMATCH
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class CSSTextScanner extends SVGParser.TextScanner {
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class AnPlusB {
|
|
|
|
/* renamed from: a, reason: collision with root package name */
|
|
public int f1128a;
|
|
public int b;
|
|
|
|
public AnPlusB(int i, int i2) {
|
|
this.f1128a = i;
|
|
this.b = i2;
|
|
}
|
|
}
|
|
|
|
public CSSTextScanner(String str) {
|
|
super(str.replaceAll("(?s)/\\*.*?\\*/", ""));
|
|
}
|
|
|
|
private int hexChar(int i) {
|
|
if (i >= 48 && i <= 57) {
|
|
return i - 48;
|
|
}
|
|
if (i >= 65 && i <= 70) {
|
|
return i - 55;
|
|
}
|
|
if (i < 97 || i > 102) {
|
|
return -1;
|
|
}
|
|
return i - 87;
|
|
}
|
|
|
|
private AnPlusB nextAnPlusB() throws CSSParseException {
|
|
IntegerParser integerParser;
|
|
AnPlusB anPlusB;
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
int i = this.position;
|
|
if (!consume('(')) {
|
|
return null;
|
|
}
|
|
skipWhitespace();
|
|
int i2 = 1;
|
|
if (consume("odd")) {
|
|
anPlusB = new AnPlusB(2, 1);
|
|
} else {
|
|
if (consume("even")) {
|
|
anPlusB = new AnPlusB(2, 0);
|
|
} else {
|
|
int i3 = (!consume(SignatureVisitor.EXTENDS) && consume('-')) ? -1 : 1;
|
|
IntegerParser parseInt = IntegerParser.parseInt(this.input, this.position, this.inputLength, false);
|
|
if (parseInt != null) {
|
|
this.position = parseInt.getEndPos();
|
|
}
|
|
if (consume('n') || consume('N')) {
|
|
if (parseInt == null) {
|
|
parseInt = new IntegerParser(1L, this.position);
|
|
}
|
|
skipWhitespace();
|
|
boolean consume = consume(SignatureVisitor.EXTENDS);
|
|
if (!consume && (consume = consume('-'))) {
|
|
i2 = -1;
|
|
}
|
|
if (consume) {
|
|
skipWhitespace();
|
|
integerParser = IntegerParser.parseInt(this.input, this.position, this.inputLength, false);
|
|
if (integerParser == null) {
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
this.position = integerParser.getEndPos();
|
|
int i4 = i2;
|
|
i2 = i3;
|
|
i3 = i4;
|
|
} else {
|
|
int i5 = i2;
|
|
i2 = i3;
|
|
i3 = i5;
|
|
integerParser = null;
|
|
}
|
|
} else {
|
|
integerParser = parseInt;
|
|
parseInt = null;
|
|
}
|
|
anPlusB = new AnPlusB(parseInt == null ? 0 : i2 * parseInt.value(), integerParser != null ? i3 * integerParser.value() : 0);
|
|
}
|
|
}
|
|
skipWhitespace();
|
|
if (consume(')')) {
|
|
return anPlusB;
|
|
}
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
|
|
private String nextAttribValue() {
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
String nextQuotedString = nextQuotedString();
|
|
return nextQuotedString != null ? nextQuotedString : nextIdentifier();
|
|
}
|
|
|
|
private List<String> nextIdentListParam() throws CSSParseException {
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
int i = this.position;
|
|
if (!consume('(')) {
|
|
return null;
|
|
}
|
|
skipWhitespace();
|
|
ArrayList arrayList = null;
|
|
do {
|
|
String nextIdentifier = nextIdentifier();
|
|
if (nextIdentifier == null) {
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
if (arrayList == null) {
|
|
arrayList = new ArrayList();
|
|
}
|
|
arrayList.add(nextIdentifier);
|
|
skipWhitespace();
|
|
} while (skipCommaWhitespace());
|
|
if (consume(')')) {
|
|
return arrayList;
|
|
}
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
|
|
private List<Selector> nextPseudoNotParam() throws CSSParseException {
|
|
List<SimpleSelector> list;
|
|
List<PseudoClass> list2;
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
int i = this.position;
|
|
if (!consume('(')) {
|
|
return null;
|
|
}
|
|
skipWhitespace();
|
|
List<Selector> nextSelectorGroup = nextSelectorGroup();
|
|
if (nextSelectorGroup == null) {
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
if (!consume(')')) {
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
Iterator<Selector> it2 = nextSelectorGroup.iterator();
|
|
while (it2.hasNext() && (list = it2.next().simpleSelectors) != null) {
|
|
Iterator<SimpleSelector> it3 = list.iterator();
|
|
while (it3.hasNext() && (list2 = it3.next().pseudos) != null) {
|
|
Iterator<PseudoClass> it4 = list2.iterator();
|
|
while (it4.hasNext()) {
|
|
if (it4.next() instanceof PseudoClassNot) {
|
|
return null;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
return nextSelectorGroup;
|
|
}
|
|
|
|
/* JADX INFO: Access modifiers changed from: private */
|
|
public List<Selector> nextSelectorGroup() throws CSSParseException {
|
|
AnonymousClass1 anonymousClass1 = null;
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
ArrayList arrayList = new ArrayList(1);
|
|
Selector selector = new Selector(anonymousClass1);
|
|
while (!empty() && nextSimpleSelector(selector)) {
|
|
if (skipCommaWhitespace()) {
|
|
arrayList.add(selector);
|
|
selector = new Selector(anonymousClass1);
|
|
}
|
|
}
|
|
if (!selector.isEmpty()) {
|
|
arrayList.add(selector);
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
private void parsePseudoClass(Selector selector, SimpleSelector simpleSelector) throws CSSParseException {
|
|
PseudoClass pseudoClass;
|
|
PseudoClassAnPlusB pseudoClassAnPlusB;
|
|
PseudoClassAnPlusB pseudoClassAnPlusB2;
|
|
String nextIdentifier = nextIdentifier();
|
|
if (nextIdentifier == null) {
|
|
throw new CSSParseException("Invalid pseudo class");
|
|
}
|
|
PseudoClassIdents fromString = PseudoClassIdents.fromString(nextIdentifier);
|
|
AnonymousClass1 anonymousClass1 = null;
|
|
switch (AnonymousClass1.$SwitchMap$com$caverock$androidsvg$CSSParser$PseudoClassIdents[fromString.ordinal()]) {
|
|
case 1:
|
|
PseudoClassAnPlusB pseudoClassAnPlusB3 = new PseudoClassAnPlusB(0, 1, true, false, null);
|
|
selector.addedAttributeOrPseudo();
|
|
pseudoClassAnPlusB2 = pseudoClassAnPlusB3;
|
|
pseudoClass = pseudoClassAnPlusB2;
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 2:
|
|
PseudoClassAnPlusB pseudoClassAnPlusB4 = new PseudoClassAnPlusB(0, 1, false, false, null);
|
|
selector.addedAttributeOrPseudo();
|
|
pseudoClass = pseudoClassAnPlusB4;
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 3:
|
|
pseudoClass = new PseudoClassOnlyChild(false, null);
|
|
selector.addedAttributeOrPseudo();
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 4:
|
|
pseudoClassAnPlusB = new PseudoClassAnPlusB(0, 1, true, true, simpleSelector.tag);
|
|
selector.addedAttributeOrPseudo();
|
|
pseudoClass = pseudoClassAnPlusB;
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 5:
|
|
PseudoClassAnPlusB pseudoClassAnPlusB5 = new PseudoClassAnPlusB(0, 1, false, true, simpleSelector.tag);
|
|
selector.addedAttributeOrPseudo();
|
|
pseudoClass = pseudoClassAnPlusB5;
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 6:
|
|
pseudoClass = new PseudoClassOnlyChild(true, simpleSelector.tag);
|
|
selector.addedAttributeOrPseudo();
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 7:
|
|
pseudoClass = new PseudoClassRoot(anonymousClass1);
|
|
selector.addedAttributeOrPseudo();
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 8:
|
|
pseudoClass = new PseudoClassEmpty(anonymousClass1);
|
|
selector.addedAttributeOrPseudo();
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 9:
|
|
case 10:
|
|
case 11:
|
|
case 12:
|
|
boolean z = fromString == PseudoClassIdents.nth_child || fromString == PseudoClassIdents.nth_of_type;
|
|
boolean z2 = fromString == PseudoClassIdents.nth_of_type || fromString == PseudoClassIdents.nth_last_of_type;
|
|
AnPlusB nextAnPlusB = nextAnPlusB();
|
|
if (nextAnPlusB == null) {
|
|
throw new CSSParseException("Invalid or missing parameter section for pseudo class: ".concat(nextIdentifier));
|
|
}
|
|
pseudoClassAnPlusB = new PseudoClassAnPlusB(nextAnPlusB.f1128a, nextAnPlusB.b, z, z2, simpleSelector.tag);
|
|
selector.addedAttributeOrPseudo();
|
|
pseudoClass = pseudoClassAnPlusB;
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 13:
|
|
List<Selector> nextPseudoNotParam = nextPseudoNotParam();
|
|
if (nextPseudoNotParam == null) {
|
|
throw new CSSParseException("Invalid or missing parameter section for pseudo class: ".concat(nextIdentifier));
|
|
}
|
|
PseudoClassNot pseudoClassNot = new PseudoClassNot(nextPseudoNotParam);
|
|
selector.specificity = pseudoClassNot.getSpecificity();
|
|
pseudoClassAnPlusB2 = pseudoClassNot;
|
|
pseudoClass = pseudoClassAnPlusB2;
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 14:
|
|
pseudoClass = new PseudoClassTarget(anonymousClass1);
|
|
selector.addedAttributeOrPseudo();
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 15:
|
|
nextIdentListParam();
|
|
pseudoClass = new PseudoClassNotSupported(nextIdentifier);
|
|
selector.addedAttributeOrPseudo();
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
case 16:
|
|
case 17:
|
|
case 18:
|
|
case 19:
|
|
case 20:
|
|
case 21:
|
|
case 22:
|
|
case 23:
|
|
case 24:
|
|
pseudoClass = new PseudoClassNotSupported(nextIdentifier);
|
|
selector.addedAttributeOrPseudo();
|
|
simpleSelector.addPseudo(pseudoClass);
|
|
return;
|
|
default:
|
|
throw new CSSParseException("Unsupported pseudo class: ".concat(nextIdentifier));
|
|
}
|
|
}
|
|
|
|
private int scanForIdentifier() {
|
|
int i;
|
|
boolean empty = empty();
|
|
int i2 = this.position;
|
|
if (empty) {
|
|
return i2;
|
|
}
|
|
int charAt = this.input.charAt(i2);
|
|
if (charAt == 45) {
|
|
charAt = advanceChar();
|
|
}
|
|
if ((charAt < 65 || charAt > 90) && ((charAt < 97 || charAt > 122) && charAt != 95)) {
|
|
i = i2;
|
|
} else {
|
|
int advanceChar = advanceChar();
|
|
while (true) {
|
|
if ((advanceChar < 65 || advanceChar > 90) && ((advanceChar < 97 || advanceChar > 122) && !((advanceChar >= 48 && advanceChar <= 57) || advanceChar == 45 || advanceChar == 95))) {
|
|
break;
|
|
}
|
|
advanceChar = advanceChar();
|
|
}
|
|
i = this.position;
|
|
}
|
|
this.position = i2;
|
|
return i;
|
|
}
|
|
|
|
public String nextCSSString() {
|
|
int hexChar;
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
char charAt = this.input.charAt(this.position);
|
|
if (charAt != '\'' && charAt != '\"') {
|
|
return null;
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
this.position++;
|
|
int intValue = nextChar().intValue();
|
|
while (intValue != -1 && intValue != charAt) {
|
|
if (intValue == 92) {
|
|
intValue = nextChar().intValue();
|
|
if (intValue != -1) {
|
|
if (intValue == 10 || intValue == 13 || intValue == 12) {
|
|
intValue = nextChar().intValue();
|
|
} else {
|
|
int hexChar2 = hexChar(intValue);
|
|
if (hexChar2 != -1) {
|
|
for (int i = 1; i <= 5 && (hexChar = hexChar((intValue = nextChar().intValue()))) != -1; i++) {
|
|
hexChar2 = (hexChar2 * 16) + hexChar;
|
|
}
|
|
sb.append((char) hexChar2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sb.append((char) intValue);
|
|
intValue = nextChar().intValue();
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public String nextIdentifier() {
|
|
int scanForIdentifier = scanForIdentifier();
|
|
int i = this.position;
|
|
if (scanForIdentifier == i) {
|
|
return null;
|
|
}
|
|
String substring = this.input.substring(i, scanForIdentifier);
|
|
this.position = scanForIdentifier;
|
|
return substring;
|
|
}
|
|
|
|
public String nextLegacyURL() {
|
|
char charAt;
|
|
int hexChar;
|
|
StringBuilder sb = new StringBuilder();
|
|
while (!empty() && (charAt = this.input.charAt(this.position)) != '\'' && charAt != '\"' && charAt != '(' && charAt != ')' && !isWhitespace(charAt) && !Character.isISOControl((int) charAt)) {
|
|
this.position++;
|
|
if (charAt == '\\') {
|
|
if (!empty()) {
|
|
String str = this.input;
|
|
int i = this.position;
|
|
this.position = i + 1;
|
|
charAt = str.charAt(i);
|
|
if (charAt != '\n' && charAt != '\r' && charAt != '\f') {
|
|
int hexChar2 = hexChar(charAt);
|
|
if (hexChar2 != -1) {
|
|
for (int i2 = 1; i2 <= 5 && !empty() && (hexChar = hexChar(this.input.charAt(this.position))) != -1; i2++) {
|
|
this.position++;
|
|
hexChar2 = (hexChar2 * 16) + hexChar;
|
|
}
|
|
sb.append((char) hexChar2);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
sb.append(charAt);
|
|
}
|
|
if (sb.length() == 0) {
|
|
return null;
|
|
}
|
|
return sb.toString();
|
|
}
|
|
|
|
public String nextPropertyValue() {
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
int i = this.position;
|
|
int charAt = this.input.charAt(i);
|
|
int i2 = i;
|
|
while (charAt != -1 && charAt != 59 && charAt != 125 && charAt != 33 && !isEOL(charAt)) {
|
|
if (!isWhitespace(charAt)) {
|
|
i2 = this.position + 1;
|
|
}
|
|
charAt = advanceChar();
|
|
}
|
|
if (this.position > i) {
|
|
return this.input.substring(i, i2);
|
|
}
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
|
|
/* JADX WARN: Removed duplicated region for block: B:12:0x0036 */
|
|
/* JADX WARN: Removed duplicated region for block: B:16:0x0053 */
|
|
/* JADX WARN: Removed duplicated region for block: B:34:0x012e */
|
|
/* JADX WARN: Removed duplicated region for block: B:36:0x0133 */
|
|
/* JADX WARN: Removed duplicated region for block: B:94:0x003c */
|
|
/*
|
|
Code decompiled incorrectly, please refer to instructions dump.
|
|
To view partially-correct add '--show-bad-code' argument
|
|
*/
|
|
public boolean nextSimpleSelector(com.caverock.androidsvg.CSSParser.Selector r11) throws com.caverock.androidsvg.CSSParseException {
|
|
/*
|
|
Method dump skipped, instructions count: 310
|
|
To view this dump add '--comments-level debug' option
|
|
*/
|
|
throw new UnsupportedOperationException("Method not decompiled: com.caverock.androidsvg.CSSParser.CSSTextScanner.nextSimpleSelector(com.caverock.androidsvg.CSSParser$Selector):boolean");
|
|
}
|
|
|
|
public String nextURL() {
|
|
if (empty()) {
|
|
return null;
|
|
}
|
|
int i = this.position;
|
|
if (!consume("url(")) {
|
|
return null;
|
|
}
|
|
skipWhitespace();
|
|
String nextCSSString = nextCSSString();
|
|
if (nextCSSString == null) {
|
|
nextCSSString = nextLegacyURL();
|
|
}
|
|
if (nextCSSString == null) {
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
skipWhitespace();
|
|
if (empty() || consume(MarkdownConstants.RIGHT_PARENTHESIS)) {
|
|
return nextCSSString;
|
|
}
|
|
this.position = i;
|
|
return null;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum Combinator {
|
|
DESCENDANT,
|
|
CHILD,
|
|
FOLLOWS
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum MediaType {
|
|
all,
|
|
aural,
|
|
braille,
|
|
embossed,
|
|
handheld,
|
|
print,
|
|
projection,
|
|
screen,
|
|
speech,
|
|
tty,
|
|
tv
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public interface PseudoClass {
|
|
boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PseudoClassAnPlusB implements PseudoClass {
|
|
|
|
/* renamed from: a, reason: collision with root package name */
|
|
private int f1129a;
|
|
private int b;
|
|
private boolean isFromStart;
|
|
private boolean isOfType;
|
|
private String nodeName;
|
|
|
|
public PseudoClassAnPlusB(int i, int i2, boolean z, boolean z2, String str) {
|
|
this.f1129a = i;
|
|
this.b = i2;
|
|
this.isFromStart = z;
|
|
this.isOfType = z2;
|
|
this.nodeName = str;
|
|
}
|
|
|
|
@Override // com.caverock.androidsvg.CSSParser.PseudoClass
|
|
public boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase) {
|
|
int i;
|
|
int i2;
|
|
String nodeName = (this.isOfType && this.nodeName == null) ? svgElementBase.getNodeName() : this.nodeName;
|
|
SVG.SvgContainer svgContainer = svgElementBase.parent;
|
|
if (svgContainer != null) {
|
|
Iterator<SVG.SvgObject> it2 = svgContainer.getChildren().iterator();
|
|
i = 0;
|
|
i2 = 0;
|
|
while (it2.hasNext()) {
|
|
SVG.SvgElementBase svgElementBase2 = (SVG.SvgElementBase) it2.next();
|
|
if (svgElementBase2 == svgElementBase) {
|
|
i = i2;
|
|
}
|
|
if (nodeName == null || svgElementBase2.getNodeName().equals(nodeName)) {
|
|
i2++;
|
|
}
|
|
}
|
|
} else {
|
|
i = 0;
|
|
i2 = 1;
|
|
}
|
|
int i3 = this.isFromStart ? i + 1 : i2 - i;
|
|
int i4 = this.f1129a;
|
|
int i5 = this.b;
|
|
return i4 == 0 ? i3 == i5 : (i3 - i5) % i4 == 0 && (Integer.signum(i3 - i5) == 0 || Integer.signum(i3 - this.b) == Integer.signum(this.f1129a));
|
|
}
|
|
|
|
public String toString() {
|
|
String str = this.isFromStart ? "" : "last-";
|
|
boolean z = this.isOfType;
|
|
int i = this.f1129a;
|
|
return z ? String.format("nth-%schild(%dn%+d of type <%s>)", str, Integer.valueOf(i), Integer.valueOf(this.b), this.nodeName) : String.format("nth-%schild(%dn%+d)", str, Integer.valueOf(i), Integer.valueOf(this.b));
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum PseudoClassIdents {
|
|
target,
|
|
root,
|
|
nth_child,
|
|
nth_last_child,
|
|
nth_of_type,
|
|
nth_last_of_type,
|
|
first_child,
|
|
last_child,
|
|
first_of_type,
|
|
last_of_type,
|
|
only_child,
|
|
only_of_type,
|
|
empty,
|
|
not,
|
|
lang,
|
|
link,
|
|
visited,
|
|
hover,
|
|
active,
|
|
focus,
|
|
enabled,
|
|
disabled,
|
|
checked,
|
|
indeterminate,
|
|
UNSUPPORTED;
|
|
|
|
private static final Map<String, PseudoClassIdents> cache = new HashMap();
|
|
|
|
static {
|
|
for (PseudoClassIdents pseudoClassIdents : values()) {
|
|
if (pseudoClassIdents != UNSUPPORTED) {
|
|
cache.put(pseudoClassIdents.name().replace('_', '-'), pseudoClassIdents);
|
|
}
|
|
}
|
|
}
|
|
|
|
public static PseudoClassIdents fromString(String str) {
|
|
PseudoClassIdents pseudoClassIdents = cache.get(str);
|
|
return pseudoClassIdents != null ? pseudoClassIdents : UNSUPPORTED;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PseudoClassNot implements PseudoClass {
|
|
private List<Selector> selectorGroup;
|
|
|
|
public PseudoClassNot(List<Selector> list) {
|
|
this.selectorGroup = list;
|
|
}
|
|
|
|
public int getSpecificity() {
|
|
Iterator<Selector> it2 = this.selectorGroup.iterator();
|
|
int i = Integer.MIN_VALUE;
|
|
while (it2.hasNext()) {
|
|
int i2 = it2.next().specificity;
|
|
if (i2 > i) {
|
|
i = i2;
|
|
}
|
|
}
|
|
return i;
|
|
}
|
|
|
|
@Override // com.caverock.androidsvg.CSSParser.PseudoClass
|
|
public boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase) {
|
|
Iterator<Selector> it2 = this.selectorGroup.iterator();
|
|
while (it2.hasNext()) {
|
|
if (CSSParser.ruleMatch(ruleMatchContext, it2.next(), svgElementBase)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
public String toString() {
|
|
return ErrorUtils$$ExternalSyntheticOutline0.m(MarkdownConstants.RIGHT_PARENTHESIS, this.selectorGroup, new StringBuilder("not("));
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PseudoClassNotSupported implements PseudoClass {
|
|
private String clazz;
|
|
|
|
public PseudoClassNotSupported(String str) {
|
|
this.clazz = str;
|
|
}
|
|
|
|
@Override // com.caverock.androidsvg.CSSParser.PseudoClass
|
|
public boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase) {
|
|
return false;
|
|
}
|
|
|
|
public String toString() {
|
|
return this.clazz;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PseudoClassOnlyChild implements PseudoClass {
|
|
private boolean isOfType;
|
|
private String nodeName;
|
|
|
|
public PseudoClassOnlyChild(boolean z, String str) {
|
|
this.isOfType = z;
|
|
this.nodeName = str;
|
|
}
|
|
|
|
@Override // com.caverock.androidsvg.CSSParser.PseudoClass
|
|
public boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase) {
|
|
int i;
|
|
String nodeName = (this.isOfType && this.nodeName == null) ? svgElementBase.getNodeName() : this.nodeName;
|
|
SVG.SvgContainer svgContainer = svgElementBase.parent;
|
|
if (svgContainer != null) {
|
|
Iterator<SVG.SvgObject> it2 = svgContainer.getChildren().iterator();
|
|
i = 0;
|
|
while (it2.hasNext()) {
|
|
SVG.SvgElementBase svgElementBase2 = (SVG.SvgElementBase) it2.next();
|
|
if (nodeName == null || svgElementBase2.getNodeName().equals(nodeName)) {
|
|
i++;
|
|
}
|
|
}
|
|
} else {
|
|
i = 1;
|
|
}
|
|
return i == 1;
|
|
}
|
|
|
|
public String toString() {
|
|
return this.isOfType ? a$$ExternalSyntheticOutline0.m("only-of-type <", this.nodeName, ">") : "only-child";
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class Rule {
|
|
Selector selector;
|
|
Source source;
|
|
SVG.Style style;
|
|
|
|
public Rule(Selector selector, SVG.Style style, Source source) {
|
|
this.selector = selector;
|
|
this.style = style;
|
|
this.source = source;
|
|
}
|
|
|
|
public String toString() {
|
|
return String.valueOf(this.selector) + " {...} (src=" + this.source + MarkdownConstants.RIGHT_PARENTHESIS;
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class RuleMatchContext {
|
|
SVG.SvgElementBase targetElement;
|
|
|
|
public String toString() {
|
|
SVG.SvgElementBase svgElementBase = this.targetElement;
|
|
return svgElementBase != null ? a$$ExternalSyntheticOutline0.m("<", svgElementBase.getNodeName(), " id=\"", this.targetElement.id, "\">") : "";
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class Ruleset {
|
|
private List<Rule> rules = null;
|
|
|
|
public void add(Rule rule) {
|
|
if (this.rules == null) {
|
|
this.rules = new ArrayList();
|
|
}
|
|
int i = 0;
|
|
while (true) {
|
|
int size = this.rules.size();
|
|
List<Rule> list = this.rules;
|
|
if (i >= size) {
|
|
list.add(rule);
|
|
return;
|
|
} else {
|
|
if (list.get(i).selector.specificity > rule.selector.specificity) {
|
|
this.rules.add(i, rule);
|
|
return;
|
|
}
|
|
i++;
|
|
}
|
|
}
|
|
}
|
|
|
|
public void addAll(Ruleset ruleset) {
|
|
if (ruleset.rules == null) {
|
|
return;
|
|
}
|
|
if (this.rules == null) {
|
|
this.rules = new ArrayList(ruleset.rules.size());
|
|
}
|
|
Iterator<Rule> it2 = ruleset.rules.iterator();
|
|
while (it2.hasNext()) {
|
|
add(it2.next());
|
|
}
|
|
}
|
|
|
|
public List<Rule> getRules() {
|
|
return this.rules;
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
List<Rule> list = this.rules;
|
|
return list == null || list.isEmpty();
|
|
}
|
|
|
|
public void removeFromSource(Source source) {
|
|
List<Rule> list = this.rules;
|
|
if (list == null) {
|
|
return;
|
|
}
|
|
Iterator<Rule> it2 = list.iterator();
|
|
while (it2.hasNext()) {
|
|
if (it2.next().source == source) {
|
|
it2.remove();
|
|
}
|
|
}
|
|
}
|
|
|
|
public int ruleCount() {
|
|
List<Rule> list = this.rules;
|
|
if (list != null) {
|
|
return list.size();
|
|
}
|
|
return 0;
|
|
}
|
|
|
|
public String toString() {
|
|
if (this.rules == null) {
|
|
return "";
|
|
}
|
|
StringBuilder sb = new StringBuilder();
|
|
Iterator<Rule> it2 = this.rules.iterator();
|
|
while (it2.hasNext()) {
|
|
sb.append(it2.next().toString());
|
|
sb.append('\n');
|
|
}
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class SimpleSelector {
|
|
Combinator combinator;
|
|
String tag;
|
|
List<Attrib> attribs = null;
|
|
List<PseudoClass> pseudos = null;
|
|
|
|
public SimpleSelector(Combinator combinator, String str) {
|
|
this.combinator = null;
|
|
this.tag = null;
|
|
this.combinator = combinator == null ? Combinator.DESCENDANT : combinator;
|
|
this.tag = str;
|
|
}
|
|
|
|
public void addAttrib(String str, AttribOp attribOp, String str2) {
|
|
if (this.attribs == null) {
|
|
this.attribs = new ArrayList();
|
|
}
|
|
this.attribs.add(new Attrib(str, attribOp, str2));
|
|
}
|
|
|
|
public void addPseudo(PseudoClass pseudoClass) {
|
|
if (this.pseudos == null) {
|
|
this.pseudos = new ArrayList();
|
|
}
|
|
this.pseudos.add(pseudoClass);
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
Combinator combinator = this.combinator;
|
|
if (combinator == Combinator.CHILD) {
|
|
sb.append("> ");
|
|
} else if (combinator == Combinator.FOLLOWS) {
|
|
sb.append("+ ");
|
|
}
|
|
String str = this.tag;
|
|
if (str == null) {
|
|
str = "*";
|
|
}
|
|
sb.append(str);
|
|
List<Attrib> list = this.attribs;
|
|
if (list != null) {
|
|
for (Attrib attrib : list) {
|
|
sb.append(AbstractJsonLexerKt.BEGIN_LIST);
|
|
sb.append(attrib.name);
|
|
int i = AnonymousClass1.$SwitchMap$com$caverock$androidsvg$CSSParser$AttribOp[attrib.operation.ordinal()];
|
|
if (i == 1) {
|
|
sb.append('=');
|
|
sb.append(attrib.value);
|
|
} else if (i == 2) {
|
|
sb.append("~=");
|
|
sb.append(attrib.value);
|
|
} else if (i == 3) {
|
|
sb.append("|=");
|
|
sb.append(attrib.value);
|
|
}
|
|
sb.append(AbstractJsonLexerKt.END_LIST);
|
|
}
|
|
}
|
|
List<PseudoClass> list2 = this.pseudos;
|
|
if (list2 != null) {
|
|
for (PseudoClass pseudoClass : list2) {
|
|
sb.append(AbstractJsonLexerKt.COLON);
|
|
sb.append(pseudoClass);
|
|
}
|
|
}
|
|
return sb.toString();
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public enum Source {
|
|
Document,
|
|
RenderOptions
|
|
}
|
|
|
|
public CSSParser(MediaType mediaType, Source source) {
|
|
this.inMediaRule = false;
|
|
this.deviceMediaType = mediaType;
|
|
this.source = source;
|
|
}
|
|
|
|
private static int getChildPosition(List<SVG.SvgContainer> list, int i, SVG.SvgElementBase svgElementBase) {
|
|
int i2 = 0;
|
|
if (i < 0) {
|
|
return 0;
|
|
}
|
|
SVG.SvgContainer svgContainer = list.get(i);
|
|
SVG.SvgContainer svgContainer2 = svgElementBase.parent;
|
|
if (svgContainer != svgContainer2) {
|
|
return -1;
|
|
}
|
|
Iterator<SVG.SvgObject> it2 = svgContainer2.getChildren().iterator();
|
|
while (it2.hasNext()) {
|
|
if (it2.next() == svgElementBase) {
|
|
return i2;
|
|
}
|
|
i2++;
|
|
}
|
|
return -1;
|
|
}
|
|
|
|
private static boolean mediaMatches(List<MediaType> list, MediaType mediaType) {
|
|
for (MediaType mediaType2 : list) {
|
|
if (mediaType2 == MediaType.all || mediaType2 == mediaType) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
|
|
private void parseAtRule(Ruleset ruleset, CSSTextScanner cSSTextScanner) throws CSSParseException {
|
|
String nextIdentifier = cSSTextScanner.nextIdentifier();
|
|
cSSTextScanner.skipWhitespace();
|
|
if (nextIdentifier == null) {
|
|
throw new CSSParseException("Invalid '@' rule");
|
|
}
|
|
if (!this.inMediaRule && nextIdentifier.equals("media")) {
|
|
List<MediaType> parseMediaList = parseMediaList(cSSTextScanner);
|
|
if (!cSSTextScanner.consume(AbstractJsonLexerKt.BEGIN_OBJ)) {
|
|
throw new CSSParseException("Invalid @media rule: missing rule set");
|
|
}
|
|
cSSTextScanner.skipWhitespace();
|
|
if (mediaMatches(parseMediaList, this.deviceMediaType)) {
|
|
this.inMediaRule = true;
|
|
ruleset.addAll(parseRuleset(cSSTextScanner));
|
|
this.inMediaRule = false;
|
|
} else {
|
|
parseRuleset(cSSTextScanner);
|
|
}
|
|
if (!cSSTextScanner.empty() && !cSSTextScanner.consume(AbstractJsonLexerKt.END_OBJ)) {
|
|
throw new CSSParseException("Invalid @media rule: expected '}' at end of rule set");
|
|
}
|
|
} else if (this.inMediaRule || !nextIdentifier.equals("import")) {
|
|
warn("Ignoring @%s rule", nextIdentifier);
|
|
skipAtRule(cSSTextScanner);
|
|
} else {
|
|
String nextURL = cSSTextScanner.nextURL();
|
|
if (nextURL == null) {
|
|
nextURL = cSSTextScanner.nextCSSString();
|
|
}
|
|
if (nextURL == null) {
|
|
throw new CSSParseException("Invalid @import rule: expected string or url()");
|
|
}
|
|
cSSTextScanner.skipWhitespace();
|
|
List<MediaType> parseMediaList2 = parseMediaList(cSSTextScanner);
|
|
if (!cSSTextScanner.empty() && !cSSTextScanner.consume(';')) {
|
|
throw new CSSParseException("Invalid @media rule: expected '}' at end of rule set");
|
|
}
|
|
if (SVG.getFileResolver() != null && mediaMatches(parseMediaList2, this.deviceMediaType)) {
|
|
String resolveCSSStyleSheet = SVG.getFileResolver().resolveCSSStyleSheet(nextURL);
|
|
if (resolveCSSStyleSheet == null) {
|
|
return;
|
|
} else {
|
|
ruleset.addAll(parse(resolveCSSStyleSheet));
|
|
}
|
|
}
|
|
}
|
|
cSSTextScanner.skipWhitespace();
|
|
}
|
|
|
|
public static List<String> parseClassAttribute(String str) {
|
|
CSSTextScanner cSSTextScanner = new CSSTextScanner(str);
|
|
ArrayList arrayList = null;
|
|
while (!cSSTextScanner.empty()) {
|
|
String nextToken = cSSTextScanner.nextToken();
|
|
if (nextToken != null) {
|
|
if (arrayList == null) {
|
|
arrayList = new ArrayList();
|
|
}
|
|
arrayList.add(nextToken);
|
|
cSSTextScanner.skipWhitespace();
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
private SVG.Style parseDeclarations(CSSTextScanner cSSTextScanner) throws CSSParseException {
|
|
SVG.Style style = new SVG.Style();
|
|
do {
|
|
String nextIdentifier = cSSTextScanner.nextIdentifier();
|
|
cSSTextScanner.skipWhitespace();
|
|
if (!cSSTextScanner.consume(AbstractJsonLexerKt.COLON)) {
|
|
throw new CSSParseException("Expected ':'");
|
|
}
|
|
cSSTextScanner.skipWhitespace();
|
|
String nextPropertyValue = cSSTextScanner.nextPropertyValue();
|
|
if (nextPropertyValue == null) {
|
|
throw new CSSParseException("Expected property value");
|
|
}
|
|
cSSTextScanner.skipWhitespace();
|
|
if (cSSTextScanner.consume('!')) {
|
|
cSSTextScanner.skipWhitespace();
|
|
if (!cSSTextScanner.consume("important")) {
|
|
throw new CSSParseException("Malformed rule set: found unexpected '!'");
|
|
}
|
|
cSSTextScanner.skipWhitespace();
|
|
}
|
|
cSSTextScanner.consume(';');
|
|
SVGParser.processStyleProperty(style, nextIdentifier, nextPropertyValue);
|
|
cSSTextScanner.skipWhitespace();
|
|
if (cSSTextScanner.empty()) {
|
|
break;
|
|
}
|
|
} while (!cSSTextScanner.consume(AbstractJsonLexerKt.END_OBJ));
|
|
return style;
|
|
}
|
|
|
|
private static List<MediaType> parseMediaList(CSSTextScanner cSSTextScanner) {
|
|
String nextWord;
|
|
ArrayList arrayList = new ArrayList();
|
|
while (!cSSTextScanner.empty() && (nextWord = cSSTextScanner.nextWord()) != null) {
|
|
try {
|
|
arrayList.add(MediaType.valueOf(nextWord));
|
|
} catch (IllegalArgumentException unused) {
|
|
}
|
|
if (!cSSTextScanner.skipCommaWhitespace()) {
|
|
break;
|
|
}
|
|
}
|
|
return arrayList;
|
|
}
|
|
|
|
private boolean parseRule(Ruleset ruleset, CSSTextScanner cSSTextScanner) throws CSSParseException {
|
|
List nextSelectorGroup = cSSTextScanner.nextSelectorGroup();
|
|
if (nextSelectorGroup == null || nextSelectorGroup.isEmpty()) {
|
|
return false;
|
|
}
|
|
if (!cSSTextScanner.consume(AbstractJsonLexerKt.BEGIN_OBJ)) {
|
|
throw new CSSParseException("Malformed rule block: expected '{'");
|
|
}
|
|
cSSTextScanner.skipWhitespace();
|
|
SVG.Style parseDeclarations = parseDeclarations(cSSTextScanner);
|
|
cSSTextScanner.skipWhitespace();
|
|
Iterator it2 = nextSelectorGroup.iterator();
|
|
while (it2.hasNext()) {
|
|
ruleset.add(new Rule((Selector) it2.next(), parseDeclarations, this.source));
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private Ruleset parseRuleset(CSSTextScanner cSSTextScanner) {
|
|
Ruleset ruleset = new Ruleset();
|
|
while (!cSSTextScanner.empty()) {
|
|
try {
|
|
if (!cSSTextScanner.consume("<!--") && !cSSTextScanner.consume("-->")) {
|
|
if (!cSSTextScanner.consume('@')) {
|
|
if (!parseRule(ruleset, cSSTextScanner)) {
|
|
break;
|
|
}
|
|
} else {
|
|
parseAtRule(ruleset, cSSTextScanner);
|
|
}
|
|
}
|
|
} catch (CSSParseException e) {
|
|
Log.e(TAG, "CSS parser terminated early due to error: " + e.getMessage());
|
|
return ruleset;
|
|
}
|
|
}
|
|
return ruleset;
|
|
}
|
|
|
|
private static boolean ruleMatch(RuleMatchContext ruleMatchContext, Selector selector, int i, List<SVG.SvgContainer> list, int i2, SVG.SvgElementBase svgElementBase) {
|
|
SimpleSelector simpleSelector = selector.get(i);
|
|
if (!selectorMatch(ruleMatchContext, simpleSelector, list, i2, svgElementBase)) {
|
|
return false;
|
|
}
|
|
Combinator combinator = simpleSelector.combinator;
|
|
if (combinator == Combinator.DESCENDANT) {
|
|
if (i == 0) {
|
|
return true;
|
|
}
|
|
while (i2 >= 0) {
|
|
if (ruleMatchOnAncestors(ruleMatchContext, selector, i - 1, list, i2)) {
|
|
return true;
|
|
}
|
|
i2--;
|
|
}
|
|
return false;
|
|
}
|
|
if (combinator == Combinator.CHILD) {
|
|
return ruleMatchOnAncestors(ruleMatchContext, selector, i - 1, list, i2);
|
|
}
|
|
int childPosition = getChildPosition(list, i2, svgElementBase);
|
|
if (childPosition <= 0) {
|
|
return false;
|
|
}
|
|
return ruleMatch(ruleMatchContext, selector, i - 1, list, i2, (SVG.SvgElementBase) svgElementBase.parent.getChildren().get(childPosition - 1));
|
|
}
|
|
|
|
private static boolean ruleMatchOnAncestors(RuleMatchContext ruleMatchContext, Selector selector, int i, List<SVG.SvgContainer> list, int i2) {
|
|
SimpleSelector simpleSelector = selector.get(i);
|
|
SVG.SvgElementBase svgElementBase = (SVG.SvgElementBase) list.get(i2);
|
|
if (!selectorMatch(ruleMatchContext, simpleSelector, list, i2, svgElementBase)) {
|
|
return false;
|
|
}
|
|
Combinator combinator = simpleSelector.combinator;
|
|
if (combinator == Combinator.DESCENDANT) {
|
|
if (i == 0) {
|
|
return true;
|
|
}
|
|
while (i2 > 0) {
|
|
i2--;
|
|
if (ruleMatchOnAncestors(ruleMatchContext, selector, i - 1, list, i2)) {
|
|
return true;
|
|
}
|
|
}
|
|
return false;
|
|
}
|
|
if (combinator == Combinator.CHILD) {
|
|
return ruleMatchOnAncestors(ruleMatchContext, selector, i - 1, list, i2 - 1);
|
|
}
|
|
int childPosition = getChildPosition(list, i2, svgElementBase);
|
|
if (childPosition <= 0) {
|
|
return false;
|
|
}
|
|
return ruleMatch(ruleMatchContext, selector, i - 1, list, i2, (SVG.SvgElementBase) svgElementBase.parent.getChildren().get(childPosition - 1));
|
|
}
|
|
|
|
private static boolean selectorMatch(RuleMatchContext ruleMatchContext, SimpleSelector simpleSelector, List<SVG.SvgContainer> list, int i, SVG.SvgElementBase svgElementBase) {
|
|
List<String> list2;
|
|
String str = simpleSelector.tag;
|
|
if (str != null && !str.equals(svgElementBase.getNodeName().toLowerCase(Locale.US))) {
|
|
return false;
|
|
}
|
|
List<Attrib> list3 = simpleSelector.attribs;
|
|
if (list3 != null) {
|
|
for (Attrib attrib : list3) {
|
|
String str2 = attrib.name;
|
|
str2.getClass();
|
|
if (str2.equals("id")) {
|
|
if (!attrib.value.equals(svgElementBase.id)) {
|
|
return false;
|
|
}
|
|
} else if (!str2.equals("class") || (list2 = svgElementBase.classNames) == null || !list2.contains(attrib.value)) {
|
|
return false;
|
|
}
|
|
}
|
|
}
|
|
List<PseudoClass> list4 = simpleSelector.pseudos;
|
|
if (list4 == null) {
|
|
return true;
|
|
}
|
|
Iterator<PseudoClass> it2 = list4.iterator();
|
|
while (it2.hasNext()) {
|
|
if (!it2.next().matches(ruleMatchContext, svgElementBase)) {
|
|
return false;
|
|
}
|
|
}
|
|
return true;
|
|
}
|
|
|
|
private void skipAtRule(CSSTextScanner cSSTextScanner) {
|
|
int i = 0;
|
|
while (!cSSTextScanner.empty()) {
|
|
int intValue = cSSTextScanner.nextChar().intValue();
|
|
if (intValue == 59 && i == 0) {
|
|
return;
|
|
}
|
|
if (intValue == 123) {
|
|
i++;
|
|
} else if (intValue == 125 && i > 0 && i - 1 == 0) {
|
|
return;
|
|
}
|
|
}
|
|
}
|
|
|
|
private static void warn(String str, Object... objArr) {
|
|
Log.w(TAG, String.format(str, objArr));
|
|
}
|
|
|
|
public Ruleset parse(String str) {
|
|
CSSTextScanner cSSTextScanner = new CSSTextScanner(str);
|
|
cSSTextScanner.skipWhitespace();
|
|
return parseRuleset(cSSTextScanner);
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PseudoClassEmpty implements PseudoClass {
|
|
private PseudoClassEmpty() {
|
|
}
|
|
|
|
/* JADX WARN: Multi-variable type inference failed */
|
|
@Override // com.caverock.androidsvg.CSSParser.PseudoClass
|
|
public boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase) {
|
|
return !(svgElementBase instanceof SVG.SvgContainer) || ((SVG.SvgContainer) svgElementBase).getChildren().size() == 0;
|
|
}
|
|
|
|
public String toString() {
|
|
return MetricKeys.EMPTY_VALUE;
|
|
}
|
|
|
|
public /* synthetic */ PseudoClassEmpty(AnonymousClass1 anonymousClass1) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PseudoClassRoot implements PseudoClass {
|
|
private PseudoClassRoot() {
|
|
}
|
|
|
|
@Override // com.caverock.androidsvg.CSSParser.PseudoClass
|
|
public boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase) {
|
|
return svgElementBase.parent == null;
|
|
}
|
|
|
|
public String toString() {
|
|
return "root";
|
|
}
|
|
|
|
public /* synthetic */ PseudoClassRoot(AnonymousClass1 anonymousClass1) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class PseudoClassTarget implements PseudoClass {
|
|
private PseudoClassTarget() {
|
|
}
|
|
|
|
@Override // com.caverock.androidsvg.CSSParser.PseudoClass
|
|
public boolean matches(RuleMatchContext ruleMatchContext, SVG.SvgElementBase svgElementBase) {
|
|
return ruleMatchContext != null && svgElementBase == ruleMatchContext.targetElement;
|
|
}
|
|
|
|
public String toString() {
|
|
return "target";
|
|
}
|
|
|
|
public /* synthetic */ PseudoClassTarget(AnonymousClass1 anonymousClass1) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
/* compiled from: r8-map-id-b9432e0f623b4a4bff4ba50a8a24c4aafad2c1e11092747b9fb5e6a22af5a940 */
|
|
public static class Selector {
|
|
List<SimpleSelector> simpleSelectors;
|
|
int specificity;
|
|
|
|
private Selector() {
|
|
this.simpleSelectors = null;
|
|
this.specificity = 0;
|
|
}
|
|
|
|
public void add(SimpleSelector simpleSelector) {
|
|
if (this.simpleSelectors == null) {
|
|
this.simpleSelectors = new ArrayList();
|
|
}
|
|
this.simpleSelectors.add(simpleSelector);
|
|
}
|
|
|
|
public void addedAttributeOrPseudo() {
|
|
this.specificity += 1000;
|
|
}
|
|
|
|
public void addedElement() {
|
|
this.specificity++;
|
|
}
|
|
|
|
public void addedIdAttribute() {
|
|
this.specificity += 1000000;
|
|
}
|
|
|
|
public SimpleSelector get(int i) {
|
|
return this.simpleSelectors.get(i);
|
|
}
|
|
|
|
public boolean isEmpty() {
|
|
List<SimpleSelector> list = this.simpleSelectors;
|
|
return list == null || list.isEmpty();
|
|
}
|
|
|
|
public int size() {
|
|
List<SimpleSelector> list = this.simpleSelectors;
|
|
if (list == null) {
|
|
return 0;
|
|
}
|
|
return list.size();
|
|
}
|
|
|
|
public String toString() {
|
|
StringBuilder sb = new StringBuilder();
|
|
Iterator<SimpleSelector> it2 = this.simpleSelectors.iterator();
|
|
while (it2.hasNext()) {
|
|
sb.append(it2.next());
|
|
sb.append(' ');
|
|
}
|
|
sb.append(AbstractJsonLexerKt.BEGIN_LIST);
|
|
return ErrorUtils$$ExternalSyntheticOutline0.m(sb, this.specificity, AbstractJsonLexerKt.END_LIST);
|
|
}
|
|
|
|
public /* synthetic */ Selector(AnonymousClass1 anonymousClass1) {
|
|
this();
|
|
}
|
|
}
|
|
|
|
public CSSParser(Source source) {
|
|
this(MediaType.screen, source);
|
|
}
|
|
|
|
public CSSParser() {
|
|
this(MediaType.screen, Source.Document);
|
|
}
|
|
|
|
public static boolean mediaMatches(String str, MediaType mediaType) {
|
|
CSSTextScanner cSSTextScanner = new CSSTextScanner(str);
|
|
cSSTextScanner.skipWhitespace();
|
|
return mediaMatches(parseMediaList(cSSTextScanner), mediaType);
|
|
}
|
|
|
|
public static boolean ruleMatch(RuleMatchContext ruleMatchContext, Selector selector, SVG.SvgElementBase svgElementBase) {
|
|
ArrayList arrayList = new ArrayList();
|
|
for (Object obj = svgElementBase.parent; obj != null; obj = ((SVG.SvgObject) obj).parent) {
|
|
arrayList.add(0, obj);
|
|
}
|
|
int size = arrayList.size() - 1;
|
|
if (selector.size() == 1) {
|
|
return selectorMatch(ruleMatchContext, selector.get(0), arrayList, size, svgElementBase);
|
|
}
|
|
return ruleMatch(ruleMatchContext, selector, selector.size() - 1, arrayList, size, svgElementBase);
|
|
}
|
|
}
|