Commit graph

51 commits

Author SHA1 Message Date
Emilio Cobos Álvarez
eb3a9e6bd7 Bug 1739079 - Make ContentIterator more resilient to unexpected situations. r=saschanaz
This shouldn't change behavior in non-hanging cases and should fix the
hang. We had similar hackish:

  mIsDone = mCurNode == nullptr;

For anon content.

Differential Revision: https://phabricator.services.mozilla.com/D132054
2021-11-24 23:58:26 +00:00
Rafal Bielski
bdf6cda786 Bug 1673913 - Fix readability-else-after-return warnings. r=masayuki,mbrodesser
Differential Revision: https://phabricator.services.mozilla.com/D94243
2021-06-16 21:53:04 +00:00
Simon Giesecke
fe7ed70053 Bug 1673931 - Avoid including nsINode/nsIContent in header files. r=mbrodesser
Differential Revision: https://phabricator.services.mozilla.com/D97738
2020-11-26 13:21:07 +00:00
Mirko Brodesser
e56085c63f Bug 1649121: part 73) Factor IsNodeContainedInRange out. r=masayuki
Removes code duplication, abstracts details away.

Differential Revision: https://phabricator.services.mozilla.com/D86703
2020-08-12 11:10:06 +00:00
Mirko Brodesser
1f712acadc Bug 1649121: part 72) Rename mEndNodes to mInclusiveAncestorsOfEndContainer. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84834
2020-08-10 12:54:02 +00:00
Mirko Brodesser
70847b14fc Bug 1649121: part 71) Factor DetermineLastContent out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84833
2020-08-10 12:53:50 +00:00
Mirko Brodesser
343ba883bf Bug 1649121: part 70) Move more code to DetermineCandidateForLastContent. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84832
2020-08-10 12:43:13 +00:00
Mirko Brodesser
768316041d Bug 1649121: part 69) Factor DetermineCandidateForLastContent out. r=masayuki
Please see the following review too, because there more code is moved to
that method.

Differential Revision: https://phabricator.services.mozilla.com/D84831
2020-08-10 12:52:27 +00:00
Mirko Brodesser
2a0f6f803c Bug 1649121: part 68) Factor DetermineFirstContent out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84795
2020-08-10 12:49:41 +00:00
Mirko Brodesser
3850a9eec3 Bug 1649121: part 67) Move more code to DetermineCandidateForFirstContent. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84794
2020-08-10 12:42:50 +00:00
Mirko Brodesser
4d83d55c27 Bug 1649121: part 66) Factor DetermineCandidateForFirstContent out. r=masayuki
Please see the next review too, because it moves more code to that
method.

Differential Revision: https://phabricator.services.mozilla.com/D84793
2020-08-10 12:48:36 +00:00
Mirko Brodesser
14102fe248 Bug 1649121: part 65) Declare more methods in ContentIteratorBase static. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84792
2020-08-10 12:42:40 +00:00
Mirko Brodesser
a596885d18 Bug 1649121: part 64) Don't reuse local offset variable in InitWithRange. r=masayuki
Simplifies factoring determining `firstCandidate` and `lastCandidate`
out.

Differential Revision: https://phabricator.services.mozilla.com/D84791
2020-08-10 12:42:32 +00:00
Mirko Brodesser
c864ad17c6 Bug 1649121: part 63) Factor CacheInclusiveAncestorsOfEndContainer out. r=masayuki
Hides details and "inclusive" ancestors is more precise.

Differential Revision: https://phabricator.services.mozilla.com/D84790
2020-08-10 12:47:05 +00:00
Mirko Brodesser
c5b7430f3b Bug 1649121: part 62) Replace bool ContentIterator::mPre with enum class. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84522
2020-08-10 12:46:29 +00:00
Mirko Brodesser
81b2cf7d74 Bug 1649121: part 61) Rename mCommonParent to mClosestCommonInclusiveAncestor. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84510
2020-08-10 09:40:41 +00:00
Mirko Brodesser
a280d7bf1f Bug 1649121: part 60) Declare some methods in ContentIteratorBase static. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D84509
2020-08-10 09:40:38 +00:00
Mirko Brodesser
59d52d5f33 Bug 1649121: part 58) Change DetermineLastNode to return the found node. r=masayuki
Clearer.

Differential Revision: https://phabricator.services.mozilla.com/D84371
2020-08-10 10:03:24 +00:00
Mirko Brodesser
3c61cc9fd4 Bug 1649121: part 57) Change DetermineFirstNode to return the found node. r=masayuki
Clearer.

Differential Revision: https://phabricator.services.mozilla.com/D84370
2020-08-10 09:40:15 +00:00
Mirko Brodesser
864cb782b0 Bug 1649121: part 56) Factor DetermineFirstNode out of ContentIteratorBase::Initializer. r=masayuki
Hides details.

Differential Revision: https://phabricator.services.mozilla.com/D84160
2020-07-22 00:54:31 +00:00
Mirko Brodesser
9f2b9f55fa Bug 1649121: part 55) Factor DetermineLastNode out of ContentIteratorBase::Initializer. r=masayuki
Hides details.

Differential Revision: https://phabricator.services.mozilla.com/D84161
2020-07-22 00:56:14 +00:00
Mirko Brodesser
34a8164638 Bug 1649121: part 54) Assert range boundaries in ContentIteratorBase::Initializer are set and valid. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83968
2020-07-21 15:12:06 +00:00
Mirko Brodesser
01f0739a5b Bug 1649121: part 53) Rename local variable endIsData in ContentIteratorBase::InitInternal. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83966
2020-07-20 12:26:09 +00:00
Mirko Brodesser
f16296808d Bug 1649121: part 52) Factor IsCollapsedNonCharacterRange out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83965
2020-07-20 12:26:02 +00:00
Mirko Brodesser
11484d03fc Bug 1649121: part 51) Factor IsSingleNodeCharacterRange out. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83964
2020-07-20 12:25:54 +00:00
Mirko Brodesser
a8183a4452 Bug 1649121: part 50) Add members for start and end. r=masayuki
Allows adding methods operating on them.

Differential Revision: https://phabricator.services.mozilla.com/D83963
2020-07-20 12:27:15 +00:00
Mirko Brodesser
92d3e395ba Bug 1649121: part 49) Break a method object out for ContentIteratorBase::InitInternal. r=masayuki
Preparatory step to make that code readable.

Differential Revision: https://phabricator.services.mozilla.com/D83962
2020-07-20 12:25:37 +00:00
Mirko Brodesser
aee46efef9 Bug 1649121: part 48) Rename MakeEmpty in ContentIteratorBase::InitInternal. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83951
2020-07-20 01:35:57 +00:00
Mirko Brodesser
61c722d5cd Bug 1649121: part 47) Rename local variable startIsData in ContentIteratorBase::InitInternal. r=masayuki
Differential Revision: https://phabricator.services.mozilla.com/D83950
2020-07-20 08:59:08 +00:00
Mirko Brodesser
efd738af5b Bug 1608071: part 2) Rename nsContentUtils::GetCommonAncestor and related methods. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D59319

--HG--
extra : moz-landing-system : lando
2020-01-13 10:29:44 +00:00
Mirko Brodesser
436419e7ff Bug 1600267: part 6) Call ComparePoints instead of ComparePoints_Deprecated in ContentIterator. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D55300

--HG--
extra : moz-landing-system : lando
2019-12-19 13:27:50 +00:00
Mirko Brodesser
b8bb35cc69 Bug 1600267: part 1) Rename nsContentUtils::ComparePoints to ComparePoints_Deprecated. r=smaug
In a follow-up commit a new `ComparePoints` method with cleaner
arguments and return value will be added.

Differential Revision: https://phabricator.services.mozilla.com/D55295

--HG--
extra : moz-landing-system : lando
2019-12-19 13:27:08 +00:00
Mirko Brodesser
e1b9454134 Bug 1587716: change RangeBoundaryBase's offset argument to uint32_t. r=smaug
`uint32_t`, because `nsRange::ComparePoints` requires it -- by webidl
interface -- to be unsigned long.

Moreover it makes `RangeBoundaryBase`'s interface cleaner, because it
already exposes the offset as a `uint32_t`.

Differential Revision: https://phabricator.services.mozilla.com/D50054

--HG--
extra : moz-landing-system : lando
2019-10-23 08:22:36 +00:00
Mirko Brodesser
7ab5217f00 Bug 1587370: remove RangeBoundaryBase::SetAfterRef and use constructor instead. r=smaug
Simpler.

Differential Revision: https://phabricator.services.mozilla.com/D48680

--HG--
extra : moz-landing-system : lando
2019-10-10 16:13:47 +00:00
Masayuki Nakano
da61ea3112 Bug 1444847 - part 3: Create RangeUtils to place public static methods of nsRange r=smaug
Some `nsRange` static methods are useful in `StaticRange` and some of them
are used in a lot of places but not related to `nsRange` directly.  This
patch moves them into new static method only class, `mozilla::RangeUtils`.

Differential Revision: https://phabricator.services.mozilla.com/D35142

--HG--
extra : moz-landing-system : lando
2019-06-28 07:48:07 +00:00
Masayuki Nakano
2a450c5196 Bug 1444847 - part 2: Sort out basic API of nsRange for consistency with coming StaticRange r=smaug
For avoiding confusion between API of `nsRange` and `StaticRange`, I'd like to
rename `nsRange::CreateRange()` to `nsRange::Create()` because
`StaticRange::CreateStaticRange()` is too long name and
`StaticRange::CreateRange()` sounds odd.  This patch renames it and changes
related methods to template methods to avoid runtime cost of temporary
`RawRangeBoundary` instance creation.

Differential Revision: https://phabricator.services.mozilla.com/D35141

--HG--
extra : moz-landing-system : lando
2019-06-28 07:47:29 +00:00
Masayuki Nakano
f421d7b889 Bug 181137 - part 8: Make ContentIteratorBase and its subclasses non-refcountable r=smaug
This patch makes ContentIteratorBase, PostContentIterator, PreContentIterator
and ContentSubtreeIterator classes non-refcountable because most users can
create their instances in stack and such users may be in a hot path.  So,
we can save a lot of cost of instantiation.

Unfortunately, only ScriptableContentIterator creates one of the concrete
classes and needs to destroy it properly.  Therefore, its
EnsureContentIterator(), destructor, traverse and unlink code becomes messy.
However, ScriptableContentIterator was designed for automated tests and we
need to maintain it not so many times.  Therefore, improvement of other
users must be worthwhiler than this demerit.

Differential Revision: https://phabricator.services.mozilla.com/D15928

--HG--
extra : moz-landing-system : lando
2019-01-11 01:52:26 +00:00
Masayuki Nakano
f8844f0d9b Bug 181137 - part 7: Get rid of nsIContentIterator interface r=smaug
Now, nobody requires nsIContentIterator interface.  So, we can get rid of it.

Unfortunately, there is no macro to keep the inherited class,
ContentSubtreeIterator, in the cycle collection to make it keep managing
ContentSubtreeIterator::mRange without nsISupports interface.  Therefore, this
patch moves it into ContentIteratorBase temporarily.  Anyway, the following
patch makes those classes not refcountable.  At that time, this issue will be
fixed.

Differential Revision: https://phabricator.services.mozilla.com/D15927

--HG--
extra : moz-landing-system : lando
2019-01-11 01:51:42 +00:00
Masayuki Nakano
da38fe53bc Bug 181137 - part 5: Make all users of PostContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PostContentIterator can access it directly.  This patch
makes them use the concrete class directly.

Differential Revision: https://phabricator.services.mozilla.com/D15923

--HG--
extra : moz-landing-system : lando
2019-01-11 01:50:19 +00:00
Masayuki Nakano
f5602b96ab Bug 181137 - part 4: Make all users of PreContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PreContentIterator can access it directly.  This patch makes
them use the concrete class directly.

Differential Revision: https://phabricator.services.mozilla.com/D15922

--HG--
extra : moz-landing-system : lando
2019-01-11 01:49:36 +00:00
Masayuki Nakano
3b6d4adf2d Bug 181137 - part 3: Make all users of ContentSutreeIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of ContentSubtreeIterator can access it directly.  This patch
makes them use the concrete class directly.

Differential Revision: https://phabricator.services.mozilla.com/D15920

--HG--
extra : moz-landing-system : lando
2019-01-11 01:49:00 +00:00
Masayuki Nakano
ad8ce91822 Bug 181137 - part 2: Make nsContentIterator class is a base class of other concrete classes r=smaug
Currently, ContentIterator is created with a bool flag to decide whether the
instance lists up post-order or pre-order.  However, this is not clear.  For
example:

nsCOMPtr<nsIContentIterator> preOrderIter = new ContentIterator(false);

This is not clear whether this does right thing or not.

This patch makes any users can create PostContentIterator for post-order
iterator, and creates PreContentIterator for pre-order iterator.  So, now,
each creator needs to writhe above as:

nsCOMPtr<nsIContentIterator> preOrderIter = new PreContentIterator();

or

nsCOMPtr<nsIContentIterator> postOrderIter = new PostContentIterator();

Additionally, with this change, if each user starts to use concrete classes
directly, compiler can stop using virtual calls because of all concrete
classes are now marked as "final".

Differential Revision: https://phabricator.services.mozilla.com/D15918

--HG--
extra : moz-landing-system : lando
2019-01-11 01:48:11 +00:00
Masayuki Nakano
2d75b78552 Bug 181137 - part 1: Move nsContentIterator and nsContentSubtreeIterator into mozilla namespace r=smaug
First, we should move nsContentIterator and nsContentSubtreeIterator into
mozilla namespace and then, remove "ns" prefix.

Additionally, this patch separates the definition of the classes into
ContentIterator.h and exposes it as "mozilla/ContentIterator.h".  This allows
everybody access those concrete classes.

Differential Revision: https://phabricator.services.mozilla.com/D15917

--HG--
rename : dom/base/nsContentIterator.cpp => dom/base/ContentIterator.cpp
rename : dom/base/nsContentIterator.cpp => dom/base/ContentIterator.h
extra : moz-landing-system : lando
2019-01-11 01:47:15 +00:00
Csoregi Natalia
13506c036a Backed out 8 changesets (bug 181137) for bustage on FragmentOrElement.cpp:1751. CLOSED TREE
Backed out changeset 99a977d519a0 (bug 181137)
Backed out changeset 65a4b245e851 (bug 181137)
Backed out changeset 5385d5fd9b8b (bug 181137)
Backed out changeset 83bec02c21d9 (bug 181137)
Backed out changeset b7ab59bf545e (bug 181137)
Backed out changeset b6fc7a332db7 (bug 181137)
Backed out changeset 654fdbad67db (bug 181137)
Backed out changeset 90a1ff49b6b1 (bug 181137)

--HG--
rename : dom/base/ContentIterator.h => dom/base/nsContentIterator.cpp
rename : editor/spellchecker/FilteredContentIterator.cpp => editor/spellchecker/nsFilteredContentIterator.cpp
rename : editor/spellchecker/FilteredContentIterator.h => editor/spellchecker/nsFilteredContentIterator.h
2019-01-10 11:42:27 +02:00
Masayuki Nakano
796ceb094f Bug 181137 - part 8: Make ContentIteratorBase and its subclasses non-refcountable r=smaug
This patch makes ContentIteratorBase, PostContentIterator, PreContentIterator
and ContentSubtreeIterator classes non-refcountable because most users can
create their instances in stack and such users may be in a hot path.  So,
we can save a lot of cost of instantiation.

Unfortunately, only ScriptableContentIterator creates one of the concrete
classes and needs to destroy it properly.  Therefore, its
EnsureContentIterator(), destructor, traverse and unlink code becomes messy.
However, ScriptableContentIterator was designed for automated tests and we
need to maintain it not so many times.  Therefore, improvement of other
users must be worthwhiler than this demerit.

Differential Revision: https://phabricator.services.mozilla.com/D15928

--HG--
extra : moz-landing-system : lando
2019-01-10 08:50:41 +00:00
Masayuki Nakano
91a9670801 Bug 181137 - part 7: Get rid of nsIContentIterator interface r=smaug
Now, nobody requires nsIContentIterator interface.  So, we can get rid of it.

Unfortunately, there is no macro to keep the inherited class,
ContentSubtreeIterator, in the cycle collection to make it keep managing
ContentSubtreeIterator::mRange without nsISupports interface.  Therefore, this
patch moves it into ContentIteratorBase temporarily.  Anyway, the following
patch makes those classes not refcountable.  At that time, this issue will be
fixed.

Differential Revision: https://phabricator.services.mozilla.com/D15927

--HG--
extra : moz-landing-system : lando
2019-01-10 08:47:54 +00:00
Masayuki Nakano
bdc602b92f Bug 181137 - part 5: Make all users of PostContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PostContentIterator can access it directly.  This patch
makes them use the concrete class directly.

Differential Revision: https://phabricator.services.mozilla.com/D15923

--HG--
extra : moz-landing-system : lando
2019-01-10 08:46:32 +00:00
Masayuki Nakano
6f5a9fb98a Bug 181137 - part 4: Make all users of PreContentIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of PreContentIterator can access it directly.  This patch makes
them use the concrete class directly.

Differential Revision: https://phabricator.services.mozilla.com/D15922

--HG--
extra : moz-landing-system : lando
2019-01-10 08:46:25 +00:00
Masayuki Nakano
e4fd546fbd Bug 181137 - part 3: Make all users of ContentSutreeIterator treat it directly rather than via nsIContentIterator r=smaug
Now, all users of ContentSubtreeIterator can access it directly.  This patch
makes them use the concrete class directly.

Differential Revision: https://phabricator.services.mozilla.com/D15920

--HG--
extra : moz-landing-system : lando
2019-01-10 08:45:07 +00:00
Masayuki Nakano
d877816981 Bug 181137 - part 2: Make nsContentIterator class is a base class of other concrete classes r=smaug
Currently, ContentIterator is created with a bool flag to decide whether the
instance lists up post-order or pre-order.  However, this is not clear.  For
example:

nsCOMPtr<nsIContentIterator> preOrderIter = new ContentIterator(false);

This is not clear whether this does right thing or not.

This patch makes any users can create PostContentIterator for post-order
iterator, and creates PreContentIterator for pre-order iterator.  So, now,
each creator needs to writhe above as:

nsCOMPtr<nsIContentIterator> preOrderIter = new PreContentIterator();

or

nsCOMPtr<nsIContentIterator> postOrderIter = new PostContentIterator();

Additionally, with this change, if each user starts to use concrete classes
directly, compiler can stop using virtual calls because of all concrete
classes are now marked as "final".

Differential Revision: https://phabricator.services.mozilla.com/D15918

--HG--
extra : moz-landing-system : lando
2019-01-10 08:44:24 +00:00