<commit_before>import hammerhead from '../../deps/hammerhead';
import testCafeCore from '../../deps/testcafe-core';

var browserUtils = hammerhead.utils.browser;

var domUtils        = testCafeCore.domUtils;
var positionUtils   = testCafeCore.positionUtils;
var styleUtils      = testCafeCore.styleUtils;
var contentEditable = testCafeCore.contentEditable;
var arrayUtils      = testCafeCore.arrayUtils;


const MODIFIERS_LIST = ['direction', 'font-family', 'font-size', 'font-size-adjust', 'font-variant', 'font-weight', 'font-style', 'letter-spacing', 'line-height', 'text-align', 'text-indent', 'text-transform', 'word-wrap', 'word-spacing', 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'border-top-width', 'border-left-width', 'border-right-width', 'border-bottom-width'];

function ensureRectangleInsideElement (element, rect) {
    var elementBorders = styleUtils.getBordersWidth(element);
    var elementOffset  = positionUtils.getOffsetPosition(element);

    // NOTE: strange behavior in Chrome - for some elements (e.g., for the 'font' element)
    // scrollHeight is 0, so we use getBoundingClientRect
    var elementHeight = element.scrollHeight || element.getBoundingClientRect().height;
    var left          = Math.ceil(rect.left);
    var top           = Math.ceil(rect.top);
    var bottom        = Math.floor(rect.bottom);

    if (!domUtils.isTextAreaElement(element)) {
        var clientOffset = positionUtils.offsetToClientCoords({
            x: elementOffset.left,
            y: elementOffset.top
        });

        var minLeft     = clientOffset.x + elementBorders.left + 1;
        var minTop      = clientOffset.y + elementBorders.top + 1;
        var bottomBound = clientOffset.y + elementBorders.top + elementBorders.bottom + elementHeight;
        var maxBottom   = rect.top + elementHeight - 1;

        left   = Math.ceil(left <= clientOffset.x ? minLeft : rect.left);
        top    = Math.ceil(top <= clientOffset.y ? minTop : rect.top);
        bottom = Math.floor(bottom >= bottomBound ? maxBottom : rect.bottom);
    }

    return {
        left:   left,
        top:    top,
        bottom: bottom
    };
}

function getAbsoluteRect (rect) {<commit_msg>fix functional test in MSEdge (#797)<commit_after>import hammerhead from '../../deps/hammerhead';
import testCafeCore from '../../deps/testcafe-core';

var browserUtils = hammerhead.utils.browser;

var domUtils        = testCafeCore.domUtils;
var positionUtils   = testCafeCore.positionUtils;
var styleUtils      = testCafeCore.styleUtils;
var contentEditable = testCafeCore.contentEditable;
var arrayUtils      = testCafeCore.arrayUtils;


const MODIFIERS_LIST = ['direction', 'font-family', 'font-size', 'font-size-adjust', 'font-variant', 'font-weight', 'font-style', 'letter-spacing', 'line-height', 'text-align', 'text-indent', 'text-transform', 'word-wrap', 'word-spacing', 'padding-top', 'padding-left', 'padding-right', 'padding-bottom', 'margin-top', 'margin-left', 'margin-right', 'margin-bottom', 'border-top-width', 'border-left-width', 'border-right-width', 'border-bottom-width'];

function ensureRectangleInsideElement (element, rect) {
    var elementBorders = styleUtils.getBordersWidth(element);
    var elementOffset  = positionUtils.getOffsetPosition(element);

    // NOTE: strange behavior in Chrome - for some elements (e.g., for the 'font' element)
    // scrollHeight is 0, so we use getBoundingClientRect
    var elementHeight = element.scrollHeight || element.getBoundingClientRect().height;
    var left          = Math.ceil(rect.left);
    var top           = Math.ceil(rect.top);
    var bottom        = Math.floor(rect.bottom);

    if (!domUtils.isTextAreaElement(element)) {
        var clientOffset = positionUtils.offsetToClientCoords({
            x: elementOffset.left,
            y: elementOffset.top
        });

        var minLeft     = clientOffset.x + elementBorders.left + 1;
        var minTop      = clientOffset.y + elementBorders.top + 1;
        var bottomBound = clientOffset.y + elementBorders.top + elementBorders.bottom + elementHeight;
        var maxBottom   = clientOffset.y + elementBorders.top + elementHeight - 1;

        left   = Math.ceil(left <= clientOffset.x ? minLeft : rect.left);
        top    = Math.ceil(top <= clientOffset.y ? minTop : rect.top);
        bottom = Math.floor(bottom >= bottomBound ? maxBottom : rect.bottom);
    }

    return {
        left:   left,
        top:    top,
        bottom: bottom
    };
}

function getAbsoluteRect (rect) {
{'fraction_non_alphanumeric': 0.13053866203301476, 'fraction_numerical': 0.0023892267593397048, 'mean_word_length': 3.236430542778289, 'pattern_counts': {'":': 0, '<': 7, '<?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': '1452131', 'n_tokens_mistral': 1377, 'n_tokens_neox': 1338, 'n_words': 310}