Commit Graph

53 Commits

Author SHA1 Message Date
Emilio Cobos Álvarez
67490bda92 Bug 1455891: Use GetFlattenedTreeParent more in nsFind. r=mats
This is the right thing to use for this kind of stuff.

MozReview-Commit-ID: FrgD48LjRSG
2018-07-06 06:53:22 +02:00
Emilio Cobos Álvarez
cf4fe9a917 Bug 1455891: Remove nsFindContentIterator. r=mats
MozReview-Commit-ID: 58AFqqaSLcC
2018-07-06 06:53:22 +02:00
Emilio Cobos Álvarez
c7ac19f39e Bug 1455891: Use TreeIterator in nsFind. r=mats
MozReview-Commit-ID: GSY5w6NYRS
2018-07-06 06:53:22 +02:00
Emilio Cobos Álvarez
9933ecf2bb Bug 1472529: More nsFind cleanup. r=mats
The general setup is that the State struct is used to iterate over text nodes
explicitly, and keeps references to the ranges so that we don't need to pass all
them around everywhere.

We need to teach nsFindContentIterator to rewind into NAC to be able to get rid
of mIterNode, which was getting out of sync when we failed to rewind to the
anchor node.

MozReview-Commit-ID: 5czYADrm1WX
2018-07-03 02:07:48 +02:00
Emilio Cobos Álvarez
4bc7841ce3 Bug 1470861: Mark some nsFind arguments const. rs=mats
MozReview-Commit-ID: 8zh1y2vRyWj
2018-06-26 14:39:41 +02:00
Emilio Cobos Álvarez
985f4b49c8 Bug 1470861: Mark some methods const now that they don't mutate nsFind itself. r=mats
This patch is idempotent.

MozReview-Commit-ID: BBZlZ5FrP5K
2018-06-26 14:39:41 +02:00
Emilio Cobos Álvarez
d36a41b6f9 Bug 1470861: Make GetBlockParent static. r=mats
This patch is idempotent.

MozReview-Commit-ID: L5JfCfnlKzM
2018-06-26 14:39:41 +02:00
Emilio Cobos Álvarez
9644646628 Bug 1470861: Remove useless code. r=mats
We're throwing away the computation when aContinueOk is true, so we can remove
that call. Removing that call removes the last usage of aContinueOk, so remove
that handling as well.

This patch is idempotent.

MozReview-Commit-ID: E3sogickWp9
2018-06-26 14:39:41 +02:00
Emilio Cobos Álvarez
92f2ff398e Bug 1470861: Make state-passing explicit in nsFind. r=mats
Instead of tweaking member variables and resetting them afterwards, just have an
object that we pass around.

This makes a bit easier to reason about nsFind IMO, and makes us able to use
more complex iterators that don't keep strong references to anything and that
kind of stuff, since we don't keep an iterator member around, and we don't
mutate the DOM from nsFind.

This patch is idempotent.

MozReview-Commit-ID: ERDnL6Q8QTU
2018-06-26 14:39:41 +02:00
Emilio Cobos Álvarez
5680f7b128 Bug 1470861: Make nsFind::ResetAll reset mIterNode / mIterOffset too. r=mats
We do reset them implicitly next time we call Find(..), since we call
ResetAll() at the beginning of it, then NextNode(..), which unconditionally
overrides them, but this is clearer for the next thing I want to do.

This patch is idempotent.

MozReview-Commit-ID: 6OW8MfkftTM
2018-06-26 14:17:40 +02:00
Emilio Cobos Álvarez
1ed763b8fc Bug 1470861: Cleanup GetBlockParent. r=mats
This patch is idempotent.

MozReview-Commit-ID: 1e9y2Fn76kU
2018-06-26 14:17:27 +02:00
Chris Peterson
f7ceeaf5cf Bug 1469769 - Part 6: Replace non-failing NS_NOTREACHED with MOZ_ASSERT_UNREACHABLE. r=froydnj
This patch is an automatic replacement of s/NS_NOTREACHED/MOZ_ASSERT_UNREACHABLE/. Reindenting long lines and whitespace fixups follow in patch 6b.

MozReview-Commit-ID: 5UQVHElSpCr
2018-06-17 22:43:11 -07:00
Emilio Cobos Álvarez
fa3afe5836 No bug - Remove unneeded DEBUG_FIND ifdef. r=me
MozReview-Commit-ID: DlLynspfZFC
2018-06-25 21:19:31 +02:00
Emilio Cobos Álvarez
c7c9807d0e No bug - Remove useless QI in DEBUG_FIND code. r=me
MozReview-Commit-ID: B6vME1WYne3
2018-06-25 11:43:21 +02:00
Emilio Cobos Álvarez
d5e7b97525 Bug 1457336: Forget the last matched character when switching blocks. r=mats
This fixes browser/components/extensions/test/browser/file_find_frames.html with
my patches. We were relying on traversing suppressed whitespace to match the
whole word properly there.

You can see the bug with the following test-case:

<p>Banana 0</p><p>Banana 1</p>

If you try to match "banana" using "Whole word", you'll only find the first
word, because we keep c = '0'. If there's a newline between the two paragraphs,
like in the test, before my patch we we would traverse it (even though it's
suppressed whitespace) and keep c = '\n', which makes the match succeed.

Fix it forgetting the state of the match completely, including c.

That test was firing a lot of "GetOffsetTo() called on frames from different
documents" assertions... That's probably worth looking into as a followup.

MozReview-Commit-ID: AzId7YWQcJI
2018-05-30 12:52:46 +02:00
Emilio Cobos Álvarez
543dd27b1e Bug 1457336: Skip only undisplayed nodes, not invisible nodes. r=mats
MozReview-Commit-ID: 5KgV1lqmim3
2018-05-30 12:52:46 +02:00
Emilio Cobos Álvarez
71e08b741e Bug 1457336: Make some functions static. r=mats
This patch should have no change in behavior.

MozReview-Commit-ID: AOAZ09g78fr
2018-05-30 12:52:46 +02:00
Emilio Cobos Álvarez
fc8f456e44 Bug 1457336: Make the debug find code less noisy. r=mats
Not sure how useful it really is compared to rr but...

MozReview-Commit-ID: 4II28NYDCNo
2018-05-30 12:52:46 +02:00
Emilio Cobos Álvarez
b54e955921 Bug 1457336: Remove dead code. r=mats
There's nothing referencing this macro...

MozReview-Commit-ID: 5NzVOFAOQMw
2018-05-30 12:52:46 +02:00
Emilio Cobos Álvarez
57745feca6 Bug 1457336: Teach nsFind about display in general. r=mats
I ended up not using the nsIFrame methods both for consistency with the plain
text serializer and because of include hell due to nsStyleStructInlines /
nsIFrameInlines.

Find doesn't care about nodes with no frames anyway, so it didn't seem worth
doing the fallback if there's no style information.

I'll file a bug for IsHTMLBlock.

MozReview-Commit-ID: 3T317a4xCB
2018-05-30 12:52:46 +02:00
Emilio Cobos Álvarez
334950f38a Bug 1457286: Teach nsFind about display: contents. r=mats
MozReview-Commit-ID: LODyc8yuuSs
2018-05-30 12:45:24 +02:00
Boris Zbarsky
aade0a5cae Bug 1455676 part 13. Remove use of nsIDOMNode from toolkit/. r=mossop
This needs pretty careful review for the update service changes, though I think
they're pretty mechanical and safe.
2018-05-29 22:58:49 -04:00
Cosmin Sabou
1c334d91d9 Backed out 10 changesets (bug 1457336, bug 1457286) for android mochitest failures on dom/base/test/test_find.html.
Backed out changeset 6b7bc00d68ae (bug 1457336)
Backed out changeset 585572d3a8e3 (bug 1457336)
Backed out changeset ded57fc8fd13 (bug 1457336)
Backed out changeset b7a0af3470b0 (bug 1457336)
Backed out changeset 3d17cdf86d69 (bug 1457336)
Backed out changeset 9df9a6524aad (bug 1457336)
Backed out changeset 727e25c0e3ad (bug 1457336)
Backed out changeset 91f27da56d68 (bug 1457336)
Backed out changeset 072fa168f471 (bug 1457336)
Backed out changeset 1f645546750f (bug 1457286)
2018-05-30 01:21:31 +03:00
Emilio Cobos Álvarez
22ff6c1e56 Bug 1457336: Forget the last matched character when switching blocks. r=mats
This fixes browser/components/extensions/test/browser/file_find_frames.html with
my patches. We were relying on traversing suppressed whitespace to match the
whole word properly there.

You can see the bug with the following test-case:

<p>Banana 0</p><p>Banana 1</p>

If you try to match "banana" using "Whole word", you'll only find the first
word, because we keep c = '0'. If there's a newline between the two paragraphs,
like in the test, before my patch we we would traverse it (even though it's
suppressed whitespace) and keep c = '\n', which makes the match succeed.

Fix it forgetting the state of the match completely, including c.

That test was firing a lot of "GetOffsetTo() called on frames from different
documents" assertions... That's probably worth looking into as a followup.

MozReview-Commit-ID: AzId7YWQcJI
2018-05-29 21:39:13 +02:00
Emilio Cobos Álvarez
72935a9e02 Bug 1457336: Skip only undisplayed nodes, not invisible nodes. r=mats
MozReview-Commit-ID: 5KgV1lqmim3
2018-05-29 21:39:12 +02:00
Emilio Cobos Álvarez
d851746e5a Bug 1457336: Make some functions static. r=mats
This patch should have no change in behavior.

MozReview-Commit-ID: AOAZ09g78fr
2018-05-29 21:39:11 +02:00
Emilio Cobos Álvarez
7b33bc6198 Bug 1457336: Make the debug find code less noisy. r=mats
Not sure how useful it really is compared to rr but...

MozReview-Commit-ID: 4II28NYDCNo
2018-05-29 21:39:10 +02:00
Emilio Cobos Álvarez
c9ee7f5b3c Bug 1457336: Remove dead code. r=mats
There's nothing referencing this macro...

MozReview-Commit-ID: 5NzVOFAOQMw
2018-05-29 21:39:09 +02:00
Emilio Cobos Álvarez
64fc52ffcb Bug 1457336: Teach nsFind about display in general. r=mats
I ended up not using the nsIFrame methods both for consistency with the plain
text serializer and because of include hell due to nsStyleStructInlines /
nsIFrameInlines.

Find doesn't care about nodes with no frames anyway, so it didn't seem worth
doing the fallback if there's no style information.

I'll file a bug for IsHTMLBlock.

MozReview-Commit-ID: 3T317a4xCB
2018-05-29 21:39:08 +02:00
Emilio Cobos Álvarez
1f5f2ed33a Bug 1457286: Teach nsFind about display: contents. r=mats
MozReview-Commit-ID: LODyc8yuuSs
2018-05-29 21:39:07 +02:00
Boris Zbarsky
02774793c2 Bug 1377980 part 2. Remove most C++ use of nsIDOMRange. r=mccr8 2018-05-17 12:01:38 -04:00
Boris Zbarsky
95d89ff9cf Bug 1377980 part 1. Remove use of nsIDOMRange in xpidl. r=mcc8 2018-05-17 12:01:37 -04:00
Boris Zbarsky
5d017f96cf Bug 1387143 part 29. Remove nsISelection. r=mats 2018-05-08 13:52:42 -04:00
Boris Zbarsky
e833274f0a Bug 1455674 part 1. Stop using nsIDOMElement in nsIEditor. r=masayuki 2018-04-26 23:35:18 -04:00
Adrian Wielgosik
38f9a663ce Bug 1447389 - Remove nsIDOMNodeList. r=bz
MozReview-Commit-ID: 11szZP6dS6V
2018-04-25 23:01:30 +02:00
Emilio Cobos Álvarez
cde47f0f7b Bug 1454251: Remove nsINode::eCOMMENT. r=bz
MozReview-Commit-ID: AbSPU25fFbM
2018-04-20 09:51:57 +02:00
Andrew McCreight
7a07e0c48b Bug 1449670, part 1 - Convert IsNodeOfType(nsINode::eTEXT) to IsText(). r=bz
This method is not a virtual call, and also looks nicer.

This patch was mostly generated by a Python script, but I manually
cleaned up the code in a few places where statements didn't need to be
split across multiple lines any more.

MozReview-Commit-ID: 8JExxqSRc59
2018-04-12 15:41:00 -07:00
Boris Zbarsky
501db43b67 Bug 1449601. Stop dereferencing a null mIterNode in find code. r=mystor
MozReview-Commit-ID: 2buTShJNqFp
2018-04-09 16:30:31 -04:00
Boris Zbarsky
32b248d7cd Bug 1447889 part 8. Remove nsIDOMRange::SelectNode/SelectNodeContents. r=mystor
MozReview-Commit-ID: 2hbF6pT31Xd
2018-03-27 00:35:21 -04:00
Boris Zbarsky
747fb5d03d Bug 1447889 part 6. Remove nsIDOMRange::SetStart/End. r=mystor
MozReview-Commit-ID: 8yOZMWBexsN
2018-03-27 00:35:21 -04:00
Boris Zbarsky
7e3b669edb Bug 1447889 part 4. Remove nsIDOMRange::GetStart/EndContainer/Offset. r=mystor
I got a bit carried away with fixing up consumers to use nsINode...  But as a
result removing these methods all together made sense.

MozReview-Commit-ID: 2z9Q6D7GY92
2018-03-27 00:35:21 -04:00
Boris Zbarsky
8315488628 Bug 1432186 part 17. Remove nsIDOMNode's parentNode attribute. r=mccr8
MozReview-Commit-ID: 4xzDwwEqnvE
2018-01-29 23:10:52 -05:00
Boris Zbarsky
f2f1b7a49a Bug 1432186 part 5. Remove nsIDOMNode's nodeType attribute. r=mccr8
MozReview-Commit-ID: LKsBgKcqtBS
2018-01-29 23:10:50 -05:00
Boris Zbarsky
38e0d324fd Bug 1432186 part 3. Remove nsIDOMNode's nodeName attribute. r=mccr8
MozReview-Commit-ID: Jg0Tuvdi6uX
2018-01-29 23:10:50 -05:00
Jonathan Kew
b5aeae87e3 Bug 1424898 - patch 2 - De-virtualize nsIWordBreaker and rename to mozilla::intl::WordBreaker. r=m_kato 2017-12-13 22:17:38 -06:00
Sylvestre Ledru
dd6b0e4a9f Bug 1424867 - Fix an ignored-qualifiers warning in nsFind.cpp r=smaug
MozReview-Commit-ID: JcNxEejtkWx
2017-12-12 08:11:39 -06:00
Nicholas Nethercote
7dbfdaf890 Bug 1400460 - Rename nsIAtom as nsAtom. r=hiro.
(Path is actually r=froydnj.)

Bug 1400459 devirtualized nsIAtom so that it is no longer a subclass of
nsISupports. This means that nsAtom is now a better name for it than nsIAtom.

MozReview-Commit-ID: 91U22X2NydP
2017-10-03 09:05:19 +11:00
Nika Layzell
fb48ede1e5 Bug 1399626 - Part 4: Allow initializing nsIContentIterator with RangeBoundaries, r=masayuki
This patch adds an overload to nsIContentIterator::Init which accepts
RangeBoundary objects, and modifies the codepath to avoid using the offset of
the start or end nodes to construct the nsIContentIterator.

MozReview-Commit-ID: 5ZqKeiUunoN
2017-10-02 11:58:00 -04:00
Masayuki Nakano
bdd99ce042 Bug 1375502 - part2: Add nsIContentIterator::Init(nsINode*, uint32_t, nsINode*, uint32_t) r=mats
nsIContentIterator::Init() takes nsRange but it's too expensive for some users.
So, there should be another Init() which can be specified a range in DOM tree
with 2 pairs of nsINode* and uint32_t.

MozReview-Commit-ID: 6JXic0KOM2d
2017-06-26 17:26:27 +09:00
Masayuki Nakano
e600000538 Bug 1377978 - Make nsRange use uint32_t to offset r=smaug
DOM Standard defines that offset of Range is unsigned long.  However, nsRange uses int32_t to them.

This patch makes nsRange use uint32_t instead.  However, this patch does NOT allow to set over INT32_MAX as offset values since a lot of users of nsRange cannot treat the values as over INT32_MAX because a lot of internal APIs take int32_t as offsets.

For easier to search such points, this patch adds static_cast<int32_t> to uint32_t variables when they are used for int32_t arguments.

And note that nsContentUtils::ComparePoints() behaves odd.  It accepts negative offset and compares such value with valid offset simply.  This patch still uses int32_t offset variables in nsRange::CompareNodeToRange() even though it may be negative value if nsINode::IndexOf() returns -1 because the caller of it depends on this behavior.

MozReview-Commit-ID: 8RbOgA86JuT
2017-07-19 22:49:52 +09:00