use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class ComputedCSSStyleDeclaration method getRightWithInheritance.
/**
* Returns the CSS {@code right} attribute, replacing inherited values with the actual parent values.
* @return the CSS {@code right} attribute, replacing inherited values with the actual parent values
*/
public String getRightWithInheritance() {
String right = getRight();
if (INHERIT.equals(right)) {
final HTMLElement parent = (HTMLElement) getElement().getParentElement();
if (parent == null) {
right = AUTO;
} else {
final ComputedCSSStyleDeclaration style = parent.getWindow().getComputedStyle(parent, null);
right = style.getRightWithInheritance();
}
}
return right;
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class ComputedCSSStyleDeclaration method getTop.
/**
* Returns the computed top (Y coordinate), relative to the node's parent's top edge.
* @param includeMargin whether or not to take the margin into account in the calculation
* @param includeBorder whether or not to take the border into account in the calculation
* @param includePadding whether or not to take the padding into account in the calculation
* @return the computed top (Y coordinate), relative to the node's parent's top edge
*/
public int getTop(final boolean includeMargin, final boolean includeBorder, final boolean includePadding) {
int top = 0;
if (null == top_) {
final String p = getPositionWithInheritance();
if (ABSOLUTE.equals(p)) {
top = getTopForAbsolutePositionWithInheritance();
} else {
// Calculate the vertical displacement caused by *previous* siblings.
DomNode prev = getElement().getDomNodeOrDie().getPreviousSibling();
boolean prevHadComputedTop = false;
while (prev != null && !prevHadComputedTop) {
if (prev instanceof HtmlElement) {
final Element e = prev.getScriptableObject();
final ComputedCSSStyleDeclaration style = e.getWindow().getComputedStyle(e, null);
// only previous block elements are counting
final String display = style.getDisplay();
if (isBlock(display)) {
int prevTop = 0;
if (style.top_ == null) {
final String prevPosition = style.getPositionWithInheritance();
if (ABSOLUTE.equals(prevPosition)) {
prevTop += style.getTopForAbsolutePositionWithInheritance();
} else {
if (RELATIVE.equals(prevPosition)) {
final String t = style.getTopWithInheritance();
prevTop += pixelValue(t);
}
}
} else {
prevHadComputedTop = true;
prevTop += style.top_;
}
prevTop += style.getCalculatedHeight(true, true);
final int margin = pixelValue(style.getMarginTop());
prevTop += margin;
top += prevTop;
}
}
prev = prev.getPreviousSibling();
}
// If the position is relative, we also need to add the specified "top" displacement.
if (RELATIVE.equals(p)) {
final String t = getTopWithInheritance();
top += pixelValue(t);
}
}
top_ = Integer.valueOf(top);
} else {
top = top_.intValue();
}
if (includeMargin) {
final int margin = pixelValue(getMarginTop());
top += margin;
}
if (includeBorder) {
final int border = pixelValue(getBorderTopWidth());
top += border;
}
if (includePadding) {
final int padding = getPaddingTopValue();
top += padding;
}
return top;
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class ComputedCSSStyleDeclaration method getPositionWithInheritance.
/**
* Returns the CSS {@code position} attribute, replacing inherited values with the actual parent values.
* @return the CSS {@code position} attribute, replacing inherited values with the actual parent values
*/
public String getPositionWithInheritance() {
String p = getStyleAttribute(POSITION, true);
if (INHERIT.equals(p)) {
final HTMLElement parent = (HTMLElement) getElement().getParentElement();
if (parent == null) {
p = STATIC;
} else {
final ComputedCSSStyleDeclaration style = parent.getWindow().getComputedStyle(parent, null);
p = style.getPositionWithInheritance();
}
}
return p;
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project htmlunit by HtmlUnit.
the class CSSImportRule method getStyleSheet.
/**
* Returns the style sheet referred to by this rule.
* @return the style sheet referred to by this rule
*/
@JsxGetter
public CSSStyleSheet getStyleSheet() {
if (importedStylesheet_ == null) {
final CSSStyleSheet owningSheet = getParentStyleSheet();
final HTMLElement ownerNode = owningSheet.getOwnerNode();
final CSSStyleSheet importedSheet = owningSheet.getImportedStyleSheet(getImportRule());
importedStylesheet_ = new CSSStyleSheet(null, ownerNode.getWindow(), importedSheet.getWrappedSheet(), importedSheet.getUri());
}
return importedStylesheet_;
}
use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement in project jenkins by jenkinsci.
the class ViewTest method newJob_descriptionSupportsHtml.
@Test
public void newJob_descriptionSupportsHtml() throws Exception {
CustomizableTLID customizableTLID = j.jenkins.getExtensionList(TopLevelItemDescriptor.class).get(CustomizableTLID.class);
customizableTLID.customId = "html-desc";
customizableTLID.customDescription = "Super <strong>looong</strong> description";
JenkinsRule.WebClient wc = j.createWebClient();
HtmlPage page = wc.goTo("view/all/newJob");
Object result = page.executeJavaScript("document.querySelector('.html-desc .desc strong')").getJavaScriptResult();
assertThat(result, instanceOf(HTMLElement.class));
assertThat(((HTMLElement) result).getTagName(), is("STRONG"));
}
Aggregations