Replacing the root element is currently a by-product of the undo impl.
Reducing the number of places aware of this impl detail helps ensure
future undo managers have less clean-up work to do when this behaviour
is finally removed.
By checking only nodes that pass the supplied node filter, the position
logic can safely ignore out-of-place cursors near highlighted annotations.
Note, this can't re-use PositionIterator.previousNode, because the logic
requires the previous sibling of the current container's previous sibling.
Moving these checks into a node filter ensures it is only required
once per node, rather than once per node-position.
This results in a 60% improvement in position iteration speed.
Some unit tests compare an XML snippet before and after the execution of a
set of operations. For this comparison to pass all the text nodes had to
be exactly the same even if they were not contained in an ODF paragraph.
This imposed a limitation on the tests as they could not have any
whitespace between node structures that were compared in the test files.
Having whitespace is useful to format the test XML data so that it is more
human readable/editable.
This commit filters out any text nodes not contained by an ODF paragraph
so that any test comparisons won't be affected by these text nodes.
This behaviour was working prior to the merge paragraph operation being
introduced. A new edge case was introduced related to cleaning up empty
spans that caused this to regress.
getTextElements may return some unexpected text nodes if the step filters
haven't correctly identified the first/last step in the paragraph. Rather
than failing completely in this case, simply log the unexpected items and
skip them.
getTextElements itself still needs to be fixed in these cases, but the
harm caused by such mistakes is slightly reduced in this instance.
The rounding direction constants in OdtStepsTranslator overlap with the
existing enum in core.StepsDirection. It makes sense to use that enum here
to specify rounding behaviour in converting DOM points to steps so the
constants have been removed and the enum has been substituted for all
usages.
This removes the option to provide a rounding predicate to decide whether
to round up or down from the convertDomPointToCursorStep method. It is replaced
with an enum that specifies whether to round up or down. The predicate was
removed as all callers supplied the same function to indicate they wanted
round up behaviour and this predicate was being duplicated.
The rounding parameter is optional and defaults to rounding down to the
previous step which is the same as before this commit.