use of com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration in project htmlunit by HtmlUnit.
the class HTMLElement method getOffsetParentInternal.
private Object getOffsetParentInternal(final boolean returnNullIfFixed) {
DomNode currentElement = getDomNodeOrDie();
if (currentElement.getParentNode() == null) {
return null;
}
final HTMLElement htmlElement = currentElement.getScriptableObject();
if (returnNullIfFixed && "fixed".equals(htmlElement.getStyle().getStyleAttribute(StyleAttributes.Definition.POSITION, true))) {
return null;
}
final ComputedCSSStyleDeclaration style = htmlElement.getWindow().getComputedStyle(htmlElement, null);
final String position = style.getPositionWithInheritance();
final boolean staticPos = "static".equals(position);
while (currentElement != null) {
final DomNode parentNode = currentElement.getParentNode();
if (parentNode instanceof HtmlBody || (staticPos && parentNode instanceof HtmlTableDataCell) || (staticPos && parentNode instanceof HtmlTable)) {
return parentNode.getScriptableObject();
}
if (parentNode != null && parentNode.getScriptableObject() instanceof HTMLElement) {
final HTMLElement parentElement = parentNode.getScriptableObject();
final ComputedCSSStyleDeclaration parentStyle = parentElement.getWindow().getComputedStyle(parentElement, null);
final String parentPosition = parentStyle.getPositionWithInheritance();
if (!"static".equals(parentPosition)) {
return parentNode.getScriptableObject();
}
}
currentElement = currentElement.getParentNode();
}
return null;
}
use of com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration in project htmlunit by HtmlUnit.
the class HtmlSerializerInnerOuterText method whiteSpaceStyle.
private static Mode whiteSpaceStyle(final DomNode domNode, final Mode defaultMode) {
if (domNode instanceof DomElement) {
final Page page = domNode.getPage();
if (page != null) {
final WebWindow window = page.getEnclosingWindow();
if (window.getWebClient().getOptions().isCssEnabled()) {
DomNode node = domNode;
while (node != null) {
if (node instanceof DomElement) {
final ComputedCSSStyleDeclaration style = window.getComputedStyle((DomElement) domNode, null);
final String value = style.getStyleAttribute(Definition.WHITE_SPACE, false);
if (StringUtils.isNoneEmpty(value)) {
if ("normal".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_NORMAL;
}
if ("nowrap".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_NORMAL;
}
if ("pre".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_PRE;
}
if ("pre-wrap".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_PRE;
}
if ("pre-line".equalsIgnoreCase(value)) {
return Mode.WHITE_SPACE_PRE_LINE;
}
}
}
node = node.getParentNode();
}
}
}
}
return defaultMode;
}
Aggregations