Closed Bug 1625970 Opened 4 years ago Closed 4 years ago

Underline action can't be reversed on text that contains inserted links

Categories

(Core :: CSS Parsing and Computation, defect, P3)

76 Branch
defect

Tracking

()

VERIFIED FIXED
mozilla77
Tracking Status
firefox-esr68 --- unaffected
firefox74 --- wontfix
firefox75 --- wontfix
firefox76 --- wontfix
firefox77 --- verified

People

(Reporter: sbadau, Assigned: boris)

References

(Regression, )

Details

(Keywords: regression)

Attachments

(3 files, 2 obsolete files)

Attached image 2020-03-30_17h23_07.gif

Affected versions

  • Firefox 74
  • Firefox 75 beta 10
  • Nightly 76.0a1

Affected platforms

  • Windows 10
  • Mac OS X 10.15
  • Ubuntu 18.04

Steps to reproduce

  1. Open Firefox and log into your Gmail account.
  2. Start writing a new email and insert a link
  3. Select all the text and hit Ctrl+U keys to underline all the text
  4. Select all the text again and press the Ctrl+U keys to cancel the underline of the text

Expected result

  • Underline action can be set and unset.

Actual result

  • Once I underline the entire text, I can't reverse it. I can only reverse the Underline action if I do not include the text section that has the inserted link.

Regression range

Additional notes

  • I reproduced this issue on Gmail and Outlook.
  • This issue is not reproducible on Yahoo.
  • please see the attached screenshot for more details.
Flags: needinfo?(boris.chiou)

I'm trying to figure out what gmail does when hitting Ctrl+U key. It seems it just adds <u></u> tag for the selected text. In Gecko, we cannot remove <u></u> if the selected area includes a link. Not 100% sure what its JS code does for this case, but I guess it may use getCompustedStyle() to check text-decoration property value, and Gecko's serialization is a little bit different from other browsers (see wpt.fyi). Is there any way to look at the script code when hitting Ctrl+U or the underline button on the toolbox?

Flags: needinfo?(boris.chiou)

Could we contact the Gmail folks to see what are they relying on? That would inform whether we should change our behavior or not.

Browser behavior is all over the place but I think our serialization code is correct / the most sensible one.

Flags: needinfo?(miket)

This sort of reminds me of Bug 833889. Ksenia, could you help find the relevant code bits that handle the underline functionality?

(I suspect Ksenia can find it faster than the Gmail team will reply 😃)

Flags: needinfo?(miket) → needinfo?(kberezina)
Attached file 1625970.html

They are using just document.execCommand( 'underline', false, null) . I've attached a reduced test case (to reproduce highlight the text and press "U" button).

As Mike mentioned this is (sort of) similar to https://bugzilla.mozilla.org/show_bug.cgi?id=833889

Both gmail and outlook using RoosterJs editor, so it can be reproduced on their demo site as well https://microsoft.github.io/roosterjs/index.html (looks like it's part of microsoft)

Flags: needinfo?(kberezina)

Thanks Ksenia!

Boris, setting ni? to make sure you see Comment #4.

Flags: needinfo?(boris.chiou)
Priority: -- → P3

I'm still debugging this. Looks like doTagRemoval is always false even when we set <u> already. I am trying to figure out why HTMLEditor::GetInlineProperty doesn't work well for underline case (i.e. u tagName). Thanks for providing the reduced test case. It's really helpful.

Flags: needinfo?(boris.chiou)

(In reply to Boris Chiou [:boris] from comment #6)

I'm still debugging this. Looks like doTagRemoval is always false even when we set <u> already. I am trying to figure out why HTMLEditor::GetInlineProperty doesn't work well for underline case (i.e. u tagName). Thanks for providing the reduced test case. It's really helpful.

And perhaps we have to update the mapping from <u> to its css property.

Ok. I got the root cause: text-decoration also serializes text color value, and we split the selected text into 2 sections: firstValue and theValue. Based on the reduced test case, the firstValue is the normal text without the link, so its computed style is underline rgb(0, 0, 0). The theValue is the text with the link, so its computed style is underline rgb(0, 0, 238). We have a special check which compares firstValue and theValue. If they are different, we make aAll to false, and if aAll is false, we set doTagRemoval to false.

The conclusion is: the color component in text-decoration makes the logical incorrect because we assume its computed value only contains text-decoration-line component. (Note: bug 1574222 changes the serialization of the color component in text-decoration, i.e. it always serializes the text color now, even if it's currentColor.) So I will update the css property we use for underline: replace text-decoration with text-decoration-line, as comment 7 mentioned.

Assignee: nobody → boris.chiou
Status: NEW → ASSIGNED
Attached file Bug 1625970 - Update test cases. (obsolete) —

We use text-decoration-line for underline and strikeThrough, so the
innerHTML would be a little bit different from others.

Spec issue: github.com/w3c/editing/issues/241.

underline and strike use text-decoration property, which is a
shorthand and may include other longhand property values, e.g.
text-decoration-color. In order to set aAll flag correctly, we
should not compaure the computed values between firstValue and
theValue. Using isSet flag should be more accurate.

Attachment #9137876 - Attachment is obsolete: true
Attachment #9137622 - Attachment is obsolete: true
Attachment #9138138 - Attachment description: Bug 1625970 - Compare isSet flags between first value and others instead of computed values. → Bug 1625970 - Compare isSet flags between first value and others for text-decoration related HTML properties.
Pushed by bchiou@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/8bbe879dca0b
Compare isSet flags between first value and others for text-decoration related HTML properties. r=masayuki
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla77

The patch landed in nightly and beta is affected.
:boris, is this bug important enough to require an uplift?
If not please set status_beta to wontfix.

For more information, please visit auto_nag documentation.

Flags: needinfo?(boris.chiou)
Flags: needinfo?(boris.chiou)
Flags: qe-verify+

Verified as fixed using the latest Firefox beta 77 (20200525134724) and latest Nightly 78.0a1 on Windows 10 x64, Ubuntu 18.04 x64 and Mac OS X 10.15.

Status: RESOLVED → VERIFIED
Flags: qe-verify+
Has Regression Range: --- → yes
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: