LayoutTests:
authoradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jul 2006 03:40:28 +0000 (03:40 +0000)
committeradele <adele@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 25 Jul 2006 03:40:28 +0000 (03:40 +0000)
        Reviewed by Justin.

        - Test for <rdar://problem/4632132> Changing style of content with mixed editability fails

        * editing/style/apple-style-editable-mix-expected.checksum: Added.
        * editing/style/apple-style-editable-mix-expected.png: Added.
        * editing/style/apple-style-editable-mix-expected.txt: Added.
        * editing/style/apple-style-editable-mix.html: Added.

WebCore:

        Reviewed by Justin.

        - Fix for <rdar://problem/4632132> Changing style of content with mixed editability fails

        Test: * editing/style/apple-style-editable-mix.html

        * dom/Node.cpp: (WebCore::Node::isContentRichlyEditable): Doesn't need to check the editable root.  It now just
          checks the user modify property of its own renderer, since that is inherited.
        * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyInlineStyle): If the end position is in a table,
        Adjust the end node to the last descendant of the table, so we don't skip over any runs.

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

LayoutTests/ChangeLog
LayoutTests/editing/style/apple-style-editable-mix-expected.checksum [new file with mode: 0644]
LayoutTests/editing/style/apple-style-editable-mix-expected.png [new file with mode: 0644]
LayoutTests/editing/style/apple-style-editable-mix-expected.txt [new file with mode: 0644]
LayoutTests/editing/style/apple-style-editable-mix.html [new file with mode: 0644]
WebCore/ChangeLog
WebCore/dom/Node.cpp
WebCore/editing/ApplyStyleCommand.cpp

index 92abfb9a1b8227961aa05fe882c165786ad628f7..15e928de404581fa54406ec4cabe3241482622e9 100644 (file)
@@ -1,3 +1,14 @@
+2006-07-24  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Justin.
+
+        - Test for <rdar://problem/4632132> Changing style of content with mixed editability fails
+
+        * editing/style/apple-style-editable-mix-expected.checksum: Added.
+        * editing/style/apple-style-editable-mix-expected.png: Added.
+        * editing/style/apple-style-editable-mix-expected.txt: Added.
+        * editing/style/apple-style-editable-mix.html: Added.
+
 2006-07-24  Dave MacLachlan  <dmaclach@mac.com>
 
         Reviewed by Darin and Alexey.
diff --git a/LayoutTests/editing/style/apple-style-editable-mix-expected.checksum b/LayoutTests/editing/style/apple-style-editable-mix-expected.checksum
new file mode 100644 (file)
index 0000000..baa7fc3
--- /dev/null
@@ -0,0 +1 @@
+9ed80b1380f3d997515d9dad14a0c2b9
\ No newline at end of file
diff --git a/LayoutTests/editing/style/apple-style-editable-mix-expected.png b/LayoutTests/editing/style/apple-style-editable-mix-expected.png
new file mode 100644 (file)
index 0000000..38dfcc3
Binary files /dev/null and b/LayoutTests/editing/style/apple-style-editable-mix-expected.png differ
diff --git a/LayoutTests/editing/style/apple-style-editable-mix-expected.txt b/LayoutTests/editing/style/apple-style-editable-mix-expected.txt
new file mode 100644 (file)
index 0000000..1dab5f4
--- /dev/null
@@ -0,0 +1,39 @@
+EDITING DELEGATE: shouldChangeSelectedDOMRange:(null) toDOMRange:range from 0 of TABLE > BODY > HTML > #document to 2 of TABLE > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChangeSelection:WebViewDidChangeSelectionNotification
+EDITING DELEGATE: shouldChangeSelectedDOMRange:range from 0 of TABLE > BODY > HTML > #document to 2 of TABLE > BODY > HTML > #document toDOMRange:range from 0 of TABLE > BODY > HTML > #document to 2 of TABLE > BODY > HTML > #document affinity:NSSelectionAffinityDownstream stillSelecting:FALSE
+EDITING DELEGATE: webViewDidChange:WebViewDidChangeNotification
+layer at (0,0) size 800x600
+  RenderView at (0,0) size 800x600
+layer at (0,0) size 800x600
+  RenderBlock {HTML} at (0,0) size 800x600
+    RenderBody {BODY} at (8,8) size 784x584
+      RenderTable {TABLE} at (0,0) size 758x24
+        RenderTableSection {TBODY} at (0,0) size 758x24
+          RenderTableRow {TR} at (0,2) size 758x20
+            RenderTableCell {TD} at (2,2) size 644x20 [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (1,1) size 642x18
+                text run at (1,1) width 642: "This tests that a style can be applied to a selection that contains both editable and non-editable content."
+                text run at (643,1) width 0: "             "
+            RenderTableCell {TD} at (648,2) size 108x20 [r=0 c=1 rs=1 cs=1]
+              RenderInline {SPAN} at (0,0) size 106x18
+                RenderInline {B} at (0,0) size 106x18
+                  RenderText {#text} at (1,1) size 106x18
+                    text run at (1,1) width 106: "Editable - line 1"
+              RenderText {#text} at (107,1) size 0x18
+                text run at (107,1) width 0: "             "
+      RenderTable {TABLE} at (0,24) size 710x24
+        RenderTableSection {TBODY} at (0,0) size 710x24
+          RenderTableRow {TR} at (0,2) size 710x20
+            RenderTableCell {TD} at (2,2) size 596x20 [r=0 c=0 rs=1 cs=1]
+              RenderText {#text} at (1,1) size 594x18
+                text run at (1,1) width 594: "The test passes if the editable content is bold, and the non editable content remains unchanged."
+                text run at (595,1) width 0: "             "
+            RenderTableCell {TD} at (600,2) size 108x20 [r=0 c=1 rs=1 cs=1]
+              RenderInline {SPAN} at (0,0) size 106x18
+                RenderInline {B} at (0,0) size 106x18
+                  RenderText {#text} at (1,1) size 106x18
+                    text run at (1,1) width 106: "Editable - line 2"
+              RenderText {#text} at (107,1) size 0x18
+                text run at (107,1) width 0: "             "
+selection start: position 0 of child 1 {TABLE} of child 1 {BODY} of child 0 {HTML} of document
+selection end:   position 2 of child 3 {TABLE} of child 1 {BODY} of child 0 {HTML} of document
diff --git a/LayoutTests/editing/style/apple-style-editable-mix.html b/LayoutTests/editing/style/apple-style-editable-mix.html
new file mode 100644 (file)
index 0000000..f0f71bd
--- /dev/null
@@ -0,0 +1,35 @@
+<html>
+    <head>
+        <script>
+            function test()
+            {
+                var tbl1 = document.getElementById('tbl1');
+                var tbl2 = document.getElementById('tbl2');
+                var selection = window.getSelection();
+                selectAllCommand();
+                boldCommand();
+            }
+        </script>
+        <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
+    </head>
+<body onload="test()" contenteditable>
+    <table id="tbl1" contenteditable=false>
+        <tr>
+            <td>This tests that a style can be applied to a selection that contains both editable and non-editable content.
+            </td>
+            <td>
+                <span contenteditable>Editable - line 1</span>
+            </td>
+        </tr>
+    </table>
+    <table id="tbl2" contenteditable=false>
+        <tr>
+            <td>The test passes if the editable content is bold, and the non editable content remains unchanged.
+            </td>
+            <td>
+                <span contenteditable>Editable - line 2</span>
+            </td>
+        </tr>
+    </table>
+</body>
+</html>
index c4a932df3514b2b116b1eb39de9ca2a56603394b..bde451f70b1796eccac71d835ad71b606d38f29e 100644 (file)
@@ -1,3 +1,16 @@
+2006-07-24  Adele Peterson  <adele@apple.com>
+
+        Reviewed by Justin.
+
+        - Fix for <rdar://problem/4632132> Changing style of content with mixed editability fails
+
+        Test: * editing/style/apple-style-editable-mix.html
+
+        * dom/Node.cpp: (WebCore::Node::isContentRichlyEditable): Doesn't need to check the editable root.  It now just
+          checks the user modify property of its own renderer, since that is inherited.
+        * editing/ApplyStyleCommand.cpp: (WebCore::ApplyStyleCommand::applyInlineStyle): If the end position is in a table,
+        Adjust the end node to the last descendant of the table, so we don't skip over any runs.
+
 2006-07-24  Darin Adler  <darin@apple.com>
 
         Reviewed by Hyatt.
index 9cd770d3cacab952e6744106e5567d90aca445a0..ff8d936d193459d0dd7d2e69e38f24af8cbfd0f4 100644 (file)
@@ -330,8 +330,7 @@ bool Node::isContentEditable() const
 
 bool Node::isContentRichlyEditable() const
 {
-    Node* root = rootEditableElement();
-    return root && root->renderer() && root->renderer()->style()->userModify() != READ_WRITE_PLAINTEXT_ONLY;
+    return renderer() && renderer()->style()->userModify() == READ_WRITE;
 }
 
 IntRect Node::getRect() const
index 3b8b0b52e53d970f5ef56a965b2c44d9b0c2db4e..1ea906cec3bb2d8c6bd30e26b13149ee569e7a22 100644 (file)
@@ -583,21 +583,26 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
     // to check a computed style
     updateLayout();
     
-    Node *node = start.node();
+    Node* node = start.node();
+    Node* endNode = end.node();
+
     if (start.offset() >= start.node()->caretMaxOffset())
         node = node->traverseNextNode();
+
+    if (end.node()->renderer()->isTable() && end.offset() == maxDeepOffset(end.node()))
+        endNode = end.node()->lastDescendant();
     
-    if (start.node() == end.node()) {
+    if (start.node() == endNode) {
         addInlineStyleIfNeeded(style, node, node);
     } else {
         while (1) {
-            if (node->childNodeCount() == 0 && node->renderer() && node->renderer()->isInline()) {
+            if (node->childNodeCount() == 0 && node->renderer() && node->renderer()->isInline() && node->isContentRichlyEditable()) {
                 Node *runStart = node;
                 while (1) {
                     Node *next = node->traverseNextNode();
                     // Break if node is the end node, or if the next node does not fit in with
                     // the current group.
-                    if (node == end.node() || 
+                    if (node == endNode || 
                         runStart->parentNode() != next->parentNode() || 
                         (next->isElementNode() && !next->hasTagName(brTag)) || 
                         (next->renderer() && !next->renderer()->isInline()))
@@ -607,7 +612,7 @@ void ApplyStyleCommand::applyInlineStyle(CSSMutableStyleDeclaration *style)
                 // Now apply style to the run we found.
                 addInlineStyleIfNeeded(style, runStart, node);
             }
-            if (node == end.node())
+            if (node == endNode)
                 break;
             node = node->traverseNextNode();
         }