Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 package org.chromium.distiller.webdocument; | |
| 2 | |
| 3 import com.google.gwt.dom.client.Document; | |
| 4 import com.google.gwt.dom.client.Element; | |
| 5 import org.chromium.distiller.DomUtil; | |
| 6 | |
| 7 /** | |
| 8 * WebFigure represents a html figure tag which contains an image and | |
|
wychen
2016/08/05 02:13:03
... represents a figure element, containing an ima
| |
| 9 * may or may not contain a caption. | |
| 10 */ | |
| 11 public class WebFigure extends WebImage { | |
| 12 | |
| 13 private Element figCaption; | |
| 14 | |
| 15 /** | |
| 16 * Build a figure element. | |
| 17 * @param e The element detected as an image. | |
| 18 * @param w The original width of the image. | |
| 19 * @param h The original height of the image. | |
| 20 * @param src The source URL of the image being extracted. | |
| 21 * @param caption The element containing the caption of the image. | |
| 22 */ | |
| 23 public WebFigure(Element e, int w, int h, String src, Element caption) { | |
| 24 super(e, w, h, src); | |
| 25 figCaption = caption; | |
| 26 } | |
| 27 | |
| 28 @Override | |
| 29 /** | |
| 30 * WebFigure extends WebImage so it can use WebImage generated output | |
| 31 * and just handle he caption since an html figure is basically a | |
|
wychen
2016/08/05 02:13:03
the
| |
| 32 * placeholder for an image and a caption. | |
| 33 */ | |
| 34 public String generateOutput(boolean textOnly) { | |
| 35 String caption = DomUtil.generateOutputFromTree(figCaption, textOnly); | |
| 36 if (textOnly) return caption; | |
| 37 | |
| 38 Element figure = Document.get().createElement("FIGURE"); | |
| 39 figure.setInnerHTML(super.generateOutput(false)); | |
|
wychen
2016/08/05 02:13:03
Could you rebase and add to WebImage:
protected Im
| |
| 40 if (!figCaption.getInnerHTML().isEmpty()) { | |
| 41 Element container = Document.get().createElement("DIV"); | |
|
wychen
2016/08/05 02:13:03
We could just use:
figure.appendChild(caption)
| |
| 42 container.setInnerHTML(caption); | |
| 43 figure.appendChild(container.getChild(0)); | |
| 44 } | |
| 45 return figure.getString(); | |
| 46 } | |
| 47 } | |
| OLD | NEW |