Bug 128998

Summary: Caret cannot leave pasted content once it has been pasted
Product: WebKit Reporter: Myles C. Maxfield <mmaxfield>
Component: New BugsAssignee: Myles C. Maxfield <mmaxfield>
Status: RESOLVED INVALID    
Severity: Normal CC: dino, enrica, jonlee, rniwa, simon.fraser, thorton, webkit-bug-importer
Priority: P2 Keywords: InRadar
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch none

Description Myles C. Maxfield 2014-02-18 14:16:27 PST
Cursor cannot leave pasted content once it has been pasted
Comment 1 Myles C. Maxfield 2014-02-18 14:19:53 PST
Created attachment 224546 [details]
Patch
Comment 2 Ryosuke Niwa 2014-02-18 14:23:42 PST
Comment on attachment 224546 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=224546&action=review

> Source/WebCore/ChangeLog:11
> +        When copying in the shouldConvertPositionStyleOnCopy mode, insert a Zero Width Space
> +        before and after the copied selection. This allows the cursor to leave the pasted content.
> +
> +        No new tests, but existing tests are updated.

I don't think this makes sense.

We should modify InsertLineBreakCommand and/or InsertParagraphSeparator to break out of the pasted content instead.
Comment 3 Radar WebKit Bug Importer 2014-02-19 12:16:13 PST
<rdar://problem/16112583>
Comment 4 Myles C. Maxfield 2014-02-19 16:31:21 PST
Created attachment 224690 [details]
Patch
Comment 5 Ryosuke Niwa 2014-02-19 16:48:11 PST
Comment on attachment 224690 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=224690&action=review

> Source/WebCore/editing/CompositeEditCommand.cpp:1405
> +    if (!document().settings() || !document().settings()->shouldConvertPositionStyleOnCopy())
> +        return false;
> +

I don't think we want to restrict this behavior to just this case mode.
It'll be also fragile because then we won't be testing this code path as much.

> Source/WebCore/editing/CompositeEditCommand.cpp:1408
> +        

Nit: whitespace.

> Source/WebCore/editing/CompositeEditCommand.cpp:1409
> +    VisiblePosition caret(endingSelection().visibleStart());

Nit: Use = instead of copy constructor syntax.

> Source/WebCore/editing/CompositeEditCommand.cpp:1412
> +    Node* body = highestEnclosingNodeOfType(caret.deepEquivalent(), &isBody);
> +    if (!body)
> +        return false;

We should look for the root editable element instead as we talked about the other day.

> Source/WebCore/editing/CompositeEditCommand.cpp:1414
> +    RefPtr<Node> br = createBreakElement(document());

Use createDefaultParagraphElement instead.

> Source/WebCore/editing/CompositeEditCommand.cpp:1420
> +    VisiblePosition previous(caret.previous(CannotCrossEditingBoundary));
> +    if (previous == VisiblePosition()) {
> +        insertNodeBefore(br, body->firstChild());
> +        return true;
> +    }

A better condition to check would be misleadingly named isStartOfDocument and isEndOfDocument.
Comment 6 Ryosuke Niwa 2014-02-19 16:48:12 PST
Comment on attachment 224690 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=224690&action=review

> Source/WebCore/editing/CompositeEditCommand.cpp:1405
> +    if (!document().settings() || !document().settings()->shouldConvertPositionStyleOnCopy())
> +        return false;
> +

I don't think we want to restrict this behavior to just this case mode.
It'll be also fragile because then we won't be testing this code path as much.

> Source/WebCore/editing/CompositeEditCommand.cpp:1408
> +        

Nit: whitespace.

> Source/WebCore/editing/CompositeEditCommand.cpp:1409
> +    VisiblePosition caret(endingSelection().visibleStart());

Nit: Use = instead of copy constructor syntax.

> Source/WebCore/editing/CompositeEditCommand.cpp:1412
> +    Node* body = highestEnclosingNodeOfType(caret.deepEquivalent(), &isBody);
> +    if (!body)
> +        return false;

We should look for the root editable element instead as we talked about the other day.

> Source/WebCore/editing/CompositeEditCommand.cpp:1414
> +    RefPtr<Node> br = createBreakElement(document());

Use createDefaultParagraphElement instead.

> Source/WebCore/editing/CompositeEditCommand.cpp:1420
> +    VisiblePosition previous(caret.previous(CannotCrossEditingBoundary));
> +    if (previous == VisiblePosition()) {
> +        insertNodeBefore(br, body->firstChild());
> +        return true;
> +    }

A better condition to check would be misleadingly named isStartOfDocument and isEndOfDocument.
Comment 7 Myles C. Maxfield 2014-02-19 17:33:52 PST
Comment on attachment 224690 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=224690&action=review

> Source/WebCore/editing/CompositeEditCommand.cpp:1401
> +bool CompositeEditCommand::breakOutOfInitialOrFinalStyle()

I should move this out of the parent class and into the base class
Comment 8 Myles C. Maxfield 2014-02-21 12:09:10 PST
This has been fixed a different way.