Search in sources :

Example 26 with JsxGetter

use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter in project htmlunit by HtmlUnit.

the class HTMLTemplateElement method getContent.

/**
 * @return the value of the {@code content} property
 */
@JsxGetter
public DocumentFragment getContent() {
    final DocumentFragment result = new DocumentFragment();
    result.setPrototype(getPrototype(result.getClass()));
    result.setParentScope(getParentScope());
    result.setDomNode(((HtmlTemplate) getDomNodeOrDie()).getContent());
    return result;
}
Also used : DocumentFragment(com.gargoylesoftware.htmlunit.javascript.host.dom.DocumentFragment) JsxGetter(com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)

Example 27 with JsxGetter

use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter in project htmlunit by HtmlUnit.

the class CSSStyleSheet method getHref.

/**
 * Returns the URL of the stylesheet.
 * @return the URL of the stylesheet
 */
@JsxGetter
public String getHref() {
    if (ownerNode_ != null) {
        final DomNode node = ownerNode_.getDomNodeOrDie();
        if (node instanceof HtmlStyle) {
            return null;
        }
        if (node instanceof HtmlLink) {
            // <link rel="stylesheet" type="text/css" href="..." />
            final HtmlLink link = (HtmlLink) node;
            final String href = link.getHrefAttribute();
            if ("".equals(href) && getBrowserVersion().hasFeature(STYLESHEET_HREF_EMPTY_IS_NULL)) {
                return null;
            }
            // Expand relative URLs.
            try {
                final HtmlPage page = (HtmlPage) link.getPage();
                final URL url = page.getFullyQualifiedUrl(href);
                return url.toExternalForm();
            } catch (final MalformedURLException e) {
                // Log the error and fall through to the return values below.
                LOG.warn(e.getMessage(), e);
            }
        }
    }
    return getUri();
}
Also used : DomNode(com.gargoylesoftware.htmlunit.html.DomNode) MalformedURLException(java.net.MalformedURLException) HtmlStyle(com.gargoylesoftware.htmlunit.html.HtmlStyle) HtmlPage(com.gargoylesoftware.htmlunit.html.HtmlPage) HtmlLink(com.gargoylesoftware.htmlunit.html.HtmlLink) URL(java.net.URL) JsxGetter(com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)

Example 28 with JsxGetter

use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter in project htmlunit by HtmlUnit.

the class Document method getReferrer.

/**
 * Returns the value of the {@code referrer} property.
 * @return the value of the {@code referrer} property
 */
@JsxGetter
public String getReferrer() {
    String referrer = "";
    final WebResponse webResponse = getPage().getWebResponse();
    if (webResponse != null) {
        referrer = webResponse.getWebRequest().getAdditionalHeaders().get(HttpHeader.REFERER);
        if (referrer == null) {
            referrer = "";
        }
    }
    return referrer;
}
Also used : WebResponse(com.gargoylesoftware.htmlunit.WebResponse) JsxGetter(com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)

Example 29 with JsxGetter

use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter in project htmlunit by HtmlUnit.

the class MediaQueryList method isMatches.

/**
 * Returns whether the document currently matches the media query list or not.
 * @return whether the document currently matches the media query list or not
 */
@JsxGetter
public boolean isMatches() {
    final CSSErrorHandler errorHandler = getWindow().getWebWindow().getWebClient().getCssErrorHandler();
    final MediaListImpl mediaList = CSSStyleSheet.parseMedia(errorHandler, media_);
    return CSSStyleSheet.isActive(this, mediaList);
}
Also used : CSSErrorHandler(com.gargoylesoftware.css.parser.CSSErrorHandler) MediaListImpl(com.gargoylesoftware.css.dom.MediaListImpl) JsxGetter(com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)

Example 30 with JsxGetter

use of com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter in project htmlunit by HtmlUnit.

the class Node method getChildNodes.

/**
 * Returns the child nodes of the current element.
 * @return the child nodes of the current element
 */
@JsxGetter
public NodeList getChildNodes() {
    if (childNodes_ == null) {
        final DomNode node = getDomNodeOrDie();
        childNodes_ = new NodeList(node, false) {

            @Override
            protected List<DomNode> computeElements() {
                final List<DomNode> response = new ArrayList<>();
                for (final DomNode child : node.getChildren()) {
                    response.add(child);
                }
                return response;
            }
        };
    }
    return childNodes_;
}
Also used : DomNode(com.gargoylesoftware.htmlunit.html.DomNode) ArrayList(java.util.ArrayList) List(java.util.List) JsxGetter(com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)

Aggregations

JsxGetter (com.gargoylesoftware.htmlunit.javascript.configuration.JsxGetter)64 DomNode (com.gargoylesoftware.htmlunit.html.DomNode)15 MalformedURLException (java.net.MalformedURLException)8 URL (java.net.URL)8 BrowserVersion (com.gargoylesoftware.htmlunit.BrowserVersion)4 HtmlPage (com.gargoylesoftware.htmlunit.html.HtmlPage)4 Window (com.gargoylesoftware.htmlunit.javascript.host.Window)4 ComputedCSSStyleDeclaration (com.gargoylesoftware.htmlunit.javascript.host.css.ComputedCSSStyleDeclaration)4 MediaListImpl (com.gargoylesoftware.css.dom.MediaListImpl)3 WebWindow (com.gargoylesoftware.htmlunit.WebWindow)3 HtmlAnchor (com.gargoylesoftware.htmlunit.html.HtmlAnchor)3 HtmlElement (com.gargoylesoftware.htmlunit.html.HtmlElement)3 HtmlInput (com.gargoylesoftware.htmlunit.html.HtmlInput)3 HtmlTableRow (com.gargoylesoftware.htmlunit.html.HtmlTableRow)3 HTMLElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement)3 JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL (com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_DETECT_WIN_DRIVES_URL)2 JS_ANCHOR_PATHNAME_NONE_FOR_BROKEN_URL (com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_NONE_FOR_BROKEN_URL)2 JS_ANCHOR_PATHNAME_NONE_FOR_NONE_HTTP_URL (com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_NONE_FOR_NONE_HTTP_URL)2 JS_ANCHOR_PATHNAME_PREFIX_WIN_DRIVES_URL (com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PATHNAME_PREFIX_WIN_DRIVES_URL)2 JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL (com.gargoylesoftware.htmlunit.BrowserVersionFeatures.JS_ANCHOR_PROTOCOL_COLON_FOR_BROKEN_URL)2