Skip to content
Permalink
Browse files
Text selection does not show continuous selection when dragging acros…
…s 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
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@294612 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
alanbujtas committed May 21, 2022
1 parent c68178d commit 56da44e3c293e980cc8ac48663c44bdf9b37e4ea
Showing 8 changed files with 96 additions and 4 deletions.
@@ -0,0 +1 @@
5 lines left on the previous page.
@@ -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>
@@ -66,6 +66,11 @@ LineBoxIterator& LineBoxIterator::traversePrevious()
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;
@@ -99,10 +99,10 @@ class LineBoxIterator {
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 @@ class LineBoxIterator {
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);

@@ -189,7 +189,7 @@ std::unique_ptr<InlineContent> adjustLinePositionsForPagination(const InlineCont
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);
@@ -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 @@ ExceptionOr<void> Internals::setPaginationLineGridEnabled(bool enabled)
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();
@@ -333,6 +333,7 @@ class Internals final : public RefCounted<Internals>, private ContextDestruction

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);
@@ -449,6 +449,7 @@ typedef (FetchRequest or FetchResponse) FetchObject;

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);

0 comments on commit 56da44e

Please sign in to comment.