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

Side by Side 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 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.extractors.embeds; 5 package org.chromium.distiller.extractors.embeds;
6 6
7 import com.google.gwt.dom.client.Element; 7 import com.google.gwt.dom.client.Element;
8 import com.google.gwt.dom.client.ImageElement; 8 import com.google.gwt.dom.client.ImageElement;
9 import org.chromium.distiller.webdocument.WebImage; 9 import org.chromium.distiller.webdocument.WebImage;
10 10
(...skipping 15 matching lines...) Expand all
26 public Set<String> getRelevantTagNames() { 26 public Set<String> getRelevantTagNames() {
27 return relevantTags; 27 return relevantTags;
28 } 28 }
29 29
30 @Override 30 @Override
31 public WebImage extract(Element e) { 31 public WebImage extract(Element e) {
32 if (!relevantTags.contains(e.getTagName())) { 32 if (!relevantTags.contains(e.getTagName())) {
33 return null; 33 return null;
34 } 34 }
35 String imgSrc = ""; 35 String imgSrc = "";
36 // Getting OffSetWidth/Height as default values, even they are
37 // affected by padding, border, etc.
38 int width = e.getOffsetWidth();
39 int height = e.getOffsetHeight();
36 if ("IMG".equals(e.getTagName())) { 40 if ("IMG".equals(e.getTagName())) {
37 // This will get the absolute URL of the image. 41 // This will get the absolute URL of the image and
38 imgSrc = ImageElement.as(e).getSrc(); 42 // the displayed image dimension.
43 ImageElement imageElement = ImageElement.as(e);
44 imgSrc = imageElement.getSrc();
45 // As an ImageElement is manipulated here, it is possible
46 // to get the real dimensions.
47 width = imageElement.getWidth();
48 height = imageElement.getHeight();
39 } 49 }
40 50
41 return new WebImage(e, e.getOffsetWidth(), e.getOffsetHeight(), imgSrc); 51 return new WebImage(e, width, height, imgSrc);
42 } 52 }
43 } 53 }
OLDNEW
« 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