Null-pointer dereference in WebCore::firstEditablePositionAfterPositionInRoot
authorjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Nov 2015 19:04:02 +0000 (19:04 +0000)
committerjiewen_tan@apple.com <jiewen_tan@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 16 Nov 2015 19:04:02 +0000 (19:04 +0000)
commit9630d1f637c0ebaa5f462f25573021e76402894f
treeb1c6177a1f33900b96e73bacf3397d2be1d91907
parenteef1ab59664e2278e3cc12806d9580ed1df309cd
Null-pointer dereference in WebCore::firstEditablePositionAfterPositionInRoot
https://bugs.webkit.org/show_bug.cgi?id=151288
<rdar://problem/23450367>

Reviewed by Darin Adler.

Source/WebCore:

Some problematic organization of body element could cause problems to JustifyRight
and Indent commnads.

Tests: editing/execCommand/justify-right-then-indent-with-problematic-body.html
       editing/execCommand/justify-right-with-problematic-body.html

* editing/CompositeEditCommand.cpp:
(WebCore::CompositeEditCommand::moveParagraphContentsToNewBlockIfNecessary):
Assertion at l1017 is not held anymore with the testcase:
editing/execCommand/justify-right-with-problematic-body.html.
Therefore, change it to an if statement.
Also, add a guardance before calling insertNewDefaultParagraphElementAt()
as insertNodeAt() requires an editable position.
(WebCore::CompositeEditCommand::moveParagraphWithClones):
Add a guardance before calling insertNodeAt() as it requires an editable position.
* editing/htmlediting.cpp:
(WebCore::firstEditablePositionAfterPositionInRoot):
(WebCore::lastEditablePositionBeforePositionInRoot):

LayoutTests:

* editing/execCommand/justify-right-then-indent-with-problematic-body-expected.txt: Added.
* editing/execCommand/justify-right-then-indent-with-problematic-body.html: Added.
* editing/execCommand/justify-right-with-problematic-body-expected.txt: Added.
* editing/execCommand/justify-right-with-problematic-body.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@192477 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/execCommand/justify-right-then-indent-with-problematic-body-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/justify-right-then-indent-with-problematic-body.html [new file with mode: 0644]
LayoutTests/editing/execCommand/justify-right-with-problematic-body-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/justify-right-with-problematic-body.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/CompositeEditCommand.cpp
Source/WebCore/editing/htmlediting.cpp