2011-06-29 Justin Garcia <justin.garcia@apple.com>
authorjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jun 2011 00:10:53 +0000 (00:10 +0000)
committerjustin.garcia@apple.com <justin.garcia@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 30 Jun 2011 00:10:53 +0000 (00:10 +0000)
commit27b7c479adaaf9590d91ccefc4ec312d65e6aa6e
tree4cb39f7841cfee990e4809c61ba3baa01ea78e0b
parente25230e7b6b7bf592e45f2399338d70ee82f14f2
2011-06-29  Justin Garcia  <justin.garcia@apple.com>

        Reviewed by Enrica Casucci.

        https://bugs.webkit.org/show_bug.cgi?id=62922
        indexForVisiblePosition(const VisiblePosition& visiblePosition) does not consider shadow content

        VisiblePositions can be inside web form text regions, which use shadow trees. Made indexForVisiblePosition
        aware of this, and added a new parameter to obtain the scope for a VisiblePosition, in addition to its index.

        Added visiblePositionForIndex to go in the opposite direction, taking into account the scope
        used to compute the index.

        These two functions use TextIterators to convert between VisiblePositions and indices. But
        TextIterator iteration using TextIteratorEmitsCharactersBetweenAllVisiblePositions does not
        exactly match VisiblePosition iteration, so using them to preserve a selection during an
        editing operation is unreliable. This can be seen in the expected results for:

        editing/execCommand/indent-pre-list.html
        editing/execCommand/crash-indenting-list-item.html

        TextIterator's TextIteratorEmitsCharactersBetweenAllVisiblePositions mode needs to be fixed, or
        these functions need to be changed to iterate using actual VisiblePositions. See:

        https://bugs.webkit.org/show_bug.cgi?id=63590
        TextIterators in TextIteratorEmitsCharactersBetweenAllVisiblePositions do not exactly match VisiblePositions

        Also:

        https://bugs.webkit.org/show_bug.cgi?id=63592
        Use visiblePositionForIndex and indexForVisiblePosition everywhere that TextIterators are used to convert between VisiblePositions and indices

        No new tests added because indexForVisiblePosition is currently only used for editing operations
        that cannot be performed inside web form fields.

        * editing/ApplyBlockElementCommand.cpp:
        (WebCore::ApplyBlockElementCommand::doApply):
        * editing/InsertListCommand.cpp:
        (WebCore::InsertListCommand::doApply):
        * editing/htmlediting.cpp:
        (WebCore::indexForVisiblePosition):
        (WebCore::visiblePositionForIndex):
        * editing/htmlediting.h:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@90072 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WebCore/ChangeLog
Source/WebCore/editing/ApplyBlockElementCommand.cpp
Source/WebCore/editing/InsertListCommand.cpp
Source/WebCore/editing/VisiblePosition.h
Source/WebCore/editing/htmlediting.cpp
Source/WebCore/editing/htmlediting.h