Skip to content

Commit d014fcc

Browse files
AlinaVarkkiDevtools-frontend LUCI CQ
authored andcommitted
[RPP] Fix Entries Link not updating position in the Network Track
The number of levels in the network track changes and it caused the annotated entries to be considered not existant in the method updating the annotation position. It caused the positioning method to exit early. Instead, check if the entry is visible before quering the entry parameters and if it is not visible, draw the arrow to the coordinate returned by `yCoordinateForNotVisibleEntry`. Bug: 378174655 Change-Id: I5575a4b343fcec275fce68f0d55371ed66e7c891 Reviewed-on: https://chromium-review.googlesource.com/c/devtools/devtools-frontend/+/6079113 Commit-Queue: Alina Varkki <[email protected]> Reviewed-by: Jack Franklin <[email protected]> Auto-Submit: Alina Varkki <[email protected]>
1 parent 83f8803 commit d014fcc

File tree

2 files changed

+54
-51
lines changed

2 files changed

+54
-51
lines changed

front_end/panels/timeline/overlays/OverlaysImpl.ts

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1024,77 +1024,79 @@ export class Overlays extends EventTarget {
10241024
return;
10251025
}
10261026

1027-
const fromEntryParams = this.#positionEntryBorderOutlineType(entriesToConnect.entryFrom, entryFromWrapper);
1028-
1029-
if (!fromEntryParams) {
1030-
// Something went wrong, we should always have parameters for the 'from' entry
1031-
return;
1032-
}
1033-
1034-
const {
1035-
entryHeight: fromEntryHeight,
1036-
entryWidth: fromEntryWidth,
1037-
cutOffHeight: fromCutOffHeight = 0,
1038-
x: fromEntryX,
1039-
y: fromEntryY,
1040-
} = fromEntryParams;
1041-
10421027
const entryFromVisibility = this.entryIsVisibleOnChart(entryFrom) && !fromEntryInCollapsedTrack;
10431028
const entryToVisibility = entryTo ? this.entryIsVisibleOnChart(entryTo) && !toEntryInCollapsedTrack : false;
10441029

1030+
// If the entry is not currently visible, draw the arrow to the edge of the screen towards the entry on the Y-axis.
1031+
let fromEntryX = 0;
1032+
let fromEntryY = this.#yCoordinateForNotVisibleEntry(entryFrom);
1033+
1034+
// If the entry is visible, draw the arrow to the entry.
1035+
if (entryFromVisibility) {
1036+
const fromEntryParams = this.#positionEntryBorderOutlineType(entriesToConnect.entryFrom, entryFromWrapper);
1037+
if (fromEntryParams) {
1038+
const fromEntryHeight = fromEntryParams?.entryHeight;
1039+
const fromEntryWidth = fromEntryParams?.entryWidth;
1040+
const fromCutOffHeight = fromEntryParams?.cutOffHeight;
1041+
fromEntryX = fromEntryParams?.x;
1042+
fromEntryY = fromEntryParams?.y;
1043+
1044+
component.fromEntryCoordinateAndDimentions =
1045+
{x: fromEntryX, y: fromEntryY, length: fromEntryWidth, height: fromEntryHeight - fromCutOffHeight};
1046+
} else {
1047+
// Something went if the entry is visible and we cannot get its' parameters.
1048+
return;
1049+
}
1050+
}
1051+
10451052
// If `fromEntry` is not visible and the link creation is not started yet, meaning that
10461053
// only the button to create the link is displayed, delete the whole overlay.
10471054
if (!entryFromVisibility && overlay.state === Trace.Types.File.EntriesLinkState.CREATION_NOT_STARTED) {
10481055
this.dispatchEvent(new AnnotationOverlayActionEvent(overlay, 'Remove'));
10491056
}
10501057

1051-
// If the 'from' entry is visible, set the entry Y as an arrow start coordinate. Ff not, get the canvas edge coordinate to for the arrow to start from.
1052-
const yPixelForFromArrow =
1053-
(entryFromVisibility ? fromEntryY : this.#yCoordinateForNotVisibleEntry(entryFrom)) ?? 0;
1054-
component.fromEntryIsSource = entryFromIsSource;
1055-
component.toEntryIsSource = entryToIsSource;
1056-
1057-
component.entriesVisibility = {
1058-
fromEntryVisibility: entryFromVisibility,
1059-
toEntryVisibility: entryToVisibility,
1060-
};
1061-
1062-
component.fromEntryCoordinateAndDimentions =
1063-
{x: fromEntryX, y: yPixelForFromArrow, length: fromEntryWidth, height: fromEntryHeight - fromCutOffHeight};
1064-
10651058
// If entryTo exists, pass the coordinates and dimentions of the entry that the arrow snaps to.
10661059
// If it does not, the event tracking mouse coordinates updates 'to coordinates' so the arrow follows the mouse instead.
10671060
const entryToWrapper = component.entryToWrapper();
10681061

10691062
if (entryTo && entryToWrapper) {
1070-
const toEntryParams = this.#positionEntryBorderOutlineType(entryTo, entryToWrapper);
1071-
1072-
if (!toEntryParams) {
1073-
// Something went wrong, we should have those parameters if 'to' entry exists
1074-
return;
1063+
let toEntryX = 0;
1064+
// If the 'to' entry is visible, set the entry Y as an arrow coordinate to point to. If not, get the canvas edge coordate to point the arrow to.
1065+
let toEntryY = this.#yCoordinateForNotVisibleEntry(entryTo);
1066+
1067+
if (entryToVisibility) {
1068+
const toEntryParams = this.#positionEntryBorderOutlineType(entryTo, entryToWrapper);
1069+
1070+
if (toEntryParams) {
1071+
const toEntryHeight = toEntryParams?.entryHeight;
1072+
const toEntryWidth = toEntryParams?.entryWidth;
1073+
const toCutOffHeight = toEntryParams?.cutOffHeight;
1074+
toEntryX = toEntryParams?.x;
1075+
toEntryY = toEntryParams?.y;
1076+
1077+
component.toEntryCoordinateAndDimentions = {
1078+
x: toEntryX,
1079+
y: toEntryY,
1080+
length: toEntryWidth,
1081+
height: toEntryHeight - toCutOffHeight,
1082+
};
1083+
} else {
1084+
// Something went if the entry is visible and we cannot get its' parameters.
1085+
return;
1086+
}
10751087
}
1076-
const {
1077-
entryHeight: toEntryHeight,
1078-
entryWidth: toEntryWidth,
1079-
cutOffHeight: toCutOffHeight = 0,
1080-
x: toEntryX,
1081-
y: toEntryY,
1082-
} = toEntryParams;
10831088

1084-
// If the 'to' entry is visible, set the entry Y as an arrow coordinate to point to. If not, get the canvas edge coordate to point the arrow to.
1085-
const yPixelForToArrow =
1086-
this.entryIsVisibleOnChart(entryTo) ? toEntryY : this.#yCoordinateForNotVisibleEntry(entryTo) ?? 0;
1087-
1088-
component.toEntryCoordinateAndDimentions = {
1089-
x: toEntryX,
1090-
y: yPixelForToArrow,
1091-
length: toEntryWidth,
1092-
height: toEntryHeight - toCutOffHeight,
1093-
};
10941089
} else if (this.#lastMouseOffsetX && this.#lastMouseOffsetY) {
10951090
// The second coordinate for in progress link gets updated on mousemove
10961091
this.#entriesLinkInProgress = overlay;
10971092
}
1093+
1094+
component.fromEntryIsSource = entryFromIsSource;
1095+
component.toEntryIsSource = entryToIsSource;
1096+
component.entriesVisibility = {
1097+
fromEntryVisibility: entryFromVisibility,
1098+
toEntryVisibility: entryToVisibility,
1099+
};
10981100
}
10991101
}
11001102

front_end/panels/timeline/overlays/components/EntriesLinkOverlay.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,7 @@ export class EntriesLinkOverlay extends HTMLElement {
120120
set entriesVisibility(entriesVisibility: {fromEntryVisibility: boolean, toEntryVisibility: boolean}) {
121121
this.#entryFromVisible = entriesVisibility.fromEntryVisibility;
122122
this.#entryToVisible = entriesVisibility.toEntryVisibility;
123+
this.#redrawConnectionArrow();
123124
}
124125

125126
// The arrow might be pointing either to an entry or an empty space.

0 commit comments

Comments
 (0)