| Index: java/org/chromium/distiller/webdocument/WebList.java
|
| diff --git a/java/org/chromium/distiller/webdocument/WebList.java b/java/org/chromium/distiller/webdocument/WebList.java
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..f09554d3743e8ee6a1330da67bf03f5e46ff6dc7
|
| --- /dev/null
|
| +++ b/java/org/chromium/distiller/webdocument/WebList.java
|
| @@ -0,0 +1,69 @@
|
| +// Copyright 2014 The Chromium Authors. All rights reserved.
|
| +// Use of this source code is governed by a BSD-style license that can be
|
| +// found in the LICENSE file.
|
| +
|
| +package org.chromium.distiller.webdocument;
|
| +
|
| +import com.google.gwt.dom.client.Element;
|
| +import com.google.gwt.dom.client.Node;
|
| +import org.chromium.distiller.DomUtil;
|
| +import org.chromium.distiller.DomWalker;
|
| +
|
| +import java.util.List;
|
| +
|
| +public class WebList extends WebElement {
|
| + private Element tableElement;
|
| +
|
| + public enum Section{START, CONTENT, END};
|
| + private String tagName;
|
| + private Section mySection;
|
| +
|
| + /**
|
| + * Create a WebList section that denotes the start/content/end section of the list.
|
| + * @param s The section of the list being built.
|
| + */
|
| + public WebList(Section s) {
|
| + mySection = s;
|
| + }
|
| +
|
| + //@Override
|
| + public String generateOutput(boolean textOnly) {
|
| + switch (mySection) {
|
| + case START:
|
| + return textOnly?"":"<" + tagName + ">";
|
| + case END:
|
| + return textOnly?"":"</" + tagName + ">";
|
| + case CONTENT:
|
| + break;
|
| + }
|
| + return "";
|
| + }
|
| +
|
| + public void addOutputNodes(final List<Node> nodes, boolean includeTitle) {
|
| + new DomWalker(new DomWalker.Visitor() {
|
| + @Override
|
| + public boolean visit(Node n) {
|
| + switch (n.getNodeType()) {
|
| + case Node.TEXT_NODE:
|
| + nodes.add(n);
|
| + return false;
|
| + case Node.ELEMENT_NODE:
|
| + if (!DomUtil.isVisible(Element.as(n))) return false;
|
| + nodes.add(n);
|
| + return true;
|
| + case Node.DOCUMENT_NODE:
|
| + default:
|
| + return false;
|
| + }
|
| + }
|
| +
|
| + @Override
|
| + public void exit(Node n) {
|
| + }
|
| +
|
| + @Override
|
| + public void skip(Element e) {
|
| + }
|
| + }).walk(tableElement);
|
| + }
|
| +}
|
|
|