[Webkit-unassigned] [Bug 26937] Copying and pasting into a contenteditable area can create <div>s surrounded by <span>s

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Feb 1 21:23:45 PST 2010


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





--- Comment #9 from Tony Chang (Google) <tony at chromium.org>  2010-02-01 21:23:42 PST ---
(In reply to comment #5)
> 4. For the re-deign of copy&paste logic, we should push down all relevant
> comptuedStyles to each root node we're copying.  e.g. when we're copying
> <span>foo</span><div>bar</div>, we should apply computedStyles to each span and
> div node, instead of adding extra node to preserve style.  This would prevent
> us from producing extra spans and there will be no need to remove span's/div's
> later.

I looked into this, but it's a bit tricky because the point where generate the
computedStyle is after we've generated the markup as a string.  I guess we
could convert into a document fragment so we could add these styles, but that
seems slow.

We could also handle this on the paste side.  In
ReplaceSelectionCommand::handleStyleSpan, we could take the style span
attributes and move them to the child nodes like you suggest doing during the
copy.  This would result in less styles copied and ideally in the example you'd
get:
<div style="text-decoration: none;"> <div style="font-weight: bold;"><div
>one</div><div style="font-weight: normal>two</div></div>

I think the main downside to this approach is that you still have the invalid
markup in your clipboard.

Ryosuke, what do you think?

-- 
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