| 71 | } |
| 72 | |
| 73 | fn interactive_accessibility_node(node: &Value) -> Option<Value> { |
| 74 | let object = node.as_object()?; |
| 75 | let children = node |
| 76 | .get("children") |
| 77 | .and_then(Value::as_array) |
| 78 | .map(|children| { |
| 79 | children |
| 80 | .iter() |
| 81 | .filter_map(interactive_accessibility_node) |
| 82 | .collect::<Vec<_>>() |
| 83 | }) |
| 84 | .unwrap_or_default(); |
| 85 | |
| 86 | if !is_interactive_accessibility_node(node) && children.is_empty() { |
| 87 | return None; |
| 88 | } |
| 89 | |
| 90 | let mut output = object.clone(); |
| 91 | if children.is_empty() { |
| 92 | output.remove("children"); |
| 93 | } else { |
| 94 | output.insert("children".to_owned(), Value::Array(children)); |
| 95 | } |
| 96 | Some(Value::Object(output)) |
| 97 | } |
| 98 | |
| 99 | fn is_interactive_accessibility_node(node: &Value) -> bool { |
| 100 | if bool_field(node, &["hidden", "isHidden"]).unwrap_or(false) { |