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.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 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 // To keep formatting/structure, at least one parent element should be i
n the output. This | 59 // To keep formatting/structure, at least one parent element should be i
n the output. This |
60 // is necessary because many times a WebText is only a single node. | 60 // is necessary because many times a WebText is only a single node. |
61 if (clonedRoot.getNodeType() != Node.ELEMENT_NODE) { | 61 if (clonedRoot.getNodeType() != Node.ELEMENT_NODE) { |
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.stripTargetAttributes(clonedRoot); |
69 DomUtil.stripIds(clonedRoot); | 70 DomUtil.stripIds(clonedRoot); |
70 DomUtil.stripFontColorAttributes(clonedRoot); | 71 DomUtil.stripFontColorAttributes(clonedRoot); |
71 DomUtil.stripStyleAttributes(clonedRoot); | 72 DomUtil.stripStyleAttributes(clonedRoot); |
72 // TODO(wychen): if we allow images in WebText later, add stripImageElem
ents(). | 73 // TODO(wychen): if we allow images in WebText later, add stripImageElem
ents(). |
73 | 74 |
74 // Since there are tag elements that are being wrapped | 75 // Since there are tag elements that are being wrapped |
75 // by a pair of {@link WebTag}s, we only need to | 76 // by a pair of {@link WebTag}s, we only need to |
76 // get the innerHTML, otherwise these tags would be duplicated. | 77 // get the innerHTML, otherwise these tags would be duplicated. |
77 Element elementClonedRoot = Element.as(clonedRoot); | 78 Element elementClonedRoot = Element.as(clonedRoot); |
78 if (textOnly) { | 79 if (textOnly) { |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
134 } | 135 } |
135 | 136 |
136 public void setGroupNumber(int group) { | 137 public void setGroupNumber(int group) { |
137 groupNumber = group; | 138 groupNumber = group; |
138 } | 139 } |
139 | 140 |
140 public int getGroupNumber() { | 141 public int getGroupNumber() { |
141 return groupNumber; | 142 return groupNumber; |
142 } | 143 } |
143 } | 144 } |
OLD | NEW |