[Webkit-unassigned] [Bug 81656] Backspace/delete produces combined font/span from existing inline elements

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Fri May 25 04:30:04 PDT 2012


https://bugs.webkit.org/show_bug.cgi?id=81656





--- Comment #9 from Aryeh Gregor <ayg at aryeh.name>  2012-05-25 04:29:08 PST ---
(In reply to comment #5)
> And it's very undesirable to leave spans like this when the user moved the caret elsewhere because the span is going to linger around in the markup and slowly bloats the HTML over time.

I agree if the tags don't have any effect -- e.g., leaving just <b></b> anywhere with no contents is wrong, because it doesn't do anything.  But here, the tags serve a very important purpose: they remember the style that the paragraph had.  In word processors, AFAICT, the style of each line is remembered even if all text on the line is deleted.  Try this test:

1) Type "foo\nbar\nbaz".

2) Select all and make bold.

3) Delete the three letters "bar", so the middle line is empty.

4) Move the cursor someplace else, then move it back to the empty middle line.

5) Type "quz".

In LibreOffice 3.4.4, the word "quz" is bold.  This is as expected: the user made all three lines bold, and all three lines should stay bold even if text is deleted from them.  The tag should only be removed if the line itself is removed.

Think about it from the perspective of a user who doesn't know anything about HTML.  The user made a whole range of text bold, so from then on, anything within that range of text should be bold.  If you type "foobarbaz", delete "bar", and then type "quz" instead, "quz" is bolded.  Why should the linebreaks make any difference?

The only reason there's a difference right now in browsers is because bolding "foobarbaz" produces "<b>foobarbaz</b>", with only one <b> tag.  Bolding "<p>foo<p>bar<p>baz" produces "<p><b>foo</b><p><b>bar</b><p><b>baz</b>", with three <b> tags.  This is an implementation detail that users shouldn't be exposed to.  It should work the same as if we produced "<b><p>foo<p>bar<p>baz</p></b>" -- deleting "bar" should leave that position bold.

> While I do agree that merging span with font is bad, I don't think we should be leaving span behind. The spec needs to change here.

I disagree, for the reasons given.  The spec matches word processors (at least LibreOffice), and I think it matches user expectations.  I don't see why the user would expect it to behave any differently depending on whether "bar" is on its own line or not.  See also <https://www.w3.org/Bugs/Public/show_bug.cgi?id=13831>, where Ehsan seems to agree with me.  If you can convince him, then I'll change the spec to match what the majority of browsers want, but I think the spec is right.

(In reply to comment #6)
> I don't think this is a reasonable expectation because leaving inline elements after deletion can bloat the markup over time.

Using the least markup necessary to achieve expected results is not bloat.  If the expected result is that deleting all text on the line and then later coming back and typing on the line results in bold text, then leaving the tags is necessary.  We should try to use the minimum markup necessary, but no less.

(In reply to comment #8)
> (In reply to comment #7)
> > Common desktop office suites like word etc keep the formatting when you delete the last character in a P tag.
> 
> I don't think this is true at least for bolding.

My test-case above found that LibreOffice does preserve bold when you delete the last character on a line.  I'm almost sure that Word does too.  I'll get back to you when I have a chance to test it.

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list