WebCore:
authorjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 00:04:01 +0000 (00:04 +0000)
committerjusting <justing@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 13 Sep 2007 00:04:01 +0000 (00:04 +0000)
commit3054d07dfe1cbf646f0a503252abf382e6d241ce
treec5b019bb6b7b371de5c84807467d0de603135cf9
parent1ab6f1f2815e4160809930f15ba68d73c8d06718
WebCore:

        Reviewed by Tristan.

        <rdar://problem/5469868>
        GoogleDocs: A hang occurs when applying list styling to a selection in a <table>

        When list insertion moves selected paragraphs into list items, it relies on
        the selection preservation code inside moveParagraphs to iterate over the
        selected paragraphs.  If a selection is ever restored incorrectly (before
        the original, or inside the original) list insertion will go into an infinite loop.

        In this hang, a table was selected and the selection preservation code incorrectly
        restored a selection, placing it inside the table.

        The bug was that a TextIterator, when being used for selection preservation, must
        emit a character between every VisiblePosition in the Range used to create the
        iterator.

        * editing/TextIterator.cpp:
        (WebCore::TextIterator::TextIterator): Renamed the boolean that we use for
        selection preservation.  It used to be m_emitForReplacedElements because
        we believed that replaced elements were the only case where TextIterators
        should have emitted differently when used for selection preservation.
        (WebCore::TextIterator::handleReplacedElement): Ditto.
        (WebCore::TextIterator::shouldRepresentNodeOffsetZero): Represent the
        position before block tables, but only if we are emitting for selection
        preservation.
        (WebCore::TextIterator::shouldEmitSpaceBeforeAndAfterNode): We should emit
        a space before and after block tables if we are emitting for selection
        preservation (because we have VisiblePositions before and after them).
        (WebCore::TextIterator::handleNonTextNode): Use a renamed variable.
        * editing/TextIterator.h: Made shouldEmitSpaceBeforeAndAfterNode a member
        function, because whether or not we emit spaces before and after a block
        table depends we're emitting for selection preservation.

LayoutTests:

        Reviewed by Tristan.

        Demonstrates bug:
        * editing/execCommand/5469868-expected.txt: Added.
        * editing/execCommand/5469868.html: Added.

        Fixed (and moved expected results to platform/mac):
        * editing/style/table-selection-expected.checksum: Removed.
        * editing/style/table-selection-expected.png: Removed.
        * editing/style/table-selection-expected.txt: Removed.
        * platform/mac/editing/style: Added.
        * platform/mac/editing/style/table-selection-expected.checksum: Added.
        * platform/mac/editing/style/table-selection-expected.png: Added.
        * platform/mac/editing/style/table-selection-expected.txt: Added.

        Fixed:
        * platform/mac/editing/execCommand/5432254-2-expected.checksum:
        * platform/mac/editing/execCommand/5432254-2-expected.png:
        * platform/mac/editing/execCommand/5432254-2-expected.txt:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@25522 268f45cc-cd09-0410-ab3c-d52691b4dbfc
12 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/5469868-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/5469868.html [new file with mode: 0644]
LayoutTests/platform/mac/editing/execCommand/5432254-2-expected.checksum
LayoutTests/platform/mac/editing/execCommand/5432254-2-expected.png
LayoutTests/platform/mac/editing/execCommand/5432254-2-expected.txt
LayoutTests/platform/mac/editing/style/table-selection-expected.checksum [moved from LayoutTests/editing/style/table-selection-expected.checksum with 100% similarity]
LayoutTests/platform/mac/editing/style/table-selection-expected.png [moved from LayoutTests/editing/style/table-selection-expected.png with 100% similarity]
LayoutTests/platform/mac/editing/style/table-selection-expected.txt [moved from LayoutTests/editing/style/table-selection-expected.txt with 71% similarity]
WebCore/ChangeLog
WebCore/editing/TextIterator.cpp
WebCore/editing/TextIterator.h