feat: extract CSS contain from browser in Playwright adapter
- Add contain: cs.contain to browser-side style extraction - Parse contain string into bitfield matching CDP extractor schema - Add inline-size to CDP styles.ts contain parser for consistency
This commit is contained in:
@@ -221,6 +221,7 @@ export async function extractStyles(
|
|||||||
if (part === 'style') containFlags |= 8
|
if (part === 'style') containFlags |= 8
|
||||||
if (part === 'strict') containFlags |= 15
|
if (part === 'strict') containFlags |= 15
|
||||||
if (part === 'content') containFlags |= 7
|
if (part === 'content') containFlags |= 7
|
||||||
|
if (part === 'inline-size') containFlags |= 16
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -465,6 +465,7 @@ export async function extractWorldFastGeometry(
|
|||||||
overflowY: cs.overflowY,
|
overflowY: cs.overflowY,
|
||||||
visibility: cs.visibility,
|
visibility: cs.visibility,
|
||||||
pointerEvents: cs.pointerEvents,
|
pointerEvents: cs.pointerEvents,
|
||||||
|
contain: cs.contain,
|
||||||
opacity: Number.parseFloat(cs.opacity) || 1,
|
opacity: Number.parseFloat(cs.opacity) || 1,
|
||||||
zIndex: cs.zIndex,
|
zIndex: cs.zIndex,
|
||||||
lineHeight: Number.parseFloat(cs.lineHeight) || 0,
|
lineHeight: Number.parseFloat(cs.lineHeight) || 0,
|
||||||
@@ -626,7 +627,22 @@ export async function extractWorldFastGeometry(
|
|||||||
zIndexKind.push(s.zIndex === 'auto' ? 0 : 1)
|
zIndexKind.push(s.zIndex === 'auto' ? 0 : 1)
|
||||||
zIndexValue.push(s.zIndex === 'auto' ? 0 : Number.parseInt(s.zIndex, 10) || 0)
|
zIndexValue.push(s.zIndex === 'auto' ? 0 : Number.parseInt(s.zIndex, 10) || 0)
|
||||||
opacity.push(s.opacity)
|
opacity.push(s.opacity)
|
||||||
containFlags.push(0)
|
const csContain = (s as any).contain
|
||||||
|
let flags = 0
|
||||||
|
if (typeof csContain === 'string') {
|
||||||
|
for (const part of csContain.split(/\s+/)) {
|
||||||
|
switch (part) {
|
||||||
|
case 'layout': flags |= 1; break
|
||||||
|
case 'paint': flags |= 2; break
|
||||||
|
case 'size': flags |= 4; break
|
||||||
|
case 'style': flags |= 8; break
|
||||||
|
case 'strict': flags |= 15; break
|
||||||
|
case 'content': flags |= 7; break
|
||||||
|
case 'inline-size': flags |= 16; break
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
containFlags.push(flags)
|
||||||
lineHeight.push(s.lineHeight)
|
lineHeight.push(s.lineHeight)
|
||||||
fontFamilyStringId.push(intern(s.fontFamily))
|
fontFamilyStringId.push(intern(s.fontFamily))
|
||||||
fontSize.push(s.fontSize)
|
fontSize.push(s.fontSize)
|
||||||
|
|||||||
Reference in New Issue
Block a user