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 return node && (!node->hasChildNodes() || editingIgnoresContent(node)); | 69 if (!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 if (renderer->isTable() || renderer->isTableRow()) | |
leviw_travelin_and_unemployed
2013/05/22 21:02:47
I'd add a comment describing why we handle tables
yosin_UTC9
2013/05/27 05:01:46
Done.
| |
77 return false; | |
78 return renderer->style()->userModify() == READ_ONLY && lowestEditableAncesto r(node); | |
70 } | 79 } |
71 | 80 |
72 // Compare two positions, taking into account the possibility that one or both | 81 // Compare two positions, taking into account the possibility that one or both |
73 // could be inside a shadow tree. Only works for non-null values. | 82 // could be inside a shadow tree. Only works for non-null values. |
74 int comparePositions(const Position& a, const Position& b) | 83 int comparePositions(const Position& a, const Position& b) |
75 { | 84 { |
76 TreeScope* commonScope = commonTreeScope(a.containerNode(), b.containerNode( )); | 85 TreeScope* commonScope = commonTreeScope(a.containerNode(), b.containerNode( )); |
77 | 86 |
78 ASSERT(commonScope); | 87 ASSERT(commonScope); |
79 if (!commonScope) | 88 if (!commonScope) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 if (node->rendererIsEditable(editableType)) | 130 if (node->rendererIsEditable(editableType)) |
122 highestRoot = node; | 131 highestRoot = node; |
123 if (node->hasTagName(bodyTag)) | 132 if (node->hasTagName(bodyTag)) |
124 break; | 133 break; |
125 node = node->parentNode(); | 134 node = node->parentNode(); |
126 } | 135 } |
127 | 136 |
128 return highestRoot; | 137 return highestRoot; |
129 } | 138 } |
130 | 139 |
131 Node* lowestEditableAncestor(Node* node) | 140 Node* lowestEditableAncestor(const Node* node) |
132 { | 141 { |
133 if (!node) | 142 if (!node) |
134 return 0; | 143 return 0; |
135 | 144 |
136 Node* lowestRoot = 0; | 145 Node* lowestRoot = 0; |
137 while (node) { | 146 while (node) { |
138 if (node->rendererIsEditable()) | 147 if (node->rendererIsEditable()) |
139 return node->rootEditableElement(); | 148 return node->rootEditableElement(); |
140 if (node->hasTagName(bodyTag)) | 149 if (node->hasTagName(bodyTag)) |
141 break; | 150 break; |
(...skipping 1059 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
1201 // if the selection starts just before a paragraph break, skip over it | 1210 // if the selection starts just before a paragraph break, skip over it |
1202 if (isEndOfParagraph(visiblePosition)) | 1211 if (isEndOfParagraph(visiblePosition)) |
1203 return visiblePosition.next().deepEquivalent().downstream(); | 1212 return visiblePosition.next().deepEquivalent().downstream(); |
1204 | 1213 |
1205 // otherwise, make sure to be at the start of the first selected node, | 1214 // otherwise, make sure to be at the start of the first selected node, |
1206 // instead of possibly at the end of the last node before the selection | 1215 // instead of possibly at the end of the last node before the selection |
1207 return visiblePosition.deepEquivalent().downstream(); | 1216 return visiblePosition.deepEquivalent().downstream(); |
1208 } | 1217 } |
1209 | 1218 |
1210 } // namespace WebCore | 1219 } // namespace WebCore |
OLD | NEW |