Граф коммитов

15 Коммитов

Автор SHA1 Сообщение Дата
Andrea Marchesini b8bb98af8c Bug 1430997 - Rename nsINode::IndexOf to nsINode::ComputeIndexOf, r=catalinb 2018-01-23 14:30:18 +01:00
Olli Pettay 7891930314 Bug 1428748 - RangeBoundary is too AddRef/Release heavy, r=mystor
--HG--
extra : rebase_source : 15efb71770d21038f4230538da8c862ab832fdc4
2018-01-08 21:27:44 +02:00
Andrea Marchesini 00e79ef07b Bug 1425321 - Renaming nsINode::GetChildAt to GetChildAt_Deprecated, r=catalinb
We want to deprecate nsINode::GetChildAt as the first step of removing DOM node
child array storage. See bug 651120.
2018-01-03 13:59:54 +01:00
Masayuki Nakano 0b2f749b62 Bug 1422668 - Back out changes of RangeBoundary.h which were added for EditorDOMPoint r=catalinb
EditorDOMPoint was a subclass of RangeBoundary.  Therefore, for heavy
use of it in editor, we've implemented a lot of complicated feature
into RangeBoundary.  However, EditorDOMPoint stopped inheriting
RangeBoundary.  So, we can get simple RangeBoundary implementation
back now.

This patch makes RangeBoundary.h almost same as 3f7cbec2446b except
keeps implementing GetPreviousSiblingOfChildAtOffset() and
GetNextSiblingOfChildAtOffset() because the former is used by
Selection and both of them are simple.  And also keeps making it
a friend of EditorDOMPoint because EditorDOMPoint still needs to
copy to/from RangeBoundary.

MozReview-Commit-ID: Hr5SA52ScK0

--HG--
extra : rebase_source : a00a46ff931a5c4fcabf910510fa448b513f50c5
2017-12-04 16:28:50 +09:00
Masayuki Nakano 1bb0ec153d Bug 1419745 - part 1: Make EditorDOMPointBase not a sub class of RangeBoundaryBase and duplicate methods of RangeBoundaryBase into EditorDOMPointBase r=m_kato
EditorDOMPointBase should store child at offset for editor uses.  E.g., when
editor wants to refer a node as child node of an EditorDOMPoint instance,
even if the node is unexpectedly moved to different container, editor wants
to keep referring the child node rather than its previous sibling.

Therefore this patch makes EditorDOMPointBase not a sub class of
RangeBoundaryBase but copying all methods and members of RangeBoundaryBase
into EditorDOMPointBase for keeping current behavior completely.

MozReview-Commit-ID: LIyPFkCfsZ9

--HG--
extra : rebase_source : fd76c4808625f8f8a86f7b4e4c1ac22fbdc11dd5
2017-11-23 00:15:29 +09:00
Masayuki Nakano ae09f805a7 Bug 1415409 - Make == operator of RangeBoundaryBase compare mRef and mOffset more carefully r=catalinb
Currently, RangeBoundaryBase can store either only mRef or mOffset.  However,
== operator of RangeBoudaryBase still compares mRef simply.  However, if one
has only mRef and the other has only mOffset, it returns false.

This patch makes == operator checks if both mOffset have been set.  If so,
this checks both mOffset.value() and mRef are matched.  However, if mRef of
only one of them is nullptr, this doesn't make it check mRef because computing
mRef needs some cost and initializing mRef from the other fixes the referring
child stronger.  If the user of the operator sets only mOffset and wait DOM
tree changes, computing mRef may break such callers.

If one has only mRef and the other has only mOffset, this patch makes it
compute mRef.  This is not the best behavior, perhaps.  However, there is no
way to compare these instances.  If this becomes a problem, we should make it
create temporary instance, but it'll waste runtime cost.  So, let's avoid using
this approach for now.

Finally, making it check both mRef simply.

MozReview-Commit-ID: 4nsW5SYDTiZ

--HG--
extra : rebase_source : b16ec01bdefc8fd847fc43513581aeb0efbf4e21
2017-11-08 13:35:00 +09:00
Masayuki Nakano 68294ac1d3 Bug 1415445 - part 4: EditorBase::CreateNode() should take EditorRawDOMPoint as insertion point instead of a set of container, child and offset of the child in the container r=m_kato
EditorBase::CreateNode() should take EditorRawDOMPoint as insertion point of
the new element instead of a set of container, child and offset of the child
in the container.

This patch initializes EditorRawDOMPoint with original 3 arguments as far as
possible.  If the relation of them are broken, MOZ_ASSERT in RawRangeBoundary
constructor detects existing bugs.

MozReview-Commit-ID: 2N55S6pRv7k

--HG--
extra : rebase_source : 2b14a7715815ca0007635b8f791ca9edbe5b65f1
2017-11-08 20:23:10 +09:00
Masayuki Nakano 806668b21a Bug 1415062 - part 2: Editor should use Selection::Collapse(const RawRangeBoundary&) as far as possible r=m_kato
In some places, editor computes index from child node for collapsing selection
at the child node.  However, it's expensive.  Therefore, editor should use
Selection::Collapse(const RawRangeBoundary&) as far as possible.

MozReview-Commit-ID: LF2MwASuXzZ

--HG--
extra : rebase_source : b7afc35c0d9d88845391b6f18de57cbff1935ae4
2017-11-07 19:50:25 +09:00
Masayuki Nakano 365f79c262 Bug 1414713 - EditorUtils::IsDescendantOf() should take EditorDOMPoint and EditorRawDOMPoint as out param r=catalinb,m_kato
EditorUtils::IsDescendantOf() current takes a pointer to offset or a pointer to
child content if the caller needs to know the child of the most ancestor node.

However, some callers should get a child as EditorDOMPoint or EditorRawDOMPoint.
Then, they can be used for some editor methods which need to take child node
for performance optimization.

This patch makes EditorUtils::IsDescendantOf() as only two overloads.  One takes
pointer to EditorRawDOMPoint as optional out argument.  The other takes pointer
to EditorDOMPoint as an out param.

Additionally, this creates new constructor of AutoTrackDOMPoint for making it
can treat EditorDOMPoint directly.

MozReview-Commit-ID: IsAGTUvKI19

--HG--
extra : rebase_source : 97469a21b974c6a1dd515ab472bbc4a88c1899c8
2017-11-06 17:01:33 +09:00
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