2010-10-14 Ryosuke Niwa <rniwa@webkit.org>
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Oct 2010 04:09:48 +0000 (04:09 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Fri, 15 Oct 2010 04:09:48 +0000 (04:09 +0000)
commit38aa8ac6ca274253757a6b4dc565d78dadde58a4
treef4832bb9f07e37890ba589f72d95418ab36d3f17
parent19081674d2427439543f4e330cf9c8dffb218955
2010-10-14  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Tony Chang and Darin Adler.

        execCommand FormatBlock creates lots of blockquotes
        https://bugs.webkit.org/show_bug.cgi?id=19795

        The bug was caused by WebKit's not reusing the block node added by previous iteration
        and its inserting block node at wrong places.

        Fixed the bug by rewriting FormatBlockCommand::formatRange.  New code resembles that of
        IndentOutdentCommand::indentIntoBlockquote.  The difference between two is that formatRange
        avoids the existing block elements when replacing blocks and it also adds a placeholder
        when removing the existing block caused paragraphs to collapse.

        Also fixed a bug in moveParagraphWithClones where erroneous br is added to the start of
        the block element to which the paragraph is moved if the block element is the start of a paragraph
        and not the end of a paragraph.

        Tests: editing/execCommand/format-block-multiple-paragraphs.html
               editing/execCommand/format-block-table.html

        * editing/CompositeEditCommand.cpp:
        (WebCore::CompositeEditCommand::moveParagraphWithClones): No longer adds erroneous br.
        * editing/EditorCommand.cpp:
        (WebCore::executeFormatBlock):
        * editing/FormatBlockCommand.cpp:
        (WebCore::FormatBlockCommand::formatRange): Rewritten; see above.
        (WebCore::FormatBlockCommand::isElementToApplyInFormatBlockCommand): Renamed from validBlockElement
        and moved from htmlediting.cpp.
        (WebCore::enclosingBlockToSplitTreeTo): Added.
        * editing/FormatBlockCommand.h:
        * editing/VisiblePosition.cpp:
        (WebCore::enclosingBlockFlowElement): Changed the return type to Element*
        * editing/VisiblePosition.h:
2010-10-14  Ryosuke Niwa  <rniwa@webkit.org>

        Reviewed by Tony Chang and Darin Adler.

        execCommand FormatBlock creates lots of blockquotes
        https://bugs.webkit.org/show_bug.cgi?id=19795

        Added tests to ensure WebKit does not add multiple block elements when applying block element to
        multiple paragraphs.  Also added a test to ensure formatBlock works with tables.

        * fast/html/nav-element-expected.txt: Preserved new lines and removed redundant br.
        * editing/execCommand/format-block-expected.txt: Preserved span and removed erroneous br.
        * editing/execCommand/format-block-from-range-selection-expected.txt: Merged dl's and removed erroneous br.
        * editing/execCommand/format-block-multiple-paragraphs-expected.txt: Added.
        * editing/execCommand/format-block-multiple-paragraphs.html: Added.
        * editing/execCommand/format-block-table-expected.txt: Added.
        * editing/execCommand/format-block-table.html: Added.
        * editing/execCommand/format-block-with-braces-expected.txt: Removed erroneous br.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@69836 268f45cc-cd09-0410-ab3c-d52691b4dbfc
19 files changed:
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/format-block-expected.txt
LayoutTests/editing/execCommand/format-block-from-range-selection-expected.txt
LayoutTests/editing/execCommand/format-block-multiple-paragraphs-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-multiple-paragraphs.html [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-table-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-table.html [new file with mode: 0644]
LayoutTests/editing/execCommand/format-block-with-braces-expected.txt
LayoutTests/fast/html/nav-element-expected.txt
WebCore/ChangeLog
WebCore/editing/ApplyBlockElementCommand.cpp
WebCore/editing/CompositeEditCommand.cpp
WebCore/editing/EditorCommand.cpp
WebCore/editing/FormatBlockCommand.cpp
WebCore/editing/FormatBlockCommand.h
WebCore/editing/VisiblePosition.cpp
WebCore/editing/VisiblePosition.h
WebCore/editing/htmlediting.cpp
WebCore/editing/htmlediting.h