Package com.google.caja.parser.html

Examples of com.google.caja.parser.html.ElKey


   */
  private void fleshOutElement(NodeBone bone, boolean splitDom) {
    Element el = (Element) bone.node;
    Element safe = (Element) bone.safeNode;
    FilePosition pos = Nodes.getFilePositionFor(el);
    ElKey elKey = ElKey.forElement(el);

    // If the element is supposed to have a FRAME_TARGET attribute, set that
    // to a safe value (the actual final value of all FRAME_TARGET attributes
    // will be assigned dynamically).
    HTML.Element elInfo = htmlSchema.lookupElement(elKey);
View Full Code Here


   * Marks as broken any elements with bad attributes and reports an error or
   * warning about broken elements.
   */
  private void checkIhtmlElements(Element ihtmlRoot) {
    for (Element ihtmlEl : allIhtml(ihtmlRoot)) {
      ElKey elKey = ElKey.forElement(ihtmlEl);
      if (!IHTML.SCHEMA.isElementAllowed(elKey)) {
        mq.addMessage(
            IhtmlMessageType.BAD_ELEMENT, Nodes.getFilePositionFor(ihtmlEl),
            elKey);
        markBroken(ihtmlEl);
View Full Code Here

          CssTree.SimpleSelector ss = (CssTree.SimpleSelector) node;
          CssTree name = (CssTree) ss.children().get(0);
          if (name instanceof CssTree.IdentLiteral) {
            CssTree.IdentLiteral lit = (CssTree.IdentLiteral) name;

            ElKey key = ElKey.forHtmlElement(lit.getValue());
                // TODO(kpreid): handle namespaces
            key = htmlSchema.virtualToRealElementName(key);
                // TODO(kpreid): should use a HtmlSchema instance instead of
                // being static (but we don't have one here).
            lit.setValue(key.localName);
View Full Code Here

    {
      List<StringLiteral> keys = new ArrayList<StringLiteral>();
      List<IntegerLiteral> values = new ArrayList<IntegerLiteral>();
      for (Map.Entry<ElKey, EnumSet<EFlag>> e : eflags.entrySet()) {
        ElKey key = e.getKey();
        int value = 0;
        for (EFlag f : e.getValue()) { value |= f.bitMask; }
        keys.add(StringLiteral.valueOf(unk, key.toString()));
        values.add(new IntegerLiteral(unk, value));
      }
      definitions.appendChild(new ExpressionStmt(unk, (Expression)
          QuasiBuilder.substV(
              "html4.ELEMENTS = { @k*: @v* };",
 
View Full Code Here

      }
    });
  }

  private static Map<ElKey, EnumSet<EFlag>> elementFlags(HtmlSchema schema) {
    final ElKey SCRIPT = ElKey.forHtmlElement("script");
    final ElKey STYLE = ElKey.forHtmlElement("style");
    Map<ElKey, EnumSet<EFlag>> elementFlags = Maps.newTreeMap();
    for (ElKey elementName : schema.getElementNames()) {
      HTML.Element el = schema.lookupElement(elementName);
      EnumSet<EFlag> flags = EnumSet.noneOf(EFlag.class);
      if (el.isEndTagOptional()) { flags.add(EFlag.OPTIONAL_ENDTAG); }
      if (el.isEmpty()) { flags.add(EFlag.EMPTY); }
      if (elementName.isHtml()) {
        switch (HtmlTextEscapingMode.getModeForTag(elementName.localName)) {
          case CDATA:
            flags.add(EFlag.CDATA);
            break;
          case RCDATA:
            flags.add(EFlag.RCDATA);
            break;
          default: break;
        }
      }
      if (!schema.isElementAllowed(elementName)) {
        flags.add(EFlag.UNSAFE);
        if (SCRIPT.equals(elementName)) {
          flags.add(EFlag.SCRIPT);
        } else if (STYLE.equals(elementName)) {
          flags.add(EFlag.STYLE);
        }
      }
      if (HtmlSchema.isElementFoldable(elementName)) {
        flags.add(EFlag.FOLDABLE);
View Full Code Here

      ElKey.HTML_WILDCARD, "type");

  private void findEmbeddedContent(Node node, List<EmbeddedContent> out) {
    if (node instanceof Element) {
      Element el = (Element) node;
      ElKey key = ElKey.forElement(el);
      ContentType expected = null;
      ExternalReference extRef = null;
      String defaultMimeType = null;
      EmbeddedContent.Scheduling scheduling = EmbeddedContent.Scheduling.NORMAL;
      if (SCRIPT.equals(key)) {
View Full Code Here

    boolean valid = true;
    switch (t.getNodeType()) {
      case Node.ELEMENT_NODE:
      {
        Element el = (Element) t;
        ElKey elKey = ElKey.forElement(el);
        {
          if (!schema.isElementAllowed(elKey)) {
            IhtmlMessageType msgType = schema.lookupElement(elKey) != null
                ? IhtmlMessageType.UNSAFE_TAG
                : IhtmlMessageType.UNKNOWN_TAG;
View Full Code Here

          extractBodyInfo(child, source);
        }
        break;
      case Node.ELEMENT_NODE:
        Element el = (Element) node;
        ElKey elKey = ElKey.forElement(el);
        if (HTML.equals(elKey)) {
          for (Node child : Nodes.childrenOf(node)) {
            extractBodyInfo(child, source);
          }
        } else if (BODY.equals(elKey)) {
View Full Code Here

   */
  private boolean validateSimpleSelector(CssTree.SimpleSelector sel) {
    boolean valid = true;
    if (null != sel.getElementName()) {
      String elName = sel.getElementName();
      ElKey elKey = ElKey.forElement(Namespaces.HTML_DEFAULT, elName);
      if (null != htmlSchema.lookupElement(elKey)) {
        if (!htmlSchema.isElementAllowed(elKey)) {
          mq.addMessage(
              PluginMessageType.UNSAFE_TAG, invalidNodeMessageLevel,
              sel.getFilePosition(), elKey);
View Full Code Here

    return valid;
  }

  private boolean validateAllAttribs(CssTree.SimpleSelector sel) {
    String qname = sel.getElementName();
    ElKey el;
    if (qname == null) {
      el = ElKey.HTML_WILDCARD;
    } else {
      el = ElKey.forElement(Namespaces.HTML_DEFAULT, qname);
    }
View Full Code Here

TOP

Related Classes of com.google.caja.parser.html.ElKey

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.