LayoutTests:
Reviewed by darin
Fixed (was missing a newline):
* editing/execCommand/
4917055-expected.txt:
Tests setting a caet before the image and changing its alignment:
* editing/execCommand/
5080333-1-expected.checksum: Added.
* editing/execCommand/
5080333-1-expected.png: Added.
* editing/execCommand/
5080333-1-expected.txt: Added.
* editing/execCommand/
5080333-1.html: Added.
Tests selecting the image and changing its alignment:
* editing/execCommand/
5080333-2-expected.checksum: Added.
* editing/execCommand/
5080333-2-expected.png: Added.
* editing/execCommand/
5080333-2-expected.txt: Added.
* editing/execCommand/
5080333-2.html: Added.
WebCore:
Reviewed by darin
<rdar://problem/
5080333>
REGRESSION: Selection changes when changing the alignment of an image
Regression occurred when we started using moveParagraphs
to move content in applyBlockStyle. moveParagraphs
moves by copying, deleting and reinserting content, and
so must be accompanied by selection preservation code.
That code uses rangeFromLocationAndLength and rangeLength,
which use TextIterators, which don't emit anything for images
and other replaced elements, causing this bug.
* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyBlockStyle): Ask rangeLength
and rangeFromLocationAndLength to request that their
TextIterators emit spaces for replaced elements.
Use rangeCompliantEquivalent()s when creating a Range from
VisiblePositions, since some VisiblePositions have illegal
deepEquivalent()s.
* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::moveParagraphs): Ditto.
* editing/TextIterator.cpp:
(WebCore::TextIterator::TextIterator):
(WebCore::TextIterator::handleReplacedElement): Emit
a space if requested.
(WebCore::TextIterator::representNodeOffsetZero): Emit
ranges before m_node, not around m_lastTextNode. These
ranges should represent the part of the document associated
with the emitted character.
(WebCore::TextIterator::rangeLength): Take in the new bool.
(WebCore::TextIterator::rangeFromLocationAndLength): Ditto.
Also, don't loop an extra time after finding the end of the
range when we're looking for zero length ranges. This appeared
to be a workaround for the bugs fixed in representNodeOffsetZero
in this patch.
* editing/TextIterator.h:
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@20449
268f45cc-cd09-0410-ab3c-
d52691b4dbfc