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.AnchorElement; | 7 import com.google.gwt.dom.client.AnchorElement; |
8 import com.google.gwt.dom.client.Document; | 8 import com.google.gwt.dom.client.Document; |
9 import com.google.gwt.dom.client.Element; | 9 import com.google.gwt.dom.client.Element; |
10 import com.google.gwt.dom.client.HeadingElement; | 10 import com.google.gwt.dom.client.HeadingElement; |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
113 m.setContent(content); | 113 m.setContent(content); |
114 return m; | 114 return m; |
115 } | 115 } |
116 | 116 |
117 public static Element createSpan(String value) { | 117 public static Element createSpan(String value) { |
118 Element s = Document.get().createElement("SPAN"); | 118 Element s = Document.get().createElement("SPAN"); |
119 s.setInnerHTML(value); | 119 s.setInnerHTML(value); |
120 return s; | 120 return s; |
121 } | 121 } |
122 | 122 |
| 123 public static Element createParagraph(String value) { |
| 124 Element s = Document.get().createElement("P"); |
| 125 s.setInnerHTML(value); |
| 126 return s; |
| 127 } |
| 128 |
| 129 public static Element createListItem(String value) { |
| 130 Element s = Document.get().createElement("LI"); |
| 131 s.setInnerText(value); |
| 132 return s; |
| 133 } |
| 134 |
123 private static void createDivTreeImpl(Element e, int depth, List<Element> di
vs) { | 135 private static void createDivTreeImpl(Element e, int depth, List<Element> di
vs) { |
124 if (depth > 2) return; | 136 if (depth > 2) return; |
125 for (int i = 0; i < 2; i++) { | 137 for (int i = 0; i < 2; i++) { |
126 Element child = createDiv(divs.size()); | 138 Element child = createDiv(divs.size()); |
127 divs.add(child); | 139 divs.add(child); |
128 e.appendChild(child); | 140 e.appendChild(child); |
129 createDivTreeImpl(child, depth + 1, divs); | 141 createDivTreeImpl(child, depth + 1, divs); |
130 } | 142 } |
131 } | 143 } |
132 | 144 |
(...skipping 19 matching lines...) Expand all Loading... |
152 /** | 164 /** |
153 * Randomly shuffle the list in-place. | 165 * Randomly shuffle the list in-place. |
154 */ | 166 */ |
155 public static void shuffle(List<?> list) { | 167 public static void shuffle(List<?> list) { |
156 int size = list.size(); | 168 int size = list.size(); |
157 for (int i=size; i>1; i--) { | 169 for (int i=size; i>1; i--) { |
158 Collections.swap(list, i-1, Random.nextInt(i)); | 170 Collections.swap(list, i-1, Random.nextInt(i)); |
159 } | 171 } |
160 } | 172 } |
161 } | 173 } |
OLD | NEW |