Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 Loading... | |
| 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 int width = e.getOffsetWidth(); | |
| 37 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.
| |
| 36 if ("IMG".equals(e.getTagName())) { | 38 if ("IMG".equals(e.getTagName())) { |
| 37 // This will get the absolute URL of the image. | 39 // This will get the absolute URL of the image and |
| 38 imgSrc = ImageElement.as(e).getSrc(); | 40 // the real image dimension. |
| 41 ImageElement imageElement = ImageElement.as(e); | |
| 42 imgSrc = imageElement.getSrc(); | |
| 43 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
| |
| 44 height = imageElement.getHeight(); | |
| 39 } | 45 } |
| 40 | 46 |
| 41 return new WebImage(e, e.getOffsetWidth(), e.getOffsetHeight(), imgSrc); | 47 return new WebImage(e, width, height, imgSrc); |
| 42 } | 48 } |
| 43 } | 49 } |
| OLD | NEW |