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
+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.
--- /dev/null
+9ed80b1380f3d997515d9dad14a0c2b9
\ No newline at end of file
--- /dev/null
+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
--- /dev/null
+<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>
+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.
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
// 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()))
// Now apply style to the run we found.
addInlineStyleIfNeeded(style, runStart, node);
}
- if (node == end.node())
+ if (node == endNode)
break;
node = node->traverseNextNode();
}