Opened 11 years ago
Closed 11 years ago
#10812 closed Bug (fixed)
Range#createBookmark2 incorrectly normalizes offsets when element is selected
Reported by: | Piotrek Koszuliński | Owned by: | Piotrek Koszuliński |
---|---|---|---|
Priority: | Normal | Milestone: | CKEditor 4.2.2 |
Component: | General | Version: | 4.2.1 |
Keywords: | Cc: |
Description (last modified by )
Unit test can be found in t/10812.
Manual TCs:
TC1 (IE and sometimes FF)
- Load this HTML:
<h1>Apollo 11<img alt="Saturn V carrying Apollo 11" src="assets/sample.jpg" /></h1>
- Select image and press align right.
- Undo.
- Expected: image is selected after undoing (although selection may differ visually from the old one)
- Actual: selection is lost.
- Depending on the HTML I was sometimes able to reproduce this on FF too, but usually it only works on IE, because it keeps DOM clean.
TC2 (all browsers)
<table border="1" cellpadding="1" cellspacing="1" style="width:500px"> <tbody> <tr> <td>a</td> <td>b</td> </tr> <tr> <td>c</td> <td>d</td> </tr> </tbody> </table>
- Load the above HTML.
- Select table (using elements path).
- Apply bold.
- Try to undo.
- Expected: entire table is selected after undoing.
- Actual: selection is lost.
Change History (19)
comment:1 Changed 11 years ago by
Status: | new → confirmed |
---|
comment:2 Changed 11 years ago by
Description: | modified (diff) |
---|---|
Version: | → 4.2.1 (GitHub - master) |
comment:3 Changed 11 years ago by
Description: | modified (diff) |
---|
comment:4 Changed 11 years ago by
Milestone: | → CKEditor 4.2.2 |
---|
comment:5 Changed 11 years ago by
Summary: | Range#createBookmark2 incorrectly normalize offsets when element is selected → Range#createBookmark2 incorrectly normalizes offsets when element is selected |
---|
comment:6 Changed 11 years ago by
Owner: | set to Olek Nowodziński |
---|---|
Status: | confirmed → review |
Created a simple fix for the issue in t/10812. It makes all tests green and fixes the manual case. Hopefully it won't break anything not covered with tests ;)
comment:7 Changed 11 years ago by
comment:8 Changed 11 years ago by
This line was first introduced in this patch http://dev.ckeditor.com/ticket/1272#comment:37 as a response for http://dev.ckeditor.com/ticket/1272#comment:36. Let's see how much has changed in last 3 years ;>
comment:9 Changed 11 years ago by
Owner: | changed from Olek Nowodziński to Piotrek Koszuliński |
---|---|
Status: | review → assigned |
TC which I mentioned in comment:8 is not reproducible on t/10812 or master.
However, I've got a really mixed feelings about createBookmark2
. I was reading its code and I'm not sure yet, but I think that it misses a lot of cases. Cases which we assume that are not possible for ranges extracted from real selection, but as this ticket proves... life can be surprising.
I also don't think that proposed patch is correct. These lines seem to be required and most likely patch passes automated tests because they are incomplete and manual tests because testing things related to text nodes normalization and selection are really hard and also browser specific.
My idea is that createBookmark2 should assume that everything is possible, because we are not able to anticipate every case possible in real life. It also shouldn't do unnecessary normalization. For example here it's moving container down the tree when it could just normalize offset to the last child's normalized index + 1.
comment:13 Changed 11 years ago by
Status: | assigned → review |
---|
comment:14 follow-up: 15 Changed 11 years ago by
Status: | review → review_failed |
---|
I added several tests, and fixed minor mistakes in code. Still:
- 34 failed/50 passed in IE8 in dt/core/dom/rangebookmarks.html
- Mixed CKEditor API with jQuery in createPlayground. As jQuery may be not available in the future due to some different testing environment, this should not happen.
comment:15 follow-up: 16 Changed 11 years ago by
Status: | review_failed → review |
---|
Replying to a.nowodzinski:
I added several tests, and fixed minor mistakes in code. Still:
- 34 failed/50 passed in IE8 in dt/core/dom/rangebookmarks.html
Fixed it with a funny hack.
- Mixed CKEditor API with jQuery in createPlayground. As jQuery may be not available in the future due to some different testing environment, this should not happen.
Then we'll replace this with something else like we'll have to change many other things. Come on - it's the quickest and cleanest solution.
comment:16 Changed 11 years ago by
Replying to Reinmar:
Replying to a.nowodzinski:
I added several tests, and fixed minor mistakes in code. Still:
- 34 failed/50 passed in IE8 in dt/core/dom/rangebookmarks.html
Fixed it with a funny hack.
- Mixed CKEditor API with jQuery in createPlayground. As jQuery may be not available in the future due to some different testing environment, this should not happen.
Then we'll replace this with something else like we'll have to change many other things. Come on - it's the quickest and cleanest solution.
I can't see anything new in branches.
comment:18 Changed 11 years ago by
Status: | review → review_passed |
---|
comment:19 Changed 11 years ago by
Resolution: | → fixed |
---|---|
Status: | review_passed → closed |
Fixed with git:5f51c3f on dev and 194136f on tests.
Pushed t/10812 with a test.