@@ -221,8 +221,9 @@ class FontSize extends BaseGatherer {
221
221
222
222
const nodeIndex = doc . layout . nodeIndex [ layoutIndex ] ;
223
223
const styles = doc . layout . styles [ layoutIndex ] ;
224
- const [ fontSizeStringId ] = styles ;
224
+ const [ fontSizeStringId , visibilityStringId ] = styles ;
225
225
const fontSize = getFloat ( fontSizeStringId ) ;
226
+ const visibility = getString ( visibilityStringId ) ;
226
227
227
228
const parentIndex = nodes . parentIndex [ nodeIndex ] ;
228
229
const grandParentIndex = nodes . parentIndex [ parentIndex ] ;
@@ -234,6 +235,7 @@ class FontSize extends BaseGatherer {
234
235
nodeIndex,
235
236
backendNodeId : nodes . backendNodeId [ nodeIndex ] ,
236
237
fontSize,
238
+ visibility,
237
239
textLength : getTextLength ( text ) ,
238
240
parentNode : {
239
241
...parentNode ,
@@ -257,17 +259,24 @@ class FontSize extends BaseGatherer {
257
259
let failingTextLength = 0 ;
258
260
259
261
for ( const textNodeData of this . getTextNodesInLayoutFromSnapshot ( snapshot ) ) {
262
+ if ( textNodeData . visibility === 'hidden' ) {
263
+ continue ;
264
+ }
265
+
260
266
totalTextLength += textNodeData . textLength ;
261
- if ( textNodeData . fontSize < MINIMAL_LEGIBLE_FONT_SIZE_PX ) {
262
- // Once a bad TextNode is identified, its parent Node is needed.
263
- failingTextLength += textNodeData . textLength ;
264
- failingNodes . push ( {
265
- nodeId : 0 , // Set later in fetchFailingNodeSourceRules.
266
- parentNode : textNodeData . parentNode ,
267
- textLength : textNodeData . textLength ,
268
- fontSize : textNodeData . fontSize ,
269
- } ) ;
267
+
268
+ if ( textNodeData . fontSize >= MINIMAL_LEGIBLE_FONT_SIZE_PX ) {
269
+ continue ;
270
270
}
271
+
272
+ // Once a bad TextNode is identified, its parent Node is needed.
273
+ failingTextLength += textNodeData . textLength ;
274
+ failingNodes . push ( {
275
+ nodeId : 0 , // Set later in fetchFailingNodeSourceRules.
276
+ parentNode : textNodeData . parentNode ,
277
+ textLength : textNodeData . textLength ,
278
+ fontSize : textNodeData . fontSize ,
279
+ } ) ;
271
280
}
272
281
273
282
return { totalTextLength, failingTextLength, failingNodes} ;
@@ -294,7 +303,7 @@ class FontSize extends BaseGatherer {
294
303
295
304
// Get the computed font-size style of every node.
296
305
const snapshot = await session . sendCommand ( 'DOMSnapshot.captureSnapshot' , {
297
- computedStyles : [ 'font-size' ] ,
306
+ computedStyles : [ 'font-size' , 'visibility' ] ,
298
307
} ) ;
299
308
300
309
const {
0 commit comments