Bug 23486

Summary: WebKit execCommand bold/italic should remove strong/em tags (since IE inserts them)
Product: WebKit Reporter: Eric Seidel (no email) <eric>
Component: HTML EditingAssignee: Eric Seidel (no email) <eric>
Status: RESOLVED FIXED    
Severity: Normal CC: jparent, justin.garcia, ojan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
Remove <strong>/<em> when toggling bold/italic to match IE (not FF) darin: review+

Description Eric Seidel (no email) 2009-01-22 16:58:31 PST
WebKit execCommand bold/italic should remove strong/em tags (since IE inserts them)

Our current behavior can be seen here:
http://trac.webkit.org/browser/trunk/LayoutTests/editing/execCommand/toggle-styles-expected.txt?rev=40139

FAIL italic removing em -- <em><span class="Apple-style-span" style="font-style: normal;">test</span></em>

The problem is that IE inserts <em> for the "italic" execCommand and <strong> for the "bold" command.  So we should remove them if we want to interoperate nicely.

FF3 does not remove either of these tags.  Ojan has strongly recommended that we diverge from FF here and remove the tags just like we currently remove <b> and <i>.
Comment 1 Eric Seidel (no email) 2009-01-22 17:34:49 PST
Created attachment 26948 [details]
Remove <strong>/<em> when toggling bold/italic to match IE (not FF)

 LayoutTests/ChangeLog                              |    9 +++++++++
 .../editing/execCommand/toggle-styles-expected.txt |    4 ++--
 WebCore/ChangeLog                                  |   12 ++++++++++++
 WebCore/editing/ApplyStyleCommand.cpp              |    6 ++++--
 4 files changed, 27 insertions(+), 4 deletions(-)
Comment 2 Oliver Hunt 2009-01-22 17:48:41 PST
Why do we want to diverge from ffx? "<insert name here> recommends" is not valid justification
Comment 3 Eric Seidel (no email) 2009-01-22 18:02:01 PST
Actually, I didn't give the right information.  FF's current behavior is clearly wrong IMO.   So we're not really diverging.  We're diverging from our old behavior, which if you're a semantic web lover, is possibly more "correct" than this new behavior... but less useful, and less IE-compatible.

<strong>foo</strong>
document.execCommand("bold")

produces:

WebKit trunk:
<strong><span class="Apple-style-span" style="font-weight: normal;">test</span></strong>

IE:
test

FF
<strong>test</strong> // clearly wrong IMO

after patch:
test
Comment 4 Darin Adler 2009-01-23 17:54:14 PST
Comment on attachment 26948 [details]
Remove <strong>/<em> when toggling bold/italic to match IE (not FF)

Seems OK. r=me
Comment 5 Eric Seidel (no email) 2009-02-04 11:44:51 PST
Landed.