Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions packages/cli/src/commands/layout-audit.browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -2318,6 +2318,13 @@
return false;
}

// A shadow layer draws the glyph shapes in its own colour, so a visible one
// keeps transparent-fill text legible.
function textShadowPaints(textShadow) {
if (!textShadow || textShadow === "none") return false;
return splitTopLevelCommas(textShadow).some((layer) => colorAlpha(layer) > 0.05);
}

// Text whose glyphs paint with an effectively transparent fill renders
// invisibly even though the element, its box, opacity and color all read as
// present — so geometry/occlusion/contrast audits miss it (contrast reads
Expand Down Expand Up @@ -2345,6 +2352,7 @@
colorAlpha(cs.webkitTextStrokeColor) > 0.05
)
return null;
if (textShadowPaints(cs.textShadow)) return null;
const clip = cs.webkitBackgroundClip || cs.backgroundClip || "";
if (/text/i.test(clip)) {
const bgImage = cs.backgroundImage || "none";
Expand Down
20 changes: 20 additions & 0 deletions packages/cli/src/commands/layout-audit.chromium.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -555,6 +555,26 @@ describe.runIf(executablePath)("layout audit in Chromium", () => {
style: "color:transparent;-webkit-text-stroke:0 #fff",
flagged: true,
},
{
name: "shadow text (transparent fill, visible text-shadow)",
style: "color:#000;-webkit-text-fill-color:transparent;text-shadow:0 8px 0 rgb(255,255,255)",
flagged: false,
},
{
name: "transparent text whose second shadow layer is visible",
style: "color:transparent;text-shadow:0 0 4px rgba(0,0,0,0),2px 2px 0 rgba(255,255,255,0.9)",
flagged: false,
},
{
name: "transparent text with an invisible text-shadow",
style: "color:transparent;text-shadow:0 8px 0 rgba(255,255,255,0)",
flagged: true,
},
{
name: "transparent text whose text-shadow takes the transparent color",
style: "color:transparent;text-shadow:0 8px 0",
flagged: true,
},
])("judges $name by what it paints", async ({ style, flagged }) => {
const codes = await auditCodes(`
<div data-composition-id="main" data-width="1920" data-height="1080" style="position:relative;width:1920px;height:1080px;background:#000">
Expand Down
Loading