[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
Tue Feb 2 09:24:58 PST 2010


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





--- Comment #11 from Enrica Casucci <enrica at apple.com>  2010-02-02 09:24:56 PST ---
(In reply to comment #10)
> (In reply to comment #9)
> > 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.
> 
> Right, I thought of several different approaches but all of them turned out to
> be bad because it affects so many other places and causes a lot of problems for
> us. And we definitely don't want to convert back to a document fragment for the
> reason you mentioned.
> 
> > 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>
> 
> This was one of the suggestions I got as well but...
> 
> > I think the main downside to this approach is that you still have the invalid
> > markup in your clipboard.
> 
> This is a quite serious problem as users may use other Web browsers and word
> processors while using WebKit. We probably want more input from other
> reviewers/committers because if we fix this problem by introducing new code on
> the paste side, it might have a profound impact on how we implement other
> editing code later.

I think that trying to address the problem on the paste side is correct.
If you try the same repro steps, but instead of pasting back to the same
editable area you paste into a different one (or you press delete after cut to
wipe out any remaining markup), you'll have a much simpler markup.
All the copy code can do, is capture is the computed style on the selection and
add as much style as needed to fully describe it. It is up to the paste code,
that knows about the style of the destination to perform any optimization, also
because we could be pasting markup that has been placed on the pasteboard by
something other than WebKit.

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