Răsfoiți Sursa

set border to 0 if box-sizing is not set to "content-box"

Gildas 7 ani în urmă
părinte
comite
9b2edd8113
1 a modificat fișierele cu 8 adăugiri și 4 ștergeri
  1. 8 4
      lib/single-file/doc-helper.js

+ 8 - 4
lib/single-file/doc-helper.js

@@ -305,10 +305,14 @@ this.docHelper = this.docHelper || (() => {
 		paddingRight = getWidth("padding-right", computedStyle);
 		paddingTop = getWidth("padding-top", computedStyle);
 		paddingBottom = getWidth("padding-bottom", computedStyle);
-		borderLeft = getWidth("border-left-width", computedStyle);
-		borderRight = getWidth("border-right-width", computedStyle);
-		borderTop = getWidth("border-top-width", computedStyle);
-		borderBottom = getWidth("border-bottom-width", computedStyle);
+		if (computedStyle.getPropertyValue("box-sizing") == "content-box") {
+			borderLeft = getWidth("border-left-width", computedStyle);
+			borderRight = getWidth("border-right-width", computedStyle);
+			borderTop = getWidth("border-top-width", computedStyle);
+			borderBottom = getWidth("border-bottom-width", computedStyle);
+		} else {
+			borderLeft = borderRight = borderTop = borderBottom = 0;
+		}
 		const width = imageElement.clientWidth;
 		const height = imageElement.clientHeight;
 		if (width >= 0 && height >= 0 && paddingLeft >= 0 && paddingRight >= 0 && paddingTop >= 0 && paddingBottom >= 0 && borderLeft >= 0 && borderRight >= 0 && borderTop >= 0 && borderBottom >= 0) {