Skip to content

Commit 6a26aa6

Browse files
committed
Added fix in getCellFromPoint in create-grid.js for 200% zoom
1 parent 6950c10 commit 6a26aa6

File tree

5 files changed

+22
-4
lines changed

5 files changed

+22
-4
lines changed

lib/commons/dom/create-grid.js

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ export default function createGrid(
2727
) {
2828
// Prevent multiple calls per run
2929
if (cache.get('gridCreated') && !parentVNode) {
30+
// a11y-engine-domforge change
3031
if (cache.get('gridSize')) {
3132
return cache.get('gridSize');
3233
}
@@ -114,6 +115,7 @@ export default function createGrid(
114115
node = treeWalker.nextNode();
115116
}
116117

118+
// a11y-engine-domforge change
117119
if (cache.get('gridSize')) {
118120
return cache.get('gridSize');
119121
}
@@ -437,6 +439,7 @@ class Grid {
437439
* @returns {number}
438440
*/
439441
toGridIndex(num) {
442+
// a11y-engine-domforge change
440443
if (cache.get('gridSize')) {
441444
return Math.floor(num / cache.get('gridSize'));
442445
}
@@ -452,10 +455,18 @@ class Grid {
452455
assert(this.boundaries, 'Grid does not have cells added');
453456
const rowIndex = this.toGridIndex(y);
454457
const colIndex = this.toGridIndex(x);
455-
assert(
456-
isPointInRect({ y: rowIndex, x: colIndex }, this.boundaries),
457-
'Element midpoint exceeds the grid bounds'
458-
);
458+
459+
// a11y-engine-domforge change
460+
if (cache.get('ruleId') === 'zoom-text-overlap-viewport') {
461+
if (!isPointInRect({ y: rowIndex, x: colIndex }, this.boundaries)) {
462+
return [];
463+
}
464+
} else {
465+
assert(
466+
isPointInRect({ y: rowIndex, x: colIndex }, this.boundaries),
467+
'Element midpoint exceeds the grid bounds'
468+
);
469+
}
459470
const row = this.cells[rowIndex - this.cells._negativeIndex] ?? [];
460471
return row[colIndex - row._negativeIndex] ?? [];
461472
}

lib/commons/dom/get-element-stack.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@ import createGrid from './create-grid';
99
* @param {Node} node
1010
* @return {Node[]}
1111
*/
12+
13+
// Additional props isCoordsPassed, x, y for a11y-engine-domforge
1214
function getElementStack(node, isCoordsPassed = false, x = null, y = null) {
1315
createGrid();
1416

@@ -19,6 +21,7 @@ function getElementStack(node, isCoordsPassed = false, x = null, y = null) {
1921
return [];
2022
}
2123

24+
// Additional props isCoordsPassed, x, y for a11y-engine-domforge
2225
return getRectStack(
2326
grid,
2427
vNode.boundingClientRect,

lib/commons/dom/get-overflow-hidden-ancestors.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ const getOverflowHiddenAncestors = memoize(
1818

1919
const overflow = vNode.getComputedStylePropertyValue('overflow');
2020

21+
// a11y-engine-domforge change
2122
if (
2223
cache.get('ruleId') &&
2324
cache.get('ruleId') === 'zoom-text-overlap-viewport'

lib/commons/dom/get-rect-stack.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import visuallySort from './visually-sort';
22
import { getRectCenter } from '../math';
33

4+
// Additional props isCoordsPassed, x, y for a11y-engine-domforge
45
export function getRectStack(
56
grid,
67
rect,
@@ -15,6 +16,7 @@ export function getRectStack(
1516
let floorX = Math.floor(center.x);
1617
let floorY = Math.floor(center.y);
1718

19+
// a11y-engine-domforge change
1820
if (isCoordsPassed) {
1921
floorX = Math.floor(x);
2022
floorY = Math.floor(y);

lib/commons/dom/get-visible-child-text-rects.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ const getVisibleChildTextRects = memoize(
3131
clientRects.push(...filterHiddenRects(contentRects, overflowHiddenNodes));
3232
});
3333

34+
// a11y-engine-domforge change
3435
if (
3536
clientRects.length <= 0 &&
3637
cache.get('ruleId') &&

0 commit comments

Comments
 (0)