Bug 19644

Summary: Text copied with Select All pastes with a indent but shouldn't
Product: WebKit Reporter: Justin Garcia <justin.garcia>
Component: HTML EditingAssignee: Justin Garcia <justin.garcia>
Status: RESOLVED FIXED    
Severity: Normal CC: eric
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Mac   
OS: OS X 10.5   
Attachments:
Description Flags
patch darin: review+

Description Justin Garcia 2008-06-17 17:09:28 PDT
Open FCKEditor http://www.fckeditor.net/demo (this also happens in a few others)
Select all of the default content
Delete
Paste

Content pastes indented slightly.  It shouldn't.  Also, press return and paste again.  You'll see that the content is indented even more.

<rdar://problem/5581805> Text copied with Select All pastes with a indent but shouldn't
Comment 1 Justin Garcia 2009-04-20 23:20:10 PDT
Created attachment 29641 [details]
patch
Comment 2 Darin Adler 2009-04-21 07:53:58 PDT
Comment on attachment 29641 [details]
patch

Ideally I'd also like to see a check if the destination already has the properties in question. For example, the same background color or same image.

> +        if (fullySelectedRootStyle->getPropertyCSSValue(CSSPropertyBackgroundImage) ||
> +            fullySelectedRootStyle->getPropertyCSSValue(CSSPropertyBackgroundColor) ||
> +            static_cast<Element*>(fullySelectedRoot)->hasAttribute(backgroundAttr))

I find this if statement really difficult to read. I would prefer that you put it in a separate function or format it differently.

I don't understand why the cast to Element* here is safe. What guarantees that fullySelectedRoot is an Element, not another kind of Node?

Given that we're mutating the DOM here, maybe fullySelectedRoot should be a RefPtr<Node>, not just a Node*.

r=me
Comment 3 Justin Garcia 2009-04-21 11:13:01 PDT
> I don't understand why the cast to Element* here is safe. What guarantees that
> fullySelectedRoot is an Element, not another kind of Node?

Currently it must be the body element, but since that's non obvious maybe I'll add a check.

> Given that we're mutating the DOM here, maybe fullySelectedRoot should be a
> RefPtr<Node>, not just a Node*.

Are we?  Does attribute checking fire listeners that can modify the DOM, or?
Comment 4 Justin Garcia 2009-04-21 12:21:01 PDT
http://trac.webkit.org/changeset/42722