REGRESSION(r183770): Crash inside WebEditorClient::shouldApplyStyle when applying...
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 May 2015 21:58:41 +0000 (21:58 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 13 May 2015 21:58:41 +0000 (21:58 +0000)
commit9b76dd54e76439a46249e976395c0b85b30f9105
tree143bfea9e9240043b18b3a381130dccafd064396
parent5bf250169a3c65d2f5de8e0d54dbf8c503d8ec23
REGRESSION(r183770): Crash inside WebEditorClient::shouldApplyStyle when applying underline
https://bugs.webkit.org/show_bug.cgi?id=144949
Source/WebCore:

<rdar://problem/20895753>

Reviewed by Darin Adler.

The crash was caused by the variant of applyStyleToSelection that takes EditingStyle passing
a null pointer to shouldApplyStyle when we're only applying text decoration changes so that
m_mutableStyle in the editing style is null. This didn't reproduce in execCommand since we
wouldn't call shouldApplyStyle in that case. It didn't reproduce in my manual testing because
font panel also sets text shadow, which ends up filling up m_mutableStyle.

Fixed the bug by creating a mutable style properties when one is not provided by EditingStyle.
Also fixed the "FIXME" in the function by converting text decoration changes to a corresponding
text decoration value. The values passed to shouldApplyStyle now matches the old behavior prior
to r183770.

Test: editing/style/underline-by-user.html

* editing/EditingStyle.cpp:
(WebCore::EditingStyle::styleWithResolvedTextDecorations): Added.
* editing/EditingStyle.h:
* editing/Editor.cpp:
(WebCore::Editor::applyStyleToSelection): Use styleWithResolvedTextDecorations to avoid the crash.

LayoutTests:

Reviewed by Darin Adler.

Added a test that emulates underlining of text by the user. Unlike document.execCommand,
testRunner.execCommand simulates a user initiated editing command and therefore invokes
shouldApplyStyle.

* editing/style/underline-by-user-expected.txt: Added.
* editing/style/underline-by-user.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@184308 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/style/underline-by-user-expected.txt [new file with mode: 0644]
LayoutTests/editing/style/underline-by-user.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/EditingStyle.cpp
Source/WebCore/editing/EditingStyle.h
Source/WebCore/editing/Editor.cpp