https://drafts.csswg.org/cssom-view/#dom-element-checkvisibility
The spec mentions "shadow-including ancestor" multiple times, but this doesn't match CSS rendering. CSS rendering uses the flat tree, not the shadow-including tree.
This makes a difference when you involve slots.
In fact it looks like Chrome uses the flat tree in the implementation too: https://source.chromium.org/chromium/chromium/src/+/main:third_party/blink/renderer/core/dom/element.cc;l=9073?q=Element::checkVisibility&ss=chromium
cc @tabatkins @josepharhar @vmpstr