From 43b184d308b47ab62ed65393e6a52ed9e4be1879 Mon Sep 17 00:00:00 2001 From: Ashish Kumar KC Date: Mon, 10 Sep 2018 15:38:47 +0530 Subject: [PATCH 1/4] Fix for Issue-1638 (https://github.com/niklasvh/html2canvas/issues/1638) Resolution: Clearing the Shadow Properties after they are consumed --- src/renderer/CanvasRenderer.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/renderer/CanvasRenderer.js b/src/renderer/CanvasRenderer.js index 3a51bc784..425622ab1 100644 --- a/src/renderer/CanvasRenderer.js +++ b/src/renderer/CanvasRenderer.js @@ -239,6 +239,11 @@ export default class CanvasRenderer implements RenderTarget { text.bounds.top + text.bounds.height ); } + this.ctx.shadowColor = null; + this.ctx.shadowOffsetX = null; + this.ctx.shadowOffsetY = null; + this.ctx.shadowBlur = null; + if (textDecoration !== null) { const textDecorationColor = textDecoration.textDecorationColor || color; From 1ad83635747c632751f4be4615372d91ed854b50 Mon Sep 17 00:00:00 2001 From: Ashish Kumar KC Date: Mon, 10 Sep 2018 15:57:49 +0530 Subject: [PATCH 2/4] Fix for Issue-1638 (https://github.com/niklasvh/html2canvas/issues/1638) Resolution: Clearing the Shadow Properties after they are consumed --- src/renderer/CanvasRenderer.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/renderer/CanvasRenderer.js b/src/renderer/CanvasRenderer.js index 425622ab1..5f3497709 100644 --- a/src/renderer/CanvasRenderer.js +++ b/src/renderer/CanvasRenderer.js @@ -239,11 +239,10 @@ export default class CanvasRenderer implements RenderTarget { text.bounds.top + text.bounds.height ); } - this.ctx.shadowColor = null; - this.ctx.shadowOffsetX = null; - this.ctx.shadowOffsetY = null; - this.ctx.shadowBlur = null; - + this.ctx.shadowColor = ''; + this.ctx.shadowOffsetX = 0; + this.ctx.shadowOffsetY = 0; + this.ctx.shadowBlur = 0; if (textDecoration !== null) { const textDecorationColor = textDecoration.textDecorationColor || color; From d823e4ca84fd9e27061131156bf8936b3340f5cd Mon Sep 17 00:00:00 2001 From: Ashish Kumar KC Date: Wed, 12 Sep 2018 10:24:43 +0530 Subject: [PATCH 3/4] Fix for Issue-1638 (https://github.com/niklasvh/html2canvas/issues/1638) Resolution: Clearing the Shadow Properties after they are consumed --- tests/reftests/textshadow.html | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/reftests/textshadow.html diff --git a/tests/reftests/textshadow.html b/tests/reftests/textshadow.html new file mode 100644 index 000000000..a803a47dd --- /dev/null +++ b/tests/reftests/textshadow.html @@ -0,0 +1,21 @@ + + + + Text-Shadow tests + + + + +
+

Hello world!

+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
+
+ + \ No newline at end of file From fc3b14b6636c4be25ab352df57d1aa0dcaae7334 Mon Sep 17 00:00:00 2001 From: Niklas von Hertzen Date: Sun, 7 Apr 2019 21:22:21 -0700 Subject: [PATCH 4/4] refactor: only clear shadow when used --- src/renderer/CanvasRenderer.js | 9 +++++---- tests/reftests/text/shadow.html | 12 ++++++++++++ tests/reftests/textshadow.html | 21 --------------------- 3 files changed, 17 insertions(+), 25 deletions(-) delete mode 100644 tests/reftests/textshadow.html diff --git a/src/renderer/CanvasRenderer.js b/src/renderer/CanvasRenderer.js index 982c6df2b..572ee08e8 100644 --- a/src/renderer/CanvasRenderer.js +++ b/src/renderer/CanvasRenderer.js @@ -235,6 +235,11 @@ export default class CanvasRenderer implements RenderTarget { text.bounds.top + text.bounds.height ); }); + + this.ctx.shadowColor = ''; + this.ctx.shadowOffsetX = 0; + this.ctx.shadowOffsetY = 0; + this.ctx.shadowBlur = 0; } else { this.ctx.fillText( text.text, @@ -242,10 +247,6 @@ export default class CanvasRenderer implements RenderTarget { text.bounds.top + text.bounds.height ); } - this.ctx.shadowColor = ''; - this.ctx.shadowOffsetX = 0; - this.ctx.shadowOffsetY = 0; - this.ctx.shadowBlur = 0; if (textDecoration !== null) { const textDecorationColor = textDecoration.textDecorationColor || color; diff --git a/tests/reftests/text/shadow.html b/tests/reftests/text/shadow.html index f4e43a483..063a51d12 100644 --- a/tests/reftests/text/shadow.html +++ b/tests/reftests/text/shadow.html @@ -50,6 +50,18 @@ testing with transparent testing with low opacity + +
+

Hello world!

+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
Sample Div with Border
+
+

Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore.

diff --git a/tests/reftests/textshadow.html b/tests/reftests/textshadow.html deleted file mode 100644 index a803a47dd..000000000 --- a/tests/reftests/textshadow.html +++ /dev/null @@ -1,21 +0,0 @@ - - - - Text-Shadow tests - - - - -
-

Hello world!

-
Sample Div with Border
-
Sample Div with Border
-
Sample Div with Border
-
Sample Div with Border
-
Sample Div with Border
-
Sample Div with Border
-
Sample Div with Border
-
-
- - \ No newline at end of file