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 com.dom_distiller.client; | 5 package com.dom_distiller.client; |
6 | 6 |
7 import com.google.gwt.core.client.JsArray; | 7 import com.google.gwt.core.client.JsArray; |
8 import com.google.gwt.dom.client.Element; | 8 import com.google.gwt.dom.client.Element; |
9 import com.google.gwt.dom.client.Node; | 9 import com.google.gwt.dom.client.Node; |
10 import com.google.gwt.dom.client.NodeList; | 10 import com.google.gwt.dom.client.NodeList; |
(...skipping 78 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 public static String getInnerText(Node node) { | 89 public static String getInnerText(Node node) { |
90 String text = javascriptInnerText(node); | 90 String text = javascriptInnerText(node); |
91 if (text != null) return text; | 91 if (text != null) return text; |
92 return node.getNodeType() == Node.ELEMENT_NODE ? Element.as(node).getInn
erText() : ""; | 92 return node.getNodeType() == Node.ELEMENT_NODE ? Element.as(node).getInn
erText() : ""; |
93 } | 93 } |
94 | 94 |
95 private static native String javascriptInnerText(Node node) /*-{ | 95 private static native String javascriptInnerText(Node node) /*-{ |
96 return node.innerText; | 96 return node.innerText; |
97 }-*/; | 97 }-*/; |
98 | 98 |
| 99 public static native double getTime() /*-{ |
| 100 // window.performance is unavailable in Gwt's dev environment. |
| 101 return window.performance ? window.performance.now() : 0; |
| 102 }-*/; |
| 103 |
99 /** | 104 /** |
100 * Use jsni for direct access to javascript's textContent. textContent is d
ifferent from | 105 * Use jsni for direct access to javascript's textContent. textContent is d
ifferent from |
101 * innerText (see http://www.kellegous.com/j/2013/02/27/innertext-vs-textcon
tent): | 106 * innerText (see http://www.kellegous.com/j/2013/02/27/innertext-vs-textcon
tent): |
102 * - textContent is the raw textual content, doesn't require layout, and is
basically a | 107 * - textContent is the raw textual content, doesn't require layout, and is
basically a |
103 * concatenation of the values of all text nodes within a subtree. | 108 * concatenation of the values of all text nodes within a subtree. |
104 * - innerText is what is presented to the user, requires layout, and exclud
es text in invisible | 109 * - innerText is what is presented to the user, requires layout, and exclud
es text in invisible |
105 * elements, e.g. <title> tags. | 110 * elements, e.g. <title> tags. |
106 */ | 111 */ |
107 public static native String javascriptTextContent(Node node) /*-{ | 112 public static native String javascriptTextContent(Node node) /*-{ |
108 return node.textContent; | 113 return node.textContent; |
109 }-*/; | 114 }-*/; |
110 } | 115 } |
OLD | NEW |