OLD | NEW |
(Empty) | |
| 1 // Copyright 2014 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. |
| 4 |
| 5 package org.chromium.distiller.webdocument; |
| 6 |
| 7 import com.google.gwt.dom.client.Element; |
| 8 import com.google.gwt.dom.client.Node; |
| 9 import org.chromium.distiller.DomUtil; |
| 10 import org.chromium.distiller.DomWalker; |
| 11 |
| 12 import java.util.List; |
| 13 |
| 14 public class WebList extends WebElement { |
| 15 private Element tableElement; |
| 16 |
| 17 public enum Section{START, CONTENT, END}; |
| 18 private String tagName; |
| 19 private Section mySection; |
| 20 |
| 21 /** |
| 22 * Create a WebList section that denotes the start/content/end section of th
e list. |
| 23 * @param s The section of the list being built. |
| 24 */ |
| 25 public WebList(Section s) { |
| 26 mySection = s; |
| 27 } |
| 28 |
| 29 //@Override |
| 30 public String generateOutput(boolean textOnly) { |
| 31 switch (mySection) { |
| 32 case START: |
| 33 return textOnly?"":"<" + tagName + ">"; |
| 34 case END: |
| 35 return textOnly?"":"</" + tagName + ">"; |
| 36 case CONTENT: |
| 37 break; |
| 38 } |
| 39 return ""; |
| 40 } |
| 41 |
| 42 public void addOutputNodes(final List<Node> nodes, boolean includeTitle) { |
| 43 new DomWalker(new DomWalker.Visitor() { |
| 44 @Override |
| 45 public boolean visit(Node n) { |
| 46 switch (n.getNodeType()) { |
| 47 case Node.TEXT_NODE: |
| 48 nodes.add(n); |
| 49 return false; |
| 50 case Node.ELEMENT_NODE: |
| 51 if (!DomUtil.isVisible(Element.as(n))) return false; |
| 52 nodes.add(n); |
| 53 return true; |
| 54 case Node.DOCUMENT_NODE: |
| 55 default: |
| 56 return false; |
| 57 } |
| 58 } |
| 59 |
| 60 @Override |
| 61 public void exit(Node n) { |
| 62 } |
| 63 |
| 64 @Override |
| 65 public void skip(Element e) { |
| 66 } |
| 67 }).walk(tableElement); |
| 68 } |
| 69 } |
OLD | NEW |