def expand_mask_border(tokens, name, base_url):
    """Expand the ``mask-border-*`` shorthand properties.

    See https://drafts.fxtf.org/css-masking/#the-mask-border

    """
    tokens = list(tokens)
    while tokens:
        if border_image_source(tokens[:1], base_url):
            yield '-source', [tokens.pop(0)]
        elif mask_border_mode(tokens[:1]):
            yield '-mode', [tokens.pop(0)]
        elif border_image_repeat(tokens[:1]):
            repeats = [tokens.pop(0)]
            while tokens and border_image_repeat(tokens[:1]):
                repeats.append(tokens.pop(0))
            yield '-repeat', repeats
        elif border_image_slice(tokens[:1]) or get_keyword(tokens[0]) == 'fill':
            slices = [tokens.pop(0)]
            while tokens and border_image_slice(slices + tokens[:1]):
                slices.append(tokens.pop(0))
            yield '-slice', slices
            if tokens and tokens[0].type == 'literal' and tokens[0].value == '/':
                # slices / *
                tokens.pop(0)
            else:
                # slices other
                continue
            if not tokens:
                # slices /
                raise InvalidValues
            if border_image_width(tokens[:1]):
                widths = [tokens.pop(0)]
                while tokens and border_image_width(widths + tokens[:1]):
                    widths.append(tokens.pop(0))
                yield '-width', widths
                if tokens and tokens[0].type == 'literal' and tokens[0].value == '/':
                    # slices / widths / slash *
                    tokens.pop(0)
                else:
                    # slices / widths other
                    continue
            elif tokens and tokens[0].type == 'literal' and tokens[0].value == '/':
                # slices / / *
                tokens.pop(0)
            else:
                # slices / other
                raise InvalidValues
            if not tokens:
                # slices / * /
                raise InvalidValues
            if border_image_outset(tokens[:1]):
                outsets = [tokens.pop(0)]
                while tokens and border_image_outset(outsets + tokens[:1]):
                    outsets.append(tokens.pop(0))
                yield '-outset', outsets
            else:
                # slash / * / other
                raise InvalidValues
        else:
            raise InvalidValues
Expand the ``mask-border-*`` shorthand properties.

See https://drafts.fxtf.org/css-masking/#the-mask-border
weasyprint/css/validation/expanders.py