[turbolizer] Fix bug in source position injection
Change-Id: If8faa3c7c0324fc9d0a2704533278828c62d5b91 Notry: true Bug: v8:8128, v8:7327 Reviewed-on: https://chromium-review.googlesource.com/c/1319765 Reviewed-by: Georg Neis <neis@chromium.org> Reviewed-by: Sigurd Schneider <sigurds@chromium.org> Commit-Queue: Sigurd Schneider <sigurds@chromium.org> Cr-Commit-Position: refs/heads/master@{#57286}
This commit is contained in:
parent
201a0c67b8
commit
5d83fdc030
@ -2,11 +2,11 @@
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import {Source,SourceResolver,sourcePositionToStringKey} from "../src/source-resolver"
|
||||
import {SelectionBroker} from "../src/selection-broker"
|
||||
import {View} from "../src/view"
|
||||
import {MySelection} from "../src/selection"
|
||||
import {anyToString,ViewElements} from "../src/util"
|
||||
import { Source, SourceResolver, sourcePositionToStringKey } from "../src/source-resolver"
|
||||
import { SelectionBroker } from "../src/selection-broker"
|
||||
import { View } from "../src/view"
|
||||
import { MySelection } from "../src/selection"
|
||||
import { anyToString, ViewElements } from "../src/util"
|
||||
|
||||
export enum CodeMode {
|
||||
MAIN_SOURCE = "main function",
|
||||
@ -220,10 +220,13 @@ export class CodeView extends View {
|
||||
insertSourcePositions(currentSpan, lineNumber, pos, end, adjust) {
|
||||
const view = this;
|
||||
const sps = this.sourceResolver.sourcePositionsInRange(this.source.sourceId, pos - adjust, end);
|
||||
let offset = 0;
|
||||
for (const sourcePosition of sps) {
|
||||
this.sourceResolver.addAnyPositionToLine(lineNumber, sourcePosition);
|
||||
const textnode = currentSpan.tagName == 'SPAN' ? currentSpan.firstChild : currentSpan;
|
||||
const replacementNode = textnode.splitText(Math.max(0, sourcePosition.scriptOffset - pos));
|
||||
const textnode = currentSpan.tagName == 'SPAN' ? currentSpan.lastChild : currentSpan;
|
||||
const splitLength = Math.max(0, sourcePosition.scriptOffset - pos - offset);
|
||||
offset += splitLength;
|
||||
const replacementNode = textnode.splitText(splitLength);
|
||||
const span = document.createElement('span');
|
||||
span.setAttribute("scriptOffset", sourcePosition.scriptOffset);
|
||||
span.classList.add("source-position")
|
||||
|
Loading…
Reference in New Issue
Block a user