WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
196127
Reproducible case of backwards nextParagraph returning a position ahead of the input position
https://bugs.webkit.org/show_bug.cgi?id=196127
Summary
Reproducible case of backwards nextParagraph returning a position ahead of th...
Tim Horton
Reported
2019-03-21 19:07:48 PDT
Don't know how to write a standalone test for this yet, but: <style>body { margin: 0; } iframe { border: none; }</style><meta name='viewport' content='initial-scale=1'><span id='the'>The</span> quick brown fox <span id='jumps'>jumps</span> over the lazy <span id='dog'>dog.</span> And then select jumps: getSelection().setBaseAndExtent(jumps, 0, jumps, 1) If you take the selection start and then call positionOfNextBoundaryOfGranularity() with granularity=paragraph and direction=backwards, *twice*, you end up at the *end* of the document.
Attachments
Bad repro
(515 bytes, text/html)
2019-03-21 19:19 PDT
,
Ryosuke Niwa
no flags
Details
Fixes the bug
(18.69 KB, patch)
2019-03-27 20:48 PDT
,
Ryosuke Niwa
no flags
Details
Formatted Diff
Diff
Patch and unit test
(7.49 KB, patch)
2019-12-13 14:57 PST
,
Daniel Bates
no flags
Details
Formatted Diff
Diff
Patch and unit test
(7.38 KB, patch)
2019-12-16 10:20 PST
,
Daniel Bates
no flags
Details
Formatted Diff
Diff
To land
(7.22 KB, patch)
2019-12-16 14:29 PST
,
Daniel Bates
no flags
Details
Formatted Diff
Diff
Show Obsolete
(3)
View All
Add attachment
proposed patch, testcase, etc.
Ryosuke Niwa
Comment 1
2019-03-21 19:19:36 PDT
Created
attachment 365668
[details]
Bad repro I can't reproduce this... Maybe nextParagraphBoundaryInDirection behaves differently from modify.
Radar WebKit Bug Importer
Comment 2
2019-03-21 19:24:42 PDT
<
rdar://problem/49135890
>
Ryosuke Niwa
Comment 3
2019-03-21 19:24:45 PDT
We should look into this. A bug like this can result in an infinite loop elsewhere.
Tim Horton
Comment 4
2019-03-21 19:24:53 PDT
You should be able to reproduce with the API test in
https://bugs.webkit.org/show_bug.cgi?id=196040
if you remove the silly check in moveByGranularity...
Ryosuke Niwa
Comment 5
2019-03-27 20:48:55 PDT
Created
attachment 366146
[details]
Fixes the bug
Ryosuke Niwa
Comment 6
2019-03-27 20:50:53 PDT
Comment on
attachment 366146
[details]
Fixes the bug Wrong bug :(
Tim Horton
Comment 7
2019-03-27 22:27:30 PDT
Aww, you had me excited
Daniel Bates
Comment 8
2019-12-13 14:48:48 PST
Hit this bug... I'm going to take a stab.
Daniel Bates
Comment 9
2019-12-13 14:51:55 PST
The issue is that WebCore::nextParagraphBoundaryInDirection() does actually handle the case where the specified position is not within a paragraph. It handle that case as if the position was on a paragraph boundary. The latter needs to be handled as well.
Daniel Bates
Comment 10
2019-12-13 14:57:41 PST
Created
attachment 385645
[details]
Patch and unit test
Daniel Bates
Comment 11
2019-12-13 14:58:36 PST
Kinda wavering on the changes here...trying to figure out what's the most readable code. Left some duplication on the table to try to get something more readable. Maybe solution should be DRY-er.
Daniel Bates
Comment 12
2019-12-13 14:59:03 PST
Patch will not apply until
bug #205142
lands.
Daniel Bates
Comment 13
2019-12-14 08:09:16 PST
Comment on
attachment 385645
[details]
Patch and unit test View in context:
https://bugs.webkit.org/attachment.cgi?id=385645&action=review
> Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:631 > + [webView synchronouslyLoadHTMLString:applyAhemStyle(@"<style>body { margin: 0; } iframe { border: none; }</style><meta name='viewport' content='initial-scale=1'><span id='the'>The</span> quick brown fox <span id='jumps'>jumps</span> over the lazy <span id='dog'>dog.</span>")];
Remove the <style> as applyAhemStyle() adds it for us.
Daniel Bates
Comment 14
2019-12-16 10:20:41 PST
Created
attachment 385779
[details]
Patch and unit test
Wenson Hsieh
Comment 15
2019-12-16 14:05:22 PST
Comment on
attachment 385779
[details]
Patch and unit test View in context:
https://bugs.webkit.org/attachment.cgi?id=385779&action=review
> Source/WebCore/ChangeLog:16 > + or backwards, respectively.
I think it would help to clarify what causes the last (third) scenario here — i.e. the last of the 3 return statements in nextParagraphBoundaryInDirection.
Daniel Bates
Comment 16
2019-12-16 14:10:30 PST
Comment on
attachment 385779
[details]
Patch and unit test View in context:
https://bugs.webkit.org/attachment.cgi?id=385779&action=review
> Tools/TestWebKitAPI/Tests/WebKitCocoa/DocumentEditingContext.mm:628 > +TEST(WebKit, DocumentEditingContextRequestLastTwoParagraphsWithCaretNotInParagraph)
No caret in this test. Will rename to DocumentEditingContextRequestLastTwoParagraphsWithSelectiontNotInAParagraph
Daniel Bates
Comment 17
2019-12-16 14:28:08 PST
(In reply to Wenson Hsieh from
comment #15
)
> Comment on
attachment 385779
[details]
> Patch and unit test > > View in context: >
https://bugs.webkit.org/attachment.cgi?id=385779&action=review
> > > Source/WebCore/ChangeLog:16 > > + or backwards, respectively. > > I think it would help to clarify what causes the last (third) scenario here > — i.e. the last of the 3 return statements in > nextParagraphBoundaryInDirection.
Nothing! There are only two cases: at boundary of paragraph and in paragraph. Somehow I wound up with a third case.
Wenson Hsieh
Comment 18
2019-12-16 14:29:25 PST
Comment on
attachment 385779
[details]
Patch and unit test View in context:
https://bugs.webkit.org/attachment.cgi?id=385779&action=review
>>> Source/WebCore/ChangeLog:16 >>> + or backwards, respectively. >> >> I think it would help to clarify what causes the last (third) scenario here — i.e. the last of the 3 return statements in nextParagraphBoundaryInDirection. > > Nothing! There are only two cases: at boundary of paragraph and in paragraph. Somehow I wound up with a third case.
Sounds like we can simplify the logic a bit, then!
Daniel Bates
Comment 19
2019-12-16 14:29:42 PST
Created
attachment 385811
[details]
To land
Daniel Bates
Comment 20
2019-12-16 14:32:15 PST
Comment on
attachment 385811
[details]
To land Clearing flags on attachment: 385811 Committed
r253578
: <
https://trac.webkit.org/changeset/253578
>
Daniel Bates
Comment 21
2019-12-16 14:32:17 PST
All reviewed patches have been landed. Closing bug.
Note
You need to
log in
before you can comment on or make changes to this bug.
Top of Page
Format For Printing
XML
Clone This Bug