* @see <a href="http://www.w3.org/TR/REC-CSS2/box.html">Box Model</a>
* @see <a href="http://dump.testsuite.org/2006/dom/style/offset/spec">Reverse Engineering by Anne van Kesteren</a>
*/
public Object jsxGet_offsetParent() {
Object offsetParent = Context.getUndefinedValue();
DomNode currentElement = getDomNodeOrDie();
final HTMLElement htmlElement = (HTMLElement) currentElement.getScriptObject();
final ComputedCSSStyleDeclaration style = htmlElement.jsxGet_currentStyle();
final String position = style.getPositionWithInheritance();
final boolean ie = getBrowserVersion().isIE();
final boolean staticPos = "static".equals(position);
final boolean fixedPos = "fixed".equals(position);
final boolean useTables = ((ie && (staticPos || fixedPos)) || (!ie && staticPos));
while (currentElement != null) {
final DomNode parentNode = currentElement.getParentNode();
if (parentNode instanceof HtmlBody
|| (useTables && parentNode instanceof HtmlTableDataCell)
|| (useTables && parentNode instanceof HtmlTable)) {
offsetParent = parentNode.getScriptObject();
break;
}
if (parentNode != null && parentNode.getScriptObject() instanceof HTMLElement) {
final HTMLElement parentElement = (HTMLElement) parentNode.getScriptObject();
final ComputedCSSStyleDeclaration parentStyle = parentElement.jsxGet_currentStyle();
final String parentPosition = parentStyle.getPositionWithInheritance();
final boolean parentIsStatic = "static".equals(parentPosition);
final boolean parentIsFixed = "fixed".equals(parentPosition);
if ((ie && !parentIsStatic && !parentIsFixed) || (!ie && !parentIsStatic)) {
offsetParent = parentNode.getScriptObject();
break;
}
}
currentElement = currentElement.getParentNode();