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

Ryosuke Niwa rniwa at webkit.org
Mon Jul 26 11:46:38 PDT 2010


Thanks a lot for the feedback!

On Sun, Jul 25, 2010 at 5:07 PM, Maciej Stachowiak <mjs at apple.com> wrote:
>
> 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.
>

I agree, it's crucial that we carefully decide on what to preserve and what
to not.

But MSDN explicitly say "character formatting" and bugs such as
Bug 13125 <https://bugs.webkit.org/show_bug.cgi?id=13125> - removeformat
execCommand loses input elements
Bug 20216 <https://bugs.webkit.org/show_bug.cgi?id=20216> - execCommand
RemoveFormat removes links
indicates that there is a demand to correct WebKit's behavior.

Here are some tricky questions:
>
> - Does font-weight: bold count as "formatting"?
>

It should.


> - Does the <b> element's default bold style count as "formatting"?
>

It should but this is tricky thing to remove because
if irreversible formatting such as text-decoration comes outside of editable
region, then we can't push down.  We currently leave it alone in
ApplyStyleCommand (see the bug
27809<https://bugs.webkit.org/show_bug.cgi?id=27809>
).

- Does the <b> element itself count as "formatting"?
>

It should unless it has attributes to preserve such as id or class in which
case we should be converting to a span.


> - Does display: block count as "formatting"?
>

I don't think this is "character formatting".


> - Does the <p> element's display: block style count as "formatting"?
> - Does the <p> element itself count as formatting?
>

No since they are not "character 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.
>

I don't think reverting back to the default style is a correct thing to do.

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 CSS table / list should be preserved because they aren't really
"character formatting".

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

I agree.  We should test and see what other browsers do in various cases.

But since it's impossible for us to enumerate every possible formatting, I
propose to just remove text-decoration, font-weight, etc... and the
corresponding presentational elements probably using ApplyStyleCommand as a
starting point.  We can then file a separate bug or so to uncover edge cases
and polish the behavior.

Best,
Ryosuke
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.webkit.org/pipermail/webkit-dev/attachments/20100726/cbe5430f/attachment.html>


More information about the webkit-dev mailing list