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

Side by Side Diff: src/com/dom_distiller/client/DomUtil.java

Issue 449923002: gwt getInnerText -> javascript innerText or textContent (Closed) Base URL: https://code.google.com/p/dom-distiller/@master
Patch Set: Created 6 years, 4 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 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 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 Style style = getComputedStyle(e); 71 Style style = getComputedStyle(e);
72 float opacity = 1.0F; 72 float opacity = 1.0F;
73 try { 73 try {
74 opacity = Float.parseFloat(style.getOpacity()); 74 opacity = Float.parseFloat(style.getOpacity());
75 } catch (NumberFormatException exception) { 75 } catch (NumberFormatException exception) {
76 } 76 }
77 return !(style.getDisplay().equals("none") || 77 return !(style.getDisplay().equals("none") ||
78 style.getVisibility().equals("hidden") || 78 style.getVisibility().equals("hidden") ||
79 opacity == 0.0F); 79 opacity == 0.0F);
80 } 80 }
81
82 /*
83 * We want to use jsni for direct access to javascript's innerText. This av oids GWT's
84 * implementation of Element::getInnerText(), which is intentionally differe nt to mimic an old
85 * IE behaviour, which returns text within <script> tags.
86 * However, in GWT, javascript innerText always returns null, so we fall bac k to the GWT
87 * implementation in that case to cater to GWT tests.
88 */
89 public static String getInnerText(Node node) {
90 String text = javascriptInnerText(node);
91 if (text != null) return text;
92 return node.getNodeType() == Node.ELEMENT_NODE ? Element.as(node).getInn erText() : "";
93 }
94
95 private static native String javascriptInnerText(Node node) /*-{
96 return node.innerText;
97 }-*/;
98
99 /**
100 * 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):
102 * - 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.
104 * - innerText is what is presented to the user, requires layout, and exclud es text in invisible
105 * elements, e.g. <title> tags.
106 */
107 public static native String javascriptTextContent(Node node) /*-{
108 return node.textContent;
109 }-*/;
81 } 110 }
OLDNEW
« no previous file with comments | « src/com/dom_distiller/client/DocumentTitleGetter.java ('k') | src/com/dom_distiller/client/IEReadingViewParser.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698