WebCore:
authorjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2007 21:32:12 +0000 (21:32 +0000)
committerjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Dec 2007 21:32:12 +0000 (21:32 +0000)
commitdea6751b73561a73792e03f73d78b439f441e879
tree4edc6e587741fad1e4708f86c4903f0ade31d69b
parente56dbf45d8446b2488b68e99055f7214e0afca98
WebCore:

        Reviewed by Darin Adler.

        <rdar://problem/5601583> GMail Editor: Copied link doesn't paste as a link, just colored text

        The code that checks the selected Range to see if it's inside an anchor
        checks ancestors of the Range's commonAncestor() but not the
        commonAncestor() itself, and so we'd fail to add markup for the enclosing
        anchor to the pasteboard.

        Some enclosing element getters check the node passed to the getter and some
        don't.  There were a few places where we incorrectly assumed that enclosing
        element getters check the node passed to the getter, but this is the only
        case that I'm able to write a test case for at the moment.

        In this patch I've:
        Changed enclosingNodeWithType and enclosingNodeWithTag to take in positions,
        like the newer enclosing element getters.  This is important because we must
        soon add code to the getters so that they understand that some editing positions
        inside nodes don't actually refer to positions inside those nodes but positions
        before and after them.  Like [table, 0].
        Changed enclosingNodeWithType and enclosingNodeWithTag to check nodes starting with
        n where [n, o] is the position passed to the getter, instead of starting the the parent
        of n.  This makes all but a few of the enclosing element getters behave consistently.
        Changed enclosingNodeWithType and enclosingNodeWithTag to not return non-editable
        nodes if the input position was editable.  This fixes a bug that that the above change
        exposed.
        Changed enclosingTableCell to simply call enclosingNodeWithType.  We should do
        this for the rest of the getters, or simply remove them in favor of enclosingNodeWithType
        unless doing so would affect readability, like it would in the case of enclosingTableCell.
        Ditto for enclosingBlock.

        * editing/AppendNodeCommand.cpp:
        (WebCore::AppendNodeCommand::doApply):
        * editing/DeleteButtonController.cpp:
        (WebCore::enclosingDeletableElement):
        * editing/DeleteSelectionCommand.cpp:
        (WebCore::DeleteSelectionCommand::initializePositionData):
        (WebCore::DeleteSelectionCommand::saveFullySelectedAnchor):
        * editing/Editor.cpp:
        (WebCore::Editor::selectionUnorderedListState):
        (WebCore::Editor::selectionOrderedListState):
        * editing/IndentOutdentCommand.cpp:
        (WebCore::IndentOutdentCommand::prepareBlockquoteLevelForInsertion):
        (WebCore::IndentOutdentCommand::outdentParagraph):
        * editing/InsertNodeBeforeCommand.cpp:
        (WebCore::InsertNodeBeforeCommand::doApply):
        * editing/InsertParagraphSeparatorCommand.cpp:
        (WebCore::InsertParagraphSeparatorCommand::doApply):
        * editing/ReplaceSelectionCommand.cpp:
        (WebCore::ReplaceSelectionCommand::shouldMerge):
        (WebCore::ReplaceSelectionCommand::removeUnrenderedTextNodesAtEnds):
        (WebCore::ReplaceSelectionCommand::positionAtEndOfInsertedContent):
        * editing/TextIterator.cpp:
        * editing/htmlediting.cpp:
        (WebCore::enclosingBlock):
        (WebCore::enclosingNodeWithTag):
        (WebCore::enclosingNodeOfType):
        (WebCore::enclosingTableCell):
        (WebCore::isTableCell):
        * editing/htmlediting.h:
        * editing/markup.cpp:
        (WebCore::appendStartMarkup):
        (WebCore::createMarkup):

LayoutTests:

        Reviewed by Darin Adler.

        <rdar://problem/5601583> GMail Editor: Copied link doesn't paste as a link, just colored text

        * editing/pasteboard/5601583-1.html: Added.
        * platform/mac/editing/pasteboard/5601583-1-expected.checksum: Added.
        * platform/mac/editing/pasteboard/5601583-1-expected.png: Added.
        * platform/mac/editing/pasteboard/5601583-1-expected.txt: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@28694 268f45cc-cd09-0410-ab3c-d52691b4dbfc
18 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/pasteboard/5601583-1.html [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/5601583-1-expected.checksum [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/5601583-1-expected.png [new file with mode: 0644]
LayoutTests/platform/mac/editing/pasteboard/5601583-1-expected.txt [new file with mode: 0644]
WebCore/ChangeLog
WebCore/editing/AppendNodeCommand.cpp
WebCore/editing/DeleteButtonController.cpp
WebCore/editing/DeleteSelectionCommand.cpp
WebCore/editing/Editor.cpp
WebCore/editing/IndentOutdentCommand.cpp
WebCore/editing/InsertNodeBeforeCommand.cpp
WebCore/editing/InsertParagraphSeparatorCommand.cpp
WebCore/editing/ReplaceSelectionCommand.cpp
WebCore/editing/TextIterator.cpp
WebCore/editing/htmlediting.cpp
WebCore/editing/htmlediting.h
WebCore/editing/markup.cpp