Open Bug 1246519 Opened 5 years ago Updated 2 years ago

document.queryCommandValue doesn't reflect the change after executing backColor [contenteditable, execCommand]

Categories

(Core :: DOM: Editor, defect)

47 Branch
defect
Not set
normal

Tracking

()

UNCONFIRMED

People

(Reporter: cyril.auburtin, Unassigned)

Details

(Whiteboard: dom-triaged)

Attachments

(1 file)

User Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:47.0) Gecko/20100101 Firefox/47.0
Build ID: 20160205030204

Steps to reproduce:

demo: http://jsfiddle.net/crl/mL5y8ehw/
after executing backColor,
in console, we see no changes in document.queryCommandValue('backColor');

I guess maybe it's because the selection is oustide the span |<span style="">...</span>|


(similar issue https://bugzilla.mozilla.org/show_bug.cgi?id=1183844)


Actual results:

no changes in commandValue('backColor')


Expected results:

it should be updated (it works for foreColor)

(attached screen capture, on the left Chrome, on the right FF)
Component: Untriaged → Editor
Product: Firefox → Core
After applying the 'backColor' command, the selected range is updated to start from the end of the text node just before the colored span and end at the end of the text node that is in the colored span. The code that queries the background color [1] checks the color at the start of the selected range which is not inside the span and thus does not return the color you are expecting.

A possible fix could be to update the selected range to be entirely within the inline style when an exec command applies an inline style. Another simpler fix could to be check the color at the end of the selected range. 

[1] https://dxr.mozilla.org/mozilla-central/rev/584870f1cbc5d060a57e147ce249f736956e2b62/editor/libeditor/nsHTMLEditor.cpp#1767
Whiteboard: dom-triaged

No, the real bug is that neither backColor nor hiliteColor return correct value in FF:
https://bugzilla.mozilla.org/show_bug.cgi?id=547848

You need to log in before you can comment on or make changes to this bug.