Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(403)

Unified Diff: java/org/chromium/distiller/webdocument/WebList.java

Issue 1265533004: Handle lists more appropriately (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Created 5 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « java/org/chromium/distiller/webdocument/WebDocumentBuilder.java ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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);
+ }
+}
« no previous file with comments | « java/org/chromium/distiller/webdocument/WebDocumentBuilder.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698