Package com.gargoylesoftware.htmlunit.javascript.host.css

Examples of com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration


                // now looks at the visibility of the frame window
                final BaseFrame frameElement = fw.getFrameElement();
                if (frameElement.isDisplayed()) {
                    final ScriptableObject scriptableObject = frameElement.getScriptObject();
                    final ComputedCSSStyleDeclaration style = ((HTMLElement) scriptableObject).jsxGet_currentStyle();
                    use = (style.getCalculatedWidth(false, false) != 0)
                        && (style.getCalculatedHeight(false, false) != 0);
                }
            }
            if (use) {
                setCurrentWindow(window);
            }
View Full Code Here


     * @param element the element
     * @param pseudo a string specifying the pseudo-element to match (may be <tt>null</tt>)
     * @return the computed style
     */
    public ComputedCSSStyleDeclaration jsxFunction_getComputedStyle(final HTMLElement element, final String pseudo) {
        ComputedCSSStyleDeclaration style;

        synchronized (computedStyles_) {
            style = computedStyles_.get(element);
        }
        if (style != null) {
            return style;
        }

        final CSSStyleDeclaration original = element.jsxGet_style();
        style = new ComputedCSSStyleDeclaration(original);

        final StyleSheetList sheets = document_.jsxGet_styleSheets();
        for (int i = 0; i < sheets.jsxGet_length(); i++) {
            final Stylesheet sheet = (Stylesheet) sheets.jsxFunction_item(i);
            LOG.debug("modifyIfNecessary: " + sheet + ", " + style + ", " + element);
View Full Code Here

     * Returns "clientHeight" attribute.
     * @return the "clientHeight" attribute
     */
    public int jsxGet_clientHeight() {
        final boolean includePadding = !getBrowserVersion().isIE();
        final ComputedCSSStyleDeclaration style = getWindow().jsxFunction_getComputedStyle(this, null);
        return style.getCalculatedHeight(false, includePadding);
    }
View Full Code Here

     * Returns "clientWidth" attribute.
     * @return the "clientWidth" attribute
     */
    public int jsxGet_clientWidth() {
        final boolean includePadding = !getBrowserVersion().isIE();
        final ComputedCSSStyleDeclaration style = getWindow().jsxFunction_getComputedStyle(this, null);
        return style.getCalculatedWidth(false, includePadding);
    }
View Full Code Here

    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;
View Full Code Here

        final MouseEvent event = MouseEvent.getCurrentMouseEvent();
        if (isAncestorOfEventTarget(event)) {
            return super.jsxGet_offsetHeight();
        }

        final ComputedCSSStyleDeclaration style = jsxGet_currentStyle();
        final boolean includeBorder = getBrowserVersion().isIE();
        return style.getCalculatedHeight(includeBorder, true);
    }
View Full Code Here

        final MouseEvent event = MouseEvent.getCurrentMouseEvent();
        if (isAncestorOfEventTarget(event)) {
            return (int) w;
        }

        final ComputedCSSStyleDeclaration style = jsxGet_currentStyle();
        if ("collapse".equals(style.jsxGet_borderCollapse())) {
            final HtmlTableRow row = getRow();
            if (row != null) {
                final HtmlElement thiz = getDomNodeOrDie();
                final List<HtmlTableCell> cells = row.getCells();
                final boolean ie = getBrowserVersion().isIE();
                final boolean leftmost = (cells.indexOf(thiz) == 0);
                final boolean rightmost = (cells.indexOf(thiz) == cells.size() - 1);
                w -= ((ie && leftmost ? 0 : 0.5) * style.getBorderLeft());
                w -= ((ie && rightmost ? 0 : 0.5) * style.getBorderRight());
            }
        }

        return (int) w;
    }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.