Title: [294612] trunk
Revision
294612
Author
za...@apple.com
Date
2022-05-21 05:38:30 -0700 (Sat, 21 May 2022)

Log Message

Text selection does not show continuous selection when dragging across pages with widows
https://bugs.webkit.org/show_bug.cgi?id=240753
<rdar://90960113>

Reviewed by Antti Koivisto.

Use the correct variable to mark the line.

Test: fast/multicol/incorrect-is-first-line-after-page-break-with-widow.html
* Source/WebCore/layout/integration/inline/InlineIteratorLineBox.cpp:
(WebCore::InlineIterator::LineBoxIterator::operator bool const):
* Source/WebCore/layout/integration/inline/InlineIteratorLineBox.h:
(WebCore::InlineIterator::LineBoxIterator::operator bool const): Deleted.
* Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp:
(WebCore::LayoutIntegration::adjustLinePositionsForPagination):
* Source/WebCore/testing/Internals.cpp:
(WebCore::Internals::lineIndexAfterPageBreak):
* Source/WebCore/testing/Internals.h:
* Source/WebCore/testing/Internals.idl:
* LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow-expected.txt: Added.
* LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow.html: Added.

Canonical link: https://commits.webkit.org/250838@main

Modified Paths

Added Paths

Diff

Added: trunk/LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow-expected.txt (0 => 294612)


--- trunk/LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow-expected.txt	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow-expected.txt	2022-05-21 12:38:30 UTC (rev 294612)
@@ -0,0 +1 @@
+5 lines left on the previous page.

Added: trunk/LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow.html (0 => 294612)


--- trunk/LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow.html	                        (rev 0)
+++ trunk/LayoutTests/fast/multicol/incorrect-is-first-line-after-page-break-with-widow.html	2022-05-21 12:38:30 UTC (rev 294612)
@@ -0,0 +1,61 @@
+<style>
+div {
+  widows: 15;
+  font-family: Ahem;
+}
+</style>
+<!-- This test case only works in paginated mode -->
+<div>
+1 some text<br>
+2 some text<br>
+3 some text<br>
+4 some text<br>
+5 some text<br>
+6 some text<br>
+7 some text<br>
+8 some text<br>
+9 some text<br>
+10 some text<br>
+11 some text<br>
+12 some text<br>
+13 some text<br>
+14 some text<br>
+15 some text<br>
+16 some text<br>
+17 some text<br>
+18 some text<br>
+19 some text<br>
+20 some text<br>
+</div>
+<!-- This content overflows the page and we are required to wrap at least 15 lines to the next page -->
+<div id=page_overflow>
+1 some text<br>
+2 some text<br>
+3 some text<br>
+4 some text<br>
+5 some text<br>
+6 some text<br>
+7 some text<br>
+8 some text<br>
+9 some text<br>
+10 some text<br>
+11 some text<br>
+12 some text<br>
+13 some text<br>
+14 some text<br>
+15 some text<br>
+16 some text<br>
+17 some text<br>
+18 some text<br>
+19 some text<br>
+20 some text<br>
+</div>
+
+<script>
+if (window.testRunner)
+  testRunner.dumpAsText();
+if (window.internals) {
+  internals.setPagination("LeftToRightPaginated", 0);
+  document.body.innerText = internals.lineIndexAfterPageBreak(document.getElementById("page_overflow")) + " lines left on the previous page.";
+}
+</script>

Modified: trunk/Source/WebCore/layout/integration/inline/InlineIteratorLineBox.cpp (294611 => 294612)


--- trunk/Source/WebCore/layout/integration/inline/InlineIteratorLineBox.cpp	2022-05-21 06:19:29 UTC (rev 294611)
+++ trunk/Source/WebCore/layout/integration/inline/InlineIteratorLineBox.cpp	2022-05-21 12:38:30 UTC (rev 294612)
@@ -66,6 +66,11 @@
     return *this;
 }
 
+LineBoxIterator::operator bool() const
+{
+    return !atEnd();
+}
+
 bool LineBoxIterator::operator==(const LineBoxIterator& other) const
 {
     return m_lineBox.m_pathVariant == other.m_lineBox.m_pathVariant;

Modified: trunk/Source/WebCore/layout/integration/inline/InlineIteratorLineBox.h (294611 => 294612)


--- trunk/Source/WebCore/layout/integration/inline/InlineIteratorLineBox.h	2022-05-21 06:19:29 UTC (rev 294611)
+++ trunk/Source/WebCore/layout/integration/inline/InlineIteratorLineBox.h	2022-05-21 12:38:30 UTC (rev 294612)
@@ -99,10 +99,10 @@
     LineBoxIterator(const LineBox&);
 
     LineBoxIterator& operator++() { return traverseNext(); }
-    LineBoxIterator& traverseNext();
+    WEBCORE_EXPORT LineBoxIterator& traverseNext();
     LineBoxIterator& traversePrevious();
 
-    explicit operator bool() const { return !atEnd(); }
+    WEBCORE_EXPORT explicit operator bool() const;
 
     bool operator==(const LineBoxIterator&) const;
     bool operator!=(const LineBoxIterator& other) const { return !(*this == other); }
@@ -119,7 +119,7 @@
     LineBox m_lineBox;
 };
 
-LineBoxIterator firstLineBoxFor(const RenderBlockFlow&);
+WEBCORE_EXPORT LineBoxIterator firstLineBoxFor(const RenderBlockFlow&);
 LineBoxIterator lastLineBoxFor(const RenderBlockFlow&);
 LeafBoxIterator closestBoxForHorizontalPosition(const LineBox&, float horizontalPosition, bool editableOnly = false);
 

Modified: trunk/Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp (294611 => 294612)


--- trunk/Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp	2022-05-21 06:19:29 UTC (rev 294611)
+++ trunk/Source/WebCore/layout/integration/inline/LayoutIntegrationPagination.cpp	2022-05-21 12:38:30 UTC (rev 294612)
@@ -189,7 +189,7 @@
             atTheTopOfColumnOrPage = atTheTopOfColumnOrPage ? lineIndex == lineBreakIndex : false;
             auto isPageBreakWithLineStrut = false;
             setPageBreakForLine(lineBreakIndex, lines, flow, struts, atTheTopOfColumnOrPage, lineDoesNotFit, isPageBreakWithLineStrut);
-            isFirstLineAfterPageBreakList[lineIndex] = isPageBreakWithLineStrut;
+            isFirstLineAfterPageBreakList[lineBreakIndex] = isPageBreakWithLineStrut;
             // Recompute line positions that we already visited but widow break pushed them to a new page.
             for (auto i = lineBreakIndex; i < lines.size(); ++i)
                 lines.at(i) = computeLineTopAndBottomWithOverflow(flow, inlineContent.lines, i, struts);

Modified: trunk/Source/WebCore/testing/Internals.cpp (294611 => 294612)


--- trunk/Source/WebCore/testing/Internals.cpp	2022-05-21 06:19:29 UTC (rev 294611)
+++ trunk/Source/WebCore/testing/Internals.cpp	2022-05-21 12:38:30 UTC (rev 294612)
@@ -115,6 +115,7 @@
 #include "IDBTransaction.h"
 #include "ImageOverlay.h"
 #include "ImageOverlayController.h"
+#include "InlineIteratorLineBox.h"
 #include "InspectorClient.h"
 #include "InspectorController.h"
 #include "InspectorDebuggableType.h"
@@ -2035,6 +2036,28 @@
     return { };
 }
 
+ExceptionOr<uint64_t> Internals::lineIndexAfterPageBreak(Element& element)
+{
+    Document* document = contextDocument();
+    if (!document || !document->frame())
+        return Exception { InvalidAccessError };
+
+    element.document().updateLayoutIgnorePendingStylesheets();
+
+    if (!element.renderer() || !is<RenderBlockFlow>(element.renderer()))
+        return Exception { NotFoundError };
+    auto& blockFlow = downcast<RenderBlockFlow>(*element.renderer());
+    if (!blockFlow.childrenInline())
+        return Exception { NotFoundError };
+
+    size_t lineIndex = 0;
+    for (auto lineBox = InlineIterator::firstLineBoxFor(blockFlow); lineBox; lineBox.traverseNext(), ++lineIndex) {
+        if (lineBox->isFirstAfterPageBreak())
+            return lineIndex;
+    }
+    return Exception { NotFoundError };
+}
+
 ExceptionOr<String> Internals::configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight)
 {
     Document* document = contextDocument();

Modified: trunk/Source/WebCore/testing/Internals.h (294611 => 294612)


--- trunk/Source/WebCore/testing/Internals.h	2022-05-21 06:19:29 UTC (rev 294611)
+++ trunk/Source/WebCore/testing/Internals.h	2022-05-21 12:38:30 UTC (rev 294612)
@@ -333,6 +333,7 @@
 
     ExceptionOr<void> setPagination(const String& mode, int gap, int pageLength);
     ExceptionOr<void> setPaginationLineGridEnabled(bool);
+    ExceptionOr<uint64_t> lineIndexAfterPageBreak(Element&);
     ExceptionOr<String> configurationForViewport(float devicePixelRatio, int deviceWidth, int deviceHeight, int availableWidth, int availableHeight);
 
     ExceptionOr<bool> wasLastChangeUserEdit(Element& textField);

Modified: trunk/Source/WebCore/testing/Internals.idl (294611 => 294612)


--- trunk/Source/WebCore/testing/Internals.idl	2022-05-21 06:19:29 UTC (rev 294611)
+++ trunk/Source/WebCore/testing/Internals.idl	2022-05-21 12:38:30 UTC (rev 294612)
@@ -449,6 +449,7 @@
 
     undefined setPagination(DOMString mode, long gap, optional long pageLength = 0);
     undefined setPaginationLineGridEnabled(boolean enabled);
+    unsigned long long lineIndexAfterPageBreak(Element element);
 
     DOMString configurationForViewport(unrestricted float devicePixelRatio, long deviceWidth, long deviceHeight, long availableWidth, long availableHeight);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to