| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2005, 2006, 2007 Apple Inc. All rights reserved. |
| 3 * | 3 * |
| 4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
| 5 * modification, are permitted provided that the following conditions | 5 * modification, are permitted provided that the following conditions |
| 6 * are met: | 6 * are met: |
| 7 * 1. Redistributions of source code must retain the above copyright | 7 * 1. Redistributions of source code must retain the above copyright |
| 8 * notice, this list of conditions and the following disclaimer. | 8 * notice, this list of conditions and the following disclaimer. |
| 9 * 2. Redistributions in binary form must reproduce the above copyright | 9 * 2. Redistributions in binary form must reproduce the above copyright |
| 10 * notice, this list of conditions and the following disclaimer in the | 10 * notice, this list of conditions and the following disclaimer in the |
| (...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 59 using namespace std; | 59 using namespace std; |
| 60 | 60 |
| 61 namespace WebCore { | 61 namespace WebCore { |
| 62 | 62 |
| 63 using namespace HTMLNames; | 63 using namespace HTMLNames; |
| 64 | 64 |
| 65 // Atomic means that the node has no children, or has children which are ignored
for the | 65 // Atomic means that the node has no children, or has children which are ignored
for the |
| 66 // purposes of editing. | 66 // purposes of editing. |
| 67 bool isAtomicNode(const Node *node) | 67 bool isAtomicNode(const Node *node) |
| 68 { | 68 { |
| 69 if (!node) | 69 return node && (!node->hasChildNodes() || editingIgnoresContent(node)); |
| 70 return false; | |
| 71 if (!node->hasChildNodes() || editingIgnoresContent(node)) | |
| 72 return true; | |
| 73 RenderObject* renderer = node->renderer(); | |
| 74 if (!renderer) | |
| 75 return false; | |
| 76 // For compatibility with IE, we allow to move caret into table cell event | |
| 77 // if TABLE and TR are uneditable. | |
| 78 if (renderer->isTable() || renderer->isTableRow()) | |
| 79 return false; | |
| 80 return renderer->style()->userModify() == READ_ONLY && lowestEditableAncesto
r(node); | |
| 81 } | 70 } |
| 82 | 71 |
| 83 // Compare two positions, taking into account the possibility that one or both | 72 // Compare two positions, taking into account the possibility that one or both |
| 84 // could be inside a shadow tree. Only works for non-null values. | 73 // could be inside a shadow tree. Only works for non-null values. |
| 85 int comparePositions(const Position& a, const Position& b) | 74 int comparePositions(const Position& a, const Position& b) |
| 86 { | 75 { |
| 87 TreeScope* commonScope = commonTreeScope(a.containerNode(), b.containerNode(
)); | 76 TreeScope* commonScope = commonTreeScope(a.containerNode(), b.containerNode(
)); |
| 88 | 77 |
| 89 ASSERT(commonScope); | 78 ASSERT(commonScope); |
| 90 if (!commonScope) | 79 if (!commonScope) |
| (...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 132 if (node->rendererIsEditable(editableType)) | 121 if (node->rendererIsEditable(editableType)) |
| 133 highestRoot = node; | 122 highestRoot = node; |
| 134 if (node->hasTagName(bodyTag)) | 123 if (node->hasTagName(bodyTag)) |
| 135 break; | 124 break; |
| 136 node = node->parentNode(); | 125 node = node->parentNode(); |
| 137 } | 126 } |
| 138 | 127 |
| 139 return highestRoot; | 128 return highestRoot; |
| 140 } | 129 } |
| 141 | 130 |
| 142 Node* lowestEditableAncestor(const Node* node) | 131 Node* lowestEditableAncestor(Node* node) |
| 143 { | 132 { |
| 144 if (!node) | 133 if (!node) |
| 145 return 0; | 134 return 0; |
| 146 | 135 |
| 147 Node* lowestRoot = 0; | 136 Node* lowestRoot = 0; |
| 148 while (node) { | 137 while (node) { |
| 149 if (node->rendererIsEditable()) | 138 if (node->rendererIsEditable()) |
| 150 return node->rootEditableElement(); | 139 return node->rootEditableElement(); |
| 151 if (node->hasTagName(bodyTag)) | 140 if (node->hasTagName(bodyTag)) |
| 152 break; | 141 break; |
| (...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1212 // if the selection starts just before a paragraph break, skip over it | 1201 // if the selection starts just before a paragraph break, skip over it |
| 1213 if (isEndOfParagraph(visiblePosition)) | 1202 if (isEndOfParagraph(visiblePosition)) |
| 1214 return visiblePosition.next().deepEquivalent().downstream(); | 1203 return visiblePosition.next().deepEquivalent().downstream(); |
| 1215 | 1204 |
| 1216 // otherwise, make sure to be at the start of the first selected node, | 1205 // otherwise, make sure to be at the start of the first selected node, |
| 1217 // instead of possibly at the end of the last node before the selection | 1206 // instead of possibly at the end of the last node before the selection |
| 1218 return visiblePosition.deepEquivalent().downstream(); | 1207 return visiblePosition.deepEquivalent().downstream(); |
| 1219 } | 1208 } |
| 1220 | 1209 |
| 1221 } // namespace WebCore | 1210 } // namespace WebCore |
| OLD | NEW |