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 com.google.gwt.dom.client.Element; | 7 import com.google.gwt.dom.client.Element; |
8 import com.google.gwt.dom.client.ImageElement; | 8 import com.google.gwt.dom.client.ImageElement; |
9 import com.google.gwt.dom.client.MetaElement; | 9 import com.google.gwt.dom.client.MetaElement; |
10 import com.google.gwt.dom.client.NodeList; | 10 import com.google.gwt.dom.client.NodeList; |
(...skipping 29 matching lines...) Expand all Loading... |
40 mRoot = root; | 40 mRoot = root; |
41 mAllMeta = root.getElementsByTagName("META"); | 41 mAllMeta = root.getElementsByTagName("META"); |
42 } | 42 } |
43 | 43 |
44 @Override | 44 @Override |
45 public String getTitle() { | 45 public String getTitle() { |
46 if (mTitle == null) findTitle(); | 46 if (mTitle == null) findTitle(); |
47 return mTitle; | 47 return mTitle; |
48 } | 48 } |
49 | 49 |
| 50 @Override |
50 public String getType() { | 51 public String getType() { |
51 return ""; // Not supported. | 52 return ""; // Not supported. |
52 } | 53 } |
53 | 54 |
54 @Override | 55 @Override |
55 public String getUrl() { | 56 public String getUrl() { |
56 return ""; // Not supported. | 57 return ""; // Not supported. |
57 } | 58 } |
58 | 59 |
59 @Override | 60 @Override |
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
230 String caption = ""; | 231 String caption = ""; |
231 if (numCaptions > 0 && numCaptions <= 2) { | 232 if (numCaptions > 0 && numCaptions <= 2) { |
232 // Use javascript innerText (instead of javascript textContent) to g
et only visible | 233 // Use javascript innerText (instead of javascript textContent) to g
et only visible |
233 // captions. | 234 // captions. |
234 for (int i = 0; i < numCaptions && caption.isEmpty(); i++) { | 235 for (int i = 0; i < numCaptions && caption.isEmpty(); i++) { |
235 caption = DomUtil.getInnerText(captions.getItem(i)); | 236 caption = DomUtil.getInnerText(captions.getItem(i)); |
236 } | 237 } |
237 } | 238 } |
238 return caption; | 239 return caption; |
239 } | 240 } |
240 | |
241 private static boolean isTextInBody(Element root, String text) { | |
242 String lowerText = text.toLowerCase(); | |
243 NodeList<Element> bodies = root.getElementsByTagName("BODY"); | |
244 for (int i = 0; i < bodies.getLength(); i++) { | |
245 // Use javascript textContent (instead of javascript innerText) to i
nclude invisible | |
246 // text. | |
247 if (DomUtil.javascriptTextContent( | |
248 bodies.getItem(i)).toLowerCase().contains(lowerText)) { | |
249 return true; | |
250 } | |
251 } | |
252 return false; | |
253 } | |
254 } | 241 } |
OLD | NEW |