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.LogUtil; | 9 import org.chromium.distiller.LogUtil; |
10 import org.chromium.distiller.TableClassifier; | 10 import org.chromium.distiller.TableClassifier; |
(...skipping 69 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
80 boolean visible = DomUtil.isVisible(e); | 80 boolean visible = DomUtil.isVisible(e); |
81 logVisibilityInfo(e, visible); | 81 logVisibilityInfo(e, visible); |
82 if (!visible) { | 82 if (!visible) { |
83 hiddenElements.add(e); | 83 hiddenElements.add(e); |
84 return false; | 84 return false; |
85 } | 85 } |
86 | 86 |
87 // Node-type specific extractors check for elements they are interested
in here. Everything | 87 // Node-type specific extractors check for elements they are interested
in here. Everything |
88 // else will be filtered through the switch below. | 88 // else will be filtered through the switch below. |
89 | 89 |
90 // Check for embedded elements that might be extracted. | 90 try { |
91 if (embedTagNames.contains(e.getTagName())) { | 91 // Check for embedded elements that might be extracted. |
92 // If the tag is marked as interesting, check the extractors. | 92 if (embedTagNames.contains(e.getTagName())) { |
93 for (EmbedExtractor extractor : extractors) { | 93 // If the tag is marked as interesting, check the extractors. |
94 WebElement embed = extractor.extract(e); | 94 for (EmbedExtractor extractor : extractors) { |
95 if (embed != null) { | 95 WebElement embed = extractor.extract(e); |
96 builder.embed(embed); | 96 if (embed != null) { |
97 return false; | 97 builder.embed(embed); |
| 98 return false; |
| 99 } |
98 } | 100 } |
99 } | 101 } |
| 102 } catch (Exception exception) { |
| 103 LogUtil.logToConsole( |
| 104 "Exception happened in EmbedExtractors: " + exception.getMessage
()); |
100 } | 105 } |
101 | 106 |
102 // Skip IFRAMEs not recognized by EmbedExtractors. | 107 // Skip IFRAMEs not recognized by EmbedExtractors. |
103 if (e.getTagName().equals("IFRAME")) { | 108 if (e.getTagName().equals("IFRAME")) { |
104 return false; | 109 return false; |
105 } | 110 } |
106 | 111 |
107 // Create a placeholder for the elements we want to preserve. | 112 // Create a placeholder for the elements we want to preserve. |
108 if (WebTag.canBeNested(e.getTagName())) { | 113 if (WebTag.canBeNested(e.getTagName())) { |
109 builder.tag(new WebTag(e.getTagName(), WebTag.TagType.START)); | 114 builder.tag(new WebTag(e.getTagName(), WebTag.TagType.START)); |
(...skipping 66 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 Element parent = e.getParentElement(); | 181 Element parent = e.getParentElement(); |
177 LogUtil.logToConsole("TABLE: " + type + | 182 LogUtil.logToConsole("TABLE: " + type + |
178 ", id=" + e.getId() + | 183 ", id=" + e.getId() + |
179 ", class=" + e.getClassName() + | 184 ", class=" + e.getClassName() + |
180 ", parent=[" + parent.getTagName() + | 185 ", parent=[" + parent.getTagName() + |
181 ", id=" + parent.getId() + | 186 ", id=" + parent.getId() + |
182 ", class=" + parent.getClassName() + | 187 ", class=" + parent.getClassName() + |
183 "]"); | 188 "]"); |
184 } | 189 } |
185 } | 190 } |
OLD | NEW |