Search in sources :

Example 1 with HTMLImageElement

use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLImageElement in project htmlunit by HtmlUnit.

the class ComputedCSSStyleDeclaration method getCalculatedHeight.

/**
 * Returns the element's calculated height, taking both relevant CSS and the element's children into account.
 * @return the element's calculated height, taking both relevant CSS and the element's children into account
 */
private int getCalculatedHeight() {
    if (height_ != null) {
        return height_.intValue();
    }
    final Element element = getElement();
    if (element instanceof HTMLImageElement) {
        height_ = ((HtmlImage) element.getDomNodeOrDie()).getHeightOrDefault();
        return height_;
    }
    final boolean isInline = "inline".equals(getDisplay()) && !(element instanceof HTMLIFrameElement);
    // height is ignored for inline elements
    if (isInline || super.getHeight().isEmpty()) {
        final int contentHeight = getContentHeight();
        if (contentHeight > 0) {
            height_ = Integer.valueOf(contentHeight);
            return height_;
        }
    }
    height_ = Integer.valueOf(getEmptyHeight());
    return height_;
}
Also used : HTMLImageElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLImageElement) HTMLIFrameElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLIFrameElement) HTMLBodyElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBodyElement) DomElement(com.gargoylesoftware.htmlunit.html.DomElement) BaseFrameElement(com.gargoylesoftware.htmlunit.html.BaseFrameElement) Element(com.gargoylesoftware.htmlunit.javascript.host.Element) HtmlElement(com.gargoylesoftware.htmlunit.html.HtmlElement) HTMLDataElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDataElement) HTMLDivElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDivElement) HTMLSlotElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLSlotElement) HTMLImageElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLImageElement) HTMLUnknownElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLUnknownElement) HTMLCanvasElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCanvasElement) StyleElement(com.gargoylesoftware.htmlunit.css.StyleElement) HTMLTimeElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLTimeElement) HTMLIFrameElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLIFrameElement) HTMLOutputElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLOutputElement) HTMLLegendElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLegendElement) HTMLElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement)

Aggregations

StyleElement (com.gargoylesoftware.htmlunit.css.StyleElement)1 BaseFrameElement (com.gargoylesoftware.htmlunit.html.BaseFrameElement)1 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)1 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)1 Element (com.gargoylesoftware.htmlunit.javascript.host.Element)1 HTMLBodyElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLBodyElement)1 HTMLCanvasElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCanvasElement)1 HTMLDataElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDataElement)1 HTMLDivElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLDivElement)1 HTMLElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement)1 HTMLIFrameElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLIFrameElement)1 HTMLImageElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLImageElement)1 HTMLLegendElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLLegendElement)1 HTMLOutputElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLOutputElement)1 HTMLSlotElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLSlotElement)1 HTMLTimeElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLTimeElement)1 HTMLUnknownElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLUnknownElement)1