Chromium Code Reviews| Index: java/org/chromium/distiller/webdocument/WebImage.java |
| diff --git a/java/org/chromium/distiller/webdocument/WebImage.java b/java/org/chromium/distiller/webdocument/WebImage.java |
| index ceb3a405279c3dbf95c723c6eb9ced12f7a095b6..df50a3587252627a5c89525eeaed13bed835f89c 100644 |
| --- a/java/org/chromium/distiller/webdocument/WebImage.java |
| +++ b/java/org/chromium/distiller/webdocument/WebImage.java |
| @@ -10,6 +10,9 @@ import com.google.gwt.dom.client.ImageElement; |
| import org.chromium.distiller.DomUtil; |
| +import java.util.ArrayList; |
| +import java.util.List; |
| + |
| /** |
| * WebImage represents an image in the WebDocument potentially needing extraction. |
| */ |
| @@ -22,6 +25,8 @@ public class WebImage extends WebElement { |
| private int width; |
| // The original height of the image in pixels. |
| private int height; |
| + // The list of image URLs. |
| + private List<String> list; |
| /** |
| * Build an image element. |
| @@ -56,6 +61,10 @@ public class WebImage extends WebElement { |
| DomUtil.makeSrcSetAbsolute(ie); |
| DomUtil.stripImageElement(ie); |
| + list = new ArrayList<>(); |
| + list.add(srcUrl); |
| + list.addAll(DomUtil.getSrcSetUrls(ie)); |
| + |
| Element container = Document.get().createDivElement(); |
| container.appendChild(ie); |
| return container.getInnerHTML(); |
| @@ -86,10 +95,14 @@ public class WebImage extends WebElement { |
| } |
| /** |
| - * Get the source URL of this image. |
| - * @return Source URL or an empty string. |
| + * Get the list of source URLs of this image. |
| + * It's more efficient to call after generateOutput(). |
| + * @return Source URLs or an empty List. |
| */ |
| - public String getSrc() { |
| - return srcUrl; |
| + public List<String> getUrlList() { |
| + if (list == null) { |
| + generateOutput(false); |
|
wychen
2016/08/01 20:59:20
This feels entangled. :(
mdjones
2016/08/01 21:14:35
Can we instead cut the top part of generateOutput
wychen
2016/08/01 21:35:15
Done.
|
| + } |
| + return list; |
| } |
| } |