// No need to calculate displacement caused by sibling nodes.
left = pixelValue(l);
}
else if ("absolute".equals(p) && !"auto".equals(r)) {
// Need to calculate the horizontal displacement caused by *all* siblings.
final HTMLElement parent = getElement().getParentHTMLElement();
final int parentWidth = parent.jsxGet_currentStyle().getCalculatedWidth(false, false);
left = parentWidth - pixelValue(r);
}
else if ("fixed".equals(p) && "auto".equals(l)) {
// Fixed to the location at which the browser puts it via normal element flowing.
final HTMLElement parent = getElement().getParentHTMLElement();
left = pixelValue(parent.jsxGet_currentStyle().getLeftWithInheritance());
}
else if ("static".equals(p)) {
// We need to calculate the horizontal displacement caused by *previous* siblings.
left = 0;
for (DomNode n = getDomNodeOrDie(); n != null; n = n.getPreviousSibling()) {
if (n.getScriptObject() instanceof HTMLElement) {
final HTMLElement e = (HTMLElement) n.getScriptObject();
final String d = e.jsxGet_currentStyle().jsxGet_display();
if ("block".equals(d)) {
break;
}
else if (!"none".equals(d)) {
left += e.jsxGet_currentStyle().getCalculatedWidth(true, true);
}
}
else if (n.getScriptObject() instanceof Text) {
left += n.getTextContent().length() * PIXELS_PER_CHAR;
}