[LFC][Integration] Support isLineBreak() in iterator
https://bugs.webkit.org/show_bug.cgi?id=204941

Reviewed by Zalan Bujtas.

* layout/displaytree/DisplayRun.h:
(WebCore::Display::Run::isLineBreak const):
* rendering/line/LineLayoutTraversalDisplayRunPath.h:
(WebCore::LineLayoutTraversal::DisplayRunPath::isLineBreak const):
(WebCore::LineLayoutTraversal::DisplayRunPath::traverseNextTextBoxInVisualOrder):

Also remove unneeded skipping of runs without text context. All runs generated from text nodes now have them.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@253204 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog
index b1fcc65..b1fc8f6 100644
--- a/Source/WebCore/ChangeLog
+++ b/Source/WebCore/ChangeLog
@@ -1,3 +1,18 @@
+2019-12-06  Antti Koivisto  <antti@apple.com>
+
+        [LFC][Integration] Support isLineBreak() in iterator
+        https://bugs.webkit.org/show_bug.cgi?id=204941
+
+        Reviewed by Zalan Bujtas.
+
+        * layout/displaytree/DisplayRun.h:
+        (WebCore::Display::Run::isLineBreak const):
+        * rendering/line/LineLayoutTraversalDisplayRunPath.h:
+        (WebCore::LineLayoutTraversal::DisplayRunPath::isLineBreak const):
+        (WebCore::LineLayoutTraversal::DisplayRunPath::traverseNextTextBoxInVisualOrder):
+
+        Also remove unneeded skipping of runs without text context. All runs generated from text nodes now have them.
+
 2019-12-05  Zalan Bujtas  <zalan@apple.com>
 
         [LFC][IFC] Fix css1/basic/containment.html
diff --git a/Source/WebCore/layout/displaytree/DisplayRun.h b/Source/WebCore/layout/displaytree/DisplayRun.h
index 3774b6d..4488118 100644
--- a/Source/WebCore/layout/displaytree/DisplayRun.h
+++ b/Source/WebCore/layout/displaytree/DisplayRun.h
@@ -98,6 +98,8 @@
     void setImage(CachedImage& image) { m_cachedImage = &image; }
     CachedImage* image() const { return m_cachedImage; }
 
+    bool isLineBreak() const { return layoutBox().isLineBreakBox() || (textContext() && textContext()->content() == "\n" && style().preserveNewline()); }
+
     const Layout::Box& layoutBox() const { return *m_layoutBox; }
     const RenderStyle& style() const { return m_layoutBox->style(); }
 
diff --git a/Source/WebCore/rendering/line/LineLayoutTraversalDisplayRunPath.h b/Source/WebCore/rendering/line/LineLayoutTraversalDisplayRunPath.h
index 9c81787..d20241c 100644
--- a/Source/WebCore/rendering/line/LineLayoutTraversalDisplayRunPath.h
+++ b/Source/WebCore/rendering/line/LineLayoutTraversalDisplayRunPath.h
@@ -61,7 +61,7 @@
 
     bool isLeftToRightDirection() const { return true; }
     bool dirOverride() const { return false; }
-    bool isLineBreak() const { return false; } // FIXME: Implement.
+    bool isLineBreak() const { return run().isLineBreak(); }
 
     bool hasHyphen() const { return false; } // FIXME: Implement.
     StringView text() const { return run().textContext()->content(); }
@@ -85,8 +85,6 @@
     {
         ASSERT(!atEnd());
         ++m_runIndex;
-        while (!atEnd() && !run().textContext())
-            ++m_runIndex;
     }
     void traverseNextTextBoxInTextOrder() {  traverseNextTextBoxInVisualOrder(); }