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

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

Issue 2285133003: Use .innerText in text-only mode (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: Created 4 years, 3 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.Document; 7 import com.google.gwt.dom.client.Document;
8 import com.google.gwt.dom.client.Element; 8 import com.google.gwt.dom.client.Element;
9 import org.chromium.distiller.DomUtil; 9 import org.chromium.distiller.DomUtil;
10 import org.chromium.distiller.TreeCloneBuilder; 10 import org.chromium.distiller.TreeCloneBuilder;
(...skipping 124 matching lines...) Expand 10 before | Expand all | Expand 10 after
135 DomUtil.stripIds(clonedRoot); 135 DomUtil.stripIds(clonedRoot);
136 DomUtil.stripFontColorAttributes(clonedRoot); 136 DomUtil.stripFontColorAttributes(clonedRoot);
137 DomUtil.stripStyleAttributes(clonedRoot); 137 DomUtil.stripStyleAttributes(clonedRoot);
138 // TODO(wychen): if we allow images in WebText later, add stripImageElem ents(). 138 // TODO(wychen): if we allow images in WebText later, add stripImageElem ents().
139 139
140 // Since there are tag elements that are being wrapped 140 // Since there are tag elements that are being wrapped
141 // by a pair of {@link WebTag}s, we only need to 141 // by a pair of {@link WebTag}s, we only need to
142 // get the innerHTML, otherwise these tags would be duplicated. 142 // get the innerHTML, otherwise these tags would be duplicated.
143 Element elementClonedRoot = Element.as(clonedRoot); 143 Element elementClonedRoot = Element.as(clonedRoot);
144 if (textOnly) { 144 if (textOnly) {
145 // TODO(wychen): .textContent should be identical to .innerText 145 return DomUtil.getInnerText(elementClonedRoot);
146 // in our use cases, but needs verification.
147 return DomUtil.javascriptTextContent(elementClonedRoot);
148 } else if (WebTag.canBeNested(elementClonedRoot.getTagName())) { 146 } else if (WebTag.canBeNested(elementClonedRoot.getTagName())) {
149 return elementClonedRoot.getInnerHTML(); 147 return elementClonedRoot.getInnerHTML();
150 } 148 }
151 return elementClonedRoot.getString(); 149 return elementClonedRoot.getString();
152 } 150 }
153 151
154 public List<Node> getTextNodes() { 152 public List<Node> getTextNodes() {
155 return allTextNodes.subList(start, end); 153 return allTextNodes.subList(start, end);
156 } 154 }
157 155
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
202 } 200 }
203 201
204 public void setGroupNumber(int group) { 202 public void setGroupNumber(int group) {
205 groupNumber = group; 203 groupNumber = group;
206 } 204 }
207 205
208 public int getGroupNumber() { 206 public int getGroupNumber() {
209 return groupNumber; 207 return groupNumber;
210 } 208 }
211 } 209 }
OLDNEW
« no previous file with comments | « java/org/chromium/distiller/webdocument/WebFigure.java ('k') | javatests/org/chromium/distiller/EmbedExtractorTest.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698