usercss: don't recalc widget height => spend 0 time in CM
300ms -> 100ms rendering time in updateInvisible() for "RU AdList CSS Fixes" style
This commit is contained in:
parent
05677d93b3
commit
3fd4343cfd
|
@ -169,6 +169,7 @@ function createAppliesToLineWidget(cm) {
|
|||
|
||||
function *createWidgets(start, end, removed) {
|
||||
let i = 0;
|
||||
let itemHeight;
|
||||
for (const section of findAppliesTo(start, end)) {
|
||||
while (removed[i] && removed[i].line.lineNo() < section.pos.line) {
|
||||
clearWidget(removed[i++]);
|
||||
|
@ -182,7 +183,9 @@ function createAppliesToLineWidget(cm) {
|
|||
});
|
||||
removed[i].section = section;
|
||||
const newNode = buildElement(section);
|
||||
if (removed[i].node.parentNode) {
|
||||
removed[i].node.parentNode.replaceChild(newNode, removed[i].node);
|
||||
}
|
||||
removed[i].node = newNode;
|
||||
removed[i].changed();
|
||||
yield removed[i];
|
||||
|
@ -193,9 +196,11 @@ function createAppliesToLineWidget(cm) {
|
|||
const widget = cm.addLineWidget(section.pos.line, buildElement(section), {
|
||||
coverGutter: true,
|
||||
noHScroll: true,
|
||||
above: true
|
||||
above: true,
|
||||
height: itemHeight ? section.applies.length * itemHeight : undefined,
|
||||
});
|
||||
widget.section = section;
|
||||
itemHeight = itemHeight || widget.node.offsetHeight;
|
||||
yield widget;
|
||||
}
|
||||
removed.slice(i).forEach(clearWidget);
|
||||
|
|
Loading…
Reference in New Issue
Block a user