Search in sources :

Example 1 with ClientRectList

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

the class Range method getClientRects.

/**
 * Retrieves a collection of rectangles that describes the layout of the contents of an object
 * or range within the client. Each rectangle describes a single line.
 * @return a collection of rectangles that describes the layout of the contents
 */
@JsxFunction
public ClientRectList getClientRects() {
    final Window w = getWindow();
    final ClientRectList rectList = new ClientRectList();
    rectList.setParentScope(w);
    rectList.setPrototype(getPrototype(rectList.getClass()));
    // simple impl for now
    for (final DomNode node : toW3C().containedNodes()) {
        final ScriptableObject scriptable = node.getScriptableObject();
        if (scriptable instanceof HTMLElement) {
            final ClientRect rect = new ClientRect(0, 0, 1, 1);
            rect.setParentScope(w);
            rect.setPrototype(getPrototype(rect.getClass()));
            rectList.add(rect);
        }
    }
    return rectList;
}
Also used : Window(com.gargoylesoftware.htmlunit.javascript.host.Window) DomNode(com.gargoylesoftware.htmlunit.html.DomNode) ScriptableObject(net.sourceforge.htmlunit.corejs.javascript.ScriptableObject) HTMLElement(com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement) ClientRect(com.gargoylesoftware.htmlunit.javascript.host.ClientRect) ClientRectList(com.gargoylesoftware.htmlunit.javascript.host.ClientRectList) JsxFunction(com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)

Aggregations

DomNode (com.gargoylesoftware.htmlunit.html.DomNode)1 JsxFunction (com.gargoylesoftware.htmlunit.javascript.configuration.JsxFunction)1 ClientRect (com.gargoylesoftware.htmlunit.javascript.host.ClientRect)1 ClientRectList (com.gargoylesoftware.htmlunit.javascript.host.ClientRectList)1 Window (com.gargoylesoftware.htmlunit.javascript.host.Window)1 HTMLElement (com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement)1 ScriptableObject (net.sourceforge.htmlunit.corejs.javascript.ScriptableObject)1