<commit_before>module minerva.controls.border.arrange {
    export interface IInput extends core.arrange.IInput {
        padding: Thickness;
        borderThickness: Thickness;
    }
    export interface IState extends core.arrange.IState {
        totalBorder: Thickness;
        childRect: Rect;
    }
    export interface IOutput extends core.arrange.IOutput {
    }

    export class BorderArrangePipeDef extends core.arrange.ArrangePipeDef {
        constructor () {
            super();
            this.addTapinBefore('doOverride', 'preOverride', preOverride)
                .replaceTapin('doOverride', doOverride);
        }

        createState (): IState {
            var state = <IState>super.createState();
            state.totalBorder = new Thickness();
            state.childRect = new Rect();
            return state;
        }
    }

    export function preOverride (input: IInput, state: IState, output: IOutput, tree: BorderUpdaterTree, finalRect: Rect): boolean {
        if (!tree.subtree)
            return true;
        var tb = state.totalBorder;
        Thickness.copyTo(input.padding, tb);
        Thickness.add(tb, input.borderThickness);

        var cr = state.childRect;
        cr.x = cr.y = 0;
        Size.copyTo(state.finalSize, cr);
        Thickness.shrinkSize(tb, cr);
        return true;
    }

    export function doOverride (input: IInput, state: IState, output: IOutput, tree: BorderUpdaterTree, finalRect: Rect): boolean {
        if (tree.subtree)
            tree.subtree.arrange(state.childRect);
        Size.copyTo(state.finalSize, output.arrangedSize);
        return true;
    }
}<commit_msg>Properly shrinking childRect for a border.<commit_after>module minerva.controls.border.arrange {
    export interface IInput extends core.arrange.IInput {
        padding: Thickness;
        borderThickness: Thickness;
    }
    export interface IState extends core.arrange.IState {
        totalBorder: Thickness;
        childRect: Rect;
    }
    export interface IOutput extends core.arrange.IOutput {
    }

    export class BorderArrangePipeDef extends core.arrange.ArrangePipeDef {
        constructor () {
            super();
            this.addTapinBefore('doOverride', 'preOverride', preOverride)
                .replaceTapin('doOverride', doOverride);
        }

        createState (): IState {
            var state = <IState>super.createState();
            state.totalBorder = new Thickness();
            state.childRect = new Rect();
            return state;
        }
    }

    export function preOverride (input: IInput, state: IState, output: IOutput, tree: BorderUpdaterTree, finalRect: Rect): boolean {
        if (!tree.subtree)
            return true;
        var tb = state.totalBorder;
        Thickness.copyTo(input.padding, tb);
        Thickness.add(tb, input.borderThickness);

        var cr = state.childRect;
        cr.x = cr.y = 0;
        Size.copyTo(state.finalSize, cr);
        Thickness.shrinkRect(tb, cr);
        return true;
    }

    export function doOverride (input: IInput, state: IState, output: IOutput, tree: BorderUpdaterTree, finalRect: Rect): boolean {
        if (tree.subtree)
            tree.subtree.arrange(state.childRect);
        Size.copyTo(state.finalSize, output.arrangedSize);
        return true;
    }
}
{'fraction_non_alphanumeric': 0.09834586466165414, 'fraction_numerical': 0.0006015037593984962, 'mean_word_length': 2.342713567839196, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5995199', 'n_tokens_mistral': 974, 'n_tokens_neox': 935, 'n_words': 221}