Skip to content

Commit 619b777

Browse files
🐛 Link newly created accessubility object to existing one while fixing ancestor tree
1 parent 780ba56 commit 619b777

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

openhtmltopdf-pdfbox/src/main/java/com/openhtmltopdf/pdfboxout/PdfBoxAccessibilityHelper.java

+7
Original file line numberDiff line numberDiff line change
@@ -913,7 +913,9 @@ private COSDictionary createMarkedContentDictionary() {
913913

914914
private void ensureAncestorTree(AbstractTreeItem child, Box parent) {
915915
// Walk up the ancestor tree making sure they all have accessibility objects.
916+
boolean newAccessibilityObjectCreated=false;
916917
while (parent != null && parent.getAccessibilityObject() == null) {
918+
newAccessibilityObjectCreated=true;
917919
AbstractStructualElement parentItem = createStructureItem(null, parent);
918920
parent.setAccessiblityObject(parentItem);
919921

@@ -923,6 +925,11 @@ private void ensureAncestorTree(AbstractTreeItem child, Box parent) {
923925
child = parentItem;
924926
parent = parent.getParent();
925927
}
928+
if(newAccessibilityObjectCreated) {
929+
AbstractStructualElement alreadyExistingAccessibilityObject = (AbstractStructualElement) parent.getAccessibilityObject();
930+
child.parent = alreadyExistingAccessibilityObject;
931+
alreadyExistingAccessibilityObject.addChild(child);
932+
}
926933
}
927934

928935
private AbstractStructualElement createStructureItem(StructureType type, Box box) {

0 commit comments

Comments
 (0)