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

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

Issue 2000093005: Support extraction of lazily-loaded images (Closed) Base URL: git@github.com:chromium/dom-distiller.git@master
Patch Set: fix comments Created 4 years, 6 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
1 // Copyright 2015 The Chromium Authors. All rights reserved. 1 // Copyright 2015 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.webdocument; 5 package org.chromium.distiller.webdocument;
6 6
7 import com.google.gwt.dom.client.Document; 7 import com.google.gwt.dom.client.Document;
8 import com.google.gwt.dom.client.Element; 8 import com.google.gwt.dom.client.Element;
9 import com.google.gwt.dom.client.ImageElement; 9 import com.google.gwt.dom.client.ImageElement;
10 10
(...skipping 27 matching lines...) Expand all
38 if (srcUrl == null) { 38 if (srcUrl == null) {
39 srcUrl = ""; 39 srcUrl = "";
40 } 40 }
41 } 41 }
42 42
43 @Override 43 @Override
44 public String generateOutput(boolean textOnly) { 44 public String generateOutput(boolean textOnly) {
45 if (textOnly) return ""; 45 if (textOnly) return "";
46 46
47 ImageElement ie = ImageElement.as(Element.as(imgElement.cloneNode(false) )); 47 ImageElement ie = ImageElement.as(Element.as(imgElement.cloneNode(false) ));
48 ie.setSrc(srcUrl);
48 ie.setSrc(ie.getSrc()); 49 ie.setSrc(ie.getSrc());
49 // If computed width or height is zero, do not override them 50 // If computed width or height is zero, do not override them
50 // to keep them visible. 51 // to keep them visible.
51 if (width > 0 && height > 0) { 52 if (width > 0 && height > 0) {
52 ie.setWidth(width); 53 ie.setWidth(width);
53 ie.setHeight(height); 54 ie.setHeight(height);
54 } 55 }
55 DomUtil.makeSrcSetAbsolute(ie); 56 DomUtil.makeSrcSetAbsolute(ie);
56 DomUtil.stripImageElement(ie); 57 DomUtil.stripImageElement(ie);
57 58
(...skipping 27 matching lines...) Expand all
85 } 86 }
86 87
87 /** 88 /**
88 * Get the source URL of this image. 89 * Get the source URL of this image.
89 * @return Source URL or an empty string. 90 * @return Source URL or an empty string.
90 */ 91 */
91 public String getSrc() { 92 public String getSrc() {
92 return srcUrl; 93 return srcUrl;
93 } 94 }
94 } 95 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698