Skip to content

Commit

Permalink
rebase tests
Browse files Browse the repository at this point in the history
  • Loading branch information
tabatkins committed Jan 25, 2024
1 parent 46d79b4 commit 86799f9
Show file tree
Hide file tree
Showing 318 changed files with 7,226 additions and 15,700 deletions.
73 changes: 23 additions & 50 deletions tests/adjacent-boilerplate/adjacent-boilerplate.html
Original file line number Diff line number Diff line change
Expand Up @@ -932,7 +932,7 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N

function positionDfnPanel(dfnPanel) {
const dfn = dfnPanel.dfn;
const dfnPos = getRootLevelAbsolutePosition(dfn);
const dfnPos = getBounds(dfn);
dfnPanel.style.top = dfnPos.bottom + "px";
dfnPanel.style.left = dfnPos.left + "px";

Expand Down Expand Up @@ -1001,32 +1001,19 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N
});
}

// TODO: shared util
// Returns the root-level absolute position {left and top} of element.
function getRootLevelAbsolutePosition(el) {
const boundsRect = el.getBoundingClientRect();
let xPos = 0;
let yPos = 0;

while (el) {
let xScroll = el.scrollLeft;
let yScroll = el.scrollTop;

// Ignore scrolling of body.
if (el.tagName === "BODY") {
xScroll = 0;
yScroll = 0;
}
xPos += (el.offsetLeft - xScroll + el.clientLeft);
yPos += (el.offsetTop - yScroll + el.clientTop);

el = el.offsetParent;
}
function getBounds(el, relativeTo=document.body) {
const relativeRect = relativeTo.getBoundingClientRect();
const elRect = el.getBoundingClientRect();
const top = elRect.top - relativeRect.top;
const left = elRect.left - relativeRect.left;
return {
left: xPos,
top: yPos,
right: xPos + boundsRect.width,
bottom: yPos + boundsRect.height,
};
top,
left,
bottom: top + elRect.height,
right: left + elRect.width,
}
}

function scrollToTargetAndHighlight(event) {
Expand Down Expand Up @@ -1359,7 +1346,7 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N

function positionRefHint(refHint) {
const link = refHint.forLink;
const linkPos = getRootLevelAbsolutePosition(link);
const linkPos = getBounds(link);
refHint.style.top = linkPos.bottom + "px";
refHint.style.left = linkPos.left + "px";

Expand All @@ -1375,31 +1362,17 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N

// TODO: shared util
// Returns the root-level absolute position {left and top} of element.
function getRootLevelAbsolutePosition(el) {
const boundsRect = el.getBoundingClientRect();
let xPos = 0;
let yPos = 0;

while (el) {
let xScroll = el.scrollLeft;
let yScroll = el.scrollTop;

// Ignore scrolling of body.
if (el.tagName === "BODY") {
xScroll = 0;
yScroll = 0;
}
xPos += (el.offsetLeft - xScroll + el.clientLeft);
yPos += (el.offsetTop - yScroll + el.clientTop);

el = el.offsetParent;
}
function getBounds(el, relativeTo=document.body) {
const relativeRect = relativeTo.getBoundingClientRect();
const elRect = el.getBoundingClientRect();
const top = elRect.top - relativeRect.top;
const left = elRect.left - relativeRect.left;
return {
left: xPos,
top: yPos,
right: xPos + boundsRect.width,
bottom: yPos + boundsRect.height,
};
top,
left,
bottom: top + elRect.height,
right: left + elRect.width,
}
}

function showRefHintListener(e) {
Expand Down
37 changes: 12 additions & 25 deletions tests/algorithm001.html
Original file line number Diff line number Diff line change
Expand Up @@ -919,7 +919,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c

function positionDfnPanel(dfnPanel) {
const dfn = dfnPanel.dfn;
const dfnPos = getRootLevelAbsolutePosition(dfn);
const dfnPos = getBounds(dfn);
dfnPanel.style.top = dfnPos.bottom + "px";
dfnPanel.style.left = dfnPos.left + "px";

Expand Down Expand Up @@ -988,32 +988,19 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
});
}

// TODO: shared util
// Returns the root-level absolute position {left and top} of element.
function getRootLevelAbsolutePosition(el) {
const boundsRect = el.getBoundingClientRect();
let xPos = 0;
let yPos = 0;

while (el) {
let xScroll = el.scrollLeft;
let yScroll = el.scrollTop;

// Ignore scrolling of body.
if (el.tagName === "BODY") {
xScroll = 0;
yScroll = 0;
}
xPos += (el.offsetLeft - xScroll + el.clientLeft);
yPos += (el.offsetTop - yScroll + el.clientTop);

el = el.offsetParent;
}
function getBounds(el, relativeTo=document.body) {
const relativeRect = relativeTo.getBoundingClientRect();
const elRect = el.getBoundingClientRect();
const top = elRect.top - relativeRect.top;
const left = elRect.left - relativeRect.left;
return {
left: xPos,
top: yPos,
right: xPos + boundsRect.width,
bottom: yPos + boundsRect.height,
};
top,
left,
bottom: top + elRect.height,
right: left + elRect.width,
}
}

function scrollToTargetAndHighlight(event) {
Expand Down
37 changes: 12 additions & 25 deletions tests/caniuse001.html
Original file line number Diff line number Diff line change
Expand Up @@ -1066,7 +1066,7 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c

function positionDfnPanel(dfnPanel) {
const dfn = dfnPanel.dfn;
const dfnPos = getRootLevelAbsolutePosition(dfn);
const dfnPos = getBounds(dfn);
dfnPanel.style.top = dfnPos.bottom + "px";
dfnPanel.style.left = dfnPos.left + "px";

Expand Down Expand Up @@ -1135,32 +1135,19 @@ <h3 class="no-num no-ref heading settled" id="index-defined-here"><span class="c
});
}

// TODO: shared util
// Returns the root-level absolute position {left and top} of element.
function getRootLevelAbsolutePosition(el) {
const boundsRect = el.getBoundingClientRect();
let xPos = 0;
let yPos = 0;

while (el) {
let xScroll = el.scrollLeft;
let yScroll = el.scrollTop;

// Ignore scrolling of body.
if (el.tagName === "BODY") {
xScroll = 0;
yScroll = 0;
}
xPos += (el.offsetLeft - xScroll + el.clientLeft);
yPos += (el.offsetTop - yScroll + el.clientTop);

el = el.offsetParent;
}
function getBounds(el, relativeTo=document.body) {
const relativeRect = relativeTo.getBoundingClientRect();
const elRect = el.getBoundingClientRect();
const top = elRect.top - relativeRect.top;
const left = elRect.left - relativeRect.left;
return {
left: xPos,
top: yPos,
right: xPos + boundsRect.width,
bottom: yPos + boundsRect.height,
};
top,
left,
bottom: top + elRect.height,
right: left + elRect.width,
}
}

function scrollToTargetAndHighlight(event) {
Expand Down
73 changes: 23 additions & 50 deletions tests/css-production-range001.html
Original file line number Diff line number Diff line change
Expand Up @@ -937,7 +937,7 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N

function positionDfnPanel(dfnPanel) {
const dfn = dfnPanel.dfn;
const dfnPos = getRootLevelAbsolutePosition(dfn);
const dfnPos = getBounds(dfn);
dfnPanel.style.top = dfnPos.bottom + "px";
dfnPanel.style.left = dfnPos.left + "px";

Expand Down Expand Up @@ -1006,32 +1006,19 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N
});
}

// TODO: shared util
// Returns the root-level absolute position {left and top} of element.
function getRootLevelAbsolutePosition(el) {
const boundsRect = el.getBoundingClientRect();
let xPos = 0;
let yPos = 0;

while (el) {
let xScroll = el.scrollLeft;
let yScroll = el.scrollTop;

// Ignore scrolling of body.
if (el.tagName === "BODY") {
xScroll = 0;
yScroll = 0;
}
xPos += (el.offsetLeft - xScroll + el.clientLeft);
yPos += (el.offsetTop - yScroll + el.clientTop);

el = el.offsetParent;
}
function getBounds(el, relativeTo=document.body) {
const relativeRect = relativeTo.getBoundingClientRect();
const elRect = el.getBoundingClientRect();
const top = elRect.top - relativeRect.top;
const left = elRect.left - relativeRect.left;
return {
left: xPos,
top: yPos,
right: xPos + boundsRect.width,
bottom: yPos + boundsRect.height,
};
top,
left,
bottom: top + elRect.height,
right: left + elRect.width,
}
}

function scrollToTargetAndHighlight(event) {
Expand Down Expand Up @@ -1382,7 +1369,7 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N

function positionRefHint(refHint) {
const link = refHint.forLink;
const linkPos = getRootLevelAbsolutePosition(link);
const linkPos = getBounds(link);
refHint.style.top = linkPos.bottom + "px";
refHint.style.left = linkPos.left + "px";

Expand All @@ -1398,31 +1385,17 @@ <h3 class="no-num no-ref heading settled" id="normative"><span class="content">N

// TODO: shared util
// Returns the root-level absolute position {left and top} of element.
function getRootLevelAbsolutePosition(el) {
const boundsRect = el.getBoundingClientRect();
let xPos = 0;
let yPos = 0;

while (el) {
let xScroll = el.scrollLeft;
let yScroll = el.scrollTop;

// Ignore scrolling of body.
if (el.tagName === "BODY") {
xScroll = 0;
yScroll = 0;
}
xPos += (el.offsetLeft - xScroll + el.clientLeft);
yPos += (el.offsetTop - yScroll + el.clientTop);

el = el.offsetParent;
}
function getBounds(el, relativeTo=document.body) {
const relativeRect = relativeTo.getBoundingClientRect();
const elRect = el.getBoundingClientRect();
const top = elRect.top - relativeRect.top;
const left = elRect.left - relativeRect.left;
return {
left: xPos,
top: yPos,
right: xPos + boundsRect.width,
bottom: yPos + boundsRect.height,
};
top,
left,
bottom: top + elRect.height,
right: left + elRect.width,
}
}

function showRefHintListener(e) {
Expand Down
Loading

0 comments on commit 86799f9

Please sign in to comment.