WebKit Bugzilla
New
Browse
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
RESOLVED FIXED
Bug 52512
REGRESSION (
r73818
): range.cloneContents() ignores end offset
https://bugs.webkit.org/show_bug.cgi?id=52512
Summary
REGRESSION (r73818): range.cloneContents() ignores end offset
David Kilzer (:ddkilzer)
Reported
2011-01-15 11:27:42 PST
Created
attachment 79068
[details]
Patch Reviewed by NOBODY (OOPS!). WebCore: The fix for
Bug 50710
in
r73799
introduced an off-by-one error when copying nodes to a local NodeVector for processing. A fix was attempted for
Bug 50854
in
r73818
, but instead of stopping at the end offset, it iterates through all the sibling nodes because the loop variable (i) is never incremented. To clean this up, revert back to the code in
r73799
and fix the off-by-one error. Test: fast/dom/Range/range-clone-contents.html * dom/Range.cpp: (WebCore::Range::processContents): Fix the loop that copies nodes to a local NodeVector by restoring the code from
r73799
and fixing the off-by-one error. LayoutTests: * fast/dom/Range/range-clone-contents-expected.txt: Added. * fast/dom/Range/range-clone-contents.html: Added. --- 5 files changed, 124 insertions(+), 6 deletions(-)
Attachments
Patch
(5.60 KB, patch)
2011-01-15 11:27 PST
,
David Kilzer (:ddkilzer)
adele
: review+
Details
Formatted Diff
Diff
View All
Add attachment
proposed patch, testcase, etc.
David Kilzer (:ddkilzer)
Comment 1
2011-01-15 11:35:04 PST
Note to reviewers: Please verify the new algorithm matches the behavior of the original code. I've gone through the new algorithm, but this code has had bugs introduced through two rewrites and two reviews, so please study it carefully before giving an r+. This is the pre-
r73799
code in processContents() in WebCore/dom/Range.cpp: Node* n = m_end.container()->firstChild(); if (n && m_end.offset()) { for (int i = 0; i + 1 < m_end.offset(); i++) { // skip to end.offset() Node* next = n->nextSibling(); if (!next) break; n = next; } Node* prev; for (; n; n = prev) { prev = n->previousSibling(); [...] } [...] } The fix is this code: Node* n = m_end.container()->firstChild(); if (n && m_end.offset()) { NodeVector nodes; for (int i = 0; i < m_end.offset() && n; i++, n = n->nextSibling()) nodes.append(n); for (int i = nodes.size() - 1; i >= 0; i--) { n = nodes[i].get(); [...] } [...] }
David Kilzer (:ddkilzer)
Comment 2
2011-01-15 11:42:50 PST
<
rdar://problem/8789045
>
Adele Peterson
Comment 3
2011-01-15 12:40:32 PST
Comment on
attachment 79068
[details]
Patch I'm not sure I understand the intermediate change before this very well, but this code looks right. You're still going to always append at least the end container's first child, since m_end.offset() won't be 0 in the inner loop. The new test looks good too, and Dave says this also passes the other editing tests, including the one that was failing for one of the earlier patches. r=me!
David Kilzer (:ddkilzer)
Comment 4
2011-01-15 12:45:09 PST
Committed
r75882
: <
http://trac.webkit.org/changeset/75882
>
Jessie Berlin
Comment 5
2011-01-15 14:24:01 PST
(In reply to
comment #4
)
> Committed
r75882
: <
http://trac.webkit.org/changeset/75882
>
fast/dom/Range/range-clone-contents.html appears to be failing on the Windows 7 Release Test bots:
http://build.webkit.org/results/Windows%207%20Release%20(Tests)/r75882%20(8257)/fast/dom/Range/range-clone-contents-pretty-diff.html
David Kilzer (:ddkilzer)
Comment 6
2011-01-15 17:19:07 PST
(In reply to
comment #5
)
> (In reply to
comment #4
) > > Committed
r75882
: <
http://trac.webkit.org/changeset/75882
> > > fast/dom/Range/range-clone-contents.html appears to be failing on the Windows 7 Release Test bots: > >
http://build.webkit.org/results/Windows%207%20Release%20(Tests)/r75882%20(8257)/fast/dom/Range/range-clone-contents-pretty-diff.html
This is the exact erroneous behavior that the test is trying to fix (where the <img> tag is left in the range instead of being removed). It's as if Range.cpp wasn't compiled on the Windows 7 bot.
David Kilzer (:ddkilzer)
Comment 7
2011-01-15 17:41:20 PST
(In reply to
comment #5
)
> (In reply to
comment #4
) > > Committed
r75882
: <
http://trac.webkit.org/changeset/75882
> > > fast/dom/Range/range-clone-contents.html appears to be failing on the Windows 7 Release Test bots: > >
http://build.webkit.org/results/Windows%207%20Release%20(Tests)/r75882%20(8257)/fast/dom/Range/range-clone-contents-pretty-diff.html
Same issue on the Windows XP box:
http://build.webkit.org/results/Windows%20XP%20Debug%20(Tests)/r75882%20(24216)/fast/dom/Range/range-clone-contents-pretty-diff.html
Oddly enough, I don't see any other bots failing on this test.
David Kilzer (:ddkilzer)
Comment 8
2011-01-15 18:16:31 PST
(In reply to
comment #7
)
> (In reply to
comment #5
) > > (In reply to
comment #4
) > > > Committed
r75882
: <
http://trac.webkit.org/changeset/75882
> > > > > fast/dom/Range/range-clone-contents.html appears to be failing on the Windows 7 Release Test bots: > > [...] > Same issue on the Windows XP box: > [...] > Oddly enough, I don't see any other bots failing on this test.
Filed
Bug 52524
to cover this. Added the test to the Windows skip list: Committed
r75889
. <
http://trac.webkit.org/changeset/75889
>
David Kilzer (:ddkilzer)
Comment 9
2011-01-17 16:51:08 PST
(In reply to
comment #8
)
> Filed
Bug 52524
to cover this. Added the test to the Windows skip list: > > Committed
r75889
. <
http://trac.webkit.org/changeset/75889
>
Turns out the buildbots just needed to do a clean build. Removed the test from the skip list: Committed
r75970
: <
http://trac.webkit.org/changeset/75970
>
Ryosuke Niwa
Comment 10
2011-02-21 02:20:50 PST
***
Bug 54861
has been marked as a duplicate of this 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