| OLD | NEW |
| 1 package org.chromium.distiller.webdocument; | 1 package org.chromium.distiller.webdocument; |
| 2 | 2 |
| 3 import com.google.gwt.dom.client.Document; | 3 import com.google.gwt.dom.client.Document; |
| 4 import com.google.gwt.dom.client.Element; | 4 import com.google.gwt.dom.client.Element; |
| 5 import org.chromium.distiller.DomUtil; | 5 import org.chromium.distiller.DomUtil; |
| 6 | 6 |
| 7 /** | 7 /** |
| 8 * WebFigure represents a figure element, containing an image and optionally a c
aption. | 8 * WebFigure represents a figure element, containing an image and optionally a c
aption. |
| 9 */ | 9 */ |
| 10 public class WebFigure extends WebImage { | 10 public class WebFigure extends WebImage { |
| (...skipping 14 matching lines...) Expand all Loading... |
| 25 } | 25 } |
| 26 | 26 |
| 27 /** | 27 /** |
| 28 * WebFigure extends WebImage so it can use WebImage generated output | 28 * WebFigure extends WebImage so it can use WebImage generated output |
| 29 * and just handle the caption since an html figure is basically a | 29 * and just handle the caption since an html figure is basically a |
| 30 * placeholder for an image and a caption. | 30 * placeholder for an image and a caption. |
| 31 */ | 31 */ |
| 32 @Override | 32 @Override |
| 33 public String generateOutput(boolean textOnly) { | 33 public String generateOutput(boolean textOnly) { |
| 34 Element figcaption = DomUtil.cloneAndProcessTree(figCaption); | 34 Element figcaption = DomUtil.cloneAndProcessTree(figCaption); |
| 35 // TODO(wychen): .textContent should be identical to .innerText | 35 if (textOnly) return DomUtil.getInnerText(figcaption); |
| 36 // in our use cases, but needs verification. | |
| 37 if (textOnly) return DomUtil.javascriptTextContent(figcaption); | |
| 38 | 36 |
| 39 Element figure = Document.get().createElement("FIGURE"); | 37 Element figure = Document.get().createElement("FIGURE"); |
| 40 figure.appendChild(getProcessedNode()); | 38 figure.appendChild(getProcessedNode()); |
| 41 if (!figCaption.getInnerHTML().isEmpty()) { | 39 if (!figCaption.getInnerHTML().isEmpty()) { |
| 42 figure.appendChild(figcaption); | 40 figure.appendChild(figcaption); |
| 43 } | 41 } |
| 44 return figure.getString(); | 42 return figure.getString(); |
| 45 } | 43 } |
| 46 } | 44 } |
| OLD | NEW |