OLD | NEW |
1 // Copyright 2014 The Chromium Authors. All rights reserved. | 1 // Copyright 2014 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 org.chromium.distiller.DomUtil; | 7 import org.chromium.distiller.DomUtil; |
8 import org.chromium.distiller.DomWalker; | 8 import org.chromium.distiller.DomWalker; |
9 import org.chromium.distiller.JavaScript; | 9 import org.chromium.distiller.JavaScript; |
10 import org.chromium.distiller.LogUtil; | 10 import org.chromium.distiller.LogUtil; |
(...skipping 122 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
133 builder.embed(embed); | 133 builder.embed(embed); |
134 return false; | 134 return false; |
135 } | 135 } |
136 } | 136 } |
137 } | 137 } |
138 } catch (Exception exception) { | 138 } catch (Exception exception) { |
139 LogUtil.logToConsole( | 139 LogUtil.logToConsole( |
140 "Exception happened in EmbedExtractors: " + exception.getMessage
()); | 140 "Exception happened in EmbedExtractors: " + exception.getMessage
()); |
141 } | 141 } |
142 | 142 |
| 143 String className = e.getAttribute("class"); |
| 144 String component = e.getAttribute("data-component"); |
| 145 if (className.equals("sharing") || className.equals("socialArea") || |
| 146 component.equals("share")) { |
| 147 // Skip social and sharing elements. |
| 148 // See crbug.com/692553, crbug.com/696556, and crbug.com/674557 |
| 149 return false; |
| 150 } |
| 151 |
143 // Create a placeholder for the elements we want to preserve. | 152 // Create a placeholder for the elements we want to preserve. |
144 if (WebTag.canBeNested(e.getTagName())) { | 153 if (WebTag.canBeNested(e.getTagName())) { |
145 builder.tag(new WebTag(e.getTagName(), WebTag.TagType.START)); | 154 builder.tag(new WebTag(e.getTagName(), WebTag.TagType.START)); |
146 } | 155 } |
147 | 156 |
148 switch (e.getTagName()) { | 157 switch (e.getTagName()) { |
149 case "BR": | 158 case "BR": |
150 builder.lineBreak(e); | 159 builder.lineBreak(e); |
151 return false; | 160 return false; |
152 // Skip data tables, keep track of them to be extracted by RelevantE
lementsFinder | 161 // Skip data tables, keep track of them to be extracted by RelevantE
lementsFinder |
(...skipping 24 matching lines...) Expand all Loading... |
177 // These types are skipped and don't affect document construction. | 186 // These types are skipped and don't affect document construction. |
178 case "HEAD": | 187 case "HEAD": |
179 case "STYLE": | 188 case "STYLE": |
180 case "SCRIPT": | 189 case "SCRIPT": |
181 case "LINK": | 190 case "LINK": |
182 case "NOSCRIPT": | 191 case "NOSCRIPT": |
183 case "IFRAME": | 192 case "IFRAME": |
184 case "svg": // The svg tag is actually in small case. | 193 case "svg": // The svg tag is actually in small case. |
185 return false; | 194 return false; |
186 } | 195 } |
| 196 |
187 builder.startElement(e); | 197 builder.startElement(e); |
188 isHiddenStack.push(isHiddenClass); | 198 isHiddenStack.push(isHiddenClass); |
189 isHiddenClass |= hasHiddenClassName; | 199 isHiddenClass |= hasHiddenClassName; |
190 return true; | 200 return true; |
191 } | 201 } |
192 | 202 |
193 @Override | 203 @Override |
194 public void exit(Node n) { | 204 public void exit(Node n) { |
195 if (n.getNodeType() == Node.ELEMENT_NODE) { | 205 if (n.getNodeType() == Node.ELEMENT_NODE) { |
196 Element e = Element.as(n); | 206 Element e = Element.as(n); |
(...skipping 20 matching lines...) Expand all Loading... |
217 Element parent = e.getParentElement(); | 227 Element parent = e.getParentElement(); |
218 LogUtil.logToConsole("TABLE: " + type + | 228 LogUtil.logToConsole("TABLE: " + type + |
219 ", id=" + e.getId() + | 229 ", id=" + e.getId() + |
220 ", class=" + e.getAttribute("class") + | 230 ", class=" + e.getAttribute("class") + |
221 ", parent=[" + parent.getTagName() + | 231 ", parent=[" + parent.getTagName() + |
222 ", id=" + parent.getId() + | 232 ", id=" + parent.getId() + |
223 ", class=" + parent.getAttribute("class") + | 233 ", class=" + parent.getAttribute("class") + |
224 "]"); | 234 "]"); |
225 } | 235 } |
226 } | 236 } |
OLD | NEW |