htmlunit-2.7

esponse;
import com.gargoylesoftware.htmlunit.html.DomAttr;
import com.gargoylesoftware.htmlunit.html.DomComment;
import com.gargoylesoftware.htmlunit.html.DomDocumentFragment;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.DomText;
import com.gargoylesoftware.htmlunit.html.FrameWindow;
import com.gargoylesoftware.htmlunit.html.HtmlDivision;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.html.impl.SimpleRange;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement;
import com.gargoylesoftware.htmlunit.xml.XmlUtil;
import java.io.IOException;
import java.util.Map;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

public class Document
  extends EventNode
{
  private static final long serialVersionUID = 3700830050839613384L;
  private static final Log LOG = LogFactory.getLog(Document.class);
  private Window window_;
  private DOMImplementation implementation_;
  private String designMode_;
  
  public void setWindow(Window window)
  {
    window_ = window;
  }
  
  public Location jsxGet_location()
  {
    return window_.jsxGet_location();
  }
  
  public void jsxSet_location(String location)
    throws IOException
  {
    window_.jsxSet_location(location);
  }
  
  public String jsxGet_referrer()
  {
    String referrer = (String)getPage().getWebResponse().getRequestSettings().getAdditionalHeaders().get("Referer");
    if (referrer == null) {
      return "";
    }
    return referrer;
  }
  
  public Element jsxGet_documentElement()
  {
    Object documentElement = getPage().getDocumentElement();
    if (documentElement == null) {
      return null;
    }
    return (Element)getScriptableFor(documentElement);
  }
  
  public SimpleScriptable jsxGet_doctype()
  {
    Object documentType = getPage().getDoctype();
    if (documentType == null) {
      return null;
    }
    return getScriptableFor(documentType);
  }
  
  public String jsxGet_designMode()
  {
    if (designMode_ == null) {
      if (getBrowserVersion().isIE())
      {
        if ((getWindow().getWebWindow() instanceof FrameWindow)) {
          designMode_ = "Inherit";
        } else {
          designMode_ = "Off";
        }
      }
      else {
        designMode_ = "off";
      }
    }
    return designMode_;
  }
  
  public void jsxSet_designMode(String mode)
  {
    boolean ie = getBrowserVersion().isIE();
    if (ie)
    {
      if ((!"on".equalsIgnoreCase(mode)) && (!"off".equalsIgnoreCase(mode)) && (!"inherit".equalsIgnoreCase(mode))) {
        throw Context.reportRuntimeError("Invalid document.designMode value '" + mode + "'.");
      }
      if (!(getWindow().getWebWindow() instanceof FrameWindow)) {
        return;
      }
      if ("on".equalsIgnoreCase(mode)) {
        designMode_ = "On";
      } else if ("off".equalsIgnoreCase(mode)) {
        designMode_ = "Off";
      } else if ("inherit".equalsIgnoreCase(mode)) {
        designMode_ = "Inherit";
      }
    }
    else if ("on".equalsIgnoreCase(mode))
    {
      designMode_ = "on";
      SgmlPage page = getPage();
      if ((page instanceof HtmlPage))
      {
        HtmlPage htmlPage = (HtmlPage)page;
        DomNode child = htmlPage.getBody().getFirstChild();
        DomNode rangeNode = child != null ? child : htmlPage.getBody();
        htmlPage.setSelectionRange(new SimpleRange(rangeNode, 0));
      }
    }
    else if ("off".equalsIgnoreCase(mode))
    {
      designMode_ = "off";
    }
  }
  
  protected SgmlPage getPage()
  {
    return (SgmlPage)getDomNodeOrDie();
  }
  
  public Object jsxGet_defaultView()
  {
    return getWindow();
  }
  
  public Object jsxFunction_createDocumentFragment()
  {
    DomDocumentFragment fragment = getDomNodeOrDie().getPage().createDomDocumentFragment();
    DocumentFragment node = new DocumentFragment();
    node.setParentScope(getParentScope());
    node.setPrototype(getPrototype(node.getClass()));
    node.setDomNode(fragment);
    return getScriptableFor(fragment);
  }
  
  public Attr jsxFunction_createAttribute(String attributeName)
  {
    return (Attr)getPage().createAttribute(attributeName).getScriptObject();
  }
  
  public BoxObject jsxFunction_getBoxObjectFor(HTMLElement element)
  {
    return element.getBoxObject();
  }
  
  public Object jsxFunction_importNode(Node importedNode, boolean deep)
  {
    return importedNode.getDomNodeOrDie().cloneNode(deep).getScriptObject();
  }
  
  public DOMImplementation jsxGet_implementation()
  {
    if (implementation_ == null)
    {
      implementation_ = new DOMImplementation();
      implementation_.setParentScope(getWindow());
      implementation_.setPrototype(getPrototype(implementation_.getClass()));
    }
    return implementation_;
  }
  
  public void jsxFunction_captureEvents(String type) {}
  
  public XPathNSResolver jsxFunction_createNSResolver(Node nodeResolver)
  {
    XPathNSResolver resolver = new XPathNSResolver();
    resolver.setElement(nodeResolver);
    resolver.setParentScope(getWindow());
    resolver.setPrototype(getPrototype(resolver.getClass()));
    return resolver;
  }
  
  public Object jsxFunction_createTextNode(String newData)
  {
    Object result = NOT_FOUND;
    try
    {
      DomNode domNode = new DomText(getDomNodeOrDie().getPage(), newData);
      Object jsElement = getScriptableFor(domNode);
      if (jsElement == NOT_FOUND) {
        LOG.debug("createTextNode(" + newData + ") cannot return a result as there isn't a JavaScript object for the DOM node " + domNode.getClass().getName());
      } else {
        result = jsElement;
      }
    }
    catch (ElementNotFoundException e) {}
    return result;
  }
  
  public Object jsxFunction_createComment(String comment)
  {
    DomNode domNode = new DomComment(getDomNodeOrDie().getPage(), comment);
    return getScriptableFor(domNode);
  }
  
  public XPathResult jsxFunction_evaluate(String expression, Node contextNode, Object resolver, int type, Object result)
  {
    XPathResult xPathResult = (XPathResult)result;
    if (xPathResult == null)
    {
      xPathResult = new XPathResult();
      xPathResult.setParentScope(getParentScope());
      xPathResult.setPrototype(getPrototype(xPathResult.getClass()));
    }
    xPathResult.init(contextNode.getDomNodeOrDie().getByXPath(expression), type);
    return xPathResult;
  }
  
  public Object jsxFunction_createElement(String tagName)
  {
    Object result = NOT_FOUND;
    try
    {
      BrowserVersion browserVersion = getBrowserVersion();
      if ((tagName.startsWith("<")) && (tagName.endsWith(">")) && (browserVersion.isFirefox()))
      {
        tagName = tagName.substring(1, tagName.length() - 1);
        if (!tagName.matches("\\w+"))
        {
          LOG.error("Unexpected exception occurred while parsing HTML snippet");
          throw Context.reportRuntimeError("Unexpected exception occurred while parsing HTML snippet: " + tagName);
        }
      }
      SgmlPage page = getPage();
      org.w3c.dom.Element element = page.createElement(tagName);
      Object jsElement = getScriptableFor(element);
      if (jsElement == NOT_FOUND) {
        LOG.debug("createElement(" + tagName + ") cannot return a result as there isn't a JavaScript object for the element " + element.getClass().getName());
      } else {
        result = jsElement;
      }
    }
    catch (ElementNotFoundException e) {}
    return result;
  }
  
  public Object jsxFunction_createElementNS(String namespaceURI, String qualifiedName)
  {
    org.w3c.dom.Element element;
    org.w3c.dom.Element element;
    if ((getBrowserVersion().isFirefox()) && ("http://www.mozilla.org/keymaster/gatekeeper/there.is.only.xul".equals(namespaceURI)))
    {
      element = new HtmlDivision(namespaceURI, qualifiedName, getPage(), null);
    }
    else
    {
      org.w3c.dom.Element element;
      if ("http://www.w3.org/1999/xhtml".equals(namespaceURI)) {
        element = getPage().createElementNS(namespaceURI, qualifiedName);
      } else {
        element = new DomElement(namespaceURI, qualifiedName, getPage(), null);
      }
    }
    return getScriptableFor(element);
  }
  
  public HTMLCollection jsxFunction_getElementsByTagName(String tagName)
  {
    HTMLCollection collection = new HTMLCollection(this);
    String exp;
    String exp;
    if (tagName.equals("*")) {
      exp = "//*";
    } else {
      exp = "//*[lower-case(local-name()) = '" + tagName.toLowerCase() + "']";
    }
    collection.init(getDomNodeOrDie(), exp);
    return collection;
  }
  
  public Object jsxFunction_getElementsByTagNameNS(Object namespaceURI, String localName)
  {
    DomNode domNode = getDomNodeOrDie();
    HTMLCollection collection = new HTMLCollection(this);
    String xpath;
    String xpath;
    if ((namespaceURI == null) || (namespaceURI.equals("*")))
    {
      xpath = ".//*[local-name()='" + localName + "']";
    }
    else
    {
      String prefix = XmlUtil.lookupPrefix((DomElement)domNode, Context.toString(namespaceURI));
      xpath = ".//" + prefix + ':' + localName;
    }
    collection.init(domNode, xpath);
    return collection;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Document
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import org.apache.commons.lang.StringUtils;

public class EventNode
  extends Node
{
  private static final long serialVersionUID = 4894810197917509182L;
  
  public void jsxSet_onclick(Object handler)
  {
    setEventHandlerProp("onclick", handler);
  }
  
  public Object jsxGet_onclick()
  {
    return getEventHandlerProp("onclick");
  }
  
  public void jsxSet_ondblclick(Object handler)
  {
    setEventHandlerProp("ondblclick", handler);
  }
  
  public Object jsxGet_ondblclick()
  {
    return getEventHandlerProp("ondblclick");
  }
  
  public void jsxSet_onblur(Object handler)
  {
    setEventHandlerProp("onblur", handler);
  }
  
  public Object jsxGet_onblur()
  {
    return getEventHandlerProp("onblur");
  }
  
  public void jsxSet_onfocus(Object handler)
  {
    setEventHandlerProp("onfocus", handler);
  }
  
  public Object jsxGet_onfocus()
  {
    return getEventHandlerProp("onfocus");
  }
  
  public void jsxSet_onfocusin(Object handler)
  {
    setEventHandlerProp("onfocusin", handler);
  }
  
  public Object jsxGet_onfocusin()
  {
    return getEventHandlerProp("onfocusin");
  }
  
  public void jsxSet_onfocusout(Object handler)
  {
    setEventHandlerProp("onfocusout", handler);
  }
  
  public Object jsxGet_onfocusout()
  {
    return getEventHandlerProp("onfocusout");
  }
  
  public void jsxSet_onkeydown(Object handler)
  {
    setEventHandlerProp("onkeydown", handler);
  }
  
  public Object jsxGet_onkeydown()
  {
    return getEventHandlerProp("onkeydown");
  }
  
  public void jsxSet_onkeypress(Object handler)
  {
    setEventHandlerProp("onkeypress", handler);
  }
  
  public Object jsxGet_onkeypress()
  {
    return getEventHandlerProp("onkeypress");
  }
  
  public void jsxSet_onkeyup(Object handler)
  {
    setEventHandlerProp("onkeyup", handler);
  }
  
  public Object jsxGet_onkeyup()
  {
    return getEventHandlerProp("onkeyup");
  }
  
  public void jsxSet_onmousedown(Object handler)
  {
    setEventHandlerProp("onmousedown", handler);
  }
  
  public Object jsxGet_onmousedown()
  {
    return getEventHandlerProp("onmousedown");
  }
  
  public void jsxSet_onmousemove(Object handler)
  {
    setEventHandlerProp("onmousemove", handler);
  }
  
  public Object jsxGet_onmousemove()
  {
    return getEventHandlerProp("onmousemove");
  }
  
  public void jsxSet_onmouseout(Object handler)
  {
    setEventHandlerProp("onmouseout", handler);
  }
  
  public Object jsxGet_onmouseout()
  {
    return getEventHandlerProp("onmouseout");
  }
  
  public void jsxSet_onmouseover(Object handler)
  {
    setEventHandlerProp("onmouseover", handler);
  }
  
  public Object jsxGet_onmouseover()
  {
    return getEventHandlerProp("onmouseover");
  }
  
  public void jsxSet_onmouseup(Object handler)
  {
    setEventHandlerProp("onmouseup", handler);
  }
  
  public Object jsxGet_onmouseup()
  {
    return getEventHandlerProp("onmouseup");
  }
  
  public void jsxSet_oncontextmenu(Object handler)
  {
    setEventHandlerProp("oncontextmenu", handler);
  }
  
  public Object jsxGet_oncontextmenu()
  {
    return getEventHandlerProp("oncontextmenu");
  }
  
  public void jsxSet_onresize(Object handler)
  {
    setEventHandlerProp("onresize", handler);
  }
  
  public Object jsxGet_onresize()
  {
    return getEventHandlerProp("onresize");
  }
  
  public void jsxSet_onpropertychange(Object handler)
  {
    setEventHandlerProp("onpropertychange", handler);
  }
  
  public Object jsxGet_onpropertychange()
  {
    return getEventHandlerProp("onpropertychange");
  }
  
  public void jsxSet_onerror(Object handler)
  {
    setEventHandlerProp("onerror", handler);
  }
  
  public Object jsxGet_onerror()
  {
    return getEventHandlerProp("onerror");
  }
  
  public boolean jsxFunction_fireEvent(String type, Event event)
  {
    if (event == null) {
      event = new MouseEvent();
    }
    String cleanedType = StringUtils.removeStart(type.toLowerCase(), "on");
    if (MouseEvent.isMouseEvent(cleanedType)) {
      event.setPrototype(getPrototype(MouseEvent.class));
    } else {
      event.setPrototype(getPrototype(Event.class));
    }
    event.setParentScope(getWindow());
    
    event.jsxSet_cancelBubble(false);
    event.jsxSet_returnValue(Boolean.TRUE);
    event.jsxSet_srcElement(this);
    event.setEventType(cleanedType);
    
    fireEvent(event);
    return ((Boolean)event.jsxGet_returnValue()).booleanValue();
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.EventNode
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.html.DomAttr;
import com.gargoylesoftware.htmlunit.html.DomElement;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.javascript.NamedNodeMap;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection;
import com.gargoylesoftware.htmlunit.xml.XmlUtil;
import java.util.Map;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Scriptable;

public class Element
  extends EventNode
{
  private static final long serialVersionUID = 5616690634173934926L;
  private NamedNodeMap attributes_;
  
  public HTMLCollection jsxFunction_selectNodes(String expression)
  {
    HTMLCollection collection = new HTMLCollection(this);
    collection.init(getDomNodeOrDie(), expression);
    return collection;
  }
  
  public Object jsxFunction_selectSingleNode(String expression)
  {
    HTMLCollection collection = jsxFunction_selectNodes(expression);
    if (collection.jsxGet_length() > 0) {
      return collection.get(0, collection);
    }
    return null;
  }
  
  public final String jsxGet_tagName()
  {
    return jsxGet_nodeName();
  }
  
  public Object jsxGet_attributes()
  {
    if (attributes_ == null) {
      attributes_ = createAttributesObject();
    }
    return attributes_;
  }
  
  protected NamedNodeMap createAttributesObject()
  {
    return new NamedNodeMap(getDomNodeOrDie());
  }
  
  public Object jsxFunction_getAttribute(String attributeName, Integer flags)
  {
    boolean ie = getBrowserVersion().isIE();
    attributeName = fixAttributeName(attributeName);
    Object value;
    Object value;
    if ((ie) && (flags != null) && (flags.intValue() == 2) && ("style".equalsIgnoreCase(attributeName))) {
      value = "";
    } else {
      value = getDomNodeOrDie().getAttribute(attributeName);
    }
    if (value == DomElement.ATTRIBUTE_NOT_DEFINED)
    {
      value = null;
      if (ie) {
        for (Scriptable object = this; object != null; object = object.getPrototype())
        {
          Object property = object.get(attributeName, this);
          if (property != NOT_FOUND)
          {
            value = property;
            break;
          }
        }
      }
    }
    return value;
  }
  
  protected String fixAttributeName(String attributeName)
  {
    return attributeName;
  }
  
  public void jsxFunction_setAttribute(String name, String value)
  {
    getDomNodeOrDie().setAttribute(name, value);
  }
  
  public Object jsxFunction_getElementsByTagName(String tagName)
  {
    DomNode domNode = getDomNodeOrDie();
    HTMLCollection collection = new HTMLCollection(this);
    collection.init(domNode, ".//*[local-name()='" + tagName + "']");
    return collection;
  }
  
  public Object jsxFunction_getAttributeNode(String name)
  {
    Map<String, DomAttr> attributes = getDomNodeOrDie().getAttributesMap();
    for (DomAttr attr : attributes.values()) {
      if (attr.getName().equals(name)) {
        return attr.getScriptObject();
      }
    }
    return null;
  }
  
  public String jsxGet_text()
  {
    StringBuilder buffer = new StringBuilder();
    toText(getDomNodeOrDie(), buffer);
    return buffer.toString();
  }
  
  private void toText(DomNode node, StringBuilder buffer)
  {
    switch (node.getNodeType())
    {
    case 10: 
    case 12: 
      return;
    case 3: 
    case 4: 
    case 7: 
    case 8: 
      buffer.append(node.getNodeValue());
      break;
    }
    for (DomNode child : node.getChildren()) {
      switch (child.getNodeType())
      {
      case 1: 
        toText(child, buffer);
        break;
      case 3: 
      case 4: 
        buffer.append(child.getNodeValue());
      }
    }
  }
  
  public Object jsxFunction_getElementsByTagNameNS(Object namespaceURI, String localName)
  {
    DomNode domNode = getDomNodeOrDie();
    HTMLCollection collection = new HTMLCollection(this);
    String xpath;
    String xpath;
    if ((namespaceURI == null) || (namespaceURI.equals("*")))
    {
      xpath = ".//" + localName;
    }
    else
    {
      String prefix = XmlUtil.lookupPrefix((DomElement)domNode, Context.toString(namespaceURI));
      xpath = ".//" + prefix + ':' + localName;
    }
    collection.init(domNode, xpath);
    return collection;
  }
  
  public boolean jsxFunction_hasAttribute(String name)
  {
    return getDomNodeOrDie().hasAttribute(name);
  }
  
  public DomElement getDomNodeOrDie()
  {
    return (DomElement)super.getDomNodeOrDie();
  }
  
  public void jsxFunction_removeAttribute(String name)
  {
    getDomNodeOrDie().removeAttribute(name);
    if (getBrowserVersion().isIE()) {
      delete(name);
    }
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Element
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

public class PluginArray
  extends SimpleArray
{
  private static final long serialVersionUID = -7794563255599220149L;
  
  public void jsxFunction_refresh(boolean reloadDocuments) {}
  
  protected String getItemName(Object element)
  {
    return ((Plugin)element).jsxGet_name();
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.PluginArray
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.BrowserVersion;
import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement;
import java.util.LinkedList;
import net.sourceforge.htmlunit.corejs.javascript.Context;

public class MouseEvent
  extends UIEvent
{
  private static final long serialVersionUID = 1990705559211878370L;
  public static final String TYPE_CLICK = "click";
  public static final String TYPE_DBL_CLICK = "dblclick";
  public static final String TYPE_MOUSE_OVER = "mouseover";
  public static final String TYPE_MOUSE_MOVE = "mousemove";
  public static final String TYPE_MOUSE_OUT = "mouseout";
  public static final String TYPE_MOUSE_DOWN = "mousedown";
  public static final String TYPE_MOUSE_UP = "mouseup";
  public static final String TYPE_CONTEXT_MENU = "contextmenu";
  public static final int BUTTON_LEFT = 0;
  public static final int BUTTON_MIDDLE = 1;
  public static final int BUTTON_RIGHT = 2;
  private static final int[] buttonCodeToIE = { 1, 4, 2 };
  private Integer screenX_;
  private Integer screenY_;
  private Integer clientX_;
  private Integer clientY_;
  private int button_;
  
  public MouseEvent()
  {
    screenX_ = Integer.valueOf(0);
    screenY_ = Integer.valueOf(0);
    setDetail(1L);
  }
  
  public MouseEvent(DomNode domNode, String type, boolean shiftKey, boolean ctrlKey, boolean altKey, int button)
  {
    super(domNode, type);
    setShiftKey(shiftKey);
    setCtrlKey(ctrlKey);
    setAltKey(altKey);
    setMetaKey(false);
    if ((button != 0) && (button != 1) && (button != 2)) {
      throw new IllegalArgumentException("Invalid button code: " + button);
    }
    button_ = button;
    if ("dblclick".equals(type)) {
      setDetail(2L);
    } else {
      setDetail(1L);
    }
  }
  
  public int jsxGet_clientX()
  {
    if (clientX_ == null) {
      clientX_ = Integer.valueOf(jsxGet_screenX());
    }
    return clientX_.intValue();
  }
  
  public int jsxGet_screenX()
  {
    if (screenX_ == null)
    {
      HTMLElement target = (HTMLElement)jsxGet_target();
      screenX_ = Integer.valueOf(target.getPosX() + 10);
    }
    return screenX_.intValue();
  }
  
  public int jsxGet_pageX()
  {
    return jsxGet_screenX();
  }
  
  public int jsxGet_clientY()
  {
    if (clientY_ == null) {
      clientY_ = Integer.valueOf(jsxGet_screenY());
    }
    return clientY_.intValue();
  }
  
  public int jsxGet_screenY()
  {
    if (screenY_ == null)
    {
      HTMLElement target = (HTMLElement)jsxGet_target();
      screenY_ = Integer.valueOf(target.getPosY() + 10);
    }
    return screenY_.intValue();
  }
  
  public int jsxGet_pageY()
  {
    return jsxGet_screenY();
  }
  
  public int jsxGet_button()
  {
    if (getBrowserVersion().isIE())
    {
      if (jsxGet_type().equals("contextmenu")) {
        return 0;
      }
      return buttonCodeToIE[button_];
    }
    return button_;
  }
  
  public int jsxGet_which()
  {
    return button_ + 1;
  }
  
  public void jsxFunction_initMouseEvent(String type, boolean bubbles, boolean cancelable, Object view, int detail, int screenX, int screenY, int clientX, int clientY, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int button, Object relatedTarget)
  {
    jsxFunction_initUIEvent(type, bubbles, cancelable, view, detail);
    screenX_ = Integer.valueOf(screenX);
    screenY_ = Integer.valueOf(screenY);
    clientX_ = Integer.valueOf(clientX);
    clientY_ = Integer.valueOf(clientY);
    setCtrlKey(ctrlKey);
    setAltKey(altKey);
    setShiftKey(shiftKey);
    setMetaKey(metaKey);
    button_ = button;
  }
  
  public static MouseEvent getCurrentMouseEvent()
  {
    LinkedList<Event> events = (LinkedList)Context.getCurrentContext().getThreadLocal("Event#current");
    if ((events != null) && (!events.isEmpty()) && ((events.getLast() instanceof MouseEvent))) {
      return (MouseEvent)events.getLast();
    }
    return null;
  }
  
  static boolean isMouseEvent(String type)
  {
    return ("click".equals(type)) || ("mouseover".equals(type)) || ("mousemove".equals(type)) || ("mouseout".equals(type)) || ("mousedown".equals(type)) || ("mouseup".equals(type)) || ("contextmenu".equals(type));
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.MouseEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.html.DomNode;

public class UIEvent
  extends Event
{
  private static final long serialVersionUID = 269569851849033800L;
  private long detail_;
  private boolean metaKey_;
  
  public UIEvent() {}
  
  public UIEvent(DomNode domNode, String type)
  {
    super(domNode, type);
  }
  
  public long jsxGet_detail()
  {
    return detail_;
  }
  
  protected void setDetail(long detail)
  {
    detail_ = detail;
  }
  
  public Object jsxGet_view()
  {
    return getWindow();
  }
  
  public void jsxFunction_initUIEvent(String type, boolean bubbles, boolean cancelable, Object view, int detail)
  {
    jsxFunction_initEvent(type, bubbles, cancelable);
    
    setDetail(detail);
  }
  
  public boolean jsxGet_metaKey()
  {
    return metaKey_;
  }
  
  protected void setMetaKey(boolean metaKey)
  {
    metaKey_ = metaKey;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.UIEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlPage;
import com.gargoylesoftware.htmlunit.javascript.SimpleScriptable;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLCollection;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement;
import net.sourceforge.htmlunit.corejs.javascript.Context;
import net.sourceforge.htmlunit.corejs.javascript.Undefined;

public class RowContainer
  extends HTMLElement
{
  private static final long serialVersionUID = 3258129146093056308L;
  private HTMLCollection rows_;
  
  public Object jsxGet_rows()
  {
    if (rows_ == null)
    {
      rows_ = new HTMLCollection(this);
      rows_.init(getDomNodeOrDie(), getXPathRows());
    }
    return rows_;
  }
  
  protected String getXPathRows()
  {
    return "./tr";
  }
  
  public void jsxFunction_deleteRow(int rowIndex)
  {
    HTMLCollection rows = (HTMLCollection)jsxGet_rows();
    int rowCount = rows.jsxGet_length();
    if (rowIndex == -1) {
      rowIndex = rowCount - 1;
    }
    boolean rowIndexValid = (rowIndex >= 0) && (rowIndex < rowCount);
    if (rowIndexValid)
    {
      SimpleScriptable row = (SimpleScriptable)rows.jsxFunction_item(new Integer(rowIndex));
      row.getDomNodeOrDie().remove();
    }
  }
  
  public Object jsxFunction_insertRow(Object index)
  {
    int rowIndex = -1;
    if (index != Undefined.instance) {
      rowIndex = (int)Context.toNumber(index);
    }
    HTMLCollection rows = (HTMLCollection)jsxGet_rows();
    int rowCount = rows.jsxGet_length();
    int r;
    int r;
    if ((rowIndex == -1) || (rowIndex == rowCount)) {
      r = Math.max(0, rowCount - 1);
    } else {
      r = rowIndex;
    }
    if ((r < 0) || (r > rowCount)) {
      throw Context.reportRuntimeError("Index or size is negative or greater than the allowed amount (index: " + rowIndex + ", " + rowCount + " rows)");
    }
    return insertRow(r);
  }
  
  public Object insertRow(int index)
  {
    HTMLCollection rows = (HTMLCollection)jsxGet_rows();
    int rowCount = rows.jsxGet_length();
    HtmlElement newRow = ((HtmlPage)getDomNodeOrDie().getPage()).createElement("tr");
    if (rowCount == 0)
    {
      getDomNodeOrDie().appendChild(newRow);
    }
    else
    {
      SimpleScriptable row = (SimpleScriptable)rows.jsxFunction_item(new Integer(index));
      if (index >= rowCount - 1) {
        row.getDomNodeOrDie().getParentNode().appendChild(newRow);
      } else {
        row.getDomNodeOrDie().insertBefore(newRow);
      }
    }
    return getScriptableFor(newRow);
  }
  
  public Object jsxFunction_moveRow(int sourceIndex, int targetIndex)
  {
    HTMLCollection rows = (HTMLCollection)jsxGet_rows();
    int rowCount = rows.jsxGet_length();
    boolean sourceIndexValid = (sourceIndex >= 0) && (sourceIndex < rowCount);
    boolean targetIndexValid = (targetIndex >= 0) && (targetIndex < rowCount);
    if ((sourceIndexValid) && (targetIndexValid))
    {
      SimpleScriptable sourceRow = (SimpleScriptable)rows.jsxFunction_item(new Integer(sourceIndex));
      SimpleScriptable targetRow = (SimpleScriptable)rows.jsxFunction_item(new Integer(targetIndex));
      targetRow.getDomNodeOrDie().insertBefore(sourceRow.getDomNodeOrDie());
      return sourceRow;
    }
    return null;
  }
  
  public String jsxGet_align()
  {
    return getAlign(true);
  }
  
  public void jsxSet_align(String align)
  {
    setAlign(align, false);
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.RowContainer
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLElement;
import com.gargoylesoftware.htmlunit.javascript.host.html.HTMLFormElement;

public class FormChild
  extends HTMLElement
{
  private static final long serialVersionUID = -4795537772440835895L;
  
  public HTMLFormElement jsxGet_form()
  {
    HtmlForm form = getDomNodeOrDie().getEnclosingForm();
    if (form == null) {
      return null;
    }
    return (HTMLFormElement)getScriptableFor(form);
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.FormChild
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.html.DomText;

public class Text
  extends CharacterDataImpl
{
  private static final long serialVersionUID = 3548915177419561974L;
  
  public void initialize() {}
  
  public Object jsxFunction_splitText(int offset)
  {
    DomText domText = (DomText)getDomNodeOrDie();
    return getScriptableFor(domText.splitText(offset));
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.Text
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.html.DomNode;
import com.gargoylesoftware.htmlunit.html.HtmlElement;
import com.gargoylesoftware.htmlunit.html.HtmlForm;
import net.sourceforge.htmlunit.corejs.javascript.Function;

public class FormField
  extends FormChild
{
  private static final long serialVersionUID = 3712016051364495710L;
  
  public void setDomNode(DomNode domNode)
  {
    super.setDomNode(domNode);
    
    HtmlForm form = ((HtmlElement)domNode).getEnclosingForm();
    if (form != null) {
      setParentScope(getScriptableFor(form));
    }
  }
  
  public String jsxGet_value()
  {
    return getDomNodeOrDie().getAttribute("value");
  }
  
  public void jsxSet_value(String newValue)
  {
    getDomNodeOrDie().setAttribute("value", newValue);
  }
  
  public String jsxGet_name()
  {
    return getDomNodeOrDie().getAttribute("name");
  }
  
  public void jsxSet_name(String newName)
  {
    getDomNodeOrDie().setAttribute("name", newName);
  }
  
  public String jsxGet_type()
  {
    return getDomNodeOrDie().getAttribute("type");
  }
  
  public void jsxSet_onchange(Object onchange)
  {
    setEventHandlerProp("onchange", onchange);
  }
  
  public Function jsxGet_onchange()
  {
    return getEventHandler("onchange");
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.FormField
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

public final class CDATASection
  extends Text
{
  private static final long serialVersionUID = -4867436967489711775L;
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.CDATASection
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

public class MutationEvent
  extends Event
{
  private static final long serialVersionUID = 4542119950659582338L;
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.MutationEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.host;

import com.gargoylesoftware.htmlunit.html.DomNode;

public class KeyboardEvent
  extends UIEvent
{
  private static final long serialVersionUID = -2422855531523175841L;
  public static final int DOM_VK_MULTIPLY = 106;
  public static final int DOM_VK_ADD = 107;
  public static final int DOM_VK_SEPARATOR = 108;
  public static final int DOM_VK_SUBTRACT = 109;
  public static final int DOM_VK_DECIMAL = 110;
  public static final int DOM_VK_DIVIDE = 111;
  public static final int DOM_VK_F1 = 112;
  public static final int DOM_VK_F2 = 113;
  public static final int DOM_VK_F3 = 114;
  public static final int DOM_VK_F4 = 115;
  public static final int DOM_VK_F5 = 116;
  public static final int DOM_VK_F6 = 117;
  public static final int DOM_VK_F7 = 118;
  public static final int DOM_VK_F8 = 119;
  public static final int DOM_VK_CLEAR = 12;
  public static final int DOM_VK_F9 = 120;
  public static final int DOM_VK_F10 = 121;
  public static final int DOM_VK_F11 = 122;
  public static final int DOM_VK_F12 = 123;
  public static final int DOM_VK_F13 = 124;
  public static final int DOM_VK_F14 = 125;
  public static final int DOM_VK_F15 = 126;
  public static final int DOM_VK_F16 = 127;
  public static final int DOM_VK_F17 = 128;
  public static final int DOM_VK_F18 = 129;
  public static final int DOM_VK_RETURN = 13;
  public static final int DOM_VK_F19 = 130;
  public static final int DOM_VK_F20 = 131;
  public static final int DOM_VK_F21 = 132;
  public static final int DOM_VK_F22 = 133;
  public static final int DOM_VK_F23 = 134;
  public static final int DOM_VK_F24 = 135;
  public static final int DOM_VK_ENTER = 14;
  public static final int DOM_VK_NUM_LOCK = 144;
  public static final int DOM_VK_SCROLL_LOCK = 145;
  public static final int DOM_VK_SHIFT = 16;
  public static final int DOM_VK_CONTROL = 17;
  public static final int DOM_VK_ALT = 18;
  public static final int DOM_VK_COMMA = 188;
  public static final int DOM_VK_PAUSE = 19;
  public static final int DOM_VK_PERIOD = 190;
  public static final int DOM_VK_SLASH = 191;
  public static final int DOM_VK_BACK_QUOTE = 192;
  public static final int DOM_VK_CAPS_LOCK = 20;
  public static final int DOM_VK_OPEN_BRACKET = 219;
  public static final int DOM_VK_BACK_SLASH = 220;
  public static final int DOM_VK_CLOSE_BRACKET = 221;
  public static final int DOM_VK_QUOTE = 222;
  public static final int DOM_VK_META = 224;
  public static final int DOM_VK_ESCAPE = 27;
  public static final int DOM_VK_CANCEL = 3;
  public static final int DOM_VK_SPACE = 32;
  public static final int DOM_VK_PAGE_UP = 33;
  public static final int DOM_VK_PAGE_DOWN = 34;
  public static final int DOM_VK_END = 35;
  public static final int DOM_VK_HOME = 36;
  public static final int DOM_VK_LEFT = 37;
  public static final int DOM_VK_UP = 38;
  public static final int DOM_VK_RIGHT = 39;
  public static final int DOM_VK_DOWN = 40;
  public static final int DOM_VK_PRINTSCREEN = 44;
  public static final int DOM_VK_INSERT = 45;
  public static final int DOM_VK_DELETE = 46;
  public static final int DOM_VK_0 = 48;
  public static final int DOM_VK_1 = 49;
  public static final int DOM_VK_2 = 50;
  public static final int DOM_VK_3 = 51;
  public static final int DOM_VK_4 = 52;
  public static final int DOM_VK_5 = 53;
  public static final int DOM_VK_6 = 54;
  public static final int DOM_VK_7 = 55;
  public static final int DOM_VK_8 = 56;
  public static final int DOM_VK_9 = 57;
  public static final int DOM_VK_SEMICOLON = 59;
  public static final int DOM_VK_HELP = 6;
  public static final int DOM_VK_EQUALS = 61;
  public static final int DOM_VK_A = 65;
  public static final int DOM_VK_B = 66;
  public static final int DOM_VK_C = 67;
  public static final int DOM_VK_D = 68;
  public static final int DOM_VK_E = 69;
  public static final int DOM_VK_F = 70;
  public static final int DOM_VK_G = 71;
  public static final int DOM_VK_H = 72;
  public static final int DOM_VK_I = 73;
  public static final int DOM_VK_J = 74;
  public static final int DOM_VK_K = 75;
  public static final int DOM_VK_L = 76;
  public static final int DOM_VK_M = 77;
  public static final int DOM_VK_N = 78;
  public static final int DOM_VK_O = 79;
  public static final int DOM_VK_BACK_SPACE = 8;
  public static final int DOM_VK_P = 80;
  public static final int DOM_VK_Q = 81;
  public static final int DOM_VK_R = 82;
  public static final int DOM_VK_S = 83;
  public static final int DOM_VK_T = 84;
  public static final int DOM_VK_U = 85;
  public static final int DOM_VK_V = 86;
  public static final int DOM_VK_W = 87;
  public static final int DOM_VK_X = 88;
  public static final int DOM_VK_Y = 89;
  public static final int DOM_VK_TAB = 9;
  public static final int DOM_VK_Z = 90;
  public static final int DOM_VK_CONTEXT_MENU = 93;
  public static final int DOM_VK_NUMPAD0 = 96;
  public static final int DOM_VK_NUMPAD1 = 97;
  public static final int DOM_VK_NUMPAD2 = 98;
  public static final int DOM_VK_NUMPAD3 = 99;
  public static final int DOM_VK_NUMPAD4 = 100;
  public static final int DOM_VK_NUMPAD5 = 101;
  public static final int DOM_VK_NUMPAD6 = 102;
  public static final int DOM_VK_NUMPAD7 = 103;
  public static final int DOM_VK_NUMPAD8 = 104;
  public static final int DOM_VK_NUMPAD9 = 105;
  private int charCode_;
  
  public KeyboardEvent() {}
  
  public KeyboardEvent(DomNode domNode, String type, int keyCode, boolean shiftKey, boolean ctrlKey, boolean altKey)
  {
    super(domNode, type);
    setKeyCode(Integer.valueOf(keyCode));
    setShiftKey(shiftKey);
    setCtrlKey(ctrlKey);
    setAltKey(altKey);
  }
  
  public void jsxFunction_initKeyEvent(String type, boolean bubbles, boolean cancelable, Object view, boolean ctrlKey, boolean altKey, boolean shiftKey, boolean metaKey, int keyCode, int charCode)
  {
    jsxFunction_initUIEvent(type, bubbles, cancelable, view, 0);
    setCtrlKey(ctrlKey);
    setAltKey(altKey);
    setShiftKey(shiftKey);
    setKeyCode(Integer.valueOf(keyCode));
    setMetaKey(metaKey);
    charCode_ = 0;
  }
  
  public Object jsxGet_charCode()
  {
    return Integer.valueOf(charCode_);
  }
  
  public static int charToKeyCode(char c)
  {
    if ((c >= 'a') && (c <= 'z')) {
      return 'A' + c - 97;
    }
    return c;
  }
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.host.KeyboardEvent
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript;

import net.sourceforge.htmlunit.corejs.javascript.Scriptable;

public abstract interface ScriptableWithFallbackGetter
  extends Scriptable
{
  public abstract Object getWithFallback(String paramString);
}

/* Location:
 * Qualified Name:     com.gargoylesoftware.htmlunit.javascript.ScriptableWithFallbackGetter
 * Java Class Version: 5 (49.0)
 * JD-Core Version:    0.7.1
 */
package com.gargoylesoftware.htmlunit.javascript.background;

import com.gargoylesoftware.htmlunit.Page;
import java.io.Serializable;

public abstract interface JavaScriptJobManager
  extends Serializable
{
  public abstract int getJobCount();
  
  public abstract int addJob(JavaScriptJob paramJavaScriptJob, Page paramPage);
  
  public abstract void removeJob(int paramInt);
  
  public abstract void removeAllJobs();
  
  public abstract void stopJob(int paramInt);
  
  public abstract int waitForJobs(long paramLong);
  
  public abstract int waitForJobsStartingBefore(long paramLong);
  
  public abstract void shutdown()
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43

Further reading...

For more information on Java 1.5 Tiger, you may find Java 1.5 Tiger, A developer's Notebook by D. Flanagan and B. McLaughlin from O'Reilly of interest.

New!JAR listings


Copyright 2006-2019. Infinite Loop Ltd