private static void CompileTextOutline(StylePropertyReader reader, out Color outlineColor, out float outlineWidth) { outlineColor = Color.clear; outlineWidth = 0.0f; var valueCount = reader.valueCount; for (int i = 0; i < valueCount; i++) { var valueType = reader.GetValueType(i); if (valueType == StyleValueType.Dimension) { outlineWidth = reader.ReadFloat(i); } else if (valueType == StyleValueType.Enum || valueType == StyleValueType.Color) { outlineColor = reader.ReadColor(i); } } }
private static bool CompileFlexShorthand(StylePropertyReader reader, out float grow, out float shrink, out Length basis) { grow = 0f; shrink = 1f; basis = Length.Auto(); bool valid = false; var valueCount = reader.valueCount; if (valueCount == 1 && reader.IsValueType(0, StyleValueType.Keyword)) { // Handle none | auto if (reader.IsKeyword(0, StyleValueKeyword.None)) { valid = true; grow = 0f; shrink = 0f; basis = Length.Auto(); } else if (reader.IsKeyword(0, StyleValueKeyword.Auto)) { valid = true; grow = 1f; shrink = 1f; basis = Length.Auto(); } } else if (valueCount <= 3) { // Handle [ <'flex-grow'> <'flex-shrink'>? || <'flex-basis'> ] valid = true; grow = 0f; shrink = 1f; basis = Length.Percent(0); bool growFound = false; bool basisFound = false; for (int i = 0; i < valueCount && valid; i++) { var valueType = reader.GetValueType(i); if (valueType == StyleValueType.Dimension || valueType == StyleValueType.Keyword) { // Basis if (basisFound) { valid = false; break; } basisFound = true; if (valueType == StyleValueType.Keyword) { if (reader.IsKeyword(i, StyleValueKeyword.Auto)) { basis = Length.Auto(); } } else if (valueType == StyleValueType.Dimension) { basis = reader.ReadLength(i); } if (growFound && i != valueCount - 1) { // If grow is already processed basis must be the last value valid = false; } } else if (valueType == StyleValueType.Float) { var value = reader.ReadFloat(i); if (!growFound) { growFound = true; grow = value; } else { shrink = value; } } else { valid = false; } } } return(valid); }