-
Notifications
You must be signed in to change notification settings - Fork 767
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' into improve-ja-translation-20230427-squashed
- Loading branch information
Showing
81 changed files
with
4,083 additions
and
2,215 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import findNearbyElms from './find-nearby-elms'; | ||
import isInTabOrder from './is-in-tab-order'; | ||
import { splitRects, hasVisualOverlap } from '../math'; | ||
import memoize from '../../core/utils/memoize'; | ||
|
||
export default memoize(getTargetRects); | ||
|
||
/** | ||
* Return all unobscured rects of a target. | ||
* @see https://www.w3.org/TR/WCAG22/#dfn-bounding-boxes | ||
* @param {VitualNode} vNode | ||
* @return {DOMRect[]} | ||
*/ | ||
function getTargetRects(vNode) { | ||
const nodeRect = vNode.boundingClientRect; | ||
const overlappingVNodes = findNearbyElms(vNode).filter(vNeighbor => { | ||
return ( | ||
hasVisualOverlap(vNode, vNeighbor) && | ||
vNeighbor.getComputedStylePropertyValue('pointer-events') !== 'none' && | ||
!isDescendantNotInTabOrder(vNode, vNeighbor) | ||
); | ||
}); | ||
|
||
if (!overlappingVNodes.length) { | ||
return [nodeRect]; | ||
} | ||
|
||
const obscuringRects = overlappingVNodes.map( | ||
({ boundingClientRect: rect }) => rect | ||
); | ||
return splitRects(nodeRect, obscuringRects); | ||
} | ||
|
||
function isDescendantNotInTabOrder(vAncestor, vNode) { | ||
return ( | ||
vAncestor.actualNode.contains(vNode.actualNode) && !isInTabOrder(vNode) | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import getTargetRects from './get-target-rects'; | ||
import { rectHasMinimumSize } from '../math'; | ||
import memoize from '../../core/utils/memoize'; | ||
|
||
export default memoize(getTargetSize); | ||
|
||
/** | ||
* Compute the target size of an element. | ||
* @see https://www.w3.org/TR/WCAG22/#dfn-targets | ||
*/ | ||
function getTargetSize(vNode, minSize) { | ||
const rects = getTargetRects(vNode); | ||
return getLargestRect(rects, minSize); | ||
} | ||
|
||
// Find the largest rectangle in the array, prioritize ones that meet a minimum size | ||
function getLargestRect(rects, minSize) { | ||
return rects.reduce((rectA, rectB) => { | ||
const rectAisMinimum = rectHasMinimumSize(minSize, rectA); | ||
const rectBisMinimum = rectHasMinimumSize(minSize, rectB); | ||
// Prioritize rects that pass the minimum | ||
if (rectAisMinimum !== rectBisMinimum) { | ||
return rectAisMinimum ? rectA : rectB; | ||
} | ||
const areaA = rectA.width * rectA.height; | ||
const areaB = rectB.width * rectB.height; | ||
return areaA > areaB ? rectA : rectB; | ||
}); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.