Gmail reply email - Bold and Italic style get stuck
authorcommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2013 04:55:02 +0000 (04:55 +0000)
committercommit-queue@webkit.org <commit-queue@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 31 Jul 2013 04:55:02 +0000 (04:55 +0000)
https://bugs.webkit.org/show_bug.cgi?id=118185

Patch by Vani Hegde <vani.hegde@samsung.com> on 2013-07-30
Reviewed by Ryosuke Niwa.

Source/WebCore:

When bold/italic style is applied to a content with mixed editability,
style is applied appropriately for the first time.
But after this, style toggling does not work any more. Same behavior
can be observed when the content on which style is applied contains
text node without renderer (Ex: text node corresponding to tab/space etc)

When bold/italic style is applied on a selection, we actually apply the
style only for text nodes that have renderers and also are contenteditable.
Similarly during style toggling, to check whether a style has been already
applied on a selection

Tests: editing/style/toggle-style-bold-italic-mixed-editability.html
       editing/style/toggle-style-bold-italic.html

* editing/EditingStyle.cpp:
(WebCore::EditingStyle::triStateOfStyle):
A particular selection on which style is applied may contain text nodes
without renderers(text nodes corresponding to tab/space) or text nodes
that are not contenteditable. We do not apply style to such text nodes.
Hence, even during style toggling we should not consider the styles
present in such nodes.

LayoutTests:

Layout tests added to test bold/italic style toggling on a content
with mixed editability.

* editing/editing.js:
(runDumpAsTextEditingTest): Replaced markupResultList with
elementsForDumpingMarkupList to store all markup data to be logged
at the end of test.
(debugForDumpAsText): Changed to use elementsForDumpingMarkupList.
(startNewMarkupGroup): Added utility function to hold intermediate
data by separating <ol>.
* editing/style/toggle-style-bold-italic-expected.txt: Added.
* editing/style/toggle-style-bold-italic-mixed-editability-expected.txt: Added.
* editing/style/toggle-style-bold-italic-mixed-editability.html: Added.
* editing/style/toggle-style-bold-italic.html: Added.

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

LayoutTests/ChangeLog
LayoutTests/editing/editing.js
LayoutTests/editing/style/toggle-style-bold-italic-expected.txt [new file with mode: 0644]
LayoutTests/editing/style/toggle-style-bold-italic-mixed-editability-expected.txt [new file with mode: 0644]
LayoutTests/editing/style/toggle-style-bold-italic-mixed-editability.html [new file with mode: 0644]
LayoutTests/editing/style/toggle-style-bold-italic.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/editing/EditingStyle.cpp

index 741f554..43397b7 100644 (file)
@@ -1,3 +1,25 @@
+2013-07-30  Vani Hegde  <vani.hegde@samsung.com>
+
+        Gmail reply email - Bold and Italic style  get stuck
+        https://bugs.webkit.org/show_bug.cgi?id=118185
+
+        Reviewed by Ryosuke Niwa.
+
+        Layout tests added to test bold/italic style toggling on a content
+        with mixed editability.
+
+        * editing/editing.js:
+        (runDumpAsTextEditingTest): Replaced markupResultList with
+        elementsForDumpingMarkupList to store all markup data to be logged
+        at the end of test.
+        (debugForDumpAsText): Changed to use elementsForDumpingMarkupList.
+        (startNewMarkupGroup): Added utility function to hold intermediate
+        data by separating <ol>.
+        * editing/style/toggle-style-bold-italic-expected.txt: Added.
+        * editing/style/toggle-style-bold-italic-mixed-editability-expected.txt: Added.
+        * editing/style/toggle-style-bold-italic-mixed-editability.html: Added.
+        * editing/style/toggle-style-bold-italic.html: Added.
+
 2013-07-30  Rob Buis  <rwlbuis@webkit.org>
 
         XMLSerializer should reset default namespace when necessary
index 14af905..8f4e3d2 100644 (file)
@@ -904,7 +904,7 @@ function runEditingTest() {
 }
 
 var dumpAsText = false;
-var markupResultList = document.createElement('ol');
+var elementsForDumpingMarkupList = [document.createElement('ol')];
 
 function runDumpAsTextEditingTest(enableCallbacks) {
     if (window.testRunner) {
@@ -920,17 +920,26 @@ function runDumpAsTextEditingTest(enableCallbacks) {
     selection.setPosition(elem, 0);
     editingTest();
 
-    document.body.appendChild(markupResultList);
+    for (var i = 0; i < elementsForDumpingMarkupList.length; i++)
+        document.body.appendChild(elementsForDumpingMarkupList[i]);
 }
 
 function debugForDumpAsText(name) {
     if (dumpAsText && document.getElementById("root")) {
         var newItem = document.createElement('li');
         newItem.appendChild(document.createTextNode(name+": "+document.getElementById("root").innerHTML));
-        markupResultList.appendChild(newItem);
+        elementsForDumpingMarkupList[elementsForDumpingMarkupList.length - 1].appendChild(newItem);
     }
 }
 
+function startNewMarkupGroup(label) {
+    if (!elementsForDumpingMarkupList[elementsForDumpingMarkupList.length - 1].hasChildNodes())
+        elementsForDumpingMarkupList.pop();
+    elementsForDumpingMarkupList.push(document.createElement('br'));
+    elementsForDumpingMarkupList.push(document.createTextNode(label));
+    elementsForDumpingMarkupList.push(document.createElement('ol'));
+}
+
 //-------------------------------------------------------------------------------------------------------
 
 
diff --git a/LayoutTests/editing/style/toggle-style-bold-italic-expected.txt b/LayoutTests/editing/style/toggle-style-bold-italic-expected.txt
new file mode 100644 (file)
index 0000000..e765982
--- /dev/null
@@ -0,0 +1,71 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > B > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > B > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > B > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > I > B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > B > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > I > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > B > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > B > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > B > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > I > B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > B > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > I > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > B > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > B > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > B > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > I > B > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > B > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > I > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > I > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document toDOMRange:range from 0 of #text > DIV > DIV > DIV > BODY > HTML > #document to 14 of #text > P > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+Tests bold/italic style toggling on a content that has text node without renderer (Ex: Tab/Space used for indentation)
+
+Some text
+Some more text
+
+
+Test for mac
+execBoldCommand: <div id="test"> <div><b>Some text</b></div> <p><b>Some more text</b></p> </div>
+execItalicCommand: <div id="test"> <div><b><i>Some text</i></b></div> <p><b><i>Some more text</i></b></p> </div>
+execBoldCommand: <div id="test"> <div><i>Some text</i></div> <p><i>Some more text</i></p> </div>
+execItalicCommand: <div id="test"> <div>Some text</div> <p>Some more text</p> </div>
+
+Test for win
+execBoldCommand: <div id="test"> <div><b>Some text</b></div> <p><b>Some more text</b></p> </div>
+execItalicCommand: <div id="test"> <div><b><i>Some text</i></b></div> <p><b><i>Some more text</i></b></p> </div>
+execBoldCommand: <div id="test"> <div><i>Some text</i></div> <p><i>Some more text</i></p> </div>
+execItalicCommand: <div id="test"> <div>Some text</div> <p>Some more text</p> </div>
+
+Test for unix
+execBoldCommand: <div id="test"> <div><b>Some text</b></div> <p><b>Some more text</b></p> </div>
+execItalicCommand: <div id="test"> <div><b><i>Some text</i></b></div> <p><b><i>Some more text</i></b></p> </div>
+execBoldCommand: <div id="test"> <div><i>Some text</i></div> <p><i>Some more text</i></p> </div>
+execItalicCommand: <div id="test"> <div>Some text</div> <p>Some more text</p> </div>
+
diff --git a/LayoutTests/editing/style/toggle-style-bold-italic-mixed-editability-expected.txt b/LayoutTests/editing/style/toggle-style-bold-italic-mixed-editability-expected.txt
new file mode 100644 (file)
index 0000000..dba58a5
--- /dev/null
@@ -0,0 +1,69 @@
+EDITING DELEGATE: shouldBeginEditingInDOMRange:range from 0 of DIV > BODY > HTML > #document to 3 of DIV > BODY > HTML > #document
+EDITING DELEGATE: webViewDidBeginEditing:WebViewDidBeginEditingNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > B > DIV > DIV > BODY > HTML > #document to 9 of #text > B > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of B > DIV > DIV > BODY > HTML > #document to 9 of #text > I > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > I > B > DIV > DIV > BODY > HTML > #document to 9 of #text > I > B > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > I > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > I > DIV > DIV > BODY > HTML > #document to 9 of #text > I > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > B > DIV > DIV > BODY > HTML > #document to 9 of #text > B > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of B > DIV > DIV > BODY > HTML > #document to 9 of #text > I > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > I > B > DIV > DIV > BODY > HTML > #document to 9 of #text > I > B > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > I > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > I > DIV > DIV > BODY > HTML > #document to 9 of #text > I > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of DIV > DIV > BODY > HTML > #document to 0 of DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > B > DIV > DIV > BODY > HTML > #document to 9 of #text > B > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of B > DIV > DIV > BODY > HTML > #document to 9 of #text > I > B > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > I > B > DIV > DIV > BODY > HTML > #document to 9 of #text > I > B > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > I > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > I > DIV > DIV > BODY > HTML > #document to 9 of #text > I > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 1 of DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document toDOMRange:range from 1 of #text > DIV > DIV > BODY > HTML > #document to 9 of #text > DIV > DIV > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+This tests bold/italic style toggling for a content with mixed editability
+
+Editable Non-editable Editable
+
+Test for mac
+execBoldCommand: <div id="test"><b> Editable </b><span contenteditable="false">Non-editable</span><b> Editable </b></div>
+execItalicCommand: <div id="test"><b><i> Editable </i></b><span contenteditable="false">Non-editable</span><b><i> Editable </i></b></div>
+execBoldCommand: <div id="test"><i> Editable </i><span contenteditable="false">Non-editable</span><i> Editable </i></div>
+execItalicCommand: <div id="test"> Editable <span contenteditable="false">Non-editable</span> Editable </div>
+
+Test for win
+execBoldCommand: <div id="test"><b> Editable </b><span contenteditable="false">Non-editable</span><b> Editable </b></div>
+execItalicCommand: <div id="test"><b><i> Editable </i></b><span contenteditable="false">Non-editable</span><b><i> Editable </i></b></div>
+execBoldCommand: <div id="test"><i> Editable </i><span contenteditable="false">Non-editable</span><i> Editable </i></div>
+execItalicCommand: <div id="test"> Editable <span contenteditable="false">Non-editable</span> Editable </div>
+
+Test for unix
+execBoldCommand: <div id="test"><b> Editable </b><span contenteditable="false">Non-editable</span><b> Editable </b></div>
+execItalicCommand: <div id="test"><b><i> Editable </i></b><span contenteditable="false">Non-editable</span><b><i> Editable </i></b></div>
+execBoldCommand: <div id="test"><i> Editable </i><span contenteditable="false">Non-editable</span><i> Editable </i></div>
+execItalicCommand: <div id="test"> Editable <span contenteditable="false">Non-editable</span> Editable </div>
+
diff --git a/LayoutTests/editing/style/toggle-style-bold-italic-mixed-editability.html b/LayoutTests/editing/style/toggle-style-bold-italic-mixed-editability.html
new file mode 100644 (file)
index 0000000..224b136
--- /dev/null
@@ -0,0 +1,30 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">This tests bold/italic style toggling for a content with mixed editability</p>
+<div contenteditable id="root">
+<div id="test">
+Editable <span contenteditable=false>Non-editable</span> Editable
+</div>
+</div>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+test('mac');
+test('win');
+test('unix');
+function test(platform) {
+    if (window.internals)
+        internals.settings.setEditingBehavior(platform);
+    startNewMarkupGroup('Test for '+platform);
+    runDumpAsTextEditingTest(true);
+}
+function editingTest() {
+    execSelectAllCommand();
+    execBoldCommand();
+    execItalicCommand();
+    execBoldCommand();
+    execItalicCommand();
+}
+</script>
+</body>
+</html>
\ No newline at end of file
diff --git a/LayoutTests/editing/style/toggle-style-bold-italic.html b/LayoutTests/editing/style/toggle-style-bold-italic.html
new file mode 100644 (file)
index 0000000..ddb01f5
--- /dev/null
@@ -0,0 +1,31 @@
+<!DOCTYPE html>
+<html>
+<body>
+<p id="description">Tests bold/italic style toggling on a content that has text node without renderer (Ex: Tab/Space used for indentation)</p>
+<div contenteditable id="root">
+<div id="test">
+<div>Some text</div>
+<p>Some more text</p>
+</div>
+</div>
+<script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+<script>
+test('mac');
+test('win');
+test('unix');
+function test(platform) {
+    if (window.internals)
+        internals.settings.setEditingBehavior(platform);
+    startNewMarkupGroup('Test for '+platform);
+    runDumpAsTextEditingTest(true);
+}
+function editingTest() {
+    execSelectAllCommand();
+    execBoldCommand();
+    execItalicCommand();
+    execBoldCommand();
+    execItalicCommand();
+}
+</script>
+</body>
+</html>
\ No newline at end of file
index 7339452..70c2069 100644 (file)
@@ -1,3 +1,32 @@
+2013-07-30  Vani Hegde  <vani.hegde@samsung.com>
+
+        Gmail reply email - Bold and Italic style  get stuck
+        https://bugs.webkit.org/show_bug.cgi?id=118185
+
+        Reviewed by Ryosuke Niwa.
+
+        When bold/italic style is applied to a content with mixed editability,
+        style is applied appropriately for the first time.
+        But after this, style toggling does not work any more. Same behavior
+        can be observed when the content on which style is applied contains
+        text node without renderer (Ex: text node corresponding to tab/space etc)
+
+        When bold/italic style is applied on a selection, we actually apply the
+        style only for text nodes that have renderers and also are contenteditable.
+        Similarly during style toggling, to check whether a style has been already
+        applied on a selection
+
+        Tests: editing/style/toggle-style-bold-italic-mixed-editability.html
+               editing/style/toggle-style-bold-italic.html
+
+        * editing/EditingStyle.cpp:
+        (WebCore::EditingStyle::triStateOfStyle):
+        A particular selection on which style is applied may contain text nodes
+        without renderers(text nodes corresponding to tab/space) or text nodes
+        that are not contenteditable. We do not apply style to such text nodes.
+        Hence, even during style toggling we should not consider the styles
+        present in such nodes.
+
 2013-07-30  Rob Buis  <rwlbuis@webkit.org>
 
         XMLSerializer should reset default namespace when necessary
index d9ca025..69c423e 100644 (file)
@@ -683,15 +683,20 @@ TriState EditingStyle::triStateOfStyle(const VisibleSelection& selection) const
         return triStateOfStyle(EditingStyle::styleAtSelectionStart(selection).get());
 
     TriState state = FalseTriState;
+    bool nodeIsStart = true;
     for (Node* node = selection.start().deprecatedNode(); node; node = NodeTraversal::next(node)) {
-        ComputedStyleExtractor computedStyle(node);
-        TriState nodeState = triStateOfStyle(&computedStyle, node->isTextNode() ? EditingStyle::DoNotIgnoreTextOnlyProperties : EditingStyle::IgnoreTextOnlyProperties);
-        if (node == selection.start().deprecatedNode())
-            state = nodeState;
-        else if (state != nodeState && node->isTextNode()) {
-            state = MixedTriState;
-            break;
+        if (node->renderer() && node->rendererIsEditable()) {
+            ComputedStyleExtractor computedStyle(node);
+            TriState nodeState = triStateOfStyle(&computedStyle, node->isTextNode() ? EditingStyle::DoNotIgnoreTextOnlyProperties : EditingStyle::IgnoreTextOnlyProperties);
+            if (nodeIsStart) {
+                state = nodeState;
+                nodeIsStart = false;
+            } else if (state != nodeState && node->isTextNode()) {
+                state = MixedTriState;
+                break;
+            }
         }
+
         if (node == selection.end().deprecatedNode())
             break;
     }