protected void renderShowHide(
      Element elem,
      String elemVarName,
      boolean hide,
      StringBuilder code,
      JSRenderElementImpl render) {
    if (NamespaceUtil.isSVGElement(elem)) {
      // El <script> de SVG no tiene objeto style, al menos en FireFox
      // y ASV3. Da igual lo que pase en los demás (Opera, Chrome etc) no
      // tiene sentido ocultar un <script>
      String localName = elem.getLocalName();
      if (localName.equals("script")) return;

      ClientDocumentStfulDelegateWebImpl clientDoc = getClientDocumentStfulDelegateWeb();
      BrowserWeb browser = clientDoc.getBrowserWeb();
      if (browser instanceof BrowserAdobeSVG) {
        // El <foreignObject> tampoco tiene objeto style en ASV3
        // este elemento ES visual pero como no está reconocido
        // en ASV3 los elementos hijo son tratados como elementos SVG
        // desconocidos sin visualización. Por tanto evitamos que de error.
        // De hecho la propiedad "display" no funciona en ASV3 (se ignora)
        // pero al menos no da error.
        if (localName.equals("foreignObject")) return;
      }
    }

    super.renderShowHide(elem, elemVarName, hide, code, render);
  }
  public static String getCodeDispatchEvent(
      EventTarget node,
      Event evt,
      String varResName,
      ClientDocumentStfulDelegateWebImpl clientDoc) {
    JSRenderEventImpl evtRender =
        JSRenderEventImpl.getJSEventRender(evt, clientDoc.getBrowserWeb());
    NodeLocationImpl nodeLoc = clientDoc.getNodeLocation((Node) node, true);

    return evtRender.getDispatchEvent(varResName, nodeLoc, evt, clientDoc);
  }
 public static String getSetNodePropertyCode(
     Node node,
     String propertyName,
     String value,
     boolean cacheIfPossible,
     ClientDocumentStfulDelegateWebImpl clientDoc) {
   return clientDoc.getNodeReference(node, cacheIfPossible, true)
       + "."
       + propertyName
       + "="
       + toTransportableStringLiteral(value, clientDoc.getBrowserWeb())
       + ";\n"; // El \n es un embellecedor
 }
 public static String getGetNodePropertyCode(
     Node object,
     String propertyName,
     boolean cacheIfPossible,
     ClientDocumentStfulDelegateWebImpl clientDoc) {
   return clientDoc.getNodeReference(object, cacheIfPossible, true) + "." + propertyName;
 }
 public static JSRenderElementImpl getJSRenderElement(
     Element elem, ClientDocumentStfulDelegateWebImpl clientDoc) {
   if (DOMUtilHTML.isHTMLElement(elem))
     return JSRenderHTMLElementImpl.getJSRenderHTMLElement(clientDoc.getBrowserWeb());
   else // El elemento puede estar en un documento (X)HTML pero no es HTML o XHTML. En documentos
        // no HTML todos los elementos tienen un namespace o DEBERIA declararse en el root del
        // documento
   return JSRenderOtherNSElementImpl.getJSRenderOtherNSElement(elem, clientDoc);
 }
  public String bindRestoreBackupStylePropertyMethod(ClientDocumentStfulDelegateWebImpl clientDoc) {
    StringBuilder code = new StringBuilder();

    String methodName = getRestoreBackupPropertyMethodName();
    if (!clientDoc.isClientMethodBounded(methodName))
      code.append(bindRestoreBackupStylePropertyMethod(methodName, clientDoc));

    return code.toString();
  }
  public int getTimeout() {
    int timeout = super.getTimeout();
    if (timeout <= 0) return -1;

    ClientDocumentStfulDelegateWebImpl clientDoc = getClientDocumentStfulDelegateWeb();
    BrowserWeb browser = clientDoc.getBrowserWeb();
    if ((browser instanceof BrowserGecko)
        || (browser instanceof BrowserOperaOld)
        || (browser instanceof BrowserAdobeSVG)
        || // ASV
        (browser
            instanceof
            BrowserBatik)) // En Batik applet no hay redimensionamiento porque no es normal cambiar
      // las dimensiones del applet
      return -1; // No es necesario el redimensionamiento, se redimensiona automáticamente cuando
    // cambia el cuadro (gracias a los valores "100%")

    return timeout;
  }
  public String getRestoreBackupStyleProperty(
      String elemVarName, String propName, ClientDocumentStfulDelegateWebImpl clientDoc) {
    StringBuilder code = new StringBuilder();

    String methodName = getRestoreBackupPropertyMethodName();
    if (!clientDoc.isClientMethodBounded(methodName))
      code.append(bindRestoreBackupStylePropertyMethod(methodName, clientDoc));

    code.append("itsNatDoc." + methodName + "(" + elemVarName + ",\"" + propName + "\");\n");
    return code.toString();
  }
  protected String bindRestoreBackupStylePropertyMethod(
      String methodName, ClientDocumentStfulDelegateWebImpl clientDoc) {
    StringBuilder code = new StringBuilder();

    code.append("var func = function (elem,propName)");
    code.append("{");
    code.append("  if (typeof elem.style == \"undefined\") return;");
    code.append("  var name = \"style_itsnat_\" + propName;");
    code.append("  var cssProp = this.getPropInNative(elem,name);\n");
    code.append("  if (cssProp == null) return;\n"); // No se salvó
    code.append("  elem.style[propName] = cssProp;\n");
    code.append("  this.removePropInNative(elem,name);\n");
    code.append("};");

    code.append("itsNatDoc." + methodName + " = func;\n");

    clientDoc.bindClientMethod(methodName);

    return code.toString();
  }
  protected String bindBackupAndSetStylePropertyMethod(
      String methodName, ClientDocumentStfulDelegateWebImpl clientDoc) {
    // Usamos variables temporales asociadas al objeto Element y no al propio "style",
    // por:
    // Safari (3.1 al menos) parece que recrea el objeto style tras un display='none" en algunos
    // casos por lo que perderíamos la variable backup.

    // Aseguramos que no se asigne un valor "undefined" pues navegadores como Gecko ignoran una
    // asignación con valor "undefined" y no cambian el valor,
    // el problema es que debemos restaurar el valor anterior y está claro que restaurar un
    // undefined no es posible,
    // el valor "" viene a ser el valor por defecto habitual.

    // Nota: Opera Mobile 9.5 SVG ignora la propiedad "dispose" (sin error), solucionado en 9.7

    StringBuilder code = new StringBuilder();

    code.append("var func = function (elem,propName,newValue)");
    code.append("{");
    code.append(
        "  if (typeof elem.style == \"undefined\") return;"); // Esto ocurre por ejemplo con
                                                              // <script> en algun navegador (no me
                                                              // acuerdo) y con <foreignObject> en
                                                              // SVG en Opera Mobile 9.5.
    code.append("  var name = \"style_itsnat_\" + propName;");
    code.append("  var cssProp = elem.style[propName];");
    code.append("  if (typeof cssProp == \"undefined\") cssProp = \"\";");
    code.append("  this.setPropInNative(elem,name,cssProp);");
    code.append("  elem.style[propName] = newValue;");
    code.append("};");

    code.append("itsNatDoc." + methodName + " = func;\n");

    clientDoc.bindClientMethod(methodName);

    return code.toString();
  }