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

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

Issue 1230583006: Fix for keeping lists structure (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Classes were documented. 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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 org.chromium.distiller.webdocument; 5 package org.chromium.distiller.webdocument;
6 6
7 import com.google.gwt.dom.client.Element; 7 import com.google.gwt.dom.client.Element;
8 import org.chromium.distiller.DomUtil; 8 import org.chromium.distiller.DomUtil;
9 import org.chromium.distiller.TreeCloneBuilder; 9 import org.chromium.distiller.TreeCloneBuilder;
10 import org.chromium.distiller.labels.DefaultLabels; 10 import org.chromium.distiller.labels.DefaultLabels;
(...skipping 51 matching lines...) Expand 10 before | Expand all | Expand 10 after
62 Node parentClone = getTextNodes().get(0).getParentElement().cloneNod e(false); 62 Node parentClone = getTextNodes().get(0).getParentElement().cloneNod e(false);
63 parentClone.appendChild(clonedRoot); 63 parentClone.appendChild(clonedRoot);
64 clonedRoot = parentClone; 64 clonedRoot = parentClone;
65 } 65 }
66 66
67 // Make sure links are absolute and IDs are gone. 67 // Make sure links are absolute and IDs are gone.
68 DomUtil.makeAllLinksAbsolute(clonedRoot); 68 DomUtil.makeAllLinksAbsolute(clonedRoot);
69 DomUtil.stripIds(clonedRoot); 69 DomUtil.stripIds(clonedRoot);
70 DomUtil.stripFontColorAttributes(clonedRoot); 70 DomUtil.stripFontColorAttributes(clonedRoot);
71 71
72 // Since LI Tag is being wrapped by a pair of {@link WebTag}s,
73 // we only need to get the innerHTML, otherwise
74 // LI tag would be duplicated.
75 Element elementClonedRoot = Element.as(clonedRoot);
72 if (textOnly) { 76 if (textOnly) {
73 return Element.as(clonedRoot).getInnerText(); 77 return elementClonedRoot.getInnerText();
78 } else if (elementClonedRoot.getTagName().equals("LI")) {
wychen 2015/08/05 19:46:15 UL and OL might need to use innerHTML as well. Eve
Marcelo Correa 2015/08/05 20:31:24 Yes, You are right. We might need to prevent that.
wychen 2015/08/06 00:04:52 It would be cleaner to aggregate the tag list in o
Marcelo Correa 2015/08/06 01:17:59 That makes two of us :P
79 return elementClonedRoot.getInnerHTML();
74 } 80 }
75 return Element.as(clonedRoot).getString(); 81 return elementClonedRoot.getString();
76 } 82 }
77 83
78 public List<Node> getTextNodes() { 84 public List<Node> getTextNodes() {
79 return allTextNodes.subList(start, end); 85 return allTextNodes.subList(start, end);
80 } 86 }
81 87
82 public void addLabel(String s) { 88 public void addLabel(String s) {
83 labels.add(s); 89 labels.add(s);
84 } 90 }
85 91
(...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after
126 } 132 }
127 133
128 public void setGroupNumber(int group) { 134 public void setGroupNumber(int group) {
129 groupNumber = group; 135 groupNumber = group;
130 } 136 }
131 137
132 public int getGroupNumber() { 138 public int getGroupNumber() {
133 return groupNumber; 139 return groupNumber;
134 } 140 }
135 } 141 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698