RESOLVED FIXED 16049
execCommand('backColor') fails on collapsed selections
https://bugs.webkit.org/show_bug.cgi?id=16049
Summary execCommand('backColor') fails on collapsed selections
Nick Santos
Reported 2007-11-19 07:24:58 PST
Repro Steps: 1) Place the cursor in a contentEditable element. 2) Execute document.execCommand('backColor', false, '#f00') in JavaScript. 3) Type some text. Expected Result: The new text should have a red background. Actual Result: The new text keeps the same background. Notes: 'backColor' works ok when text is actually selected. If we replace 'backColor' with 'foreColor' in step #2, the new text is red as expected. Verified on Safari3/Win and Webkit-Nightly/OSX.
Attachments
Mark Rowe (bdash)
Comment 1 2007-11-19 08:11:45 PST
JSEditor.cpp shows that BackColor and ForeColor have different values for the enabledFn member of their CommandImp: WebCore/editing/JSEditor.cpp: { "BackColor", { execBackColor, enabledAnyRichlyEditableRangeSelection, stateNone, valueBackColor } }, WebCore/editing/JSEditor.cpp: { "ForeColor", { execForeColor, enabledAnySelection, stateNone, valueForeColor } }, BackColor requires a range selection which would cause the command to be disabled for collapsed selections. The fix here may be as simple as changing the enabledFn to enabledAnyRichlyEditableSelection. A quick test suggests that this gives the same behaviour as IE on the test case.
Eric Seidel (no email)
Comment 2 2008-01-10 12:58:33 PST
So it sounds like all this bug needs is some understanding of what a change to enabledAnyRichlyEditableSelection would mean for the rest of the web. :) I guess we solve that with a test case.
Julie Parent
Comment 3 2008-06-19 15:54:40 PDT
+1 on fixing this. We have horrible, horrible hacks in place to get this working in the Google editor. I'd love to get rid of them!
Justin Garcia
Comment 4 2008-06-19 16:11:14 PDT
(In reply to comment #1) > JSEditor.cpp shows that BackColor and ForeColor have different values for the > enabledFn member of their CommandImp: > > WebCore/editing/JSEditor.cpp: { "BackColor", { execBackColor, > enabledAnyRichlyEditableRangeSelection, stateNone, valueBackColor } }, > WebCore/editing/JSEditor.cpp: { "ForeColor", { execForeColor, > enabledAnySelection, stateNone, valueForeColor } }, Yikes that's completely wrong, BackColor should have enabledAnyRichlyEditableRangeSelection, and I don't know why ForeColor has enabledAnySelection, it should be disabled in a plain text region too.
Justin Garcia
Comment 5 2008-06-19 16:12:04 PDT
> BackColor should have enabledAnyRichlyEditableRangeSelection that should read "enabledAnyRichlyEditableSelection".
Justin Garcia
Comment 6 2008-06-19 18:16:35 PDT
Note You need to log in before you can comment on or make changes to this bug.