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

Side by Side Diff: java/org/chromium/distiller/webdocument/filters/WebTagStructureKeeper.java

Issue 1230583006: Fix for keeping lists structure (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: StackEntry removed, using WebTag content flag instead. 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.filters;
2
3 import org.chromium.distiller.webdocument.WebDocument;
4 import org.chromium.distiller.webdocument.WebElement;
5 import org.chromium.distiller.webdocument.WebTag;
6 import org.chromium.distiller.webdocument.WebText;
7
8 import java.util.Stack;
9
10 public class WebTagStructureKeeper {
mdjones 2015/08/03 23:29:45 How about NestedElement{Builder|Organizer|Retainer
11 public static void process(WebDocument document) {
12 boolean isContent = false;
13 int stackMark = -1;
14 Stack<WebTag> stack = new Stack<>();
15
16 for (WebElement e : document.getElements()) {
17 if (e instanceof WebText) {
mdjones 2015/08/03 23:29:45 Though I'm not sure it is a common case, this does
18 if (!isContent) {
19 isContent = e.getIsContent();
20 }
21 } else if (e instanceof WebTag) {
22 WebTag webTag = (WebTag) e;
23 if (webTag.isStartTag()) {
24 webTag.setIsContent(isContent);
25 stack.push(webTag);
26 isContent = false;
27 } else {
28 WebTag startWebTag = stack.pop();
29 boolean content = isContent || stackMark >= stack.size();
mdjones 2015/08/03 23:29:45 isContent |= stackMark >= stackSize(); Then just
30 if (content) {
31 stackMark = stack.size() - 1;
32 }
33 startWebTag.setIsContent(content);
34 webTag.setIsContent(content);
35 isContent = startWebTag.getIsContent();
wychen 2015/08/04 02:37:01 Does this pass the test? Moving this line 2 lines
36 }
37 }
38 }
39 }
40 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698