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.
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.