Bug 26443 - [:first-letter][createlink][contenteditable] Safari creates a link on wrong characters with document.execCommand("createlink", false, "somelink") if the contenteditable element has a :first-letter rule applied to it.
Summary: [:first-letter][createlink][contenteditable] Safari creates a link on wrong c...
Status: RESOLVED CONFIGURATION CHANGED
Alias: None
Product: WebKit
Classification: Unclassified
Component: HTML Editing (show other bugs)
Version: 528+ (Nightly build)
Hardware: Mac (Intel) OS X 10.5
: P1 Normal
Assignee: Nobody
URL:
Keywords:
Depends on: 6185
Blocks: 58911
  Show dependency treegraph
 
Reported: 2009-06-16 06:57 PDT by Dan POPA
Modified: 2022-06-23 22:08 PDT (History)
6 users (show)

See Also:


Attachments
Testcase showing described behavior (1.38 KB, text/html)
2009-06-16 06:59 PDT, Dan POPA
no flags Details

Note You need to log in before you can comment on or make changes to this bug.
Description Dan POPA 2009-06-16 06:57:55 PDT
Safari crashes on document.execCommand("createlink", false, "somelink") if the contenteditable element has a :first-letter rule applied to it.

Steps to reproduce:
1. have the following in a page:
<style>
.someclass:first-letter {
	font-weight: bold;
}
</style>
<div class="someclass" contenteditable="true">contentEditable element. Some text and some words.</div>

<input type="button" value="Create link" onclick="document.execCommand('createlink', false, 'http://www.google.com')" />

2. Select something from the contenteditable DIV.
3. Click the button.

Result: Safari crashes after a few seconds.


A few details, notes on this behavior:

Note 1: Can't select the first character/letter, see bug #6185

Note 2: Safari doesn't crash if the selection is inside the first word and it starts before or after the second character in the first word. The selection is shifted one character to the left.
The contenteditable element cannot be focused anymore after createlink if the selection started before the second character, only the link can be focused in this case.

See attachment for testcase.
Comment 1 Dan POPA 2009-06-16 06:59:43 PDT
Created attachment 31348 [details]
Testcase showing described behavior
Comment 2 Dan POPA 2009-06-16 07:01:22 PDT
Possible related bugs:

bug #22256	Reproduceable crash with @font-face and :first-letter pseudo class
bug #15602	Quirksmode: CSS1: WebKit fails dynamic :first-letter test
bug #14550	Non-layout style change does not update nested first-letter
bug #6185	Bug 6185: CSS1: character styled with :first-letter is not selectable
Comment 3 Dan POPA 2009-06-16 07:08:35 PDT
No crash in Safari 3.2.3

But the selection is shifted one character to the left and clicking after the newly created link doesn't set the selection at the click location (same as in the second note from the bug description)
Comment 4 thaddee6yann 2009-12-28 02:32:11 PST
Possibly related issues:

* any text insertion is shifted by a seemingly arbitrary number of characters, usually 1.
* a character entered at the end duplicates the line and sometimes deletes a number of characters at the end of the line.

Note: this is only true on the first line.
Comment 5 Kent Tamura 2010-08-09 01:51:48 PDT
I took a look at the code, and my conclusion is we should close Bug#6185 before this.
("close" means to fix it or to decide we won't fix it.)
Comment 6 Ahmad Saleem 2022-06-23 15:58:21 PDT
Based on attached test and following steps from Description, I am not able to crash Safari 15.5 on macOS 12.4. This was fixed long back as commented in Comment 03.

Although - first letter non-selection bug is still present on attached test case (for which we have separate bug - https://bugs.webkit.org/show_bug.cgi?id=6185). Although, Comment 05 mentions that this bug should remain open till some conclusion is reached for the bug).

IMO - We can close this since it is not crashing and leave 6185 open for fixing since now all other browsers have fixed it and first letter is selectable. Thanks!
Comment 7 Ryosuke Niwa 2022-06-23 22:08:22 PDT
Safari doesn't hit any crash anymore.