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.
Following initial design there should be multiple different operation sets
possible, all working on the same document classes.
So relying on a certain optype and its spec in the code of ops.OdtDocument
is conflicting with that.
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.
Avoid some unnecessary work by only trimming insignificant whitespace
in the direction of the merge. This is the only place that whitespace
can inadvertently become significant whitespace.
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.
Transformed all read-only uses to use node.getElements*. Any loop that
immediately modifies the nodes in the list has been updated to use the
DomUtils.getElements* version.
The operation was attempting to assert that the source step was the
first step within the paragraph as well. Instead, it was only asserting
that the source paragraph was adjacent to the destination paragraph.
Removed getStyleElement, getParagraphStyleElement and
getParagraphStyleAttributes from OdtDocument as these functions simply
redirect to their implementations in odf.Formatting.
This function only redirected to the OdfUtils version and many callers
already had an existing instance of OdfUtils to use. Any callers who did
not have an instance of OdfUtils now create one to continue using the
function.
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.