Chromium Code Reviews| 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; | 5 package org.chromium.distiller; |
| 6 | 6 |
| 7 import org.chromium.distiller.proto.DomDistillerProtos; | 7 import org.chromium.distiller.proto.DomDistillerProtos; |
| 8 import org.chromium.distiller.proto.DomDistillerProtos.DebugInfo; | 8 import org.chromium.distiller.proto.DomDistillerProtos.DebugInfo; |
| 9 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo; | 9 import org.chromium.distiller.proto.DomDistillerProtos.TimingInfo; |
| 10 import org.chromium.distiller.StringUtil; | |
| 10 | 11 |
| 11 import com.google.gwt.core.client.js.JsExport; | 12 import com.google.gwt.core.client.js.JsExport; |
| 12 import com.google.gwt.dom.client.Document; | 13 import com.google.gwt.dom.client.Document; |
| 13 import com.google.gwt.user.client.Window; | 14 import com.google.gwt.user.client.Window; |
| 14 | 15 |
| 15 @JsExport("DomDistiller") | 16 @JsExport("DomDistiller") |
| 16 public class DomDistiller { | 17 public class DomDistiller { |
| 17 @JsExport | 18 @JsExport |
| 18 public static DomDistillerProtos.DomDistillerResult apply() { | 19 public static DomDistillerProtos.DomDistillerResult apply() { |
| 19 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create()) ; | 20 return applyWithOptions(DomDistillerProtos.DomDistillerOptions.create()) ; |
| 20 } | 21 } |
| 21 | 22 |
| 22 @JsExport | 23 @JsExport |
| 23 public static DomDistillerProtos.DomDistillerResult applyWithOptions( | 24 public static DomDistillerProtos.DomDistillerResult applyWithOptions( |
| 24 DomDistillerProtos.DomDistillerOptions options) { | 25 DomDistillerProtos.DomDistillerOptions options) { |
| 25 double startTime = DomUtil.getTime(); | 26 double startTime = DomUtil.getTime(); |
| 27 StringUtil.selectCountWordsFunc(Document.get().getBody().getInnerText()) ; | |
|
cjhopman
2015/05/21 19:32:02
This should use textcontent not innertext
wychen
2015/05/21 23:07:03
Done.
| |
| 26 DomDistillerProtos.DomDistillerResult result = | 28 DomDistillerProtos.DomDistillerResult result = |
| 27 DomDistillerProtos.DomDistillerResult.create(); | 29 DomDistillerProtos.DomDistillerResult.create(); |
| 28 ContentExtractor contentExtractor = | 30 ContentExtractor contentExtractor = |
| 29 new ContentExtractor(Document.get().getDocumentElement()); | 31 new ContentExtractor(Document.get().getDocumentElement()); |
| 30 result.setTitle(contentExtractor.extractTitle()); | 32 result.setTitle(contentExtractor.extractTitle()); |
| 31 | 33 |
| 32 LogUtil.setDebugLevel( | 34 LogUtil.setDebugLevel( |
| 33 options.hasDebugLevel() ? options.getDebugLevel() : LogUtil.DEBU G_LEVEL_NONE); | 35 options.hasDebugLevel() ? options.getDebugLevel() : LogUtil.DEBU G_LEVEL_NONE); |
| 34 LogUtil.logToConsole("DomDistiller debug level: " + LogUtil.getDebugLeve l()); | 36 LogUtil.logToConsole("DomDistiller debug level: " + LogUtil.getDebugLeve l()); |
| 35 | 37 |
| (...skipping 15 matching lines...) Expand all Loading... | |
| 51 result.setMarkupInfo(contentExtractor.getMarkupParser().getMarkupInfo()) ; | 53 result.setMarkupInfo(contentExtractor.getMarkupParser().getMarkupInfo()) ; |
| 52 timingInfo.setTotalTime(DomUtil.getTime() - startTime); | 54 timingInfo.setTotalTime(DomUtil.getTime() - startTime); |
| 53 result.setTimingInfo(timingInfo); | 55 result.setTimingInfo(timingInfo); |
| 54 result.setStatisticsInfo(contentExtractor.getStatisticsInfo()); | 56 result.setStatisticsInfo(contentExtractor.getStatisticsInfo()); |
| 55 DebugInfo debugInfo = DebugInfo.create(); | 57 DebugInfo debugInfo = DebugInfo.create(); |
| 56 debugInfo.setLog(LogUtil.getAndClearLog()); | 58 debugInfo.setLog(LogUtil.getAndClearLog()); |
| 57 result.setDebugInfo(debugInfo); | 59 result.setDebugInfo(debugInfo); |
| 58 return result; | 60 return result; |
| 59 } | 61 } |
| 60 } | 62 } |
| OLD | NEW |