Commit Graph

6 Commits

Author SHA1 Message Date
Masayuki Nakano
45ce515072 Bug 1408544 - part 2: RangeBoundaryBase shouldn't compute mRef when mOffset is specified r=catalinb
RangeBoundaryBase shouldn't compute mRef when it's initialized with offset.
E.g., some users of the template class may initialize it with a container and
offset in it but it may not refer mRef or may refer after modifying offset.

On the other hand, RangeBoundaryBase::InvalidateOffset() is a special method.
It assumes that mRef is always initialized when it's called but can be
invalidate mOffset until retrieved actually.  This is necessary for
nsRange::mStart and nsRange::mEnd since the offset may be changed when
some nodes are inserted before the referring node.

So, now, InvalidateOffset() should be a protected method and make nsRange a
friend class of RangeBoundaryBase.  Then, when nsRange sets mStart and/or mEnd,
nsRange itself should guarantee that their mRefs are initialized.

MozReview-Commit-ID: Alr4YkDXIND

--HG--
extra : rebase_source : 7e6828374db7989ae91b9e485571ec553f7435af
2017-11-02 21:25:14 +09:00
Masayuki Nakano
8b6c211c36 Bug 1408544 - part 1: Reimplement EditorDOMPoint as a subclass of RangeBoundary r=catalinb,m_kato
A lot of methods in editor returns a child offset with an out param when it
returns its container and offset in the container.  This is ugly hack for
performance of nsINode::IndexOf().  However, there are a lot of regression
since the relation between offset and child node can be broken really easily.

So, we should make EditorDOMPoint as a subclass of RangeBoundary and manage
a set of container, reference child and its offset in it (e.g.,
SetNextSibling() added by this patch).

Note that RangeBoundary's performance is not good for temporary use if we set
a point with offset, it immediately retrieves mRef.  The following patch will
improve this performance.

MozReview-Commit-ID: 7mcJ1P1OjVr

--HG--
rename : editor/libeditor/EditorUtils.h => editor/libeditor/EditorDOMPoint.h
extra : rebase_source : 785094fcfc592d9e5b48cbc36ed225dbb8bb4111
2017-11-01 14:41:03 +09:00
Nika Layzell
b69ed2bf16 Bug 1399626 - Part 6: Stop asserting that RangeBoundary objects are valid as they are created, r=masayuki
This is necessary, as we now use RangeBoundary objects as intermediate types to
pass (parent,offset) pairs into constructors for nsRange. We are allowed to try
to construct invalid nsRange objects, but unfortunately doing so would fire an
assertion if we don't allow constructing invalid RangeBoundary objects.

It's possible to check if the RangeBoundary object is valid by calling
`IsSetAndValid`, which should be done for error checking when you don't trust
the source of the RangeBoundary object anyway.

MozReview-Commit-ID: 3Pf80ndRZLW
2017-10-02 11:58:00 -04:00
Nika Layzell
31035d4882 Bug 1399626 - Part 1: Add some helper methods to RangeBoundary, r=masayuki
MozReview-Commit-ID: Cy4oEQKdX39
2017-10-02 11:57:59 -04:00
Michael Layzell
9601431bf2 Bug 1384915 - Part 2: Make NodePosition a wrapper around RangeBoundary, r=masayuki 2017-09-25 18:14:42 -04:00
Michael Layzell
8e30ba31d0 Bug 1384915 - Part 1: Refactor RangeBoundary out of nsRange so it can be used by other classes, r=masayuki 2017-09-25 18:14:42 -04:00