-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Use layout to improve handling of interposed elements (#1464)
* Add failing test * Add initial implementation of automatically answering interposed question when we have layout * Add test of ignored-interposed-elements question behavior when layout is available * Remove comments * Add helper function for getting bounding box of element for a specific device * Extract ignored interposed answer logic to function * Add changesets * Fix changeset * Extract API * Address review comments * Refactor for reuse and readability * Remove redundant test * Add optional context parameter to * Add changeset * Extract API * Fix typo Co-authored-by: Jean-Yves Moyen <[email protected]> * Fix typo Co-authored-by: Jean-Yves Moyen <[email protected]> * Remove redundant comment Co-authored-by: Jean-Yves Moyen <[email protected]> --------- Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: Jean-Yves Moyen <[email protected]>
- Loading branch information
1 parent
10da6ba
commit 9f74d99
Showing
12 changed files
with
149 additions
and
6 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"@siteimprove/alfa-rules": minor | ||
--- | ||
|
||
**Changed:** Color contrast rules, currently SIA-R66 and SIA-R69, can now tell which interposed elements can be ignored if layout is available. | ||
|
||
If layout is not available the rules keep the current behavior of asking a `ignored-interposed-elements` question. |
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,5 @@ | ||
--- | ||
"@siteimprove/alfa-selector": minor | ||
--- | ||
|
||
**Added:** A function `isEmpty` to `Context` class |
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,7 @@ | ||
--- | ||
"@siteimprove/alfa-style": minor | ||
--- | ||
|
||
**Added:** A function for getting the bounding box of an element given a device. | ||
|
||
This should be the only way of accessing an elements bounding box and prepares us for having device dependent boxes. |
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
25 changes: 25 additions & 0 deletions
25
packages/alfa-style/src/element/helpers/get-bounding-box.ts
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,25 @@ | ||
import { Device } from "@siteimprove/alfa-device"; | ||
import { Element } from "@siteimprove/alfa-dom"; | ||
import { None, Option } from "@siteimprove/alfa-option"; | ||
import { Rectangle } from "@siteimprove/alfa-rectangle"; | ||
import { Context } from "@siteimprove/alfa-selector"; | ||
|
||
/** | ||
* @public | ||
* Gets the bounding box, corresponding to a specific device, of an element | ||
* | ||
* @privateRemarks | ||
* We don't use the passed in device yet, but later we should use it to ensure the device used to collect the bounding box corresponds to the current device | ||
*/ | ||
export function getBoundingBox( | ||
element: Element, | ||
device: Device, | ||
context: Context = Context.empty() | ||
): Option<Rectangle> { | ||
// We assume layout is only grabbed on empty contexts, so if the context is non-empty we don't have layout | ||
if (!context.isEmpty()) { | ||
return None; | ||
} | ||
|
||
return element.box; | ||
} |
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