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


_______________________________________________
webkit-dev mailing list
webkit-dev@lists.webkit.org
http://lists.webkit.org/mailman/listinfo.cgi/webkit-dev

Reply via email to