Search in sources :

Example 1 with HTMLIFrameElement

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

the class WebClient method resolveWindow.

private WebWindow resolveWindow(final WebWindow opener, final String name) {
    if (name == null || name.isEmpty() || TARGET_SELF.equals(name)) {
        return opener;
    }
    if (TARGET_PARENT.equals(name)) {
        return opener.getParentWindow();
    }
    if (TARGET_TOP.equals(name)) {
        return opener.getTopWindow();
    }
    if (TARGET_BLANK.equals(name)) {
        return null;
    }
    // first search for frame windows inside our window hierarchy
    WebWindow window = opener;
    while (true) {
        final Page page = window.getEnclosedPage();
        if (page != null && page.isHtmlPage()) {
            try {
                final FrameWindow frame = ((HtmlPage) page).getFrameByName(name);
                final ScriptableObject scriptable = frame.getFrameElement().getScriptableObject();
                if (scriptable instanceof HTMLIFrameElement) {
                    ((HTMLIFrameElement) scriptable).onRefresh();
                }
                return frame;
            } catch (final ElementNotFoundException e) {
            // Fall through
            }
        }
        if (window == window.getParentWindow()) {
            // TODO: should getParentWindow() return null on top windows?
            break;
        }
        window = window.getParentWindow();
    }
    try {
        return getWebWindowByName(name);
    } catch (final WebWindowNotFoundException e) {
    // Fall through - a new window will be created below
    }
    return null;
}
Also used : ScriptableObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject) XHtmlPage(com.gargoylesoftware.htmlunit.html.XHtmlPage) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HTMLIFrameElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLIFrameElement) XHtmlPage(com.gargoylesoftware.htmlunit.html.XHtmlPage) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) FrameWindow(com.gargoylesoftware.htmlunit.html.FrameWindow)

Example 2 with HTMLIFrameElement

use of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLIFrameElement 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

HTMLIFrameElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLIFrameElement)2 StyleElement (com.gargoylesoftware.htmlunit.css.StyleElement)1 BaseFrameElement (com.gargoylesoftware.htmlunit.html.BaseFrameElement)1 DomElement (com.gargoylesoftware.htmlunit.html.DomElement)1 FrameWindow (com.gargoylesoftware.htmlunit.html.FrameWindow)1 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)1 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)1 XHtmlPage (com.gargoylesoftware.htmlunit.html.XHtmlPage)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 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