|
1629 | 1629 | return contentOverlapIssues(root, time); |
1630 | 1630 | }; |
1631 | 1631 |
|
1632 | | - // Frozen-sweep guard (#U10, checkPipeline.ts): a compact per-sample |
1633 | | - // fingerprint of every visible element's box, opacity, and rendered text |
1634 | | - // state, in DOM order. Node |
1635 | | - // calls this once per seeked grid point and compares the strings across the |
1636 | | - // whole run — if every sample produces the identical string, the seek never |
1637 | | - // actually moved anything and the whole audit run is unreliable. Deliberately |
1638 | | - // a single opaque string (not a structured array) since Node only ever needs |
1639 | | - // equality, not per-element diffing. |
1640 | | - // Pixel-only media motion (a 2D/WebGL canvas repainting or a playing video |
1641 | | - // without any element moving) is invisible to a DOM-state fingerprint |
1642 | | - // and false-positives sweep_static. Downsample each visible canvas/video to |
1643 | | - // 8x8 and fold its pixels into the fingerprint. Tainted, zero-sized, or |
1644 | | - // unreadable media hashes to a constant — no worse than DOM-state-only |
1645 | | - // detection and never a new false negative for DOM-motion compositions. |
1646 | | - // Media inside iframes is intentionally outside this fingerprint: it lives |
1647 | | - // in a separate document, and cross-origin frames are inaccessible under SOP. |
1648 | | - function mediaPixelHash(element) { |
1649 | | - try { |
1650 | | - const rect = element.getBoundingClientRect(); |
1651 | | - const sourceWidth = element.videoWidth || element.width || rect.width; |
1652 | | - const sourceHeight = element.videoHeight || element.height || rect.height; |
1653 | | - if (!sourceWidth || !sourceHeight) return "x"; |
1654 | | - const off = document.createElement("canvas"); |
1655 | | - off.width = 8; |
1656 | | - off.height = 8; |
1657 | | - const ctx = off.getContext("2d"); |
1658 | | - if (!ctx) return "x"; |
1659 | | - ctx.drawImage(element, 0, 0, 8, 8); |
1660 | | - const data = ctx.getImageData(0, 0, 8, 8).data; |
1661 | | - let hash = 0; |
1662 | | - for (let i = 0; i < data.length; i++) hash = (hash * 31 + data[i]) >>> 0; |
1663 | | - return String(hash); |
1664 | | - } catch { |
1665 | | - return "x"; |
1666 | | - } |
1667 | | - } |
1668 | | - |
1669 | | - function foldFingerprintField(hash, value) { |
1670 | | - hash ^= value.length; |
1671 | | - hash = Math.imul(hash, 16777619); |
1672 | | - for (let i = 0; i < value.length; i++) { |
1673 | | - hash ^= value.charCodeAt(i); |
1674 | | - hash = Math.imul(hash, 16777619); |
1675 | | - } |
1676 | | - return hash; |
1677 | | - } |
1678 | | - |
1679 | | - function cssFingerprintValue(value) { |
1680 | | - return value === "none" || value === "normal" ? "" : value || ""; |
1681 | | - } |
1682 | | - |
1683 | | - function foldCounterState(hash, style) { |
1684 | | - hash = foldFingerprintField(hash, cssFingerprintValue(style.counterReset)); |
1685 | | - hash = foldFingerprintField(hash, cssFingerprintValue(style.counterIncrement)); |
1686 | | - return foldFingerprintField(hash, cssFingerprintValue(style.counterSet)); |
1687 | | - } |
1688 | | - |
1689 | | - function counterStateHash(style) { |
1690 | | - const reset = cssFingerprintValue(style.counterReset); |
1691 | | - const increment = cssFingerprintValue(style.counterIncrement); |
1692 | | - const set = cssFingerprintValue(style.counterSet); |
1693 | | - if (!reset && !increment && !set) return ""; |
1694 | | - let hash = 2166136261; |
1695 | | - hash = foldCounterState(hash, style); |
1696 | | - return (hash >>> 0).toString(36); |
1697 | | - } |
1698 | | - |
1699 | | - function foldLiveControlState(hash, element) { |
1700 | | - if (element.tagName === "INPUT") { |
1701 | | - hash = foldFingerprintField(hash, element.type || ""); |
1702 | | - hash = foldFingerprintField(hash, element.value || ""); |
1703 | | - hash = foldFingerprintField(hash, element.checked ? "1" : "0"); |
1704 | | - return foldFingerprintField(hash, element.indeterminate ? "1" : "0"); |
1705 | | - } |
1706 | | - if (element.tagName === "TEXTAREA") { |
1707 | | - return foldFingerprintField(hash, element.value || ""); |
1708 | | - } |
1709 | | - if (element.tagName !== "SELECT") return foldFingerprintField(hash, ""); |
1710 | | - hash = foldFingerprintField(hash, String(element.selectedIndex)); |
1711 | | - hash = foldFingerprintField(hash, element.value || ""); |
1712 | | - for (let i = 0; i < element.options.length; i++) { |
1713 | | - hash = foldFingerprintField(hash, element.options[i].selected ? "1" : "0"); |
1714 | | - } |
1715 | | - return hash; |
1716 | | - } |
1717 | | - |
1718 | | - function textualStateHash(element, style) { |
1719 | | - // Chromium resolves attr() here, so pseudo computed content is the |
1720 | | - // platform-owned rendered value rather than a CSS expression to reparse. |
1721 | | - const before = getComputedStyle(element, "::before"); |
1722 | | - const after = getComputedStyle(element, "::after"); |
1723 | | - // Visible descendants are fingerprinted separately; direct nodes prevent |
1724 | | - // a hidden descendant's text mutation from masquerading as visible motion. |
1725 | | - let directText = ""; |
1726 | | - for (const node of directTextNodes(element)) { |
1727 | | - directText += node.textContent || ""; |
1728 | | - } |
1729 | | - let hash = 2166136261; |
1730 | | - hash = foldFingerprintField(hash, directText); |
1731 | | - hash = foldLiveControlState(hash, element); |
1732 | | - hash = foldFingerprintField(hash, cssFingerprintValue(before.content)); |
1733 | | - hash = foldFingerprintField(hash, cssFingerprintValue(after.content)); |
1734 | | - hash = foldCounterState(hash, style); |
1735 | | - hash = foldCounterState(hash, before); |
1736 | | - hash = foldCounterState(hash, after); |
1737 | | - return (hash >>> 0).toString(36); |
1738 | | - } |
1739 | | - |
1740 | | - window.__hyperframesLayoutGeometry = function collectLayoutGeometry() { |
1741 | | - const root = |
1742 | | - document.querySelector("[data-composition-id][data-width][data-height]") || |
1743 | | - document.querySelector("[data-composition-id]") || |
1744 | | - document.body; |
1745 | | - const allElements = [root, ...root.querySelectorAll("*")]; |
1746 | | - const elements = allElements.filter((element) => isVisibleElement(element)); |
1747 | | - const parts = elements.map((element) => { |
1748 | | - const rect = toRect(element.getBoundingClientRect()); |
1749 | | - const opacity = round(opacityChain(element)); |
1750 | | - // Variable-font axis animation (font-variation-settings) is a real, |
1751 | | - // visible motion channel that moves no geometry and no opacity, so a |
1752 | | - // box+opacity+text fingerprint reads it as a frozen timeline. Worse in a |
1753 | | - // DUPLEXED face (Recursive holds an identical advance width at every |
1754 | | - // weight by design), where not even the line width shifts — the whole |
1755 | | - // run then false-positives sweep_static. Fold the computed axis string |
1756 | | - // in; it is "normal" for every element that does not use it, so this |
1757 | | - // adds nothing to the fingerprint of an ordinary composition. |
1758 | | - const style = getComputedStyle(element); |
1759 | | - const axes = style.fontVariationSettings; |
1760 | | - const textState = textualStateHash(element, style); |
1761 | | - return `${rect.left},${rect.top},${rect.width},${rect.height},${opacity},${ |
1762 | | - axes && axes !== "normal" ? axes : "" |
1763 | | - },${textState}`; |
1764 | | - }); |
1765 | | - const visibleElements = new Set(elements); |
1766 | | - for (let ancestor = root.parentElement; ancestor; ancestor = ancestor.parentElement) { |
1767 | | - const state = counterStateHash(getComputedStyle(ancestor)); |
1768 | | - if (state) parts.push(`c:${state}`); |
1769 | | - } |
1770 | | - // Counter declarations can live on zero-box owners while a visible |
1771 | | - // descendant's ::before/::after paints the resulting value. |
1772 | | - for (const element of allElements) { |
1773 | | - if (visibleElements.has(element)) continue; |
1774 | | - const state = counterStateHash(getComputedStyle(element)); |
1775 | | - if (state) parts.push(`c:${state}`); |
1776 | | - } |
1777 | | - // img shares the same pixel-only-motion blind spot as canvas/video: an |
1778 | | - // equal-size, equal-position opaque src/visibility swap moves no |
1779 | | - // geometry and no opacity. mediaPixelHash already handles it generically |
1780 | | - // (drawImage accepts any CanvasImageSource; width/height fall back to |
1781 | | - // rect.width/height same as canvas/video), so only the element selector |
1782 | | - // needed widening. |
1783 | | - for (const media of root.querySelectorAll("canvas, video, img")) { |
1784 | | - if (!isVisibleElement(media)) continue; |
1785 | | - parts.push(`p:${mediaPixelHash(media)}`); |
1786 | | - } |
1787 | | - return parts.join("|"); |
1788 | | - }; |
| 1632 | + // The frozen-sweep fingerprint (window.__hyperframesLayoutGeometry, #U10 in |
| 1633 | + // checkPipeline.ts) lives in motion-signature.browser.js, the single owner |
| 1634 | + // of "what counts as motion" shared with motion-sample.browser.js's |
| 1635 | + // liveness signature. |
1789 | 1636 |
|
1790 | 1637 | // Rotation-pivot sampling (rotation_pivot_drift). Per sample, report every |
1791 | 1638 | // rotatable candidate's bbox center, size, and current rotation angle. Node |
|
0 commit comments