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

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: comments addressed Created 4 years, 9 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
« no previous file with comments | « java/org/chromium/distiller/DomUtil.java ('k') | java/org/chromium/distiller/webdocument/WebImage.java » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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..c9b527a117c8c5d99d483b94de5ff2bd6d486f9c 100644
--- a/java/org/chromium/distiller/extractors/embeds/ImageExtractor.java
+++ b/java/org/chromium/distiller/extractors/embeds/ImageExtractor.java
@@ -33,11 +33,21 @@ public class ImageExtractor implements EmbedExtractor {
return null;
}
String imgSrc = "";
+ // Getting OffSetWidth/Height as default values, even they are
+ // affected by padding, border, etc.
+ int width = e.getOffsetWidth();
+ int height = e.getOffsetHeight();
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 displayed image dimension.
+ ImageElement imageElement = ImageElement.as(e);
+ imgSrc = imageElement.getSrc();
+ // As an ImageElement is manipulated here, it is possible
+ // to get the real dimensions.
+ width = imageElement.getWidth();
+ height = imageElement.getHeight();
}
- return new WebImage(e, e.getOffsetWidth(), e.getOffsetHeight(), imgSrc);
+ return new WebImage(e, width, height, imgSrc);
}
}
« no previous file with comments | « java/org/chromium/distiller/DomUtil.java ('k') | java/org/chromium/distiller/webdocument/WebImage.java » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698