int left = 0;
final HTMLElement offsetParent = getOffsetParent();
// Add the offset for this node.
DomNode node = getDomNodeOrDie();
HTMLElement element = (HTMLElement) node.getScriptObject();
left += element.jsxGet_currentStyle().getLeft(true, false, false);
// If this node is absolutely positioned, we're done.
final String position = element.jsxGet_currentStyle().getPositionWithInheritance();
if ("absolute".equals(position)) {
return left;
}
// Add the offset for the ancestor nodes.
node = node.getParentNode();
while (node != null && node.getScriptObject() != offsetParent) {
if (node.getScriptObject() instanceof HTMLElement) {
element = (HTMLElement) node.getScriptObject();
left += element.jsxGet_currentStyle().getLeft(true, true, true);
}
node = node.getParentNode();
}
if (offsetParent != null) {
left += offsetParent.jsxGet_currentStyle().getMarginLeft();
left += offsetParent.jsxGet_currentStyle().getPaddingLeft();