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

Side by Side Diff: java/org/chromium/distiller/webdocument/WebTag.java

Issue 1230583006: Fix for keeping lists structure (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: canBeNested move out of the switch. Created 5 years, 4 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 unified diff | Download patch
OLDNEW
(Empty)
1 package org.chromium.distiller.webdocument;
2
3 import java.util.HashSet;
4 import java.util.Set;
5
6 /**
7 * This class represents HTML tags that need to be preserved over
8 * the distillation process.
9 */
10 public class WebTag extends WebElement {
11 private String tagName;
12 private TagType tagType;
13
14 public enum TagType {
15 START, END
16 }
17
18 private static Set<String> nestingTags;
19 static {
20 nestingTags = new HashSet<String>();
21 nestingTags.add("UL");
22 nestingTags.add("OL");
23 nestingTags.add("LI");
24 }
25
26 public WebTag(String tagName, TagType tagType) {
27 this.tagName = tagName;
28 this.tagType = tagType;
29 }
30
31 public boolean isStartTag() {
32 return tagType == TagType.START;
33 }
34
35 public String getTagName() {
36 return tagName;
37 }
38
39 @Override
40 public String generateOutput(boolean textOnly) {
41 if (textOnly) {
42 return "";
43 }
44 return "<" + (isStartTag() ? "" : "/") + tagName + ">";
45 }
46
47 public static boolean canBeNested(String tagName) {
48 return nestingTags.contains(tagName);
49 }
50 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698