This commit is contained in:
Josh at WLTechBlog
2025-12-09 14:25:47 -07:00
parent 8d7566cad6
commit c68187e942
2 changed files with 67 additions and 8 deletions

View File

@@ -9298,9 +9298,28 @@ func (d *Daemon) checkContrast(tabID string, selector string, timeout int) (*Con
}
}
const fgColor = style.color;
const fontSize = style.fontSize;
const fontWeight = style.fontWeight;
// Get the actual text-bearing element for accurate color detection
// If the element has child elements with text, use the first visible child's color
let textElement = element;
let textStyle = style;
// Check if element has child elements (not just text nodes)
const childElements = Array.from(element.children).filter(child => {
const childText = child.textContent.trim();
if (!childText) return false;
const childStyle = window.getComputedStyle(child);
return childStyle.display !== 'none' && childStyle.visibility !== 'hidden';
});
// If there are visible child elements with text, use the first one's color
if (childElements.length > 0) {
textElement = childElements[0];
textStyle = window.getComputedStyle(textElement);
}
const fgColor = textStyle.color;
const fontSize = textStyle.fontSize;
const fontWeight = textStyle.fontWeight;
// Three-tier background detection with progressive fallback
let bgColor = null;