Smart quoting could move the caret backwards in some configurations
authorrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2015 21:52:49 +0000 (21:52 +0000)
committerrniwa@webkit.org <rniwa@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 3 Feb 2015 21:52:49 +0000 (21:52 +0000)
commit8a7892222a13f090e3f25fef22bb1278898b9c0a
tree50b617ea0b1a8fe31880c3bb4104ab52d00726fb
parente81f76d7e99fceea9de50da90e1076d651617ca4
Smart quoting could move the caret backwards in some configurations
https://bugs.webkit.org/show_bug.cgi?id=141203
Source/WebCore:

<rdar://problem/17452543>

Reviewed by Enrica Casucci.

The bug was caused by markAndReplaceFor not running the code to preserve the selection after
text replacement only when smart quote is enabled. Furthermore, when smart link was disabled,
we never applied smart quote due to the following condition at line 2502:

if (!(shouldPerformReplacement || shouldCheckForCorrection || shouldMarkLink) || !doReplacement)
    continue;

This condition prevented the code to apply smart quote from running when both continuous
spellchecking, smart link, and text replacement are disabled.

Fixed the bug by treating smart quotes and smart dashes like any other text replacement and set
shouldPerformReplacement to true whenever either one of those text checking options are present.

Smart link didn't have this issue due to the explicit check for shouldMarkLink.

Smart dashes didn't suffer this problem either because dashes replacement happens only once
the caret has moved past the dashes but his patch makes go through the same code path to preserve
the selection as well for consistency.

Test: editing/inserting/smart-quote-with-all-configurations.html

* editing/Editor.cpp:
(WebCore::Editor::markAndReplaceFor):

LayoutTests:

Reviewed by Enrica Casucci.

Added a regression test for smart quote under all combinations of
spellchecking and substitution configurations.

* editing/inserting/smart-quote-with-all-configurations-expected.txt: Added.
* editing/inserting/smart-quote-with-all-configurations.html: Added.
* platform/efl/TestExpectations:
* platform/gtk/TestExpectations:
* platform/ios-simulator-wk2/TestExpectations:
* platform/win/TestExpectations:
* platform/wk2/TestExpectations:

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@179569 268f45cc-cd09-0410-ab3c-d52691b4dbfc
LayoutTests/ChangeLog
LayoutTests/editing/inserting/smart-quote-with-all-configurations.html [new file with mode: 0644]
LayoutTests/platform/efl/TestExpectations
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/ios-simulator-wk2/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/platform/wk2/TestExpectations
Source/WebCore/ChangeLog
Source/WebCore/editing/Editor.cpp