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

Side by Side Diff: java/org/chromium/distiller/webdocument/WebFigure.java

Issue 2020403002: Add support for figure element (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: mdjones' comments addressed Created 4 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
(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 figure element, containing an image and optionally a c aption.
9 */
10 public class WebFigure extends WebImage {
11
12 private Element figCaption;
13
14 /**
15 * Build a figure element.
16 * @param e The element detected as an image.
17 * @param w The original width of the image.
18 * @param h The original height of the image.
19 * @param src The source URL of the image being extracted.
20 * @param caption The element containing the caption of the image.
21 */
22 public WebFigure(Element e, int w, int h, String src, Element caption) {
23 super(e, w, h, src);
24 figCaption = caption;
25 }
26
27 /**
28 * WebFigure extends WebImage so it can use WebImage generated output
29 * and just handle the caption since an html figure is basically a
30 * placeholder for an image and a caption.
31 */
32 @Override
33 public String generateOutput(boolean textOnly) {
34 Element figcaption = DomUtil.cloneAndProcessTree(figCaption);
35 if (textOnly) return figcaption.getInnerText();
36
37 Element figure = Document.get().createElement("FIGURE");
38 figure.appendChild(getProcessedNode());
39 if (!figCaption.getInnerHTML().isEmpty()) {
40 figure.appendChild(figcaption);
41 }
42 return figure.getString();
43 }
44 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698