Ejemplo n.º 1
0
  protected void dispatchSVGDocEvent(String eventType) {
    SVGSVGElement root = (SVGSVGElement) document.getDocumentElement();
    // Event is dispatched on outermost SVG element.
    EventTarget t = root;

    DocumentEvent de = (DocumentEvent) document;
    AbstractEvent ev = (AbstractEvent) de.createEvent("SVGEvents");
    ev.initEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, eventType, false, false);
    t.dispatchEvent(ev);
  }
Ejemplo n.º 2
0
 private Event createEvent(String eventType, int seekTo) {
   DocumentEvent doc = (DocumentEvent) SmilMediaElementImpl.this.getOwnerDocument();
   EventImpl event = (EventImpl) doc.createEvent("Event");
   event.initEvent(eventType, false, false, seekTo);
   if (LOCAL_LOGV)
     Log.v(
         TAG,
         "Dispatching 'begin' event to "
             + SmilMediaElementImpl.this.getTagName()
             + " "
             + SmilMediaElementImpl.this.getSrc()
             + " at "
             + System.currentTimeMillis());
   return event;
 }
Ejemplo n.º 3
0
 /**
  * Fires a 'DOMActivate' event to the specified target.
  *
  * @param target the event target
  * @param detailArg the detailArg parameter of the event
  */
 protected void fireDOMActivateEvent(EventTarget target, int detailArg) {
   DocumentEvent docEvt = (DocumentEvent) ((Element) target).getOwnerDocument();
   UIEvent uiEvt = (UIEvent) docEvt.createEvent("UIEvents");
   uiEvt.initUIEvent("DOMActivate", true, true, null, detailArg);
   target.dispatchEvent(uiEvt);
 }
Ejemplo n.º 4
0
  /** Auxiliary method for dispatchSVGLoad. */
  protected void dispatchSVGLoad(Element elt, boolean checkCanRun, String lang) {
    for (Node n = elt.getFirstChild(); n != null; n = n.getNextSibling()) {
      if (n.getNodeType() == Node.ELEMENT_NODE) {
        dispatchSVGLoad((Element) n, checkCanRun, lang);
      }
    }

    DocumentEvent de = (DocumentEvent) elt.getOwnerDocument();
    AbstractEvent ev = (AbstractEvent) de.createEvent("SVGEvents");
    String type;
    if (bridgeContext.isSVG12()) {
      type = "load";
    } else {
      type = "SVGLoad";
    }
    ev.initEventNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, type, false, false);
    NodeEventTarget t = (NodeEventTarget) elt;

    final String s = elt.getAttributeNS(null, SVGConstants.SVG_ONLOAD_ATTRIBUTE);
    if (s.length() == 0) {
      // No script to run so just dispatch the event to DOM
      // (For java presumably).
      t.dispatchEvent(ev);
      return;
    }

    final Interpreter interp = getInterpreter();
    if (interp == null) {
      // Can't load interpreter so just dispatch normal event
      // to the DOM (for java presumably).
      t.dispatchEvent(ev);
      return;
    }

    if (checkCanRun) {
      // Check that it is ok to run embeded scripts
      checkCompatibleScriptURL(lang, docPURL);
      checkCanRun = false; // we only check once for onload handlers
    }

    DocumentLoader dl = bridgeContext.getDocumentLoader();
    SVGDocument d = (SVGDocument) elt.getOwnerDocument();
    int line = dl.getLineNumber(elt);
    final String desc =
        Messages.formatMessage(
            EVENT_SCRIPT_DESCRIPTION,
            new Object[] {d.getURL(), SVGConstants.SVG_ONLOAD_ATTRIBUTE, new Integer(line)});

    EventListener l =
        new EventListener() {
          public void handleEvent(Event evt) {
            try {
              Object event;
              if (evt instanceof ScriptEventWrapper) {
                event = ((ScriptEventWrapper) evt).getEventObject();
              } else {
                event = evt;
              }
              interp.bindObject(EVENT_NAME, event);
              interp.bindObject(ALTERNATE_EVENT_NAME, event);
              interp.evaluate(new StringReader(s), desc);
            } catch (IOException io) {
            } catch (InterpreterException e) {
              handleInterpreterException(e);
            }
          }
        };
    t.addEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, type, l, false, null);
    t.dispatchEvent(ev);
    t.removeEventListenerNS(XMLConstants.XML_EVENTS_NAMESPACE_URI, type, l, false);
  }
Ejemplo n.º 5
0
 /**
  * Fires a 'DOMFocusOut' event to the specified target.
  *
  * @param target the event target
  */
 protected void fireDOMFocusOutEvent(EventTarget target) {
   DocumentEvent docEvt = (DocumentEvent) ((Element) target).getOwnerDocument();
   UIEvent uiEvt = (UIEvent) docEvt.createEvent("UIEvents");
   uiEvt.initUIEvent("DOMFocusOut", true, false, null, 0);
   target.dispatchEvent(uiEvt);
 }