Fix `unicode-bidi: plaintext` when there are forced breaks

The `unicode-bidi: plaintext`[1] computes the heuristic
direction for each "paragraph", separated by forced breaks.

However, non-first lines of each "paragraph" were using the
heuristic direction of the first "paragraph". This patch fixes
them to use the heuristic direction of the "paragraph" they
belong to.

[1]: https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext

Bug: 1193066
Change-Id: Ie73f662d76d16dea1122a41386c14f31d751f6ef
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2799874
Reviewed-by: Yoshifumi Inoue <yosin@chromium.org>
Commit-Queue: Koji Ishii <kojii@chromium.org>
Cr-Commit-Position: refs/heads/master@{#868803}
diff --git a/css/css-writing-modes/bidi-plaintext-br-001.html b/css/css-writing-modes/bidi-plaintext-br-001.html
new file mode 100644
index 0000000..0d96934
--- /dev/null
+++ b/css/css-writing-modes/bidi-plaintext-br-001.html
@@ -0,0 +1,44 @@
+<!DOCTYPE html>
+<title>unicode-bidi: plaintext with forced breaks</title>
+<link rel="help" href='https://drafts.csswg.org/css-writing-modes-3/#valdef-unicode-bidi-plaintext'/>
+<link rel="match" href='reference/bidi-plaintext-br-001-ref.html'/>
+<link rel="author" title="Koji Ishii" href='mailto:kojii@chromium.org'/>
+<style>
+div.test {
+  font-family: Arial;
+  line-height: 1;
+  width: 10ch;
+  border: 1px solid blue;
+  unicode-bidi: plaintext;
+}
+</style>
+<body>
+  <div class="test">
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+    MMMMM
+  </div>
+  <div class="test">
+    MMMMM
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+  </div>
+  <div class="test">
+    a<br>
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+    MMMMM
+  </div>
+  <div class="test">
+    a<br>
+    MMMMM
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+  </div>
+  <div class="test">
+    &#x5D0;<br>
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+    MMMMM
+  </div>
+  <div class="test">
+    &#x5D0;<br>
+    MMMMM
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+  </div>
+</body>
diff --git a/css/css-writing-modes/reference/bidi-plaintext-br-001-ref.html b/css/css-writing-modes/reference/bidi-plaintext-br-001-ref.html
new file mode 100644
index 0000000..23bb3e9
--- /dev/null
+++ b/css/css-writing-modes/reference/bidi-plaintext-br-001-ref.html
@@ -0,0 +1,47 @@
+<!DOCTYPE html>
+<style>
+div.test {
+  font-family: Arial;
+  line-height: 1;
+  width: 10ch;
+  border: 1px solid blue;
+}
+</style>
+<body>
+  <div class="test" dir="rtl">
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+    MMMMM
+  </div>
+  <div class="test">
+    MMMMM
+    &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+  </div>
+  <div class="test">
+    <div>a</div>
+    <div dir="rtl">
+      &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+      MMMMM
+    </div>
+  </div>
+  <div class="test">
+    <div>a</div>
+    <div>
+      MMMMM
+      &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+    </div>
+  </div>
+  <div class="test">
+    <div dir="rtl">&#x5D0;</div>
+    <div dir="rtl">
+      &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+      MMMMM
+    </div>
+  </div>
+  <div class="test">
+    <div dir="rtl">&#x5D0;</div>
+    <div>
+      MMMMM
+      &#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;&#x5D0;
+    </div>
+  </div>
+</body>