Commit Graph

50 Commits

Author SHA1 Message Date
Rafal Bielski
2a76aff71b 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
ab22065576 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
fe7ba3a7aa 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
48604a3c23 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
2896486990 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
aec21accbd 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
a830088e37 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
47253d7162 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
0a979d5273 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
1ec432d27c 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
bf11884bbf 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
58c095332e 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
bf680d9b82 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
156a16b2c0 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
51b3045880 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
96d7c7f607 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
d53c47a7fa 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
0b89da9dde 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
8b28ba3f2d 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
a50e1c415a 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
97ec67a0ad 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
abaf51852a 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
9f28cafdca 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
714eab83e9 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
5c0a236b0d 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
8b32aee1ee 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
626ea0f0f1 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
587433ac96 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
d02e84d2d2 Bug 1608071: part 2) Rename nsContentUtils::GetCommonAncestor and related methods. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D59319
2020-01-13 10:29:44 +00:00
Mirko Brodesser
4629088a78 Bug 1600267: part 6) Call ComparePoints instead of ComparePoints_Deprecated in ContentIterator. r=smaug
Differential Revision: https://phabricator.services.mozilla.com/D55300
2019-12-19 13:27:50 +00:00
Mirko Brodesser
9317c60217 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
2019-12-19 13:27:08 +00:00
Mirko Brodesser
90e32194c1 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
2019-10-23 08:22:36 +00:00
Mirko Brodesser
3917625b27 Bug 1587370: remove RangeBoundaryBase::SetAfterRef and use constructor instead. r=smaug
Simpler.

Differential Revision: https://phabricator.services.mozilla.com/D48680
2019-10-10 16:13:47 +00:00
Masayuki Nakano
0af2378d06 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
2019-06-28 07:48:07 +00:00
Masayuki Nakano
e1ccf4df16 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
2019-06-28 07:47:29 +00:00
Masayuki Nakano
67508411d2 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
2019-01-11 01:52:26 +00:00
Masayuki Nakano
f2a04fe873 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
2019-01-11 01:51:42 +00:00
Masayuki Nakano
8d411b4487 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
2019-01-11 01:50:19 +00:00
Masayuki Nakano
3ef3eaf11b 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
2019-01-11 01:49:36 +00:00
Masayuki Nakano
7999b49986 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
2019-01-11 01:49:00 +00:00
Masayuki Nakano
d06f149942 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
2019-01-11 01:48:11 +00:00
Masayuki Nakano
32a3f7c0ac 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
2019-01-11 01:47:15 +00:00
Csoregi Natalia
ec11d4a214 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)
2019-01-10 11:42:27 +02:00
Masayuki Nakano
e3bc6266ea 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
2019-01-10 08:50:41 +00:00
Masayuki Nakano
58163408b9 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
2019-01-10 08:47:54 +00:00
Masayuki Nakano
9246e803f4 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
2019-01-10 08:46:32 +00:00
Masayuki Nakano
bdda093c32 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
2019-01-10 08:46:25 +00:00
Masayuki Nakano
602d7d0153 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
2019-01-10 08:45:07 +00:00
Masayuki Nakano
626739d7d1 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
2019-01-10 08:44:24 +00:00
Masayuki Nakano
cb438a512a 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
2019-01-10 08:43:50 +00:00