ViewModelInfo infoFromPoint(MouseEvent e) {
checkDocument();
Range r = docRange.createRange();
InlineText fndTxt = null;
Box box = panel.getRootLayer().find(panel.getLayoutContext(), e.getX(), e.getY(), true);
if (box == null) {
return null;
}
Element elt = null;
int offset = 0;
InlineLayoutBox ilb = null;
boolean containsWholeIlb = false;
if (box instanceof InlineLayoutBox) {
ilb = (InlineLayoutBox) box;
} else {
for (; ilb == null;) {
List ilbs = getInlineLayoutBoxes(box, false);
for (int i = ilbs.size() - 1; i >= 0; i--) {
InlineLayoutBox ilbt = (InlineLayoutBox) ilbs.get(i);
if (ilbt.getAbsY() <= e.getY() && ilbt.getAbsX() <= e.getX()) {
if (ilb == null || (ilbt.getAbsY() > ilb.getAbsY())
|| (ilbt.getAbsY() == ilb.getAbsY() && ilbt.getX() > ilb.getX())) {
if (ilbt.isContainsVisibleContent()) {
boolean hasDecentTextNode = false;
int x = ilbt.getAbsX();
for (Iterator it = ilbt.getInlineChildren().iterator(); it
.hasNext();) {
Object o = it.next();
if (o instanceof InlineText) {
InlineText txt = (InlineText) o;
if (txt.getTextNode() != null) {
hasDecentTextNode = true;
break;
}
}
}
if (hasDecentTextNode) {
ilb = ilbt;
}
}
}
containsWholeIlb = true;
}
}
if (ilb == null) {
if (box.getParent() == null) {
return null;
}
box = box.getParent();
}
}
}
int x = ilb.getAbsX();
InlineText lastItxt = null;