<commit_before>SWF.embed = function(file, container, options) {
  var canvas = document.createElement('canvas');
  var ctx = canvas.getContext('kanvas-2d');
  var loader = new flash.display.Loader;
  var loaderInfo = loader.contentLoaderInfo;
  var stage = new flash.display.Stage;

  // HACK support of HiDPI displays
  var pixelRatio = 'devicePixelRatio' in window ? window.devicePixelRatio : 1;
  if (pixelRatio > 1) {
    var cssScale = 'scale(' + (1/pixelRatio) + ', ' + (1/pixelRatio) + ')';
    canvas.setAttribute('style', '-moz-transform: ' + cssScale + ';' +
                                 '-webkit-transform: ' + cssScale + ';' +
                                 'transform: ' + cssScale + ';' +
                                 '-moz-transform-origin: 0% 0%;' +
                                 '-webkit-transform-origin: 0% 0%;' +
                                 'transform-origin: 0% 0%;');
  }

  loader._stage = stage;
  stage._loader = loader;

  function fitCanvas(container, canvas) {
    canvas.width = container.clientWidth * pixelRatio;
    canvas.height = container.clientHeight * pixelRatio;
  }

  loaderInfo.addEventListener('init', function () {
    stage._frameRate = loaderInfo._frameRate;
    stage._loaderInfo = loaderInfo;
    stage._stageHeight = loaderInfo._height;
    stage._stageWidth = loaderInfo._width;

    if (container.clientHeight) {
      fitCanvas(container, canvas);
      window.addEventListener('resize', function () {
        fitCanvas.bind(container, canvas);
      });
    } else {
      canvas.width = stage._stageWidth * pixelRatio;
      canvas.height = stage._stageHeight * pixelRatio;
    }

    container.setAttribute("style", "position: relative; overflow:hidden;");

    canvas.addEventListener('click', function () {
      ShumwayKeyboardListener.focus = stage;

      if (stage._clickTarget)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('click'));
    });
    canvas.addEventListener('dblclick', function () {
      if (stage._clickTarget && stage._clickTarget._doubleClickEnabled)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('doubleClick'));
    });
    canvas.addEventListener('mousedown', function () {
      if (stage._clickTarget)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('mouseDown'));
    });
    canvas.addEventListener('mousemove', function (domEvt) {
      var node = this;
      var left = 0;
      var top = 0;
      if (node.offsetParent) {
        do {
          left += node.offsetLeft;
          top += node.offsetTop;
        } while (node = node.offsetParent);
      }

      stage._mouseX = domEvt.pageX - left;
      stage._mouseY = domEvt.pageY - top;
    });
    canvas.addEventListener('mouseup', function () {
      if (stage._clickTarget)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('mouseUp'));
    });

    var bgcolor = loaderInfo._backgroundColor;
    stage._color = bgcolor;
    canvas.style.background = toStringRgba(bgcolor);

    var root = loader._content;
    stage._children[0] = root;
    stage._control.appendChild(root._control);

    container.appendChild(canvas);
    renderStage(stage, ctx);
  });

  if (options.onComplete) {
    loaderInfo.addEventListener("complete", function () {
      options.onComplete();
    });
  }

  loader._loadFrom(file);
};
<commit_msg>Fixes alignment for HiDPI display/hack<commit_after>SWF.embed = function(file, container, options) {
  var canvas = document.createElement('canvas');
  var ctx = canvas.getContext('kanvas-2d');
  var loader = new flash.display.Loader;
  var loaderInfo = loader.contentLoaderInfo;
  var stage = new flash.display.Stage;

  // HACK support of HiDPI displays
  var pixelRatio = 'devicePixelRatio' in window ? window.devicePixelRatio : 1;
  var canvasHolder = null;
  if (pixelRatio > 1) {
    var cssScale = 'scale(' + (1/pixelRatio) + ', ' + (1/pixelRatio) + ')';
    canvas.setAttribute('style', '-moz-transform: ' + cssScale + ';' +
                                 '-webkit-transform: ' + cssScale + ';' +
                                 'transform: ' + cssScale + ';' +
                                 '-moz-transform-origin: 0% 0%;' +
                                 '-webkit-transform-origin: 0% 0%;' +
                                 'transform-origin: 0% 0%;');
    canvasHolder = document.createElement('div');
    canvasHolder.setAttribute('style', 'display: inline-block; overflow: hidden;');
    canvasHolder.appendChild(canvas);
  }

  loader._stage = stage;
  stage._loader = loader;

  function fitCanvas(container, canvas) {
    if (canvasHolder) {
      canvasHolder.style.width = container.clientWidth + 'px';
      canvasHolder.style.height = container.clientHeight + 'px';
    }
    canvas.width = container.clientWidth * pixelRatio;
    canvas.height = container.clientHeight * pixelRatio;
  }

  loaderInfo.addEventListener('init', function () {
    stage._frameRate = loaderInfo._frameRate;
    stage._loaderInfo = loaderInfo;
    stage._stageHeight = loaderInfo._height;
    stage._stageWidth = loaderInfo._width;

    if (container.clientHeight) {
      fitCanvas(container, canvas);
      window.addEventListener('resize', function () {
        fitCanvas.bind(container, canvas);
      });
    } else {
      if (canvasHolder) {
        canvasHolder.style.width = stage._stageWidth + 'px';
        canvasHolder.style.height = stage._stageHeight + 'px';
      }
      canvas.width = stage._stageWidth * pixelRatio;
      canvas.height = stage._stageHeight * pixelRatio;
    }

    container.setAttribute("style", "position: relative;");

    canvas.addEventListener('click', function () {
      ShumwayKeyboardListener.focus = stage;

      if (stage._clickTarget)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('click'));
    });
    canvas.addEventListener('dblclick', function () {
      if (stage._clickTarget && stage._clickTarget._doubleClickEnabled)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('doubleClick'));
    });
    canvas.addEventListener('mousedown', function () {
      if (stage._clickTarget)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('mouseDown'));
    });
    canvas.addEventListener('mousemove', function (domEvt) {
      var node = this;
      var left = 0;
      var top = 0;
      if (node.offsetParent) {
        do {
          left += node.offsetLeft;
          top += node.offsetTop;
        } while (node = node.offsetParent);
      }

      stage._mouseX = domEvt.pageX - left;
      stage._mouseY = domEvt.pageY - top;
    });
    canvas.addEventListener('mouseup', function () {
      if (stage._clickTarget)
        stage._clickTarget.dispatchEvent(new flash.events.MouseEvent('mouseUp'));
    });

    var bgcolor = loaderInfo._backgroundColor;
    stage._color = bgcolor;
    canvas.style.background = toStringRgba(bgcolor);

    var root = loader._content;
    stage._children[0] = root;
    stage._control.appendChild(root._control);

    container.appendChild(canvasHolder || canvas);
    renderStage(stage, ctx);
  });

  if (options.onComplete) {
    loaderInfo.addEventListener("complete", function () {
      options.onComplete();
    });
  }

  loader._loadFrom(file);
};

{'fraction_non_alphanumeric': 0.13194349197640928, 'fraction_numerical': 0.0038403511178164863, 'mean_word_length': 2.751028806584362, 'pattern_counts': {'":': 0, '<': 3, '<?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': 10, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2799709', 'n_tokens_mistral': 2061, 'n_tokens_neox': 2017, 'n_words': 383}