Verified Commit 4228d7ea authored by Stouffi's avatar Stouffi
Browse files

Fixes several issues in chunker layout

Fixes a persisting issue from !98
  createBreakToken would not return the correct break token if not all content of the last element with data-ref have been rendered.
Fixes findOverflow who could not determine whether a node was displayed on the next column with page margin at 0
  due to a wrong comparison with floored left position and rounded end position. Now both are rounded.
Enhancement: findOverflow will skip children more frequently if right and end positions are equals.
parent e3646265
......@@ -285,14 +285,28 @@ class Layout {
if (!renderedNode) {
// Find closest element with data-ref
renderedNode = findElement(prevValidNode(temp), rendered);
// renderedNode is actually the last unbroken box of rendered node
// We just need to return node as the next sibling of renderedNode within source node.
// Check if temp is the last rendered node at its level.
if (!temp.nextSibling) {
// We need to ensure that the previous sibling of temp is fully rendered.
const renderedNodeFromSource = findElement(renderedNode, source)
const walker = document.createTreeWalker(renderedNodeFromSource, NodeFilter.SHOW_ELEMENT)
const lastChildOfRenderedNodeFromSource = walker.lastChild()
const lastChildOfRenderedNodeMatchingFromRendered = findElement(lastChildOfRenderedNodeFromSource, rendered)
// Check if we found that the last child in source
if (!lastChildOfRenderedNodeMatchingFromRendered) {
// Pending content to be rendered before virtual break token
// Otherwise we will return a break token as per below
// renderedNode is actually the last unbroken box that does not overflow.
// Break Token is therefore the next sibling of renderedNode within source node.
node = findElement(renderedNode, source).nextSibling;
offset = 0;
} else {
node = findElement(renderedNode, source);
offset = 0;
} else {
renderedNode = findElement(container, rendered);
......@@ -400,7 +414,7 @@ class Layout {
if (node) {
let pos = getBoundingClientRect(node);
let left = Math.floor(pos.left);
let left = Math.round(pos.left);
let right = Math.floor(pos.right);
if (!range && left >= end) {
......@@ -463,7 +477,7 @@ class Layout {
// Skip children
if (skip || right < end) {
if (skip || right <= end) {
next = nodeAfter(node, rendered);
if (next) {
walker = walk(next, rendered);
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment