1 38 package com.gargoylesoftware.htmlunit.javascript.host; 39 40 import java.io.IOException ; 41 import java.net.MalformedURLException ; 42 import java.net.URL ; 43 import java.util.ArrayList ; 44 import java.util.Arrays ; 45 import java.util.Collection ; 46 import java.util.Collections ; 47 import java.util.Iterator ; 48 import java.util.List ; 49 import java.util.Map ; 50 51 import org.apache.commons.collections.CollectionUtils; 52 import org.jaxen.JaxenException; 53 import org.jaxen.XPath; 54 import org.mozilla.javascript.Context; 55 import org.mozilla.javascript.Function; 56 import org.mozilla.javascript.NativeArray; 57 import org.mozilla.javascript.Scriptable; 58 import org.xml.sax.helpers.AttributesImpl ; 59 60 import com.gargoylesoftware.htmlunit.Page; 61 import com.gargoylesoftware.htmlunit.StringWebResponse; 62 import com.gargoylesoftware.htmlunit.WebClient; 63 import com.gargoylesoftware.htmlunit.WebResponse; 64 import com.gargoylesoftware.htmlunit.WebWindow; 65 import com.gargoylesoftware.htmlunit.html.DomCharacterData; 66 import com.gargoylesoftware.htmlunit.html.DomNode; 67 import com.gargoylesoftware.htmlunit.html.DomText; 68 import com.gargoylesoftware.htmlunit.html.HTMLParser; 69 import com.gargoylesoftware.htmlunit.html.HtmlBody; 70 import com.gargoylesoftware.htmlunit.html.HtmlElement; 71 import com.gargoylesoftware.htmlunit.html.HtmlPage; 72 import com.gargoylesoftware.htmlunit.html.IElementFactory; 73 import com.gargoylesoftware.htmlunit.html.xpath.HtmlUnitXPath; 74 import com.gargoylesoftware.htmlunit.javascript.ElementArray; 75 76 91 public class HTMLElement extends NodeImpl { 92 private static final long serialVersionUID = -6864034414262085851L; 93 private static final int BEHAVIOR_ID_UNKNOWN = -1; 94 private static final int BEHAVIOR_ID_CLIENT_CAPS = 0; 95 private static final int BEHAVIOR_ID_HOMEPAGE = 1; 96 private static final String BEHAVIOR_CLIENT_CAPS = "#default#clientCaps"; 97 private static final String BEHAVIOR_HOMEPAGE = "#default#homePage"; 98 static final String POSITION_BEFORE_BEGIN = "beforeBegin"; 99 static final String POSITION_AFTER_BEGIN = "afterBegin"; 100 static final String POSITION_BEFORE_END = "beforeEnd"; 101 static final String POSITION_AFTER_END = "afterEnd"; 102 103 106 private static final List OUTER_HTML_READONLY = 107 Arrays.asList(new String [] { 108 "caption", "col", "colgroup", "frameset", "html", 109 "tbody", "td", "tfoot", "th", "thead", "tr"}); 110 111 private Style style_; 112 113 116 public HTMLElement() { 117 } 118 119 120 124 public void jsConstructor() { 125 } 126 127 128 133 public Object jsxGet_style() { 134 return style_; 135 } 136 137 138 142 public void setDomNode( final DomNode domNode ) { 143 super.setDomNode(domNode); 144 145 style_ = (Style)makeJavaScriptObject("Style"); 146 style_.initialize(this); 147 } 148 149 150 154 public String jsxGet_id() { 155 return getHtmlElementOrDie().getId(); 156 } 157 158 159 164 public void jsxSet_id( final String newId ) { 165 getHtmlElementOrDie().setId( newId ); 166 } 167 168 169 173 public boolean jsxGet_disabled() { 174 return getHtmlElementOrDie().isAttributeDefined("disabled"); 175 } 176 177 178 182 public void jsxSet_disabled( final boolean disabled ) { 183 final HtmlElement element = getHtmlElementOrDie(); 184 if( disabled ) { 185 element.setAttributeValue("disabled", "disabled"); 186 } 187 else { 188 element.removeAttribute("disabled"); 189 } 190 } 191 192 193 197 public String jsxGet_tagName() { 198 return getHtmlElementOrDie().getTagName().toUpperCase(); 199 } 200 201 202 208 public Object get( final String name, final Scriptable start ) { 209 Object result = super.get( name, start ); 210 if ( result == NOT_FOUND ) { 211 final HtmlElement htmlElement = getHtmlElementOrNull(); 212 if ( htmlElement != null && name.toLowerCase().equals(name)) { 216 final String value = htmlElement.getAttributeValue(name); 217 if (HtmlElement.ATTRIBUTE_NOT_DEFINED != value) { 218 getLog().debug("Found attribute for evalution of property \"" + name 219 + "\" for of " + start); 220 result = value; 221 } 222 } 223 } 224 225 return result; 226 } 227 228 233 public String jsxFunction_getAttribute(final String attributeName) { 234 final String value = getHtmlElementOrDie().getAttributeValue(attributeName); 235 if (value == HtmlElement.ATTRIBUTE_NOT_DEFINED) { 236 return null; 237 } 238 else { 239 return value; 240 } 241 } 242 243 251 public void jsxFunction_setAttribute(final String name, final String value) { 252 getHtmlElementOrDie().setAttributeValue(name, value); 253 } 254 255 260 public void jsxFunction_removeAttribute(final String name) { 261 getHtmlElementOrDie().removeAttribute(name); 262 } 263 264 269 public Object jsxFunction_getAttributeNode(final String attributeName) { 270 final Attribute att = (Attribute) makeJavaScriptObject(Attribute.JS_OBJECT_NAME); 271 att.init(attributeName, getHtmlElementOrDie()); 272 return att; 273 } 274 275 280 public Attribute jsxFunction_setAttributeNode(final Attribute newAtt) { 281 final String name = newAtt.jsxGet_name(); 282 final String value = newAtt.jsxGet_value(); 283 final Attribute replacedAtt = (Attribute) jsxFunction_getAttributeNode(name); 284 replacedAtt.detachFromParent(); 285 getHtmlElementOrDie().setAttributeValue(name, value); 286 return replacedAtt; 287 } 288 289 294 public Object jsxFunction_getElementsByTagName( final String tagName ) { 295 final HtmlElement element = (HtmlElement)getDomNodeOrDie(); 296 final List list = element.getHtmlElementsByTagNames( 297 Collections.singletonList(tagName.toLowerCase())); 298 299 CollectionUtils.transform(list, getTransformerScriptableFor()); 300 301 return new NativeArray( list.toArray() ); 302 } 303 304 308 public Object jsxGet_className() { 309 return getHtmlElementOrDie().getAttributeValue("class"); 310 } 311 312 316 public void jsxSet_className(final String className) { 317 getHtmlElementOrDie().setAttributeValue("class", className); 318 } 319 320 324 public String jsxGet_innerHTML() { 325 final StringBuffer buf = new StringBuffer (); 326 printChildren(buf, getDomNodeOrDie()); 328 329 return buf.toString(); 330 } 331 332 336 public String jsxGet_innerText() { 337 final StringBuffer buf = new StringBuffer (); 338 printChildren(buf, getDomNodeOrDie(), false); 340 341 return buf.toString(); 342 } 343 344 345 352 public String jsxGet_outerHTML() { 353 final StringBuffer buf = new StringBuffer (); 354 printNode(buf, getDomNodeOrDie()); 356 357 return buf.toString(); 358 } 359 360 private void printChildren(final StringBuffer buffer, final DomNode node) { 361 printChildren(buffer, node, true); 362 } 363 364 private void printChildren(final StringBuffer buffer, final DomNode node, final boolean asInnerHTML) { 365 for (final Iterator iter = node.getChildIterator(); iter.hasNext();) { 366 printNode(buffer, (DomNode) iter.next(), asInnerHTML); 367 } 368 } 369 370 private void printNode(final StringBuffer buffer, final DomNode node) { 371 printNode(buffer, node, true); 372 } 373 374 private void printNode( 375 final StringBuffer buffer, final DomNode node, 376 final boolean asInnerHTML) { 377 if (node instanceof DomCharacterData) { 378 buffer.append(node.getNodeValue().replaceAll(" ", " ")); } 380 else if (asInnerHTML) { 381 final HtmlElement htmlElt = (HtmlElement) node; 382 buffer.append("<"); 383 buffer.append(htmlElt.getTagName()); 384 385 for (final Iterator iterator=htmlElt.getAttributeEntriesIterator(); iterator.hasNext(); ) { 387 buffer.append(' ' ); 388 final Map.Entry entry = (Map.Entry ) iterator.next(); 389 buffer.append(entry.getKey()); 390 buffer.append( "=\"" ); 391 buffer.append(entry.getValue()); 392 buffer.append( "\"" ); 393 } 394 if (htmlElt.getFirstChild() == null) { 395 buffer.append("/"); 396 } 397 buffer.append(">"); 398 399 printChildren(buffer, node, asInnerHTML); 400 if (htmlElt.getFirstChild() != null) { 401 buffer.append("</"); 402 buffer.append(htmlElt.getTagName()); 403 buffer.append(">"); 404 } 405 } 406 else { 407 final HtmlElement htmlElement = (HtmlElement) node; 408 if (htmlElement.getTagName().equals("p")) { 409 buffer.append("\r\n"); } 411 412 if (!htmlElement.getTagName().equals("script")) { 413 printChildren(buffer, node, asInnerHTML); 414 } 415 416 } 417 } 418 419 423 public void jsxSet_innerHTML(final String value) { 424 final DomNode domNode = getDomNodeOrDie(); 425 domNode.removeAllChildren(); 426 427 for (final Iterator iter = parseHtmlSnippet(value).iterator(); iter.hasNext();) { 428 final DomNode child = (DomNode) iter.next(); 429 domNode.appendChild(child); 430 } 431 } 432 433 437 public void jsxSet_innerText(final String value) { 438 final DomNode domNode = getDomNodeOrDie(); 439 domNode.removeAllChildren(); 440 441 final DomNode node = new DomText(getDomNodeOrDie().getPage(), value); 442 domNode.appendChild(node); 443 } 444 445 446 453 public void jsxSet_outerHTML(final String value) { 454 final DomNode domNode = getDomNodeOrDie(); 455 456 if (OUTER_HTML_READONLY.contains(domNode.getNodeName())) { 457 throw Context.reportRuntimeError("outerHTML is read-only for tag " + domNode.getNodeName()); 458 } 459 460 for (final Iterator iter = parseHtmlSnippet(value).iterator(); iter.hasNext();) { 461 final DomNode child = (DomNode) iter.next(); 462 domNode.insertBefore(child); 463 } 464 domNode.remove(); 465 } 466 467 472 private Collection parseHtmlSnippet(final String htmlSnippet) { 473 if (htmlSnippet.indexOf('<') >= 0) { 474 final WebClient webClient = getDomNodeOrDie().getPage().getWebClient(); 476 final boolean jsEnabled = webClient.isJavaScriptEnabled(); 477 webClient.setJavaScriptEnabled(false); 480 481 final WebResponse webResp = new StringWebResponse("<html><body>" + htmlSnippet + "</body></html>", 482 getDomNodeOrDie().getPage().getWebResponse().getUrl()); 483 try { 484 final WebWindow pseudoWindow = new WebWindow() { 485 public Page getEnclosedPage() { 486 return null; 487 } 488 public String getName() { 489 return null; 490 } 491 public void setName(final String name) { 492 } 494 public WebWindow getParentWindow() { 495 return null; 496 } 497 public Object getScriptObject() { 498 return null; 499 } 500 public WebWindow getTopWindow() { 501 return null; 502 } 503 public WebClient getWebClient() { 504 return webClient; 505 } 506 public void setEnclosedPage(final Page page) { 507 } 508 public void setScriptObject(final Object scriptObject) { 509 } 510 }; 511 final HtmlPage pseudoPage = HTMLParser.parse(webResp, pseudoWindow); 512 final HtmlBody body = (HtmlBody) pseudoPage.getDocumentElement().getFirstChild(); 513 514 final Collection nodes = new ArrayList (); 515 for (final Iterator iter = body.getChildIterator(); iter.hasNext();) { 516 final DomNode child = (DomNode) iter.next(); 517 nodes.add(copy(child, getHtmlElementOrDie().getPage())); 518 } 519 return nodes; 520 } 521 catch (final Exception e) { 522 getLog().error("Unexpected exception occured while parsing html snippet", e); 523 throw Context.reportRuntimeError("Unexpected exception occured while parsing html snippet: " 524 + e.getMessage()); 525 } 526 finally { 527 webClient.setJavaScriptEnabled(jsEnabled); 529 } 530 } 531 else { 532 final DomNode node = new DomText(getDomNodeOrDie().getPage(), htmlSnippet); 534 return Collections.singleton(node); 535 } 536 } 537 538 546 private DomNode copy(final DomNode node, final HtmlPage page) { 547 final DomNode copy; 548 if (node instanceof DomText) { 549 copy = new DomText(page, node.getNodeValue()); 550 } 551 else { 552 final HtmlElement htmlElt = (HtmlElement) node; 553 final IElementFactory factory = HTMLParser.getFactory(htmlElt.getNodeName()); 554 copy = factory.createElement(page, node.getNodeName(), readAttributes(htmlElt)); 555 for (final Iterator iter = node.getChildIterator(); iter.hasNext();) { 556 final DomNode child = (DomNode) iter.next(); 557 copy.appendChild(copy(child, page)); 558 } 559 } 560 561 return copy; 562 } 563 564 569 protected AttributesImpl readAttributes(final HtmlElement element) { 570 final AttributesImpl attributes = new AttributesImpl (); 571 for (final Iterator iter = element.getAttributeEntriesIterator(); iter.hasNext();) { 572 final Map.Entry entry = (Map.Entry ) iter.next(); 573 final String name = (String ) entry.getKey(); 574 final String value = (String ) entry.getValue(); 575 attributes.addAttribute(null, name, name, null, value); 576 } 577 578 return attributes; 579 } 580 581 589 public void jsxFunction_insertAdjacentHTML(final String where, final String text) { 590 final DomNode currentNode = getDomNodeOrDie(); 591 final DomNode node; 592 final boolean append; 593 594 if (POSITION_AFTER_BEGIN.equals(where)) { 596 if (currentNode.getFirstChild() == null) { 597 node = currentNode; 599 append = true; 600 } 601 else { 602 node = currentNode.getFirstChild(); 604 append = false; 605 } 606 } 607 else if (POSITION_BEFORE_BEGIN.equals(where)) { 608 node = currentNode; 610 append = false; 611 } 612 else if (POSITION_BEFORE_END.equals(where)) { 613 node = currentNode; 615 append = true; 616 } 617 else if (POSITION_AFTER_END.equals(where)) { 618 if (currentNode.getNextSibling() == null) { 619 node = currentNode.getParentNode(); 621 append = true; 622 } 623 else { 624 node = currentNode.getNextSibling(); 626 append = false; 627 } 628 } 629 else { 630 throw Context.reportRuntimeError("Illegal position value: \"" + where + "\""); 631 } 632 633 for (final Iterator iter = parseHtmlSnippet(text).iterator(); iter.hasNext();) { 635 final DomNode child = (DomNode) iter.next(); 636 if (append) { 637 node.appendChild(child); 638 } 639 else { 640 node.insertBefore(child); 641 } 642 } 643 } 644 645 655 public int jsxFunction_addBehavior(final String behavior) { 656 if (BEHAVIOR_CLIENT_CAPS.equalsIgnoreCase(behavior)) { 657 final Class c = getClass(); 658 defineProperty("availHeight", c, 0); 659 defineProperty("availWidth", c, 0); 660 defineProperty("bufferDepth", c, 0); 661 defineProperty("colorDepth", c, 0); 662 defineProperty("connectionType", c, 0); 663 defineProperty("cookieEnabled", c, 0); 664 defineProperty("cpuClass", c, 0); 665 defineProperty("height", c, 0); 666 defineProperty("javaEnabled", c, 0); 667 defineProperty("platform", c, 0); 668 defineProperty("systemLanguage", c, 0); 669 defineProperty("userLanguage", c, 0); 670 defineProperty("width", c, 0); 671 defineFunctionProperties(new String [] {"addComponentRequest"}, c, 0); 672 defineFunctionProperties(new String [] {"clearComponentRequest"}, c, 0); 673 defineFunctionProperties(new String [] {"compareVersions"}, c, 0); 674 defineFunctionProperties(new String [] {"doComponentRequest"}, c, 0); 675 defineFunctionProperties(new String [] {"getComponentVersion"}, c, 0); 676 defineFunctionProperties(new String [] {"isComponentInstalled"}, c, 0); 677 return BEHAVIOR_ID_CLIENT_CAPS; 678 } 679 else if (BEHAVIOR_HOMEPAGE.equalsIgnoreCase(behavior)) { 680 final Class c = getClass(); 681 defineFunctionProperties(new String [] {"isHomePage"}, c, 0); 682 defineFunctionProperties(new String [] {"setHomePage"}, c, 0); 683 defineFunctionProperties(new String [] {"navigateHomePage"}, c, 0); 684 return BEHAVIOR_ID_HOMEPAGE; 685 } 686 else { 687 getLog().warn("Unimplemented behavior: " + behavior); 688 return BEHAVIOR_ID_UNKNOWN; 689 } 690 } 691 692 696 public void jsxFunction_removeBehavior(final int id) { 697 switch (id) { 698 case BEHAVIOR_ID_CLIENT_CAPS: 699 delete("availHeight"); 700 delete("availWidth"); 701 delete("bufferDepth"); 702 delete("colorDepth"); 703 delete("connectionType"); 704 delete("cookieEnabled"); 705 delete("cpuClass"); 706 delete("height"); 707 delete("javaEnabled"); 708 delete("platform"); 709 delete("systemLanguage"); 710 delete("userLanguage"); 711 delete("width"); 712 delete("addComponentRequest"); 713 delete("clearComponentRequest"); 714 delete("compareVersions"); 715 delete("doComponentRequest"); 716 delete("getComponentVersion"); 717 delete("isComponentInstalled"); 718 break; 719 case BEHAVIOR_ID_HOMEPAGE: 720 delete("isHomePage"); 721 delete("setHomePage"); 722 delete("navigateHomePage"); 723 break; 724 default: 725 getLog().warn("Unexpected behavior id: " + id + ". Ignoring."); 726 } 727 } 728 729 731 736 public int getAvailHeight() { 737 return getWindow().jsxGet_screen().jsxGet_availHeight(); 738 } 739 740 745 public int getAvailWidth() { 746 return getWindow().jsxGet_screen().jsxGet_availWidth(); 747 } 748 749 754 public int getBufferDepth() { 755 return getWindow().jsxGet_screen().jsxGet_bufferDepth(); 756 } 757 758 763 public int getColorDepth() { 764 return getWindow().jsxGet_screen().jsxGet_colorDepth(); 765 } 766 767 773 public String getConnectionType() { 774 return "modem"; 775 } 776 777 782 public boolean getCookieEnabled() { 783 return getWindow().jsxGet_navigator().jsxGet_cookieEnabled(); 784 } 785 786 791 public String getCpuClass() { 792 return getWindow().jsxGet_navigator().jsxGet_cpuClass(); 793 } 794 795 800 public int getHeight() { 801 return getWindow().jsxGet_screen().jsxGet_height(); 802 } 803 804 809 public boolean getJavaEnabled() { 810 return getWindow().jsxGet_navigator().jsxFunction_javaEnabled(); 811 } 812 813 818 public String getPlatform() { 819 return getWindow().jsxGet_navigator().jsxGet_platform(); 820 } 821 822 827 public String getSystemLanguage() { 828 return getWindow().jsxGet_navigator().jsxGet_systemLanguage(); 829 } 830 831 836 public String getUserLanguage() { 837 return getWindow().jsxGet_navigator().jsxGet_userLanguage(); 838 } 839 840 845 public int getWidth() { 846 return getWindow().jsxGet_screen().jsxGet_width(); 847 } 848 849 857 public void addComponentRequest(final String id, final String idType, final String minVersion) { 858 getLog().debug("Call to addComponentRequest(" + id + ", " + idType + ", " + minVersion + ") ignored."); 859 } 860 861 866 public void clearComponentRequest() { 867 getLog().debug("Call to clearComponentRequest() ignored."); 868 } 869 870 877 public int compareVersions(final String v1, final String v2) { 878 final int i = v1.compareTo(v2); 879 if(i == 0) { return 0; } 880 else if(i < 0) { return -1; } 881 else { return 1; } 882 } 883 884 889 public boolean doComponentRequest() { 890 return false; 891 } 892 893 900 public String getComponentVersion(final String id, final String idType) { 901 return "1.0"; 902 } 903 904 911 public boolean isComponentInstalled(final String id, final String idType, final String minVersion) { 912 return false; 913 } 914 915 919 protected Window getWindow() { 920 return (Window) getDomNodeOrDie().getPage().getEnclosingWindow().getScriptObject(); 921 } 922 923 925 933 public boolean isHomePage(final String url) { 934 try { 935 final URL newUrl = new URL (url); 936 final URL currentUrl = getDomNodeOrDie().getPage().getWebResponse().getUrl(); 937 final String home = getDomNodeOrDie().getPage().getWebClient().getHomePage(); 938 final boolean sameDomains = newUrl.getHost().equalsIgnoreCase(currentUrl.getHost()); 939 final boolean isHomePage = (home != null && home.equals(url)); 940 return (sameDomains && isHomePage); 941 } 942 catch(final MalformedURLException e) { 943 return false; 944 } 945 } 946 947 952 public void setHomePage(final String url) { 953 getDomNodeOrDie().getPage().getWebClient().setHomePage(url); 954 } 955 956 961 public void navigateHomePage() throws IOException { 962 final WebClient webClient = getDomNodeOrDie().getPage().getWebClient(); 963 webClient.getPage(new URL (webClient.getHomePage())); 964 } 965 966 968 972 public void jsxSet_onclick(final Function onclick) { 973 getHtmlElementOrDie().setEventHandler("onclick", onclick); 974 } 975 976 980 public Function jsxGet_onclick() { 981 return getHtmlElementOrDie().getEventHandler("onclick"); 982 } 983 984 990 public Object jsxGet_children() { 991 final DomNode element = getDomNodeOrDie(); 992 final ElementArray children = (ElementArray) makeJavaScriptObject(ElementArray.JS_OBJECT_NAME); 993 994 try { 995 final XPath xpath = new HtmlUnitXPath("./*", HtmlUnitXPath.buildSubtreeNavigator(element)); 996 children.init(element, xpath); 997 } 998 catch (final JaxenException e) { 999 throw Context.reportRuntimeError("Failed initializing children: " + e.getMessage()); 1001 } 1002 return children; 1003 } 1004 1005 1008 public void jsxSet_ondblclick(final Function ondblclick) { 1009 getHtmlElementOrDie().setEventHandler("ondblclick", ondblclick); 1010 } 1011 1012 1016 public Function jsxGet_ondblclick() { 1017 return getHtmlElementOrDie().getEventHandler("ondblclick"); 1018 } 1019 1020 1024 public void jsxSet_onblur(final Function onblur) { 1025 getHtmlElementOrDie().setEventHandler("onblur", onblur); 1026 } 1027 1028 1032 public Function jsxGet_onblur() { 1033 return getHtmlElementOrDie().getEventHandler("onblur"); 1034 } 1035 1036 1040 public void jsxSet_onfocus(final Function onfocus) { 1041 getHtmlElementOrDie().setEventHandler("onfocus", onfocus); 1042 } 1043 1044 1048 public Function jsxGet_onfocus() { 1049 return getHtmlElementOrDie().getEventHandler("onfocus"); 1050 } 1051 1052 1056 public void jsxSet_onkeydown(final Function onkeydown) { 1057 getHtmlElementOrDie().setEventHandler("onkeydown", onkeydown); 1058 } 1059 1060 1064 public Function jsxGet_onkeydown() { 1065 return getHtmlElementOrDie().getEventHandler("onkeydown"); 1066 } 1067 1068 1072 public void jsxSet_onkeypress(final Function onkeypress) { 1073 getHtmlElementOrDie().setEventHandler("onkeypress", onkeypress); 1074 } 1075 1076 1080 public Function jsxGet_onkeypress() { 1081 return getHtmlElementOrDie().getEventHandler("onkeypress"); 1082 } 1083 1084 1088 public void jsxSet_onkeyup(final Function onkeyup) { 1089 getHtmlElementOrDie().setEventHandler("onkeyup", onkeyup); 1090 } 1091 1092 1096 public Function jsxGet_onkeyup() { 1097 return getHtmlElementOrDie().getEventHandler("onkeyup"); 1098 } 1099 1100 1104 public void jsxSet_onmousedown(final Function onmousedown) { 1105 getHtmlElementOrDie().setEventHandler("onmousedown", onmousedown); 1106 } 1107 1108 1112 public Function jsxGet_onmousedown() { 1113 return getHtmlElementOrDie().getEventHandler("onmousedown"); 1114 } 1115 1116 1120 public void jsxSet_onmousemove(final Function onmousemove) { 1121 getHtmlElementOrDie().setEventHandler("onmousemove", onmousemove); 1122 } 1123 1124 1128 public Function jsxGet_onmousemove() { 1129 return getHtmlElementOrDie().getEventHandler("onmousemove"); 1130 } 1131 1132 1136 public void jsxSet_onmouseout(final Function onmouseout) { 1137 getHtmlElementOrDie().setEventHandler("onmouseout", onmouseout); 1138 } 1139 1140 1144 public Function jsxGet_onmouseout() { 1145 return getHtmlElementOrDie().getEventHandler("onmouseout"); 1146 } 1147 1148 1152 public void jsxSet_onmouseover(final Function onmouseover) { 1153 getHtmlElementOrDie().setEventHandler("onmouseover", onmouseover); 1154 } 1155 1156 1160 public Function jsxGet_onmouseover() { 1161 return getHtmlElementOrDie().getEventHandler("onmouseover"); 1162 } 1163 1164 1168 public void jsxSet_onmouseup(final Function onmouseup) { 1169 getHtmlElementOrDie().setEventHandler("onmouseup", onmouseup); 1170 } 1171 1172 1176 public Function jsxGet_onmouseup() { 1177 return getHtmlElementOrDie().getEventHandler("onmouseup"); 1178 } 1179 1180 1184 public void jsxSet_onresize(final Function onresize) { 1185 getHtmlElementOrDie().setEventHandler("onresize", onresize); 1186 } 1187 1188 1192 public Function jsxGet_onresize() { 1193 return getHtmlElementOrDie().getEventHandler("onresize"); 1194 } 1195 1196 1202 public int jsxGet_offsetHeight() { 1203 return 1; 1204 } 1205 1206 1212 public int jsxGet_offsetWidth() { 1213 return 1; 1214 } 1215 1216 1222 public int jsxGet_offsetLeft() { 1223 return 1; 1224 } 1225 1226 1232 public int jsxGet_offsetTop() { 1233 return 1; 1234 } 1235 1236 1240 public String toString() { 1241 return "HTMLElement for " + getHtmlElementOrNull(); 1242 } 1243} 1244 | Popular Tags |