Commit Graph

81 Commits

Author SHA1 Message Date
Sylvestre Ledru
230ce836cb Bug 1519636 - Reformat recent changes to the Google coding style r=Ehsan,kvark
# ignore-this-changeset

Differential Revision: https://phabricator.services.mozilla.com/D63787
2020-02-24 15:33:38 +00:00
Emilio Cobos Álvarez
43098f2a53 Bug 1601118 - Fix nsFind state initialization logic. r=smaug
We should start seeking from the child-at-start/end-offset, rather than the
selection container.

The logic to select the starting node was backwards too...

If we're finding backwards we want to start looking from the beginning of the
range and vice versa. But I think that doesn't really matter since
nsWebBrowserFind always gives us a start range with start == end.

Differential Revision: https://phabricator.services.mozilla.com/D63553
2020-02-21 17:41:34 +00:00
Mihai Alexandru Michis
6d63e53788 Backed out changeset 9a03944aff45 (bug 1601118) for causing AssertionError in geckoview.test.FinderTest
CLOSED TREE
2020-02-21 16:14:06 +02:00
Emilio Cobos Álvarez
76d7ad46e2 Bug 1601118 - Fix nsFind state initialization logic. r=smaug
We should start seeking from the child-at-start/end-offset, rather than the
selection container.

The logic to select the starting node was backwards too...

If we're finding backwards we want to start looking from the beginning of the
range and vice versa. But I think that doesn't really matter since
nsWebBrowserFind always gives us a start range with start == end.

Differential Revision: https://phabricator.services.mozilla.com/D63553
2020-02-21 13:19:37 +00:00
Alex Henrie
9ee4dc3b13 Bug 1611568 - Ignore combining diacritic characters when "Match Diacritics" is off. r=jfkthame
Differential Revision: https://phabricator.services.mozilla.com/D61081
2020-02-10 18:09:05 +00:00
Masayuki Nakano
4f417fdeec Bug 1612085 - part 1: Hide constructor of nsRange r=smaug
`nsRange` instances are allocated a lot in the heap especially by editor and
spellchecker.  The allocation cost is too bad for benchmarks.  Therefore,
we should reuse released instances as far as possible.  For managing it in
static factory methods of `nsRange`, we need to hide `nsRange` constructor.

Differential Revision: https://phabricator.services.mozilla.com/D61237
2020-01-30 13:23:35 +00:00
Alex Henrie
497b982004 Bug 202251 - Add an option to ignore diacritics when searching. r=fluent-reviewers,mikedeboer,jfkthame,flod
Differential Revision: https://phabricator.services.mozilla.com/D51841
2019-12-09 19:26:40 +00:00
Gabriele Svelto
f03cdb2b2d Bug 1600545 - Remove useless inclusions of header files generated from IDL files in modules/, netwerk/, parser/, security/, startupcache/, storage/, toolkit/, tools/, uriloader/, widget/, xpcom/ and xpfe/ r=Ehsan
The inclusions were removed with the following very crude script and the
resulting breakage was fixed up by hand. The manual fixups did either
revert the changes done by the script, replace a generic header with a more
specific one or replace a header with a forward declaration.

find . -name "*.idl" | grep -v web-platform | grep -v third_party | while read path; do
    interfaces=$(grep "^\(class\|interface\).*:.*" "$path" | cut -d' ' -f2)
    if [ -n "$interfaces" ]; then
        if [[ "$interfaces" == *$'\n'* ]]; then
          regexp="\("
          for i in $interfaces; do regexp="$regexp$i\|"; done
          regexp="${regexp%%\\\|}\)"
        else
          regexp="$interfaces"
        fi
        interface=$(basename "$path")
        rg -l "#include.*${interface%%.idl}.h" . | while read path2; do
            hits=$(grep -v "#include.*${interface%%.idl}.h" "$path2" | grep -c "$regexp" )
            if [ $hits -eq 0 ]; then
                echo "Removing ${interface} from ${path2}"
                grep -v "#include.*${interface%%.idl}.h" "$path2" > "$path2".tmp
                mv -f "$path2".tmp "$path2"
            fi
        done
    fi
done

Differential Revision: https://phabricator.services.mozilla.com/D55444
2019-12-06 09:17:57 +00:00
Brindusan Cristian
f8193f77a3 Backed out changeset b89936db7178 (bug 202251) for bc failures at browser_misused_characters_in_strings.js. CLOSED TREE 2019-12-05 23:10:09 +02:00
Alex Henrie
a6c666a04f Bug 202251 - Add an option to ignore diacritics when searching. r=fluent-reviewers,mikedeboer,jfkthame,flod
Differential Revision: https://phabricator.services.mozilla.com/D51841
2019-12-05 18:08:20 +00:00
Emilio Cobos Álvarez
e9ad71d0d9 Bug 1596445 - Add some supporting code to nsINode to deal with NAC and shadow DOM separately. r=bzbarsky
We'll use these to remove GetBindingParent.

Differential Revision: https://phabricator.services.mozilla.com/D53029
2019-11-15 15:10:45 +00:00
Alex Henrie
1617de93d3 Bug 969980 - Use case folding for case-insensitive searches. r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D50940
2019-10-29 19:56:56 +00:00
Alex Henrie
5017d5faac Bug 1589786 - Handle surrogate pairs in nsFind. r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D49822
2019-10-25 01:15:07 +00:00
Mihai Alexandru Michis
2f0f159cad Backed out changeset 0063a5b2f5b3 (bug 1589786) for causing bustages in TestDLLBlocklist.obj and sandboxBroker.i_o CLOSED TREE 2019-10-24 19:41:56 +03:00
Alex Henrie
9cdb8cd316 Bug 1589786 - Handle surrogate pairs in nsFind. r=Ehsan
Differential Revision: https://phabricator.services.mozilla.com/D49822
2019-10-24 13:38:32 +00:00
Emilio Cobos Álvarez
f4c6ad1714 Bug 1576817 - Fix a regression from bug 1490974 where we'll fail to find visibility: visible descendants of visibility: hidden nodes. r=bradwerth
The split between IsDisplayedNode and IsVisibleNode is pretty intentional, since
visibility: visible descendants of visiblity: hidden ancestors are in fact
visible.

We skip fully-invisible ranges in here instead:

https://searchfox.org/mozilla-central/rev/325c1a707819602feff736f129cb36055ba6d94f/toolkit/components/find/nsFind.cpp#776

Differential Revision: https://phabricator.services.mozilla.com/D43745
2019-08-28 15:15:23 +00:00
Emilio Cobos Álvarez
2bd02f5b8d Bug 1576817 - Only allow finding editable anonymous nodes in form controls. r=bradwerth
We want to find the text inside the input that the user types, but not stuff
like the placeholder. So check that the anonymous subtree is editable, or skip
it otherwise.

Differential Revision: https://phabricator.services.mozilla.com/D43744
2019-08-28 15:35:48 +00:00
Emilio Cobos Álvarez
bb1a6929f2 Bug 1576817 - Simplify some code added in bug 1490974. r=bradwerth
Differential Revision: https://phabricator.services.mozilla.com/D43743
2019-08-28 15:11:55 +00:00
Brad Werth
cae3e7412e Bug 1542324 Part 1: Make nsFind::Find handle empty string searches. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D28908
2019-04-25 21:37:09 +00:00
Brad Werth
f2c3863845 Bug 1538042 Part 1: Change nsIFind::Find to have access to text length. r=mccr8
Differential Revision: https://phabricator.services.mozilla.com/D25005
2019-03-29 15:55:57 +00:00
Brad Werth
f157615adf Bug 1490974 Part 1: For find-in-page, prevent invisible nodes and option nodes from being included in find results. r=mikedeboer
Differential Revision: https://phabricator.services.mozilla.com/D10631
2019-02-27 21:23:55 +00:00
Ehsan Akhgari
498e2df734 Bug 1521000 - Part 2: Adjust our clang-format rules to include spaces after the hash for nested preprocessor directives r=sylvestre
# ignore-this-changeset
2019-01-18 10:16:18 +01: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
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
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
Emilio Cobos Álvarez
dc336a73ba Bug 1517241 - Rename nsIDocument to mozilla::dom::Document. r=smaug
Summary: Really sorry for the size of the patch. It's mostly automatic
s/nsIDocument/Document/ but I had to fix up in a bunch of places manually to
add the right namespacing and such.

Overall it's not a very interesting patch I think.

nsDocument.cpp turns into Document.cpp, nsIDocument.h into Document.h and
nsIDocumentInlines.h into DocumentInlines.h.

I also changed a bunch of nsCOMPtr usage to RefPtr, but not all of it.

While fixing up some of the bits I also removed some unneeded OwnerDoc() null
checks and such, but I didn't do anything riskier than that.
2019-01-03 17:48:33 +01:00
Emilio Cobos Álvarez
b8f39e7368 Bug 1510485 - Properly handle errors in nsFind when returning a range. r=bzbarsky
Bug 1505887 changed the behavior here from content calling into nsFind via
window.find(), by making the SetStart and SetEnd calls here fail instead of
succeed for NAC (like the text in textareas).

This patch makes us handle that error gracefully moving on to the next match,
instead of trying to preserve the previous behavior.

This means that we'll fail to highlight textarea content and such from
window.find, which Chromium does, looks like. Though Chromium doesn't expose
the ranges as selection either. In any case I don't think that this is a very
common thing given bugs like bug 1442466, which this bug fixes.

I haven't found anything close to a spec for what window.find() should do... If
we decide to go with this patch then I'll add a crashtest for this and a test
for bug 1442466 as well. Otherwise I'll add a way to skip the security check in
nsFind somehow for NAC, or relax the security restrictions in SetStart /
SetEnd, I guess.

Differential Revision: https://phabricator.services.mozilla.com/D14013
2018-12-11 01:06:32 +00:00
Sylvestre Ledru
e5a134f73a Bug 1511181 - Reformat everything to the Google coding style r=ehsan a=clang-format
# ignore-this-changeset
2018-11-30 11:46:48 +01:00
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