use of elemental.html.ClientRect in project che by eclipse.
the class PositionController method ensureVisibleAndGetRect.
/**
* Ensures that an element is not display: none and is just visibility hidden so we can get an
* accurate client rect.
*/
private static ClientRect ensureVisibleAndGetRect(Element element) {
// Try to get rect and see if it isn't all 0's
ClientRect rect = element.getBoundingClientRect();
double rectSum = rect.getBottom() + rect.getTop() + rect.getLeft() + rect.getRight() + rect.getHeight() + rect.getWidth();
if (rectSum != 0) {
return rect;
}
// We make an attempt to get an accurate measurement of the element
CSSStyleDeclaration style = element.getStyle();
String visibility = CssUtils.setAndSaveProperty(element, "visibility", "hidden");
String display = style.getDisplay();
// if display set to none we remove it and let its normal style show through
if (style.getDisplay().equals("none")) {
style.removeProperty("display");
} else {
// it's likely display: none in a css class so we just have to guess.
// We guess display:block since that's common on containers.
style.setDisplay("block");
}
rect = element.getBoundingClientRect();
style.setDisplay(display);
style.setVisibility(visibility);
return rect;
}
use of elemental.html.ClientRect in project che by eclipse.
the class QuickAssistAssistantImpl method showPossibleQuickAssists.
@Override
public void showPossibleQuickAssists(final int line, final Element anchorElement) {
final ClientRect anchorRect = anchorElement.getBoundingClientRect();
showPossibleQuickAssists(line, anchorRect.getRight(), anchorRect.getBottom());
}
Aggregations