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 java.util.List; | 7 import java.util.List; |
8 import java.util.ArrayList; | 8 import java.util.ArrayList; |
9 | 9 |
10 import com.google.gwt.dom.client.AnchorElement; | 10 import com.google.gwt.dom.client.AnchorElement; |
(...skipping 91 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
102 return m; | 102 return m; |
103 } | 103 } |
104 | 104 |
105 public static MetaElement createMetaName(String name, String content) { | 105 public static MetaElement createMetaName(String name, String content) { |
106 MetaElement m = Document.get().createMetaElement(); | 106 MetaElement m = Document.get().createMetaElement(); |
107 m.setName(name); | 107 m.setName(name); |
108 m.setContent(content); | 108 m.setContent(content); |
109 return m; | 109 return m; |
110 } | 110 } |
111 | 111 |
| 112 public static Element createSpan(String value) { |
| 113 Element s = Document.get().createElement("SPAN"); |
| 114 s.setInnerHTML(value); |
| 115 return s; |
| 116 } |
| 117 |
112 private static void createDivTreeImpl(Element e, int depth, List<Element> di
vs) { | 118 private static void createDivTreeImpl(Element e, int depth, List<Element> di
vs) { |
113 if (depth > 2) return; | 119 if (depth > 2) return; |
114 for (int i = 0; i < 2; i++) { | 120 for (int i = 0; i < 2; i++) { |
115 Element child = createDiv(divs.size()); | 121 Element child = createDiv(divs.size()); |
116 divs.add(child); | 122 divs.add(child); |
117 e.appendChild(child); | 123 e.appendChild(child); |
118 createDivTreeImpl(child, depth + 1, divs); | 124 createDivTreeImpl(child, depth + 1, divs); |
119 } | 125 } |
120 } | 126 } |
121 | 127 |
122 public static String getElementAsString(Element e) { | 128 public static String getElementAsString(Element e) { |
123 Element div = Document.get().createDivElement(); | 129 Element div = Document.get().createDivElement(); |
124 div.appendChild(e.cloneNode(true)); | 130 div.appendChild(e.cloneNode(true)); |
125 return div.getInnerHTML(); | 131 return div.getInnerHTML(); |
126 } | 132 } |
127 | 133 |
128 public static String formHrefWithWindowLocationPath(String strToAppend) { | 134 public static String formHrefWithWindowLocationPath(String strToAppend) { |
129 String noUrlParams = Window.Location.getPath(); | 135 String noUrlParams = Window.Location.getPath(); |
130 // Append '/' if necessary. | 136 // Append '/' if necessary. |
131 if (!strToAppend.isEmpty() && !StringUtil.match(noUrlParams, "\\/$")) { | 137 if (!strToAppend.isEmpty() && !StringUtil.match(noUrlParams, "\\/$")) { |
132 noUrlParams += "/"; | 138 noUrlParams += "/"; |
133 } | 139 } |
134 return noUrlParams + strToAppend; | 140 return noUrlParams + strToAppend; |
135 } | 141 } |
136 | 142 |
137 } | 143 } |
OLD | NEW |