Selection direction is not preserved when applying styles
https://bugs.webkit.org/show_bug.cgi?id=110979

Patch by Sukolsak Sakshuwong <sukolsak@gmail.com> on 2013-04-13
Reviewed by Ryosuke Niwa.

Source/WebCore:

The patch is based on the one submitted by Shezan Baig.

If the starting selection was directional and its base was not first,
switch newStart and newEnd when setting the ending direction. Otherwise,
leave the order unchanged.

Test: editing/style/preserve-selection-direction.html

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::updateStartEnd):

LayoutTests:

Add a test, based on the work by Shezan Baig

* editing/style/preserve-selection-direction-expected.txt: Added.
* editing/style/preserve-selection-direction.html: Added.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@148378 268f45cc-cd09-0410-ab3c-d52691b4dbfc