2011-02-23 Benjamin Kalman <kalman@chromium.org>
authorkalman@chromium.org <kalman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Feb 2011 10:10:13 +0000 (10:10 +0000)
committerkalman@chromium.org <kalman@chromium.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 23 Feb 2011 10:10:13 +0000 (10:10 +0000)
commitec9906b8f82958fb18da4a80320a5f7e3f618589
treef87a0e9b6c856fe647ea627f2176368a01f81fff
parentc681834a7c7ea8812162088ab3b27d02d466b700
2011-02-23  Benjamin Kalman  <kalman@chromium.org>

        Reviewed by Ojan Vafai.

        Moving or selecting backwards by words jumps to start of contenteditable region if contenteditable=false span is encountered
        https://bugs.webkit.org/show_bug.cgi?id=51001

        Add regression test.

        * editing/selection/extend-backward-by-word-over-non-editable-expected.txt: Added.
        * editing/selection/extend-backward-by-word-over-non-editable.html: Added.
2011-02-23  Benjamin Kalman  <kalman@chromium.org>

        Reviewed by Ojan Vafai.

        Moving or selecting backwards by words jumps to start of contenteditable region if contenteditable=false span is encountered
        https://bugs.webkit.org/show_bug.cgi?id=51001

        Test: editing/selection/extend-backward-by-word-over-non-editable.html

        Revert some previous changes (the TextIteratorEndsAtEditingBoundary text iteration behaviour) which caused this
        bug in the first place, and fix SimplifiedBackwardsTextIterator's iteration range check as an alternative fix.

        The original bug was that double-clicking on an inline editable span at the start of a paragraph would clear the
        selection (webkit.org/b/36360).  This was caused by upstream/downstream VisbiblePosition complications.  To fix,
        refuse to iterate beyond the start node (rather than refusing to iterate across editable boundaries, which
        causes this bug).

        To see why this is correct, and to make it clearer that is indeed what is happening, the text iterator code has
        been slightly restructured to express the invariant that the iterator will never advance past the start node.

        * editing/TextIterator.cpp:
        (WebCore::TextIterator::TextIterator): Remove references to TextIterationEndsAtEditing boundary.
        (WebCore::SimplifiedBackwardsTextIterator::SimplifiedBackwardsTextIterator): Remove m_pastStartNode as the
        mechanism for iteration range checking, and use a flag m_havePassedStartNode instead.
        (WebCore::SimplifiedBackwardsTextIterator::advance): Clean up, use advanceRespectingRange and
        m_havePassedStartNode for iteration range checking rather than m_pastStartNode.
        (WebCore::SimplifiedBackwardsTextIterator::advanceRespectingRange): The new way of modifying m_node
        which updates m_havePassedStartNode and refuses to continue when it becomes true.
        * editing/TextIterator.h: Remove TextIteratorEndsAtEditingBoundary, update for new/removed prototypes and
        member variables.
        * editing/visible_units.cpp:
        (WebCore::previousBoundary): Remove references to TextIteratorEndsAtEditingBoundary.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@79429 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/selection/extend-backward-by-word-over-non-editable-expected.txt [new file with mode: 0644]
LayoutTests/editing/selection/extend-backward-by-word-over-non-editable.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/TextIterator.cpp
Source/WebCore/editing/TextIterator.h
Source/WebCore/editing/visible_units.cpp