[webkit-dev] [HTML Editing] WebKit's implementation of removeFormat is completely different from other UAs.

Maciej Stachowiak mjs at apple.com
Sun Jul 25 17:07:17 PDT 2010


On Jul 25, 2010, at 1:03 AM, Ryosuke Niwa wrote:

> Are there Apple or third-party products that heavily rely on the current implementation of RemoveFormatCommand?
> If not, I want to completely re-implement RemoveFormat to match the behavior of other browsers.
> 
> In MSDN, RemoveFormat is described as:
> Removes the font and character formatting from the current selection.
> The following code removes all formatting from the selected text.
> 
> ActiveDocument.execCommand "removeformat
> 
> In MDC, it's described as:
> Removes all formatting from the current selection.
> 
> However, our current implementation deletes all selected contents and type them back in,
> losing all sorts of elements such as input, img, hyper links, tables, lists, and etc...
> 
> There are two options to resolve this problem:
> Store all elements deleted and their positions and insert (restore) them back.
> Remove format more gracefully by walking through the DOM and removing stylesheets and presentational elements.
> I want to re-implement RemoveFormat because I don't think option 1 really is an option.

I think the key question here is what counts as as "formatting". That needs to be determined empirically by testing other browsers, not just by reading their docs.

Here are some tricky questions:

- Does font-weight: bold count as "formatting"?
- Does the <b> element's default bold style count as "formatting"?
- Does the <b> element itself count as "formatting"?
- Does display: block count as "formatting"?
- Does the <p> element's display: block style count as "formatting"?
- Does the <p> element itself count as formatting?

You could make a rule that only non-default styles count as "formatting", but it would seem weird if "RemoveFormat" allowed the selection to retain bold or italic text, so I wonder if other browsers actually do that.

You could ask similar questions about tables and lists. In particular, do we preserve table and list elements with their default styles, but CSS table or list layout properties are not allowed?

I think with information based on testing other browsers, and test cases demonstrating this behavior, we could make a more informed decision.

Regards,
Maciej


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100725/bd9a2a92/attachment.html>


More information about the webkit-dev mailing list