Bug 25868
| Summary: | Frame::markAllMatchesForText prematurely aborts while highlighting text | ||
|---|---|---|---|
| Product: | WebKit | Reporter: | Finnur Thorarinsson <finnur.webkit> |
| Component: | New Bugs | Assignee: | Nobody <webkit-unassigned> |
| Status: | UNCONFIRMED | ||
| Severity: | Normal | CC: | ahmad.saleem792, mitz, rniwa, simon.fraser |
| Priority: | P2 | ||
| Version: | 528+ (Nightly build) | ||
| Hardware: | PC | ||
| OS: | All | ||
Finnur Thorarinsson
I can easily reproduce a problem with highlighting in Frame::markAllMatchesForText.
The problem is this:
On certain HTML files, the markAllMatchesForText is aborted before reaching the end (resulting in failure to highlight matches).
A superficial look through the annotations lead me to a bug titled "Searching in text areas" (https://bugs.webkit.org/show_bug.cgi?id=7023), which was fixed and I think causes this.
I have a reduced HTML code that I use to reproduce this bug:
<!doctype html>
<body>
<input type=text value="html">
Call markAllMatchesForText with html[space] and it should highlight these words: html html done.
</body>
Note that <input type=text> has the string "html" in it.
If you call markAllMatchesForText for "html " (note the trailing space) on this frame, it will break and not highlight anything (see comment). Observe my comment in the snippet below, which is where it breaks.
unsigned Frame::markAllMatchesForText(const String& target, bool caseFlag, unsigned limit)
{
if (target.isEmpty())
return 0;
RefPtr<Range> searchRange(rangeOfContents(document()));
ExceptionCode exception = 0;
unsigned matchCount = 0;
do {
RefPtr<Range> resultRange(findPlainText(searchRange.get(), target, true, caseFlag));
if (resultRange->collapsed(exception)) {
if (!resultRange->startContainer()->isInShadowTree())
break; // << NOTE: THIS IS WHERE IT ABORTS.
If it is easy to fix, feel free to suggest changes to this code that will make this work and I would be happy to try it out in my tree and submit a patch (if it works).
| Attachments | ||
|---|---|---|
| Add attachment proposed patch, testcase, etc. |
Ahmad Saleem
This looks totally different code now:
https://searchfox.org/wubkat/source/Source/WebCore/page/Page.cpp#983
unsigned Page::markAllMatchesForText(const String& target, FindOptions options, bool shouldHighlight, unsigned maxMatchCount)
{
return findMatchesForText(target, options, maxMatchCount, shouldHighlight ? HighlightMatches : DoNotHighlightMatches, MarkMatches);
}
Anything to do here?