Package com.gargoylesoftware.htmlunit.javascript.host.html

Examples of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement$ProxyDomNode


        }
        else if (index >= nodes_.jsxGet_length()) {
            return Context.getUndefinedValue();
        }

        final HTMLElement element = (HTMLElement) nodes_.jsxFunction_item(new Integer(index));

        final Stylesheet sheet;
        // <style type="text/css"> ... </style>
        if (element instanceof HTMLStyleElement) {
            sheet = ((HTMLStyleElement) element).jsxGet_sheet();
View Full Code Here


     */
    protected static int pixelValue(final HTMLElement element, final CssValue value) {
        final String s = value.get(element);
        if (s.endsWith("%") || (s.length() == 0 && element instanceof HTMLHtmlElement)) {
            final int i = NumberUtils.toInt(s.replaceAll("(\\d+).*", "$1"), 100);
            final HTMLElement parent = element.getParentHTMLElement();
            final int absoluteValue = (parent == null) ? value.getWindowDefaultValue() : pixelValue(parent, value);
            return (int) ((i / 100D) * absoluteValue);
        }
        return pixelValue(s);
    }
View Full Code Here

     */
    @Override
    protected String getStyleAttribute(final String name, final boolean camelCase) {
        String s = super.getStyleAttribute(name, camelCase);
        if (s.length() == 0 && isInheritable(name, camelCase)) {
            final HTMLElement parent = getElement().getParentHTMLElement();
            if (parent != null) {
                s = getWindow().jsxFunction_getComputedStyle(parent, null).getStyleAttribute(name, camelCase);
            }
        }
        return s;
View Full Code Here

     */
    @Override
    public String jsxGet_fontSize() {
        String value = super.jsxGet_fontSize();
        if (value.length() == 0) {
            final HTMLElement parent = getElement().getParentHTMLElement();
            if (parent != null) {
                value = parent.jsxGet_currentStyle().jsxGet_fontSize();
            }
        }
        if (value.length() == 0) {
            value = "16px";
        }
View Full Code Here

                // We're floating; simplistic approximation: text content * pixels per character.
                width = this.<DomNode>getDomNodeOrDie().getTextContent().length() * PIXELS_PER_CHAR;
            }
            else if ("block".equals(display)) {
                // Block elements take up 100% of the parent's width.
                final HTMLElement parentJS = (HTMLElement) parent.getScriptObject();
                final String parentWidth = getWindow().jsxFunction_getComputedStyle(parentJS, null).jsxGet_width();
                if (getBrowserVersion().isIE() && "auto".equals(parentWidth)) {
                    width = WINDOW_WIDTH;
                }
                else {
                    width = pixelValue(parentJS, new CssValue(WINDOW_WIDTH) {
                        @Override public String get(final ComputedCSSStyleDeclaration style) {
                            return style.jsxGet_width();
                        }
                    });
                }
                width -= (getBorderHorizontal() + getPaddingHorizontal());
            }
            else {
                // Inline elements take up however much space is required by their children.
                width = 0;
                for (DomNode child : this.<DomNode>getDomNodeOrDie().getChildren()) {
                    if (child.getScriptObject() instanceof HTMLElement) {
                        final HTMLElement e = (HTMLElement) child.getScriptObject();
                        final int w = e.jsxGet_currentStyle().getCalculatedWidth(true, true);
                        width += w;
                    }
                    else if (child.getScriptObject() instanceof Text) {
                        width += child.getTextContent().length() * PIXELS_PER_CHAR;
                    }
View Full Code Here

        }

        Integer childrenHeight = null;
        for (DomNode child : this.<DomNode>getDomNodeOrDie().getChildren()) {
            if (child.getScriptObject() instanceof HTMLElement) {
                final HTMLElement e = (HTMLElement) child.getScriptObject();
                final int x = e.jsxGet_currentStyle().getCalculatedHeight(true, true);
                childrenHeight = (childrenHeight != null ? childrenHeight + x : x);
            }
        }

        int height;
View Full Code Here

            // No need to calculate displacement caused by sibling nodes.
            left = pixelValue(l);
        }
        else if ("absolute".equals(p) && !"auto".equals(r)) {
            // Need to calculate the horizontal displacement caused by *all* siblings.
            final HTMLElement parent = getElement().getParentHTMLElement();
            final int parentWidth = parent.jsxGet_currentStyle().getCalculatedWidth(false, false);
            left = parentWidth - pixelValue(r);
        }
        else if ("fixed".equals(p) && "auto".equals(l)) {
            // Fixed to the location at which the browser puts it via normal element flowing.
            final HTMLElement parent = getElement().getParentHTMLElement();
            left = pixelValue(parent.jsxGet_currentStyle().getLeftWithInheritance());
        }
        else if ("static".equals(p)) {
            // We need to calculate the horizontal displacement caused by *previous* siblings.
            left = 0;
            for (DomNode n = getDomNodeOrDie(); n != null; n = n.getPreviousSibling()) {
                if (n.getScriptObject() instanceof HTMLElement) {
                    final HTMLElement e = (HTMLElement) n.getScriptObject();
                    final String d = e.jsxGet_currentStyle().jsxGet_display();
                    if ("block".equals(d)) {
                        break;
                    }
                    else if (!"none".equals(d)) {
                        left += e.jsxGet_currentStyle().getCalculatedWidth(true, true);
                    }
                }
                else if (n.getScriptObject() instanceof Text) {
                    left += n.getTextContent().length() * PIXELS_PER_CHAR;
                }
View Full Code Here

     */
    public String getPositionWithInheritance() {
        String p = jsxGet_position();
        if ("inherit".equals(p)) {
            if (getBrowserVersion().hasFeature(CAN_INHERIT_CSS_PROPERTY_VALUES)) {
                final HTMLElement parent = getElement().getParentHTMLElement();
                p = (parent != null ? parent.jsxGet_currentStyle().getPositionWithInheritance() : "static");
            }
            else {
                p = "static";
            }
        }
View Full Code Here

     */
    public String getLeftWithInheritance() {
        String left = jsxGet_left();
        if ("inherit".equals(left)) {
            if (getBrowserVersion().hasFeature(CAN_INHERIT_CSS_PROPERTY_VALUES)) {
                final HTMLElement parent = getElement().getParentHTMLElement();
                left = (parent != null ? parent.jsxGet_currentStyle().getLeftWithInheritance() : "auto");
            }
            else {
                left = "auto";
            }
        }
View Full Code Here

     */
    public String getRightWithInheritance() {
        String right = jsxGet_right();
        if ("inherit".equals(right)) {
            if (getBrowserVersion().hasFeature(CAN_INHERIT_CSS_PROPERTY_VALUES)) {
                final HTMLElement parent = getElement().getParentHTMLElement();
                right = (parent != null ? parent.jsxGet_currentStyle().getRightWithInheritance() : "auto");
            }
            else {
                right = "auto";
            }
        }
View Full Code Here

TOP

Related Classes of com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement$ProxyDomNode

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.