/** * @see net.sourceforge.htmlunit.corejs.javascript.Scriptable#getPrototype */ public Scriptable getPrototype() { return obj.getPrototype(); } /**
/** * Delegates to * * @return true iff rhs appears in lhs' proto chain */ public static boolean jsDelegatesTo(Scriptable lhs, Scriptable rhs) { Scriptable proto = lhs.getPrototype(); while (proto != null) { if (proto.equals(rhs)) return true; proto = proto.getPrototype(); } return false; }
private static Scriptable getBase(Scriptable obj, String name) { do { if (obj.has(name, obj)) break; obj = obj.getPrototype(); } while(obj != null); return obj; }
private static Scriptable getBase(Scriptable obj, int index) { do { if (obj.has(index, obj)) break; obj = obj.getPrototype(); } while(obj != null); return obj; }
private int getRecursiveAttributesLength() { int length = 0; for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { length += object.getIds().length; } return length; }
private int getRecursiveAttributesLength() { int length = 0; for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { length += object.getIds().length; } return length; }
private boolean isRecursiveAttribute(final String name) { for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { for (final Object id : object.getIds()) { if (name.equals(Context.toString(id))) { return true; } } } return false; }
private boolean isRecursiveAttribute(final String name) { for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { for (final Object id : object.getIds()) { if (name.equals(Context.toString(id))) { return true; } } } return false; }
private int getRecursiveAttributesLength() { int length = 0; for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { length += object.getIds().length; } return length; }
private boolean isRecursiveAttribute(final String name) { for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { for (final Object id : object.getIds()) { if (name.equals(Context.toString(id))) { return true; } } } return false; }
@Override public Object get(Context cx) { switch (type) { case SPECIAL_NONE: return ScriptRuntime.getObjectProp(target, name, cx); case SPECIAL_PROTO: return target.getPrototype(); case SPECIAL_PARENT: return target.getParentScope(); default: throw Kit.codeBug(); } }
private String getRecusiveAttributeNameAt(final int index) { int i = 0; for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { for (final Object id : object.getIds()) { if (i == index) { return Context.toString(id); } i++; } } return null; } }
private String getRecusiveAttributeNameAt(final int index) { int i = 0; for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { for (final Object id : object.getIds()) { if (i == index) { return Context.toString(id); } i++; } } return null; } }
private String getRecusiveAttributeNameAt(final int index) { int i = 0; for (Scriptable object = getDomNodeOrDie().getScriptObject(); object != null; object = object.getPrototype()) { for (final Object id : object.getIds()) { if (i == index) { return Context.toString(id); } i++; } } return null; } }
/** * Builds a function that will execute the JavaScript code provided. * @param node the element for which the event is build * @param eventName the event for which this handler is created * @param jsSnippet the JavaScript code */ public EventHandler(final DomNode node, final String eventName, final String jsSnippet) { node_ = node; eventName_ = eventName; jsSnippet_ = "function on" + eventName + "(event) {" + jsSnippet + "\n}"; final ScriptableObject w = node.getPage().getEnclosingWindow().getScriptableObject(); final Scriptable function = (Scriptable) w.get("Function", w); setPrototype(function.getPrototype()); }
/** * Builds a function that will execute the JavaScript code provided. * @param node the element for which the event is build * @param eventName the event for which this handler is created * @param jsSnippet the JavaScript code */ public EventHandler(final DomNode node, final String eventName, final String jsSnippet) { node_ = node; eventName_ = eventName; jsSnippet_ = "function on" + eventName + "(event) {" + jsSnippet + "\n}"; final ScriptableObject w = node.getPage().getEnclosingWindow().getScriptableObject(); final Scriptable function = (Scriptable) w.get("Function", w); setPrototype(function.getPrototype()); }
/** * {@inheritDoc} */ @Override public Object get(final String name, final Scriptable start) { if (this != start) { return super.get(name, start); } Scriptable prototype = getPrototype(); while (prototype != null) { final Object value = prototype.get(name, start); if (value != Scriptable.NOT_FOUND) { return value; } prototype = prototype.getPrototype(); } final Definition style = StyleAttributes.getDefinition(name, getBrowserVersion()); if (style != null) { return getStyleAttribute(style); } return super.get(name, start); }
/** * Returns the current document instance, using <tt>thisObj</tt> as a hint. * @param thisObj a hint as to the current document (may be the prototype when function is used without "this") * @return the current document instance */ private static HTMLDocument getDocument(final Scriptable thisObj) { // if function is used "detached", then thisObj is the top scope (ie Window), not the real object // cf unit test DocumentTest#testDocumentWrite_AssignedToVar // may be the prototype too // cf DocumentTest#testDocumentWrite_AssignedToVar2 if (thisObj instanceof HTMLDocument && thisObj.getPrototype() instanceof HTMLDocument) { return (HTMLDocument) thisObj; } final Window window = getWindow(thisObj); final BrowserVersion browser = window.getWebWindow().getWebClient().getBrowserVersion(); if (browser.isIE()) { return window.jsxGet_document(); } throw Context.reportRuntimeError("Function can't be used detached from document"); }
/** * Builds a function that will execute the JavaScript code provided. * @param node the element for which the event is build * @param eventName the event for which this handler is created * @param jsSnippet the JavaScript code */ public EventHandler(final DomNode node, final String eventName, final String jsSnippet) { node_ = node; eventName_ = eventName; final String functionSignature; if (node.getPage().getEnclosingWindow().getWebClient().getBrowserVersion().isIE()) { functionSignature = "function()"; } else { functionSignature = "function(event)"; } jsSnippet_ = functionSignature + " {" + jsSnippet + "\n}"; final Window w = (Window) node.getPage().getEnclosingWindow().getScriptObject(); final Scriptable function = (Scriptable) w.get("Function", w); setPrototype(function.getPrototype()); }
/** * Builds a function that will execute the JavaScript code provided. * @param node the element for which the event is build * @param eventName the event for which this handler is created * @param jsSnippet the JavaScript code */ public EventHandler(final DomNode node, final String eventName, final String jsSnippet) { node_ = node; eventName_ = eventName; final String functionSignature; if (node.getPage().getEnclosingWindow().getWebClient().getBrowserVersion().isIE()) { functionSignature = "function()"; } else { functionSignature = "function(event)"; } jsSnippet_ = functionSignature + " {" + jsSnippet + "\n}"; final Window w = (Window) node.getPage().getEnclosingWindow().getScriptObject(); final Scriptable function = (Scriptable) w.get("Function", w); setPrototype(function.getPrototype()); }