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

Unified Diff: java/org/chromium/distiller/extractors/embeds/ImageExtractor.java

Issue 1754213004: Retain image sizes (Closed) Base URL: https://github.com/chromium/dom-distiller.git@master
Patch Set: Moving preserved attributes to the whitelist. Created 4 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: java/org/chromium/distiller/extractors/embeds/ImageExtractor.java
diff --git a/java/org/chromium/distiller/extractors/embeds/ImageExtractor.java b/java/org/chromium/distiller/extractors/embeds/ImageExtractor.java
index a450ea9d23f276a71b664a0e78254dee7159fdeb..a03fbfc882c61d6ee5e1c409dd45499cd9da1242 100644
--- a/java/org/chromium/distiller/extractors/embeds/ImageExtractor.java
+++ b/java/org/chromium/distiller/extractors/embeds/ImageExtractor.java
@@ -33,11 +33,17 @@ public class ImageExtractor implements EmbedExtractor {
return null;
}
String imgSrc = "";
+ int width = e.getOffsetWidth();
+ int height = e.getOffsetHeight();
wychen 2016/03/11 08:25:35 offsetWidth/Height would be affected by padding, b
dalmirsilva 2016/03/14 18:28:06 Done.
if ("IMG".equals(e.getTagName())) {
- // This will get the absolute URL of the image.
- imgSrc = ImageElement.as(e).getSrc();
+ // This will get the absolute URL of the image and
+ // the real image dimension.
+ ImageElement imageElement = ImageElement.as(e);
+ imgSrc = imageElement.getSrc();
+ width = imageElement.getWidth();
wychen 2016/03/11 08:25:35 What if the dimension specified in CSS is differen
wychen 2016/03/11 08:25:35 If only width or height is specified, the other on
dalmirsilva 2016/03/14 18:28:05 We believe GWT uses getWidth/Height as native meth
+ height = imageElement.getHeight();
}
- return new WebImage(e, e.getOffsetWidth(), e.getOffsetHeight(), imgSrc);
+ return new WebImage(e, width, height, imgSrc);
}
}

Powered by Google App Engine
This is Rietveld 408576698