|
|
@@ -18,7 +18,7 @@
|
|
|
* along with SingleFile. If not, see <http://www.gnu.org/licenses/>.
|
|
|
*/
|
|
|
|
|
|
-/* global fontFaceProxy */
|
|
|
+/* global fontFaceProxy, getComputedStyle */
|
|
|
|
|
|
this.docHelper = this.docHelper || (() => {
|
|
|
|
|
|
@@ -161,7 +161,10 @@ this.docHelper = this.docHelper || (() => {
|
|
|
doc.querySelectorAll("img[src]").forEach((imageElement, imageElementIndex) => {
|
|
|
imageElement.setAttribute(imagesAttributeName(options.sessionId), imageElementIndex);
|
|
|
let imageData;
|
|
|
- if (imageElement.src) {
|
|
|
+ const computedStyle = getComputedStyle(imageElement);
|
|
|
+ const paddingIsSet = computedStyle.padding != "0px";
|
|
|
+ const marginIsSet = computedStyle.margin != "0px";
|
|
|
+ if (imageElement.src && !paddingIsSet && !marginIsSet) {
|
|
|
let naturalWidth = imageElement.naturalWidth;
|
|
|
let naturalHeight = imageElement.naturalHeight;
|
|
|
if (naturalWidth <= 1 && naturalHeight <= 1) {
|
|
|
@@ -172,24 +175,8 @@ this.docHelper = this.docHelper || (() => {
|
|
|
naturalHeight = imgElement.height;
|
|
|
imgElement.remove();
|
|
|
}
|
|
|
- const marginValue = imageElement.style.getPropertyValue("margin");
|
|
|
- const marginPriority = imageElement.style.getPropertyPriority("margin");
|
|
|
- const paddingValue = imageElement.style.getPropertyValue("padding");
|
|
|
- const paddingPriority = imageElement.style.getPropertyPriority("padding");
|
|
|
- imageElement.style.setProperty("margin", "0", "important");
|
|
|
- imageElement.style.setProperty("padding", "0", "important");
|
|
|
const clientWidth = imageElement.clientWidth;
|
|
|
const clientHeight = imageElement.clientHeight;
|
|
|
- if (marginValue || marginPriority) {
|
|
|
- imageElement.style.setProperty("margin", marginValue, marginPriority);
|
|
|
- } else {
|
|
|
- imageElement.style.removeProperty("margin");
|
|
|
- }
|
|
|
- if (paddingValue || paddingPriority) {
|
|
|
- imageElement.style.setProperty("padding", paddingValue, paddingPriority);
|
|
|
- } else {
|
|
|
- imageElement.style.removeProperty("padding");
|
|
|
- }
|
|
|
imageData = {
|
|
|
width: imageElement.width,
|
|
|
height: imageElement.height,
|
|
|
@@ -198,6 +185,8 @@ this.docHelper = this.docHelper || (() => {
|
|
|
naturalWidth,
|
|
|
naturalHeight
|
|
|
};
|
|
|
+ } else {
|
|
|
+ imageData = {};
|
|
|
}
|
|
|
data.push(imageData);
|
|
|
});
|