contenteditable justify commands applied to next paragraph as well
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Oct 2013 05:11:44 +0000 (05:11 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 2 Oct 2013 05:11:44 +0000 (05:11 +0000)
https://bugs.webkit.org/show_bug.cgi?id=90611

Patch by Santosh Mahto <santosh.ma@samsung.com> on 2013-10-01
Reviewed by Ryosuke Niwa.

Source/WebCore:

When the selection extends from first paragraph to start of next
paragraph then Justify command is applied to both the paragraph,
Instead it should be applied only to first paragraph.

Co-author: Sudarshan C P <sudarshan.cp@samsung.com>

Test: editing/execCommand/contenteditable-justify-next-paragraph.html

* editing/ApplyStyleCommand.cpp:
(WebCore::ApplyStyleCommand::applyBlockStyle):
Adjusted visibleEnd to previous position.

LayoutTests:

Added a test for selecting one paragraph and the beginning of another
paragraph to ensure that only the first fully-selected paragraph should
be justified when justifying the selection.

* editing/execCommand/align-in-span-expected.txt: Updated.
* editing/execCommand/contenteditable-justify-next-paragraph-expected.txt: Added.
* editing/execCommand/contenteditable-justify-next-paragraph.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/execCommand/align-in-span-expected.txt
LayoutTests/editing/execCommand/contenteditable-justify-next-paragraph-expected.txt [new file with mode: 0644]
LayoutTests/editing/execCommand/contenteditable-justify-next-paragraph.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/ApplyStyleCommand.cpp

index 7bada0f59790ad8ba6ac5e8db8da9e6c6e3e606f..10d19596fd706f121016205e02e9887543a1ebb8 100644 (file)
@@ -1,3 +1,18 @@
+2013-10-01  Santosh Mahto  <santosh.ma@samsung.com>
+
+        contenteditable justify commands applied to next paragraph as well
+        https://bugs.webkit.org/show_bug.cgi?id=90611
+
+        Reviewed by Ryosuke Niwa.
+
+        Added a test for selecting one paragraph and the beginning of another
+        paragraph to ensure that only the first fully-selected paragraph should
+        be justified when justifying the selection.
+
+        * editing/execCommand/align-in-span-expected.txt: Updated.
+        * editing/execCommand/contenteditable-justify-next-paragraph-expected.txt: Added.
+        * editing/execCommand/contenteditable-justify-next-paragraph.html: Added.
+
 2013-10-01  Alexey Proskuryakov  <ap@apple.com>
 
         Flaky Test: media/media-element-play-after-eos.html
index 4d8e80601f9da26865cdc21acaa212edb15e94e8..6d5f0913123bf84a907b0fbab87d385cfa41831f 100644 (file)
@@ -1,4 +1,3 @@
 Line 1. 
 Select all text in this line and use justify command.
 Line 3.
-
diff --git a/LayoutTests/editing/execCommand/contenteditable-justify-next-paragraph-expected.txt b/LayoutTests/editing/execCommand/contenteditable-justify-next-paragraph-expected.txt
new file mode 100644 (file)
index 0000000..d42bafc
--- /dev/null
@@ -0,0 +1,15 @@
+This test is for a bug when selection extends complete line on first paragraph and applying justifyCenter command will be applied to next paragraph also. Only first Paragraph with id "paragraph1" should have attribute style="text-align: center"
+| "
+    "
+| <p>
+|   id="paragraph1"
+|   style="text-align: center;"
+|   "<#selection-anchor>Paragraph one."
+| "
+    "
+| <p>
+|   id="paragraph2"
+|   <#selection-focus>
+|   "Paragraph two."
+| "
+"
diff --git a/LayoutTests/editing/execCommand/contenteditable-justify-next-paragraph.html b/LayoutTests/editing/execCommand/contenteditable-justify-next-paragraph.html
new file mode 100644 (file)
index 0000000..26f79e0
--- /dev/null
@@ -0,0 +1,22 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../resources/dump-as-markup.js"></script>
+</head>
+
+<body>
+<div id="container" contenteditable >
+    <p id="paragraph1">Paragraph one.</p>
+    <p id="paragraph2">Paragraph two.</p>
+</div>
+</body>
+
+<script>
+    document.getElementById('container').focus();
+    getSelection().modify('Extend', 'Forward', 'Line');
+    document.execCommand('JustifyCenter', false, null);
+
+    Markup.description('This test is for a bug when selection extends complete line on first paragraph and applying justifyCenter command will be applied to next paragraph also. Only first Paragraph with id "paragraph1" should have attribute style="text-align: center"');
+    Markup.dump('container');
+</script>
+</html>
index efbf12f1a5802bbe6aa72c6699573fed8045de39..86a1bef76c0a7b4a38c367d3fe6bf627d899f439 100644 (file)
@@ -1,3 +1,22 @@
+2013-10-01  Santosh Mahto  <santosh.ma@samsung.com>
+
+        contenteditable justify commands applied to next paragraph as well
+        https://bugs.webkit.org/show_bug.cgi?id=90611
+
+        Reviewed by Ryosuke Niwa.
+
+        When the selection extends from first paragraph to start of next
+        paragraph then Justify command is applied to both the paragraph,
+        Instead it should be applied only to first paragraph.
+
+        Co-author: Sudarshan C P <sudarshan.cp@samsung.com>
+
+        Test: editing/execCommand/contenteditable-justify-next-paragraph.html
+
+        * editing/ApplyStyleCommand.cpp:
+        (WebCore::ApplyStyleCommand::applyBlockStyle):
+        Adjusted visibleEnd to previous position.
+
 2013-10-01  Andreas Kling  <akling@apple.com>
 
         Move mouse event dispatch from Node to Element.
index 46df6e602d7c07457f3644d2464acb2f30e84ec5..fbac83360cf47c0a58e77f68526e15801564899f 100644 (file)
@@ -271,6 +271,8 @@ void ApplyStyleCommand::applyBlockStyle(EditingStyle *style)
 
     VisiblePosition paragraphStart(startOfParagraph(visibleStart));
     VisiblePosition nextParagraphStart(endOfParagraph(paragraphStart).next());
+    if (visibleEnd != visibleStart && isStartOfParagraph(visibleEnd))
+        visibleEnd = visibleEnd.previous(CannotCrossEditingBoundary);
     VisiblePosition beyondEnd(endOfParagraph(visibleEnd).next());
     while (paragraphStart.isNotNull() && paragraphStart != beyondEnd) {
         StyleChange styleChange(style, paragraphStart.deepEquivalent());