Handle word-spacing for leading white space on SVG text

SVGTextLayoutEngineSpacing checking if the current and last characters
were non-nuls before attempting to apply word-spacing. This would mean
that we'd never add word-spacing at the beginning of a text box.
Remove the checks for non-nuls.

Bug: 902839
Change-Id: I751e1bd1317f7411960d137b7e55a3b83e8cb0df
Reviewed-on: https://chromium-review.googlesource.com/c/1326156
Reviewed-by: Stephen Chenney <schenney@chromium.org>
Commit-Queue: Fredrik Söderquist <fs@opera.com>
Cr-Commit-Position: refs/heads/master@{#606528}
diff --git a/third_party/WebKit/LayoutTests/svg/text/word-spacing-leading-ws-expected.html b/third_party/WebKit/LayoutTests/svg/text/word-spacing-leading-ws-expected.html
new file mode 100644
index 0000000..f718ea6
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/text/word-spacing-leading-ws-expected.html
@@ -0,0 +1,2 @@
+<!DOCTYPE html>
+<div style="width: 100px; height: 100px; background-color: green"></div>
diff --git a/third_party/WebKit/LayoutTests/svg/text/word-spacing-leading-ws.html b/third_party/WebKit/LayoutTests/svg/text/word-spacing-leading-ws.html
new file mode 100644
index 0000000..9acb62c
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/svg/text/word-spacing-leading-ws.html
@@ -0,0 +1,9 @@
+<!DOCTYPE html>
+<script src="../../resources/ahem.js"></script>
+<svg>
+  <rect width="100" height="100" fill="red"/>
+  <g fill="green" style="font-size: 50px; font-family: Ahem; word-spacing: 50px">
+    <text x="-100" y="40" style="white-space: pre"> XX</text>
+    <text x="-100" y="90" style="white-space: pre"><tspan> XX</tspan></text>
+  </g>
+</svg>
diff --git a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.cc b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.cc
index 8a5581b..0b629e8 100644
--- a/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.cc
+++ b/third_party/blink/renderer/core/layout/svg/svg_text_layout_engine_spacing.cc
@@ -39,8 +39,7 @@
     return 0;
 
   float spacing = font_.GetFontDescription().LetterSpacing();
-  if (current_character && last_character &&
-      font_.GetFontDescription().WordSpacing()) {
+  if (font_.GetFontDescription().WordSpacing()) {
     if (Character::TreatAsSpace(current_character) &&
         !Character::TreatAsSpace(last_character))
       spacing += font_.GetFontDescription().WordSpacing();