| OLD | NEW |
| 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 Loading... |
| 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 Loading... |
| 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 } |
| OLD | NEW |