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

Side by Side Diff: src/com/dom_distiller/client/RelevantElementsFinder.java

Issue 322553005: Improve handling of <video>, <figure> and <br> (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: Created 6 years, 6 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
« no previous file with comments | « src/com/dom_distiller/client/FilteringDomVisitor.java ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 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 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package com.dom_distiller.client; 5 package com.dom_distiller.client;
6 6
7 import com.google.gwt.dom.client.Element; 7 import com.google.gwt.dom.client.Element;
8 import com.google.gwt.dom.client.Node; 8 import com.google.gwt.dom.client.Node;
9 9
10 import java.util.ArrayList; 10 import java.util.ArrayList;
(...skipping 37 matching lines...) Expand 10 before | Expand all | Expand 10 after
48 * Finds the relevant elements rooted at |root|. 48 * Finds the relevant elements rooted at |root|.
49 */ 49 */
50 private void find(final Node root) { 50 private void find(final Node root) {
51 DomVisitor domVisitor = new DomVisitor(); 51 DomVisitor domVisitor = new DomVisitor();
52 new DomWalker(domVisitor).walk(root); 52 new DomWalker(domVisitor).walk(root);
53 } 53 }
54 54
55 private static final Set<String> sRelevantTags; 55 private static final Set<String> sRelevantTags;
56 static { 56 static {
57 sRelevantTags = new HashSet<String>(); 57 sRelevantTags = new HashSet<String>();
58 sRelevantTags.add("BR");
59 sRelevantTags.add("FIGURE");
58 sRelevantTags.add("IMG"); 60 sRelevantTags.add("IMG");
59 sRelevantTags.add("TABLE"); 61 sRelevantTags.add("TABLE");
62 sRelevantTags.add("VIDEO");
60 } 63 }
61 64
62 /** 65 /**
63 * This class traverses the root element pre-orderly and determines if a vis ible element is 66 * This class traverses the root element pre-orderly and determines if a vis ible element is
64 * relevant with respect to Boilerpipe's content nodes. A relevant element is then possibly 67 * relevant with respect to Boilerpipe's content nodes. A relevant element is then possibly
65 * extracted by ElementVisitor. The final output is a combined ordered list of the content 68 * extracted by ElementVisitor. The final output is a combined ordered list of the content
66 * nodes and extracted elements. 69 * nodes and extracted elements.
67 */ 70 */
68 private class DomVisitor implements DomWalker.Visitor { 71 private class DomVisitor implements DomWalker.Visitor {
69 private boolean inContent; 72 private boolean inContent;
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
184 case Node.DOCUMENT_NODE: 187 case Node.DOCUMENT_NODE:
185 default: 188 default:
186 return false; // Don't recurse into comments or sub-documen ts. 189 return false; // Don't recurse into comments or sub-documen ts.
187 } 190 }
188 } 191 }
189 192
190 @Override 193 @Override
191 public void exit(Node n) {} 194 public void exit(Node n) {}
192 } // ElementVisitor 195 } // ElementVisitor
193 } 196 }
OLDNEW
« no previous file with comments | « src/com/dom_distiller/client/FilteringDomVisitor.java ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698