<commit_before>class RetainedDebug {
  static void borderElements(stage) {
    var ctx = stage.ctx;
    ctx.save();
    ctx.globalAlpha = 0.5;
    ctx.lineWidth = 5;
    ctx.beginPath();
    _borderElement(ctx, stage.rootElement);
    ctx.stroke();
    ctx.restore();
  }

  static void borderHitTest(Stage stage, core.Coordinate point){
    var ctx = stage.ctx;

    var hits = RetainedUtil.hitTest(stage, point);

    if(hits.length > 0){
      ctx.save();
      ctx.lineWidth = 2;

      ctx.beginPath();

      hits.forEach((e) {
        _borderElement(ctx, e, true);
      });
      ctx.stroke();
      ctx.restore();
    }
  }

  static void _borderElement(CanvasRenderingContext2D ctx, PElement element, [bool excludeChildren = false, core.Predicate<PElement> filter = null]) {
    ctx.save();
    final tx = element.getTransformToRoot();
    CanvasUtil.transform(ctx, tx);

    ctx.lineWidth = 2 / ((tx.scaleX + tx.scaleY) / 2);

    if (filter == null || filter(element)) {
      _borderElementCore(ctx, element);
    }

    if (!excludeChildren) {
      for (var i = 0; i < element.visualChildCount; i++) {
        var e = element.getVisualChild(i);
        ctx.save();
        _borderElement(ctx, e, false, filter);
        ctx.restore();
      }
    }
    ctx.restore();
  }

  static void _borderElementCore(CanvasRenderingContext2D ctx, PElement element) {
    if (Mouse.isMouseDirectlyOver(element)) {
      ctx.strokeStyle = 'red';
    } else if (Mouse.isMouseOver(element)) {
      ctx.strokeStyle = 'pink';
    } else if (element.cacheEnabled) {
      ctx.strokeStyle = 'yellow';
    } else {
      ctx.strokeStyle = 'orange';
    }
    ctx.strokeRect(0, 0, element.width, element.height);
  }
}
<commit_msg>RetainedDebug transforming points instead of the canvas drawing context<commit_after>class RetainedDebug {
  static void borderElements(stage) {
    var ctx = stage.ctx;
    ctx.save();
    ctx.globalAlpha = 0.5;
    ctx.lineWidth = 5;
    ctx.beginPath();
    _borderElement(ctx, stage.rootElement);
    ctx.stroke();
    ctx.restore();
  }

  static void borderHitTest(Stage stage, core.Coordinate point){
    var ctx = stage.ctx;

    var hits = RetainedUtil.hitTest(stage, point);

    if(hits.length > 0){
      ctx.save();
      ctx.lineWidth = 2;

      ctx.beginPath();

      hits.forEach((e) {
        _borderElement(ctx, e, true);
      });
      ctx.stroke();
      ctx.restore();
    }
  }

  static void _borderElement(CanvasRenderingContext2D ctx, PElement element, [bool excludeChildren = false, core.Predicate<PElement> filter = null]) {
    if (filter == null || filter(element)) {
      _borderElementCore(ctx, element);
    }

    if (!excludeChildren) {
      for (var i = 0; i < element.visualChildCount; i++) {
        var e = element.getVisualChild(i);
        _borderElement(ctx, e, false, filter);
      }
    }
  }

  static void _borderElementCore(CanvasRenderingContext2D ctx, PElement element) {
    if (Mouse.isMouseDirectlyOver(element)) {
      ctx.strokeStyle = 'red';
    } else if (Mouse.isMouseOver(element)) {
      ctx.strokeStyle = 'pink';
    } else if (element.cacheEnabled) {
      ctx.strokeStyle = 'yellow';
    } else {
      ctx.strokeStyle = 'orange';
    }

    final corners = RetainedUtil.getCorners(element);

    ctx.moveTo(corners[3].x, corners[3].y);
    for(final p in corners) {
      ctx.lineTo(p.x, p.y);
    }
  }
}

{'fraction_non_alphanumeric': 0.13580246913580246, 'fraction_numerical': 0.006466784244562022, 'mean_word_length': 2.7354555433589463, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 7, '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': '6591041', 'n_tokens_mistral': 1123, 'n_tokens_neox': 1082, 'n_words': 237}