The design language that makes your AI harness better at design.
JavaScript
Round 7 recall and gates: prose divs, label collectors, small text, validity, vendors, paint
Paul Bakausa271cf28ace1
diff --git a/crates/browser/src/validity.rs b/crates/browser/src/validity.rsindex 7912c55ca..c3c101ee4 100644--- a/crates/browser/src/validity.rs+++ b/crates/browser/src/validity.rs@@ -12,6 +12,9 @@//! Header and HTTP-status signals stand alone. Titles and DOM markers only//! count on a small page, because a real page can carry a captcha widget on a//! form or be titled "Access denied" in a CMS without being a block page.+//! A known bot manager's challenge sheet showing over the viewport counts on+//! any page ([`CHALLENGE_OVERLAYS`]): it is laid over a page already rendered+//! behind it.//!//! The probe also names the known consent managers ([`crate::consent`]) whose//! banner is showing, how much visible text sits inside them, and what content@@ -80,14 +83,33 @@ pub const CHALLENGE_MARKERS: &[(&str, &str)] = &[(".geetest_holder, #nc_1_wrapper, #aliyunCaptcha-sliding-wrapper", "slider-captcha"),];+/// Challenge sheets a bot manager lays over the real page it has already+/// rendered, so the page behind is a full page and the small-page gate never+/// applies. Each entry is `(selector, label)`; one counts only while it is+/// showing and covers at least [`CHALLENGE_OVERLAY_MIN_COVER`] of the+/// viewport. HUMAN Security (formerly PerimeterX) serves its "Press & hold"+/// check as `iframe#px-captcha-modal`, fixed over the whole viewport at+/// z-index 2147483647 (target.com, run 28 captures 4166, 4168, 4170, 4172,+/// whose pages load `client.px-cloud.net` as `script#humanSensor`).+pub const CHALLENGE_OVERLAYS: &[(&str, &str)] = &[("#px-captcha-modal, #px-captcha-wrapper", "human-press-and-hold")];++/// The share of the viewport a challenge overlay covers before it stands in+/// front of the page.+pub const CHALLENGE_OVERLAY_MIN_COVER: f64 = 0.5;+/// The in-page probe: title, visible text length, final URL, which-/// challenge markers are present, and which consent managers are showing-/// with the visible text inside them. Read-only; returns a plain object.+/// challenge markers are present, which challenge overlays are showing over+/// the page, and which consent managers are showing with the visible text+/// inside them. Read-only; returns a plain object.pub fn probe_js() -> String {let markers: Vec<Value> = CHALLENGE_MARKERS.iter().map(|(selector, label)| json!([selector, label])).collect();+ let overlays: Vec<Value> = CHALLENGE_OVERLAYS+ .iter()+ .map(|(selector, label)| json!([selector, label]))+ .collect();format!(r#"(() => {{const markers = {markers};@@ -95,6 +117,21 @@ pub fn probe_js() -> String {for (const [selector, label] of markers) {{try {{ if (document.querySelector(selector)) found.push(label); }} catch (e) {{}}}}+ const overlayMarkers = {overlays};+ const overlays = [];+ const vw = window.innerWidth || 0, vh = window.innerHeight || 0;+ for (const [selector, label] of overlayMarkers) {{+ try {{+ for (const el of document.querySelectorAll(selector)) {{+ const cs = getComputedStyle(el);+ if (cs.display === 'none' || cs.visibility === 'hidden' || parseFloat(cs.opacity) <= 0.02) continue;+ const r = el.getBoundingClientRect();+ const w = Math.max(0, Math.min(r.right, vw) - Math.max(r.left, 0));+ const h = Math.max(0, Math.min(r.bottom, vh) - Math.max(r.top, 0));+ if (vw > 0 && vh > 0 && (w * h) / (vw * vh) >= {cover}) {{ overlays.push(label); break; }}+ }}+ }} catch (e) {{}}+ }}{consent}const text = (document.body && document.body.innerText) || '';return {{@@ -102,12 +139,15 @@ pub fn probe_js() -> String {textChars: text.replace(/\s+/g, ' ').trim().length,href: String(location.href || ''),markers: found,+ overlays,consent,consentChars,consentOutside,}};}})()"#,markers = Value::Array(markers),+ overlays = Value::Array(overlays),+ cover = CHALLENGE_OVERLAY_MIN_COVER,consent = crate::consent::probe_fragment(),)}@@ -119,6 +159,8 @@ pub struct PageProbe {pub text_chars: u64,pub href: String,pub markers: Vec<String>,+ /// Challenge overlays ([`CHALLENGE_OVERLAYS`]) showing over the page.+ pub overlays: Vec<String>,/// Known consent managers whose banner was showing, before any was hidden.pub consent: Vec<String>,/// Visible characters inside those managers' roots.@@ -138,6 +180,11 @@ impl PageProbe {.and_then(Value::as_array).map(|a| a.iter().filter_map(Value::as_str).map(String::from).collect()).unwrap_or_default(),+ overlays: v+ .get("overlays")+ .and_then(Value::as_array)+ .map(|a| a.iter().filter_map(Value::as_str).map(String::from).collect())+ .unwrap_or_default(),consent: v.get("consent").and_then(Value::as_array)@@ -149,7 +196,7 @@ impl PageProbe {}pub fn to_value(&self) -> Value {- json!({+ let mut v = json!({"title": self.title,"textChars": self.text_chars,"href": self.href,@@ -157,7 +204,13 @@ impl PageProbe {"consent": self.consent,"consentChars": self.consent_chars,"consentOutside": self.consent_outside,- })+ });+ // Named only when one shows, so a page with none records what it did+ // before overlays were probed.+ if !self.overlays.is_empty() {+ v["overlays"] = json!(self.overlays);+ }+ v}}@@ -303,6 +356,11 @@ pub fn classify_with(response: Option<&DocumentResponse>, probe: &PageProbe, con}}}+ // A challenge sheet over a rendered page blocks it whatever the page+ // behind it holds.+ for o in &probe.overlays {+ challenge.push(format!("overlay {o}"));+ }let small = probe.text_chars <= SMALL_PAGE_CHARS;if small {let title = probe.title.trim().to_lowercase();@@ -520,6 +578,30 @@ mod tests {);}+ #[test]+ fn a_press_and_hold_sheet_over_a_rendered_page_is_a_challenge() {+ // target.com, run 28: HUMAN Security's `iframe#px-captcha-modal` over+ // the home page, 2270 visible characters and no challenge title.+ let mut p = probe("Target : Expect More. Pay Less.", 2270, &[]);+ p.overlays = vec!["human-press-and-hold".into()];+ assert_eq!(+ classify(Some(&resp(200, &[])), &p),+ PageValidity::Blocked {+ kind: BlockKind::Challenge,+ evidence: vec!["overlay human-press-and-hold".into()],+ }+ );+ // On a large page it still stands in front of the site.+ p.text_chars = 40000;+ assert!(classify(Some(&resp(200, &[])), &p).is_blocked());+ // With no sheet showing, the same page is the page.+ p.overlays.clear();+ assert_eq!(classify(Some(&resp(200, &[])), &p), PageValidity::Ok);+ let v = p.to_value();+ assert!(v.get("overlays").is_none(), "{v}");+ assert_eq!(PageProbe::from_value(&v), p);+ }+#[test]fn http_error_without_challenge_signals() {let v = classify(Some(&resp(404, &[])), &probe("Page not found", 400, &[]));@@ -554,7 +636,7 @@ mod tests {#[test]fn probe_js_embeds_every_marker() {let js = probe_js();- for (selector, label) in CHALLENGE_MARKERS {+ for (selector, label) in CHALLENGE_MARKERS.iter().chain(CHALLENGE_OVERLAYS) {assert!(js.contains(label));assert!(js.contains(&selector.replace('\'', "'")));}diff --git a/crates/core/src/browser/driver.rs b/crates/core/src/browser/driver.rsindex 6ae3e56f6..9ff0a10c5 100644--- a/crates/core/src/browser/driver.rs+++ b/crates/core/src/browser/driver.rs@@ -1025,10 +1025,45 @@ fn drop_covered_class_forms(findings: &mut Vec<BrowserFinding>) {}).map(|f| f.type_.clone()).collect();- if computed.is_empty() {+ if !computed.is_empty() {+ findings.retain(|f| !(f.detail.ends_with(CLASS_FORM_SUFFIX) && computed.contains(&f.type_)));+ }+ drop_covered_palette_forms(findings);+}++/// ai-color-palette reports one finding per element and concern. Its class+/// forms (`Purple/violet gradient (Tailwind)`, `text-purple-600 on heading`)+/// name what its computed forms read off the same element, so a computed+/// form speaks for them. And a gradient clipped to the text is what+/// gradient-text reports: the palette's gradient forms on that element are a+/// second report of one fill (observations-28, round 7 branch 5).+fn drop_covered_palette_forms(findings: &mut Vec<BrowserFinding>) {+ let palette = |f: &BrowserFinding| f.type_ == "ai-color-palette";+ let is_gradient_form = |f: &BrowserFinding| {+ palette(f) && (f.detail.ends_with(" gradient background") || f.detail == "Purple/violet gradient (Tailwind)")+ };+ let is_class_text_form = |f: &BrowserFinding| {+ palette(f) && f.detail.starts_with("text-") && f.detail.ends_with(" on heading")+ };+ let computed_gradient = findings+ .iter()+ .any(|f| palette(f) && f.detail.ends_with(" gradient background"));+ let computed_text = findings+ .iter()+ .any(|f| palette(f) && f.detail.starts_with("Purple/violet text (") && f.detail.ends_with(" on heading"));+ let clipped_gradient = findings.iter().any(|f| f.type_ == "gradient-text");+ if !(computed_gradient || computed_text || clipped_gradient) {return;}- findings.retain(|f| !(f.detail.ends_with(CLASS_FORM_SUFFIX) && computed.contains(&f.type_)));+ findings.retain(|f| {+ if clipped_gradient && is_gradient_form(f) {+ return false;+ }+ if computed_gradient && palette(f) && f.detail == "Purple/violet gradient (Tailwind)" {+ return false;+ }+ !(computed_text && is_class_text_form(f))+ });}/// Whether the page's painted root background is dark: the first of `html`@@ -1103,7 +1138,9 @@ fn reconcile_page_level_forms(let stands = match item.finding.type_.as_str() {// Both page forms describe one treatment, text clipped to a// gradient, and the element forms read it off every element.- "gradient-text" => element_findings("gradient-text").is_empty(),+ "gradient-text" => {+ element_findings("gradient-text").is_empty() && !clipped_gradients_all_silent(dom)+ }"bounce-easing" => {let page = bounce_declarations(&item.finding.detail);!element_findings("bounce-easing").iter().any(|f| {@@ -1129,6 +1166,30 @@ fn reconcile_page_level_forms(out}+/// Whether every element on the page that computes a gradient clipped to its+/// text was measured silent by the element form: not painted at capture, or+/// painting no ramp on its glyphs (a watermark, one colour over the text).+/// Then the stylesheet's declaration shows nothing either. With no such+/// element (the clip sits on a pseudo-element), or one the element form did+/// not read (a wrapper of per-word spans), the text form stands as before.+fn clipped_gradients_all_silent(dom: &dyn Dom) -> bool {+ let clipped: Vec<ElId> = dom+ .query_all(None, "*")+ .unwrap_or_default()+ .into_iter()+ .filter(|&el| {+ let clip = dom.style(el, "webkitBackgroundClip");+ let clip = if clip.is_empty() { dom.style(el, "backgroundClip") } else { clip };+ clip == "text" && dom.style(el, "backgroundImage").contains("gradient")+ })+ .collect();+ !clipped.is_empty()+ && clipped.into_iter().all(|el| {+ super::painted::unpainted_for(dom, el, super::painted::PaintGate::Text).is_some()+ || !super::element_checks::gradient_text_paints_a_ramp(dom, el)+ })+}+/// One bounce declaration as a finding names it.#[derive(Debug, Clone, PartialEq)]enum BounceDeclaration {@@ -1217,6 +1278,19 @@ fn dark_glow_page_form_stands(}let claims_dark = item.finding.detail.ends_with("on dark page");let (Some(selector), Some(hosts)) = (item.selector.as_deref(), item.matches.as_ref()) else {+ // No rule to name (an inline `style` attribute, a keyframe step):+ // the declaration reaches the page through the elements whose+ // computed shadow carries it, and the element form read each of+ // those, its size, opacity, surface and paint at capture, and+ // reported it or measured no glow (liquid-log-glow.lovable.app's+ // progress fill at width 0, jyes.com.tw's loading toast). Only a+ // declaration no element computes is left to the text.+ let casters = glow_declaration(&item.finding.detail)+ .map(|(prop, hex)| elements_casting_glow(dom, &prop, &hex))+ .unwrap_or_default();+ if !casters.is_empty() {+ return false;+ }if !claims_dark {return true;}diff --git a/crates/core/src/browser/element_checks.rs b/crates/core/src/browser/element_checks.rsindex 4388fb7b5..59d758d5c 100644--- a/crates/core/src/browser/element_checks.rs+++ b/crates/core/src/browser/element_checks.rs@@ -8,7 +8,9 @@ use super::background::{read_own_background_color, resolve_background_info, resolve_text_gradient_stops, resolve_text_surface,surface_label, BackgroundInfo, TextSurface,};-use crate::checks::gradient_geometry::{self as geo, Box2};+use crate::checks::gradient_geometry::{+ self as geo, gradient_paint_under_text, BackgroundLayers, Box2, PaintBox, UnderText,+};use super::dom::{class_attr, class_attr_or_prop, closest_or_none, direct_text, has_direct_text_longer_than,matches_or_false, pf0, safe_id, style_px, tag_lower, Dom, ElId, ElStyle, Rect,@@ -816,6 +818,87 @@ fn fold_surface_opacity(Some(fg)}+/// The largest stop alpha, times the element's opacity, under which a+/// gradient clipped to text is a watermark rather than coloured type:+/// vestra.ai's `span.lp-wm` paints its ramp at 6 to 8%.+const GRADIENT_TEXT_MIN_STOP_ALPHA: f64 = 0.15;++/// How far apart, on any channel, two painted colours are before a reader+/// sees two colours rather than one. A box whose samples all sit within it+/// shows one fill.+const RAMP_MIN_CHANNEL_DELTA: f64 = 12.0;++/// What `node`'s own gradient layers paint inside `text`, from its computed+/// background geometry ([`geo::gradient_paint_under_text`]).+pub(crate) fn own_gradient_under(dom: &dyn Dom, node: ElId, text: &Rect) -> UnderText {+ let rect = dom.rect(node);+ let px = |prop: &str| style_px(dom, node, prop);+ let paint = PaintBox {+ border_box: Box2::new(rect.left, rect.top, rect.width, rect.height),+ border: [+ px("borderTopWidth"),+ px("borderRightWidth"),+ px("borderBottomWidth"),+ px("borderLeftWidth"),+ ],+ padding: [px("paddingTop"), px("paddingRight"), px("paddingBottom"), px("paddingLeft")],+ };+ let image = dom.style(node, "backgroundImage");+ let size = dom.style(node, "backgroundSize");+ let position = dom.style(node, "backgroundPosition");+ let shorthand = dom.style(node, "background");+ let layers = BackgroundLayers { image: &image, size: &size, position: &position, shorthand: &shorthand };+ gradient_paint_under_text(&layers, &paint, &Box2::new(text.left, text.top, text.width, text.height))+}++/// Whether the painted samples show one colour: every sample within+/// [`RAMP_MIN_CHANNEL_DELTA`] of the first on every channel, alpha included.+fn samples_are_one_colour(samples: &[Rgba]) -> bool {+ let Some(first) = samples.first() else {+ return false;+ };+ samples.iter().all(|c| {+ (c.r - first.r).abs() < RAMP_MIN_CHANNEL_DELTA+ && (c.g - first.g).abs() < RAMP_MIN_CHANNEL_DELTA+ && (c.b - first.b).abs() < RAMP_MIN_CHANNEL_DELTA+ && (c.alpha_or_one() - first.alpha_or_one()).abs() * 255.0 < RAMP_MIN_CHANNEL_DELTA+ })+}++/// Whether a gradient clipped to `el`'s text paints type a reader sees: its+/// strongest stop is at least [`GRADIENT_TEXT_MIN_STOP_ALPHA`] once the+/// element's own opacity is applied (an ancestor's is left to the Text gate,+/// as [`ai_palette_is_visible`] explains). Where the stops+/// cannot be read the finding stands, as before.+///+/// How much of the ramp the glyphs show is not read. uncoverroads.com's+/// single digit in the corner of a 266px ramp box sees about a third of the+/// ramp, 28 levels on the green channel, and coachcall.ai's centred short+/// headings see a quarter of theirs: geometry cannot tell the judged misfire+/// from the tell.+pub(crate) fn gradient_text_paints_a_ramp(dom: &dyn Dom, el: ElId) -> bool {+ let image = dom.style(el, "backgroundImage");+ let stops = parse_gradient_colors(Some(&image));+ if stops.is_empty() {+ return true;+ }+ let strongest = stops.iter().map(|c| c.alpha_or_one()).fold(0.0, f64::max);+ strongest * own_opacity(dom, el) >= GRADIENT_TEXT_MIN_STOP_ALPHA+}++/// The smallest type [`box_holds_a_text_line`] reads as a line of text.+const SHORT_LINE_MIN_FONT_PX: f64 = 8.0;++/// Whether a box under 10px tall is one line of the text it holds: its type+/// is at least [`SHORT_LINE_MIN_FONT_PX`], and the box is at least nine+/// tenths of the font size tall, so the glyphs fit in it.+fn box_holds_a_text_line(dom: &dyn Dom, el: ElId, rect: &Rect) -> bool {+ let font_size = parse_float(&dom.style(el, "fontSize"));+ font_size.is_finite()+ && font_size >= SHORT_LINE_MIN_FONT_PX+ && rect.height >= font_size * 0.9+}+/// JS: checks.mjs#checkElementColorsDOM(el)pub fn check_element_colors_dom(dom: &dyn Dom,@@ -837,7 +920,12 @@ pub fn check_element_colors_dom(&& dom.parent(el).is_some_and(|p| !js::trim(&direct_text(dom, p)).is_empty());- if rect.height < 10.0 || (rect.width < 10.0 && !narrow_run) {+ // The same holds on the other axis: a whole line of 9px text set tight+ // (coachcall.ai's 148 x 9.45px chat timestamps) is under 10px tall and+ // still read. A box as tall as the glyphs it holds is a line of text, not+ // a mark.+ let short_line = has_direct_text && rect.width >= 10.0 && box_holds_a_text_line(dom, el, &rect);+ if (rect.height < 10.0 && !short_line) || (rect.width < 10.0 && !narrow_run) {return Vec::new();}if dom.style(el, "visibility") == "hidden" || effective_opacity_dom(dom, el) <= 0.02 {@@ -1029,6 +1117,9 @@ pub fn check_element_colors_dom(&mut |h: &RuleHit| safe_tag_text_hit_stands(dom, el, h, resolved) && verdict_stands(h),);findings.retain(|h| verdict_stands(h));+ if findings.iter().any(|h| h.id == "gradient-text") && !gradient_text_paints_a_ramp(dom, el) {+ findings.retain(|h| h.id != "gradient-text");+ }if tag == "input" || tag == "textarea" {let placeholder = dom.attr(el, "placeholder").unwrap_or_default();let placeholder = js::trim(&placeholder);@@ -1068,7 +1159,8 @@ pub fn check_element_colors_dom(/// JS: checks.mjs#checkElementIconTileDOM(el)pub fn check_element_icon_tile_dom(dom: &dyn Dom, el: ElId) -> Vec<RuleHit> {let tag = tag_lower(dom, el);- if !HEADING_TAGS.contains(&tag.as_str()) {+ let card_title = !HEADING_TAGS.contains(&tag.as_str()) && is_card_title(dom, el, &tag);+ if !HEADING_TAGS.contains(&tag.as_str()) && !card_title {return Vec::new();}let Some(found) = super::text_collectors::label_before_heading(dom, el) else {@@ -1099,7 +1191,8 @@ pub fn check_element_icon_tile_dom(dom: &dyn Dom, el: ElId) -> Vec<RuleHit> {sibling_width: sib_rect.width,sibling_height: sib_rect.height,sibling_bottom: sib_rect.bottom,- sibling_bg_color: parse_rgb(Some(&dom.style(sibling, "backgroundColor"))),+ // Tailwind 4 computes `bg-primary/10` to an `oklab(... / 0.1)` fill.+ sibling_bg_color: parse_rgb_or_any(&dom.style(sibling, "backgroundColor")),sibling_bg_image: Some(dom.style(sibling, "backgroundImage")),sibling_border_width: math_max(style_px(dom, sibling, "borderTopWidth"),@@ -1112,9 +1205,42 @@ pub fn check_element_icon_tile_dom(dom: &dyn Dom, el: ElId) -> Vec<RuleHit> {.map(|r| r.width).filter(|w| num_truthy(*w)).unwrap_or(0.0),+ heading_is_card_title: card_title,})}+/// The weight and size a card title set on a `div` carries: shadcn's+/// `CardTitle` is `div.font-semibold` at `text-lg` or `text-2xl`.+const CARD_TITLE_MIN_WEIGHT: f64 = 600.0;+const CARD_TITLE_MIN_PX: f64 = 16.0;+/// The longest text a card title holds.+const CARD_TITLE_MAX_CHARS: usize = 80;++/// Whether `el` is a card title set on a non-heading tag: a `div` or `span`+/// laid out as a block, outside any heading, whose own text is one short+/// bold line (kin-ai.replit.app's shadcn feature cards). The tile rule+/// anchors on it as on a heading. A `p` is copy, not a title: a dropzone's+/// bold prompt under its upload icon stays silent.+fn is_card_title(dom: &dyn Dom, el: ElId, tag: &str) -> bool {+ if !matches!(tag, "div" | "span") {+ return false;+ }+ if !matches!(dom.style(el, "display").as_str(), "block" | "flow-root") {+ return false;+ }+ let text = js::trim(&direct_text(dom, el)).to_string();+ let len = utf16_len(&text);+ if !(2..=CARD_TITLE_MAX_CHARS).contains(&len) || !dom.children(el).is_empty() {+ return false;+ }+ let weight = parse_float(&dom.style(el, "fontWeight"));+ let size = parse_float(&dom.style(el, "fontSize"));+ if !(weight >= CARD_TITLE_MIN_WEIGHT && size >= CARD_TITLE_MIN_PX) {+ return false;+ }+ closest_or_none(dom, el, "h1, h2, h3, h4, h5, h6, [role=\"heading\"], a, button, label").is_none()+}+/// The box a tile is drawn on. A `display: contents` wrapper generates no box,/// so its last element child stands for it, and a wrapper that paints nothing/// around a single child of its own size (a Framer `-container`) stands for@@ -1238,6 +1364,9 @@ pub fn check_element_hero_eyebrow_dom(dom: &dyn Dom, el: ElId) -> Vec<RuleHit> {let Some(sibling) = dom.previous_element_sibling(el) else {return Vec::new();};+ // A chip wraps its text in a span beside an icon or inside a bare box:+ // the element holding the text sets its size, case and tracking.+ let ty = super::text_collectors::label_type_element(dom, sibling);check_hero_eyebrow(&HeroEyebrowOpts {heading_tag: tag,heading_text: Some(dom.text_content(el)),@@ -1250,12 +1379,13 @@ pub fn check_element_hero_eyebrow_dom(dom: &dyn Dom, el: ElId) -> Vec<RuleHit> {.is_some(),sibling_tag: Some(tag_lower(dom, sibling)),sibling_text: Some(dom.text_content(sibling)),- sibling_text_transform: Some(dom.style(sibling, "textTransform")),- sibling_font_size: style_px(dom, sibling, "fontSize"),- sibling_letter_spacing: style_px(dom, sibling, "letterSpacing"),- sibling_font_weight: Some(dom.style(sibling, "fontWeight")),- sibling_color: Some(dom.style(sibling, "color")),+ sibling_text_transform: Some(dom.style(ty, "textTransform")),+ sibling_font_size: style_px(dom, ty, "fontSize"),+ sibling_letter_spacing: style_px(dom, ty, "letterSpacing"),+ sibling_font_weight: Some(dom.style(ty, "fontWeight")),+ sibling_color: Some(dom.style(ty, "color")),sibling_has_accent_dash_pseudo: dom_accent_dash_pseudo(dom, sibling),+ sibling_tracking_floor_em: Some(crate::checks::rules::HERO_EYEBROW_TRACKING_EM),})}@@ -1580,6 +1710,21 @@ fn ai_palette_gradient_hit(dom: &dyn Dom, el: ElId) -> Option<RuleHit> {if gradient_occluded_by_media_child(dom, el, &rect) {return None;}+ // What the box shows at rest: a hover wipe drawn as two hard stops on a+ // tile twice the box's width (jpmorganchase.com's buttons) shows one of+ // its colours, a flat fill. The samples read every layer over the whole+ // border box, so a layer clipped to the padding or content box (a white+ // fill over a gradient border ring, joongang.co.kr) is not measured.+ // Where the geometry cannot be read, the stops decide as before.+ let clip = dom.style(el, "backgroundClip");+ let clipped_to_border_box = clip.is_empty() || clip.split(',').all(|c| js::trim(c) == "border-box");+ if clipped_to_border_box {+ if let UnderText::Paint(samples) = own_gradient_under(dom, el, &rect) {+ if samples_are_one_colour(&samples) {+ return None;+ }+ }+ }let opacity = own_opacity(dom, el);let mut painted = 0usize;let mut in_band = 0usize;@@ -1941,6 +2086,21 @@ fn gpt_border_shadow_pair_dom(dom: &dyn Dom, el: ElId) -> Option<(f64, f64)> {// edge only where it shows against the fill it rims (the surface, when the// element paints none). Where a surface cannot be read, as before.let surface = painted_surface_under(dom, el);+ // Under a gradient ancestor there is no one surface, but there are its+ // stops: a halo that shows over at most half of them lands on a surface+ // it does not change (uncoverroads.com's near-black halo on an aurora band+ // that is near-black but for 6 to 8% tints).+ if surface.is_none() {+ if let Some(surfaces) = gradient_surfaces_under(dom, el) {+ let shows = surfaces+ .iter()+ .filter(|s| gpt_border_shadow_halo_blur_px_over(Some(&box_shadow), Some(s)).is_some())+ .count();+ if shows * 2 <= surfaces.len() {+ return None;+ }+ }+ }let blur = gpt_border_shadow_halo_blur_px_over(Some(&box_shadow), surface.as_ref())?;let fill = surface.map(|s| own_fill_over(dom, el, &s));let style = ElStyle { dom, el };@@ -2001,6 +2161,63 @@ pub(crate) fn painted_surface_under(dom: &dyn Dom, el: ElId) -> Option<Rgba> {Some(surface)}+/// The colours a box is painted onto when one ancestor between it and the+/// first opaque fill paints a gradient: each of the gradient's stops,+/// composited with the translucent fills above and below it, over that fill+/// (or the light canvas). `None` where [`painted_surface_under`] reads one+/// surface, or where the walk meets a picture, a second gradient, or a+/// colour that does not parse.+pub(crate) fn gradient_surfaces_under(dom: &dyn Dom, el: ElId) -> Option<Vec<Rgba>> {+ // Top first; each layer is the colours it may paint.+ let mut layers: Vec<Vec<Rgba>> = Vec::new();+ let mut gradients = 0usize;+ let mut current = dom.parent(el);+ let mut base: Option<Rgba> = None;+ while let Some(p) = current {+ let image = dom.style(p, "backgroundImage");+ if !image.is_empty() && image != "none" {+ let lower = image.to_ascii_lowercase();+ if lower.contains("url(") || !lower.contains("gradient") {+ return None;+ }+ let stops = parse_gradient_colors(Some(&image));+ if stops.is_empty() {+ return None;+ }+ gradients += 1;+ layers.push(stops);+ }+ let raw = dom.style(p, "backgroundColor");+ if !measures::css_color_is_transparent(Some(&raw)) {+ let color = parse_any_color(Some(&raw))?;+ if color.alpha_or_one() >= 0.999 {+ base = Some(color);+ break;+ }+ layers.push(vec![color]);+ }+ current = dom.parent(p);+ }+ if gradients != 1 {+ return None;+ }+ let base = match base {+ Some(b) => b,+ None if super::quality::canvas_is_light(&dom.style(el, "colorScheme")) => {+ parse_any_color(Some(super::quality::CANVAS_BACKGROUND))?+ }+ None => return None,+ };+ let mut surfaces = vec![base];+ for layer in layers.iter().rev() {+ surfaces = surfaces+ .iter()+ .flat_map(|s| layer.iter().map(move |c| composite_color_over(c, s)))+ .collect();+ }+ Some(surfaces)+}+/// `el`'s own background colour composited over `surface`, or `surface` when/// it paints none (or none that parses).pub(crate) fn own_fill_over(dom: &dyn Dom, el: ElId, surface: &Rgba) -> Rgba {diff --git a/crates/core/src/browser/painted.rs b/crates/core/src/browser/painted.rsindex bc6be9b7e..015c958e1 100644--- a/crates/core/src/browser/painted.rs+++ b/crates/core/src/browser/painted.rs@@ -97,14 +97,17 @@ pub enum OwnOpacity {}/// The rules that measure one element's text. Style tells about the page-/// (gradient text, fonts, borders) describe authored CSS whatever state is-/// showing and are not gated; `italic-serif-display` reports one heading's-/// display treatment, which a visitor meets only where the heading is shown.+/// (fonts, borders) describe authored CSS whatever state is showing and are+/// not gated; `italic-serif-display` reports one heading's display+/// treatment, which a visitor meets only where the heading is shown, and+/// `gradient-text` the ramp painted on one run of text, which a label in a+/// closed menu never shows (bt.cn's mobile dropdown, observations-28 row 20).pub const PAINT_GATED_TEXT_RULES: &[&str] = &["all-caps-body","body-text-viewport-edge","cramped-padding","extreme-negative-tracking",+ "gradient-text","gray-on-color","italic-serif-display","justified-text",@@ -1839,9 +1842,10 @@ mod tests {BrowserFinding::new("italic-serif-display", "italic serif h1 (playfair display) at 60px"),BrowserFinding::new("blinking-cursor", "i.caret — 5x10px blinking cursor"),];+ findings.push(BrowserFinding::new("font-overuse-stand-in", "an ungated style tell"));retain_painted(&d, a, &mut findings);let ids: Vec<&str> = findings.iter().map(|f| f.type_.as_str()).collect();- assert_eq!(ids, vec!["gradient-text"]);+ assert_eq!(ids, vec!["font-overuse-stand-in"]);// Painted, every finding stays.d.set_rect(wrap, 40.0, 300.0, 400.0, 40.0);@@ -1854,7 +1858,7 @@ mod tests {assert_eq!(kept.len(), 3);assert_eq!(paint_gate("content-hidden-at-rest"), None);- assert_eq!(paint_gate("gradient-text"), None);+ assert_eq!(paint_gate("gradient-text"), Some(PaintGate::Text));assert_eq!(paint_gate("layout-transition"), Some(PaintGate::Box));assert_eq!(paint_gate("bounce-easing"), Some(PaintGate::Box));assert_eq!(paint_gate("dark-glow"), Some(PaintGate::Box));diff --git a/crates/core/src/browser/quality.rs b/crates/core/src/browser/quality.rsindex 9f4e28936..0b88c4f82 100644--- a/crates/core/src/browser/quality.rs+++ b/crates/core/src/browser/quality.rs@@ -411,6 +411,30 @@ fn rendered_lines(dom: &dyn Dom, el: ElId, t: &Rect) -> (bool, f64) {/// wholly in inline children (`<p><i>…</i></p>`).const LINE_PROSE_TAGS: &[&str] = &["p", "li", "dd", "blockquote"];+/// Generic block boxes a CMS or a builder writes prose straight into, with no+/// `<p>` around it: cencora.com's `div.module__body`, aina-tech.io's+/// `div.mt-10.text-base` between two measured paragraphs.+const PROSE_BLOCK_TAGS: &[&str] = &["div", "section", "article", "aside", "main"];++/// Where prose written straight into a generic block is not prose: inside a+/// control, a link, or an editable field.+const PROSE_BLOCK_SKIP_SELECTOR: &str = "a, button, label, summary, select, textarea, [role=\"button\"], [role=\"link\"], [role=\"tab\"], [role=\"menuitem\"], [role=\"option\"], [contenteditable=\"true\"], [contenteditable=\"\"]";++/// Whether `el` is prose written straight into a generic block box: a+/// [`PROSE_BLOCK_TAGS`] element laid out as a block, holding text of its own+/// and nothing but phrasing under it, outside any control, and not set as+/// preformatted text. `line-length` and `body-text-viewport-edge` measure it+/// the way they measure a `<p>`, from its text runs only: where those cannot+/// be measured, a generic box is not taken for a paragraph.+fn is_prose_block(dom: &dyn Dom, el: ElId, tag: &str, has_direct_text: bool) -> bool {+ has_direct_text+ && PROSE_BLOCK_TAGS.contains(&tag)+ && matches!(dom.style(el, "display").as_str(), "block" | "flow-root")+ && !dom.style(el, "whiteSpace").starts_with("pre")+ && holds_only_phrasing(dom, el)+ && closest_or_none(dom, el, PROSE_BLOCK_SKIP_SELECTOR).is_none()+}+/// The line-height `normal` stands for when counting line boxes: a text rect/// one line tall is at most about 1.5em, two lines at least about 2.3em.const NORMAL_LINE_HEIGHT_EM: f64 = 1.2;@@ -427,6 +451,40 @@ const TEXT_FILLS_MEASURE: f64 = 0.9;/// that of its box may hold as many characters as the box estimate says.const LINE_FILLS_MEASURE: f64 = 0.8;+/// The controls whose labels wide tracking may set: links and buttons.+const TRACKED_CONTROL_LABEL: &str = "a[href], button, [role=\"button\"], [role=\"link\"], [role=\"tab\"]";++/// The letters in `text`: what a reader takes in as a label's length. The+/// spaces, digits and dots between words of a caps label+/// ("SCHEDULE AND CREATE 100 SOCIAL VIDEOS IN 20 MINS") are not.+fn letter_count(text: &str) -> usize {+ text.chars().filter(|c| c.is_alphabetic()).count()+}++/// Whether `el`'s text is a label-length run on one line: at most+/// [`TRACKED_LABEL_MAX_CHARS`] letters, and a text box that does not wrap.+fn short_one_line_label(dom: &dyn Dom, el: ElId, line_height_px: Option<f64>) -> bool {+ letter_count(js::trim(&dom.text_content(el))) <= TRACKED_LABEL_MAX_CHARS+ && !text_wraps_to_multiple_lines(+ dom.direct_text_rect(el).map(|r| r.height).unwrap_or(0.0),+ line_height_px,+ )+}++/// Whether `el` is a label typed in capitals: its text is a capitalized run+/// ([`is_capitalized_run`]) and a label-length run on one line+/// ([`short_one_line_label`]). `text-transform` does not say so, the markup+/// does. With `every_letter`, each letter has to be a capital: a line of+/// Hangul or kana with one Latin brand name in capitals ("인벤(INVEN)") is+/// running text, and letters with no case do not make it a label.+fn typed_caps_label(dom: &dyn Dom, el: ElId, line_height_px: Option<f64>, every_letter: bool) -> bool {+ let text = dom.text_content(el);+ let text = js::trim(&text);+ is_capitalized_run(text)+ && (!every_letter || text.chars().filter(|c| c.is_alphabetic()).all(|c| c.is_uppercase()))+ && short_one_line_label(dom, el, line_height_px)+}+/// Characters on a line `width_px` wide at `font_size_px`, with glyphs/// `advance_em` wide on average.fn chars_per_line_at(width_px: f64, font_size_px: f64, advance_em: f64) -> f64 {@@ -598,7 +656,8 @@ pub fn body_text_gutter_floor(viewport_width: f64) -> f64 {/// Where a paragraph's body text starts and ends on the x axis, as/// `body-text-viewport-edge` reads it, or `None` when the rule does not-/// measure it: not a `<p>` or `<li>` of more than 40 characters, inside a+/// measure it: not a `<p>` or `<li>` (or prose written straight into a+/// generic block, [`is_prose_block`]) of more than 40 characters, inside a/// `<nav>` or `<header>`, on its own fill, positioned, half the viewport wide/// or less, cut by a scroller or a moving track rather than the page, or/// wholly past either side of the viewport.@@ -609,7 +668,8 @@ pub fn body_text_gutter_floor(viewport_width: f64) -> f64 {/// that track's clip rather than the page edge. A box that only hides its/// overflow proves no track, so text it cuts at the screen edge counts./// Prose whose words sit wholly in inline children is measured the same-/// way. Where the text cannot be measured the box stands in, as before.+/// way. Where the text cannot be measured the box stands in, as before,+/// except for a generic block, which is measured on its text or not at all.fn body_text_edge_span(dom: &dyn Dom, q: &QualityInput) -> Option<(f64, f64)> {let el = q.el;let tag = q.tag.as_str();@@ -620,7 +680,8 @@ fn body_text_edge_span(dom: &dyn Dom, q: &QualityInput) -> Option<(f64, f64)> {let spx = |k: &str| style_px(dom, el, k);let is_edge_tag = matches!(js::to_upper_case(tag).as_str(), "P" | "LI");let edge_prose = !has_direct_text && is_edge_tag && holds_only_phrasing(dom, el);- if !((has_direct_text || edge_prose) && q.text_len > 40 && is_edge_tag && viewport_width > 0.0) {+ let prose_block = !is_edge_tag && is_prose_block(dom, el, tag, has_direct_text);+ if !((has_direct_text || edge_prose) && q.text_len > 40 && (is_edge_tag || prose_block) && viewport_width > 0.0) {return None;}let in_nav_header = closest_or_none(dom, el, "nav").is_some() || closest_or_none(dom, el, "header").is_some();@@ -660,7 +721,7 @@ fn body_text_edge_span(dom: &dyn Dom, q: &QualityInput) -> Option<(f64, f64)> {(t.left, t.right)}}- None if has_direct_text => (rect.left, rect.right),+ None if has_direct_text && !prose_block => (rect.left, rect.right),None => return None,};// Text wholly past either side of the viewport meets no edge a reader@@ -737,8 +798,11 @@ pub fn check_quality(dom: &dyn Dom, q: &QualityInput) -> Vec<RuleHit> {// text cannot be measured the box stands in, as before.let prose_in_phrasing =!has_direct_text && LINE_PROSE_TAGS.contains(&tag) && holds_only_phrasing(dom, el);+ let prose_block = !QUALITY_TEXT_TAGS.contains(&tag)+ && (text_len as f64) > line_max+ && is_prose_block(dom, el, tag, has_direct_text);if (has_direct_text || prose_in_phrasing)- && QUALITY_TEXT_TAGS.contains(&tag)+ && (QUALITY_TEXT_TAGS.contains(&tag) || prose_block)&& rect.width > 0.0&& (text_len as f64) > line_max{@@ -787,7 +851,7 @@ pub fn check_quality(dom: &dyn Dom, q: &QualityInput) -> Vec<RuleHit> {None}}- None if has_direct_text => Some(chars_per_line_at(rect.width, text_size, advance)),+ None if has_direct_text && !prose_block => Some(chars_per_line_at(rect.width, text_size, advance)),None => None,};if let Some(cpl) = estimate.filter(|cpl| *cpl > line_max + 5.0) {@@ -1179,13 +1243,22 @@ pub fn check_quality(dom: &dyn Dom, q: &QualityInput) -> Vec<RuleHit> {}// --- Tiny body text ---+ // Body text is running prose. A label set in capitals is not, whether+ // `text-transform` says so or the capitals are typed into the markup+ // (adant.ai's "ANIMATION · CINEMATIC 3D" card meta), and neither is a+ // command set in a monospace face with its whitespace kept (stroq.dev's+ // terminal mock), which is code whatever its class names.if has_direct_text && text_len > 20 && font_size < 12.0 {let skip_tags = ["sub", "sup", "code", "kbd", "samp", "var", "caption", "figcaption"];let in_ui_context = closest_or_none(dom, el, TINY_TEXT_UI_CONTEXT).is_some();- let is_uppercase = st("textTransform") == "uppercase";+ let is_uppercase = st("textTransform") == "uppercase"+ || typed_caps_label(dom, el, q.line_height_px, true);+ let is_code_run = crate::checks::text_rules::is_monospace_family(&st("fontFamily"))+ && st("whiteSpace").starts_with("pre");if !skip_tags.contains(&tag)&& !in_ui_context&& !is_uppercase+ && !is_code_run&& !is_non_rendered_text(dom, el, tag){findings.push(RuleHit::new(@@ -1268,14 +1341,14 @@ pub fn check_quality(dom: &dyn Dom, q: &QualityInput) -> Vec<RuleHit> {// says so outright; capitals typed into the markup do// not, so that reading is held to label size on one// line and running text keeps the rule.+ // A link or button label is read at a glance too+ // (lpga.or.jp's bold CJK "Instagram" link), held to the+ // same size on one line.+ let control_label = closest_or_none(dom, el, TRACKED_CONTROL_LABEL).is_some()+ && short_one_line_label(dom, el, q.line_height_px);let caps_label = st("textTransform") == "uppercase"- || (text_len <= TRACKED_LABEL_MAX_CHARS- && is_capitalized_run(js::trim(&dom.text_content(el)))- && !text_wraps_to_multiple_lines(- dom.direct_text_rect(el).map(|r| r.height).unwrap_or(0.0),- q.line_height_px,- ));- if !caps_label {+ || typed_caps_label(dom, el, q.line_height_px, false);+ if !caps_label && !control_label {findings.push(RuleHit::new("wide-tracking",format!("letter-spacing: {}em on body text", to_fixed(tracking_em, 2)),@@ -1650,7 +1723,10 @@ pub fn check_page_overflow_dom(dom: &dyn Dom) -> Vec<BrowserFinding> {}// (element, side, how far its text reaches past that side)let mut past: Vec<(ElId, Side, f64)> = Vec::new();- for el in dom.query_all(None, "p, li").unwrap_or_default() {+ for el in dom+ .query_all(None, "p, li, div, section, article, aside, main")+ .unwrap_or_default()+ {if !super::driver::element_is_scanned(dom, el) {continue;}diff --git a/crates/core/src/browser/text_collectors.rs b/crates/core/src/browser/text_collectors.rsindex a0cca0dc4..a791df64c 100644--- a/crates/core/src/browser/text_collectors.rs+++ b/crates/core/src/browser/text_collectors.rs@@ -42,10 +42,28 @@ fn collapsed_text_content(dom: &dyn Dom, el: ElId) -> String {js::trim(&collapse_ws(&dom.text_content(el))).to_string()}-/// JS: checks.mjs#isKickerCardContext(heading, kicker)+/// How many viewports tall a card-context element may be before it is the+/// page's frame rather than a card: outreign.io wraps its whole page in+/// `main > article`, 11,527px tall, and a card on a phone runs under two+/// screens.+pub const KICKER_CARD_MAX_VIEWPORTS: f64 = 2.0;++/// JS: checks.mjs#isKickerCardContext(heading, kicker), less a page-scale+/// ancestor: an `article` (or list item, link, button) more than+/// [`KICKER_CARD_MAX_VIEWPORTS`] viewports tall holds the page, and a label+/// and heading inside it share no card. Where the box or the viewport is not+/// measured the ancestor counts, as before.pub fn is_kicker_card_context(dom: &dyn Dom, heading: ElId, kicker: ElId) -> bool {match dom.closest(heading, KICKER_CARD_CONTEXT_SELECTOR) {- Ok(Some(item)) => dom.contains(item, kicker),+ Ok(Some(item)) => {+ let viewport = dom.inner_height();+ let height = dom.rect(item).height;+ let page_scale = viewport.is_finite()+ && viewport > 0.0+ && height.is_finite()+ && height > viewport * KICKER_CARD_MAX_VIEWPORTS;+ !page_scale && dom.contains(item, kicker)+ }_ => false,}}@@ -167,7 +185,20 @@ pub fn collect_kicker_candidates(dom: &dyn Dom) -> Vec<KickerCandidate> {}) {continue;}- if heading_tag == "h1" && heading_font_size >= 48.0 && kicker_letter_spacing >= 1.6 {+ // The hero rule takes a tracked label over a display h1. Its em+ // floor reaches only the labels that rule reads: the h1's own+ // previous sibling, at eyebrow size.+ if heading_tag == "h1"+ && heading_font_size >= 48.0+ && (kicker_letter_spacing >= crate::checks::rules::HERO_EYEBROW_TRACKING_PX+ || (found.levels == 0+ && kicker_font_size <= 14.0+ && crate::checks::rules::hero_eyebrow_tracked(+ kicker_letter_spacing,+ kicker_font_size,+ Some(crate::checks::rules::HERO_EYEBROW_TRACKING_EM),+ )))+ {continue;}// A pair a visitor cannot see (a section at `hidden`, an inactive@@ -380,9 +411,13 @@ pub fn label_near_heading(dom: &dyn Dom, label: ElId, heading: ElId) -> bool {}/// The element that sets a label's type: the label itself when it has text of-/// its own, else its only element child, at most three levels down. Framer-/// sets an eyebrow's size, tracking and case on a `p` inside a bare `div`, and-/// a mono index often sits in a `span` inside a sized column.+/// its own, else the one element child that holds its text, at most three+/// levels down. Framer sets an eyebrow's size, tracking and case on a `p`+/// inside a bare `div`, and a mono index often sits in a `span` inside a sized+/// column. A chip puts an icon beside its text span (redoubt.agency's flag+/// svg, uncoverroads.com's status dot): children that hold no text are the+/// chip's marks, and the one that holds the text sets the type. A wrapper+/// with two children that both hold text is read as itself.pub fn label_type_element(dom: &dyn Dom, label: ElId) -> ElId {let mut el = label;for _ in 0..3 {@@ -390,10 +425,14 @@ pub fn label_type_element(dom: &dyn Dom, label: ElId) -> ElId {return el;}let children = dom.children(el);- if children.len() != 1 {+ let mut with_text = children+ .iter()+ .copied()+ .filter(|&c| !js::trim(&dom.text_content(c)).is_empty());+ let (Some(only), None) = (with_text.next(), with_text.next()) else {return el;- }- el = children[0];+ };+ el = only;}el}diff --git a/crates/core/src/checks/rules.rs b/crates/core/src/checks/rules.rsindex 2b62526c5..40f16ce4b 100644--- a/crates/core/src/checks/rules.rs+++ b/crates/core/src/checks/rules.rs@@ -1168,7 +1168,7 @@ pub const ICON_TILE_MIN_BG_ALPHA: f64 = 0.05;/// JS: checks.mjs#checkIconTilepub fn check_icon_tile(opts: &IconTileOpts) -> Vec<RuleHit> {- if !is_heading_tag(&opts.heading_tag) {+ if !is_heading_tag(&opts.heading_tag) && !opts.heading_is_card_title {return Vec::new();}let sibling_tag = match opts.sibling_tag.as_deref() {@@ -1449,7 +1449,12 @@ pub fn check_hero_eyebrow(opts: &HeroEyebrowOpts) -> Vec<RuleHit> {let is_uppercased = opts.sibling_text_transform.as_deref() == Some("uppercase")|| (text.bytes().any(|b| b.is_ascii_uppercase())&& !text.bytes().any(|b| b.is_ascii_lowercase()));- let is_classic_tracked = is_uppercased && opts.sibling_letter_spacing >= 1.6;+ let is_classic_tracked = is_uppercased+ && hero_eyebrow_tracked(+ opts.sibling_letter_spacing,+ opts.sibling_font_size,+ opts.sibling_tracking_floor_em,+ );let weight = {let n = match opts.sibling_font_weight.as_deref() {@@ -1684,12 +1689,22 @@ pub(crate) fn glow_is_perceptible(/// How far the chromatic layers of one shadow value lift `surface` at the/// edge of the box (see [`GLOW_MIN_LIFT`]). Neutral layers are elevation, not-/// glow light, and do not count.+/// glow light, and do not count, and neither does a layer carrying under half+/// the light a glow needs ([`GLOW_MIN_STRENGTH_PX`]): Tailwind's `shadow-lg`+/// in a 0.2 purple adds a 6px layer at 1.2px of light to its 15px one, and+/// the pair lit nothing on gameghost.manus.space's black page. The layers of+/// an elevation ramp that each carry some of the light still add up.fn glow_surface_lift(value: &str, surface: &Rgba, element_opacity: Option<f64>) -> f64 {let opacity = element_opacity.unwrap_or(1.0);split_commas_outside_parens(value).into_iter()- .filter_map(|layer| find_shadow_color(layer).and_then(|info| info.color))+ .filter_map(|layer| {+ let info = find_shadow_color(layer)?;+ let color = info.color?;+ let vals = extract_shadow_lengths(layer, Some((info.start, info.end)));+ let blur = vals.get(2).copied().unwrap_or(0.0);+ (blur * color.alpha_or_one() * opacity >= GLOW_MIN_STRENGTH_PX / 2.0).then_some(color)+ }).filter(|color| has_chroma(Some(color), Some(30.0))).map(|color| {let difference = (color.r - surface.r)@@ -2079,6 +2094,7 @@ mod tests {sibling_border_radius: 8.0,has_icon_child: true,icon_child_width: 20.0,+ heading_is_card_title: false,};assert_eq!(check_icon_tile(&opts(0.1)).len(), 1);assert_eq!(check_icon_tile(&opts(0.05)).len(), 1);@@ -2495,6 +2511,22 @@ mod tests {};assert!(avatar(0.15).is_empty());assert_eq!(avatar(0.4).len(), 1);+ // Tailwind's `shadow-lg shadow-purple-900/20` on a black page: the 6px+ // layer carries 1.2px of light and lights nothing, and the 15px layer+ // alone lifts the page by 14 (gameghost.manus.space).+ let black = Rgba::new(0.0, 0.0, 0.0, 1.0);+ let shadow_lg = check_glow(&GlowOpts {+ box_shadow: Some(+ "oklab(0.381 0.100917 -0.144194 / 0.2) 0px 10px 15px -3px, oklab(0.381 0.100917 -0.144194 / 0.2) 0px 4px 6px -4px"+ .to_string(),+ ),+ text_shadow: None,+ effective_bg: Some(black),+ element_opacity: Some(1.0),+ element_size: Some((208.0, 36.0)),+ surface: Some(black),+ });+ assert!(shadow_lg.is_empty(), "{shadow_lg:?}");// With no resolved fill behind it (a gradient, an image) the lift is// not measured, and the strength floor decides as before.let unresolved = check_glow(&GlowOpts {diff --git a/crates/core/src/checks/vectors_a.rs b/crates/core/src/checks/vectors_a.rsindex eed756172..8ad26af7d 100644--- a/crates/core/src/checks/vectors_a.rs+++ b/crates/core/src/checks/vectors_a.rs@@ -256,6 +256,7 @@ pub fn call(module: &str, fn_name: &str, args: &[Value]) -> Option<Value> {sibling_border_radius: to_number(f(0, "siblingBorderRadius")),has_icon_child: truthy(f(0, "hasIconChild")),icon_child_width: to_number(f(0, "iconChildWidth")),+ heading_is_card_title: false,};hits_to_js(&rules::check_icon_tile(&opts))}@@ -297,6 +298,7 @@ pub fn call(module: &str, fn_name: &str, args: &[Value]) -> Option<Value> {sibling_font_weight: opt_str(f(0, "siblingFontWeight")),sibling_color: opt_str(f(0, "siblingColor")),sibling_has_accent_dash_pseudo: truthy(f(0, "siblingHasAccentDashPseudo")),+ sibling_tracking_floor_em: None,};hits_to_js(&rules::check_hero_eyebrow(&opts))}diff --git a/crates/core/src/third_party.rs b/crates/core/src/third_party.rsindex cecdbec36..0c26e92dc 100644--- a/crates/core/src/third_party.rs+++ b/crates/core/src/third_party.rs@@ -47,7 +47,14 @@ pub struct WidgetVendor {/// The widget vendors, from the corpus evidence: Taboola recommendation cards/// on ynet.co.il and climatempo.com.br (findings 110423, 110711, 123649,/// 123650, 123679), and a Swiper carousel's vendor CSS on nubank.com.br-/// (111379, 111514).+/// (111379, 111514). Run 28 adds four more (observations-28, section 3):+/// Slick's track and slide wrappers on lpga.or.jp (141946) and the dot+/// buttons Slick writes on jyes.com.tw (141986, 142493), SuperSlide's+/// `div.tempWrap` on scol.com.cn (141745, 141937), react-fast-marquee on+/// cnnbrasil.com.br (143060, 143061), and Kaltura's player on cencora.com+/// (143584 to 143586, 143613 to 143615). A vendor listed twice has two+/// scopes: Slick's structural wrappers hold the site's slides, while the dot+/// list is Slick's own markup down to the button.pub const WIDGET_VENDORS: &[WidgetVendor] = &[WidgetVendor {name: "Taboola",@@ -65,6 +72,43 @@ pub const WIDGET_VENDORS: &[WidgetVendor] = &[class_prefixes: &[],classes: &["swiper", "swiper-container", "swiper-wrapper", "swiper-slide"],},+ WidgetVendor {+ name: "Slick",+ scope: WidgetScope::OwnElement,+ id_prefixes: &[],+ class_prefixes: &[],+ classes: &["slick-slider", "slick-list", "slick-track", "slick-slide", "slick-arrow"],+ },+ WidgetVendor {+ name: "Slick",+ scope: WidgetScope::Subtree,+ id_prefixes: &[],+ class_prefixes: &[],+ classes: &["slick-dots"],+ },+ WidgetVendor {+ name: "SuperSlide",+ scope: WidgetScope::OwnElement,+ id_prefixes: &[],+ class_prefixes: &[],+ classes: &["tempWrap"],+ },+ WidgetVendor {+ // The marquee clones and moves the site's children; what they collide+ // with or show at rest is the vendor's motion.+ name: "react-fast-marquee",+ scope: WidgetScope::Subtree,+ id_prefixes: &[],+ class_prefixes: &["rfm-"],+ classes: &[],+ },+ WidgetVendor {+ name: "Kaltura",+ scope: WidgetScope::Subtree,+ id_prefixes: &[],+ class_prefixes: &["playkit-"],+ classes: &["kaltura-player", "kaltura-player-container"],+ },];fn marks(dom: &dyn Dom, el: ElId, vendor: &WidgetVendor) -> bool {@@ -114,7 +158,12 @@ pub struct AdTechVendor {/// tags back and throws when it patches `document.createElement`. Product/// analytics (PostHog) and a site's own bundles and telemetry chunks, ad/// code served from the site's own host included, are not on the list and-/// stay first-party script errors.+/// stay first-party script errors. Run 28 adds (observations-28, section 3)+/// the nagich.co.il accessibility overlay on walla.co.il (142928, 142984) and+/// Chase's shared `Reporting.js` tag library, served from `asset.chase.com`+/// to jpmorganchase.com (143250); Prisma Media's ad core on+/// cuisineactuelle.fr throws from its Prebid call (143089, 143154), which+/// [`AD_TECH_APIS`] names.pub const AD_TECH_VENDORS: &[AdTechVendor] = &[AdTechVendor { name: "AnyMind", sources: &["anymind360.com"] },AdTechVendor { name: "Prebid", sources: &["/prebid"] },@@ -125,19 +174,23 @@ pub const AD_TECH_VENDORS: &[AdTechVendor] = &[name: "Google Ads",sources: &["googlesyndication.com", "doubleclick.net", "googleadservices.com"],},+ AdTechVendor { name: "Nagich", sources: &["nagich.co.il"] },+ AdTechVendor { name: "Chase Reporting", sources: &["asset.chase.com/web/library/digddsautomation/reportingjs/"] },];/// Ad APIs whose rejection names itself in the message: Chrome removed the/// Topics API (`document.browsingTopics() is deprecated and has been/// removed`, findings 65354, 65585 on co-trip.jp) and ad scripts still call/// it; the Protected Audience calls are the same kind of rejection; AdSense-/// throws `adsbygoogle.push() error` at slots it cannot fill. Each maps to+/// throws `adsbygoogle.push() error` at slots it cannot fill, and an ad core+/// calling a Prebid build that lacks a method names `_prebidjs`. Each maps to/// the vendor it names.pub const AD_TECH_APIS: &[(&str, &str)] = &[("browsingTopics", "ad tech"),("joinAdInterestGroup", "ad tech"),("runAdAuction", "ad tech"),("adsbygoogle", "Google Ads"),+ ("_prebidjs", "Prebid"),];/// The ad-tech vendor behind an uncaught page error, from where it was@@ -241,6 +294,83 @@ mod tests {assert_eq!(ad_tech_vendor("Minified React error #418", Some("at https://example.com/app.js:1:1")), None);}+ #[test]+ fn run_28_ad_tech_hosts_name_their_vendor() {+ assert_eq!(+ ad_tech_vendor(+ "Uncaught (in promise) TypeError: ze._prebidjs.getAdserverTargetingForAdUnitCode is not a function",+ Some("at mapConversionRateInAdserverWithPrebidTargeting, https://tra.scds.pmdstatic.net/advertising-core/5/core-ads.js:1:73446")+ ),+ Some("Prebid")+ );+ assert_eq!(+ ad_tech_vendor(+ "Uncaught (in promise) TypeError: e.some is not a function",+ Some("at i, https://js.nagich.co.il/core/4.6.12/accessibility.js:1:3216")+ ),+ Some("Nagich")+ );+ assert_eq!(+ ad_tech_vendor(+ "Uncaught TypeError: Cannot convert undefined or null to object",+ Some("at o, https://asset.chase.com/web/library/digddsautomation/reportingjs/Reporting.js:1:121552")+ ),+ Some("Chase Reporting")+ );+ // Chase's own bundles on the same host stay first-party.+ assert_eq!(+ ad_tech_vendor("Uncaught TypeError: x is undefined", Some("at a, https://asset.chase.com/web/app/main.js:1:1")),+ None+ );+ }++ #[test]+ fn run_28_widget_vendors_tag_their_markup() {+ let mut d = FakeDom::new();+ let (_html, body) = d.with_page();+ // Slick: the list is Slick's, the site's slide content is not; the+ // dot list is Slick's down to its buttons.+ let slider = d.add(Some(body), "div");+ d.set_attr(slider, "class", "banner slick-initialized slick-slider");+ let list = d.add(Some(slider), "div");+ d.set_attr(list, "class", "slick-list draggable");+ let slide = d.add(Some(list), "div");+ d.set_attr(slide, "class", "slick-slide slick-active");+ let caption = d.add(Some(slide), "p");+ let dots = d.add(Some(slider), "ul");+ d.set_attr(dots, "class", "slick-dots");+ let dot = d.add(Some(dots), "li");+ d.set_attr(dot, "id", "slick-slide00");+ let button = d.add(Some(dot), "button");+ assert_eq!(widget_vendor(&d, list), Some("Slick"));+ assert_eq!(widget_vendor(&d, slide), Some("Slick"));+ assert_eq!(widget_vendor(&d, caption), None);+ assert_eq!(widget_vendor(&d, button), Some("Slick"));+ // SuperSlide's wrapper.+ let wrap = d.add(Some(body), "div");+ d.set_attr(wrap, "class", "tempWrap");+ let item = d.add(Some(wrap), "span");+ assert_eq!(widget_vendor(&d, wrap), Some("SuperSlide"));+ assert_eq!(widget_vendor(&d, item), None);+ // react-fast-marquee and Kaltura tag their whole subtree.+ let marquee = d.add(Some(body), "div");+ d.set_attr(marquee, "class", "rfm-marquee-container ");+ let child = d.add(Some(marquee), "div");+ d.set_attr(child, "class", "rfm-child");+ let ticker = d.add(Some(child), "span");+ assert_eq!(widget_vendor(&d, ticker), Some("react-fast-marquee"));+ let player = d.add(Some(body), "div");+ d.set_attr(player, "class", "kaltura-player embed-responsive-item");+ let area = d.add(Some(player), "div");+ d.set_attr(area, "class", "playkit-video-area");+ let video = d.add(Some(area), "video");+ assert_eq!(widget_vendor(&d, video), Some("Kaltura"));+ // Look-alike classes are not the vendors'.+ let other = d.add(Some(body), "div");+ d.set_attr(other, "class", "slick-like rfm tempwrap kaltura");+ assert_eq!(widget_vendor(&d, other), None);+ }+#[test]fn tagged_detail_ends_with_the_vendor() {assert_eq!(diff --git a/crates/foundation/src/rules/types.rs b/crates/foundation/src/rules/types.rsindex 705618048..6b2924754 100644--- a/crates/foundation/src/rules/types.rs+++ b/crates/foundation/src/rules/types.rs@@ -344,6 +344,12 @@ pub struct IconTileOpts {pub sibling_border_radius: f64,pub has_icon_child: bool,pub icon_child_width: f64,+ /// The anchor is a card title set on a non-heading tag (shadcn's+ /// `CardTitle` is a `div.font-semibold`), which the engines recognize+ /// from its type. `false` keeps the h1 to h6 anchor alone, the JS+ /// contract the recorded vectors pin.+ #[serde(default)]+ pub heading_is_card_title: bool,}// ─── resolveSerif / checkItalicSerif ────────────────────────────────────────@@ -383,6 +389,34 @@ pub struct HeroEyebrowOpts {pub sibling_font_weight: Option<String>,pub sibling_color: Option<String>,pub sibling_has_accent_dash_pseudo: bool,+ /// The tracking, in em of the sibling's size, that counts as tracked caps+ /// alongside the fixed 1.6px floor ([`HERO_EYEBROW_TRACKING_PX`]). The+ /// engines pass [`HERO_EYEBROW_TRACKING_EM`]; `None` keeps the fixed floor+ /// alone, which is the JS contract the recorded vectors pin.+ #[serde(default)]+ pub sibling_tracking_floor_em: Option<f64>,+}++/// The fixed tracking floor of the hero eyebrow's tracked-caps signature.+pub const HERO_EYEBROW_TRACKING_PX: f64 = 1.6;++/// The tracking, in em, at which an uppercase label reads as tracked caps+/// whatever its size: Tailwind's `tracking-widest` (0.1em) at 12px is 1.2px,+/// under the fixed floor, and it is the most common eyebrow setting+/// (redoubt.agency). kicker-above-heading's own floor is 0.06em.+pub const HERO_EYEBROW_TRACKING_EM: f64 = 0.08;++/// Whether `letter_spacing_px` at `font_size_px` is tracked caps for the hero+/// eyebrow: at least the fixed floor, or, where the engine passes one, at+/// least `floor_em` of the size.+pub fn hero_eyebrow_tracked(letter_spacing_px: f64, font_size_px: f64, floor_em: Option<f64>) -> bool {+ if letter_spacing_px >= HERO_EYEBROW_TRACKING_PX {+ return true;+ }+ match floor_em {+ Some(em) if font_size_px > 0.0 => letter_spacing_px > 0.0 && letter_spacing_px >= font_size_px * em - 1e-9,+ _ => false,+ }}// ─── checkKickerAboveHeading ────────────────────────────────────────────────diff --git a/crates/html/src/adapters.rs b/crates/html/src/adapters.rsindex 5c158e81a..2b7b8f944 100644--- a/crates/html/src/adapters.rs+++ b/crates/html/src/adapters.rs@@ -262,7 +262,17 @@ pub fn collect_kicker_candidates(doc: &StaticDocument) -> Vec<KickerCandidate> {}) {continue;}- if heading_tag == "h1" && heading_font_size >= 48.0 && kicker_letter_spacing >= 1.6 {+ // The hero rule takes a tracked label over a display h1, at eyebrow+ // size once its em floor is what counts.+ if heading_tag == "h1"+ && heading_font_size >= 48.0+ && (kicker_letter_spacing >= 1.6 || kicker_font_size <= 14.0)+ && impeccable_core::checks::rules::hero_eyebrow_tracked(+ kicker_letter_spacing,+ kicker_font_size,+ Some(impeccable_core::checks::rules::HERO_EYEBROW_TRACKING_EM),+ )+ {continue;}candidates.push(KickerCandidate {@@ -1138,6 +1148,7 @@ pub fn check_element_icon_tile(el: &StaticElement<'_>, tag: &str) -> Vec<RuleHitsibling_border_radius: resolve_border_radius_px(sib_style, sib_width),has_icon_child: icon_child.is_some() || has_inline_emoji_icon,icon_child_width: icon_width,+ heading_is_card_title: false,})}@@ -1197,6 +1208,7 @@ pub fn check_element_hero_eyebrow(sibling_font_weight: Some(font_weight_raw.to_string()),sibling_color: Some(color_raw.to_string()),sibling_has_accent_dash_pseudo: el.doc.has_accent_dash_pseudo(sibling.id()),+ sibling_tracking_floor_em: Some(impeccable_core::checks::rules::HERO_EYEBROW_TRACKING_EM),})}