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

Side by Side Diff: java/org/chromium/distiller/TableClassifier.java

Issue 1725243002: Fix some warnings in Eclipse (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: address comments Created 4 years, 7 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; 5 package org.chromium.distiller;
6 6
7 import com.google.gwt.dom.client.Element; 7 import com.google.gwt.dom.client.Element;
8 import com.google.gwt.dom.client.MetaElement; 8 import com.google.gwt.dom.client.MetaElement;
9 import com.google.gwt.dom.client.NodeList; 9 import com.google.gwt.dom.client.NodeList;
10 import com.google.gwt.dom.client.TableCellElement; 10 import com.google.gwt.dom.client.TableCellElement;
(...skipping 179 matching lines...) Expand 10 before | Expand all | Expand 10 after
190 } 190 }
191 } 191 }
192 192
193 // 9) Table occupying > 95% of document width without viewport meta is l ayout table; 193 // 9) Table occupying > 95% of document width without viewport meta is l ayout table;
194 // viewport condition is not in said url, added here for typical mobile- optimized sites. 194 // viewport condition is not in said url, added here for typical mobile- optimized sites.
195 // The order here is different from said url: the latter has it after #1 4 (>=20 rows is 195 // The order here is different from said url: the latter has it after #1 4 (>=20 rows is
196 // data table), but our eval sets indicate the need to bump this way up to here, because 196 // data table), but our eval sets indicate the need to bump this way up to here, because
197 // many (old) pages have layout tables with the "summary" attribute (#10 ). 197 // many (old) pages have layout tables with the "summary" attribute (#10 ).
198 Element docElement = t.getOwnerDocument().getDocumentElement(); 198 Element docElement = t.getOwnerDocument().getDocumentElement();
199 int docWidth = docElement.getOffsetWidth(); 199 int docWidth = docElement.getOffsetWidth();
200 if (docWidth > 0 && (double) t.getOffsetWidth() > 0.95 * (double) docWid th) { 200 if (docWidth > 0 && t.getOffsetWidth() > 0.95 * docWidth) {
201 boolean viewportFound = false; 201 boolean viewportFound = false;
202 NodeList<Element> allMeta = docElement.getElementsByTagName("META"); 202 NodeList<Element> allMeta = docElement.getElementsByTagName("META");
203 for (int i = 0; i < allMeta.getLength() && !viewportFound; i++) { 203 for (int i = 0; i < allMeta.getLength() && !viewportFound; i++) {
204 MetaElement meta = MetaElement.as(allMeta.getItem(i)); 204 MetaElement meta = MetaElement.as(allMeta.getItem(i));
205 viewportFound = meta.getName().equalsIgnoreCase("viewport"); 205 viewportFound = meta.getName().equalsIgnoreCase("viewport");
206 } 206 }
207 if (!viewportFound) { 207 if (!viewportFound) {
208 return logAndReturn(Reason.MORE_95_PERCENT_DOC_WIDTH, "", Type.L AYOUT); 208 return logAndReturn(Reason.MORE_95_PERCENT_DOC_WIDTH, "", Type.L AYOUT);
209 } 209 }
210 } 210 }
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
250 // advertisement elements) is layout table. 250 // advertisement elements) is layout table.
251 if (hasOneOfElements(directDescendants, sObjectTags)) { 251 if (hasOneOfElements(directDescendants, sObjectTags)) {
252 return logAndReturn(Reason.EMBED_OBJECT_APPLET_IFRAME, "", Type.LAYO UT); 252 return logAndReturn(Reason.EMBED_OBJECT_APPLET_IFRAME, "", Type.LAYO UT);
253 } 253 }
254 254
255 // 17) Table occupying > 90% of document height is layout table. 255 // 17) Table occupying > 90% of document height is layout table.
256 // This is not in said url, added here because many (old) pages have tab les that don't fall 256 // This is not in said url, added here because many (old) pages have tab les that don't fall
257 // into any of the above heuristics but are for layout, and hence should n't default to data 257 // into any of the above heuristics but are for layout, and hence should n't default to data
258 // by #18. 258 // by #18.
259 int docHeight = docElement.getOffsetHeight(); 259 int docHeight = docElement.getOffsetHeight();
260 if (docHeight > 0 && (double) t.getOffsetHeight() > 0.9 * (double) docHe ight) { 260 if (docHeight > 0 && t.getOffsetHeight() > 0.9 * docHeight) {
261 return logAndReturn(Reason.MORE_90_PERCENT_DOC_HEIGHT, "", Type.LAYO UT); 261 return logAndReturn(Reason.MORE_90_PERCENT_DOC_HEIGHT, "", Type.LAYO UT);
262 } 262 }
263 263
264 // 18) Otherwise, it's data table. 264 // 18) Otherwise, it's data table.
265 return logAndReturn(Reason.DEFAULT, "", Type.DATA); 265 return logAndReturn(Reason.DEFAULT, "", Type.DATA);
266 } 266 }
267 267
268 private static boolean hasNestedTables(Element t) { 268 private static boolean hasNestedTables(Element t) {
269 return t.getElementsByTagName("TABLE").getLength() > 0; 269 return t.getElementsByTagName("TABLE").getLength() > 0;
270 } 270 }
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after
323 } 323 }
324 324
325 private static Type logAndReturn(Reason reason, String append, Type type) { 325 private static Type logAndReturn(Reason reason, String append, Type type) {
326 if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO)) { 326 if (LogUtil.isLoggable(LogUtil.DEBUG_LEVEL_VISIBILITY_INFO)) {
327 LogUtil.logToConsole(reason + append + " -> " + type); 327 LogUtil.logToConsole(reason + append + " -> " + type);
328 } 328 }
329 sReason = reason; 329 sReason = reason;
330 return type; 330 return type;
331 } 331 }
332 } 332 }
OLDNEW
« no previous file with comments | « java/org/chromium/distiller/StringUtil.java ('k') | java/org/chromium/distiller/TreeCloneBuilder.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698