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 // 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()) | |
ojan
2013/05/27 06:51:54
I don't think this bit is right. Even if we were t
yosin_UTC9
2013/05/27 09:10:13
I don't think there are web contents depend on thi
| |
79 return false; | |
80 return renderer->style()->userModify() == READ_ONLY && lowestEditableAncesto r(node); | |
70 } | 81 } |
71 | 82 |
72 // Compare two positions, taking into account the possibility that one or both | 83 // 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. | 84 // could be inside a shadow tree. Only works for non-null values. |
74 int comparePositions(const Position& a, const Position& b) | 85 int comparePositions(const Position& a, const Position& b) |
75 { | 86 { |
76 TreeScope* commonScope = commonTreeScope(a.containerNode(), b.containerNode( )); | 87 TreeScope* commonScope = commonTreeScope(a.containerNode(), b.containerNode( )); |
77 | 88 |
78 ASSERT(commonScope); | 89 ASSERT(commonScope); |
79 if (!commonScope) | 90 if (!commonScope) |
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
121 if (node->rendererIsEditable(editableType)) | 132 if (node->rendererIsEditable(editableType)) |
122 highestRoot = node; | 133 highestRoot = node; |
123 if (node->hasTagName(bodyTag)) | 134 if (node->hasTagName(bodyTag)) |
124 break; | 135 break; |
125 node = node->parentNode(); | 136 node = node->parentNode(); |
126 } | 137 } |
127 | 138 |
128 return highestRoot; | 139 return highestRoot; |
129 } | 140 } |
130 | 141 |
131 Node* lowestEditableAncestor(Node* node) | 142 Node* lowestEditableAncestor(const Node* node) |
132 { | 143 { |
133 if (!node) | 144 if (!node) |
134 return 0; | 145 return 0; |
135 | 146 |
136 Node* lowestRoot = 0; | 147 Node* lowestRoot = 0; |
137 while (node) { | 148 while (node) { |
138 if (node->rendererIsEditable()) | 149 if (node->rendererIsEditable()) |
139 return node->rootEditableElement(); | 150 return node->rootEditableElement(); |
140 if (node->hasTagName(bodyTag)) | 151 if (node->hasTagName(bodyTag)) |
141 break; | 152 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 | 1212 // if the selection starts just before a paragraph break, skip over it |
1202 if (isEndOfParagraph(visiblePosition)) | 1213 if (isEndOfParagraph(visiblePosition)) |
1203 return visiblePosition.next().deepEquivalent().downstream(); | 1214 return visiblePosition.next().deepEquivalent().downstream(); |
1204 | 1215 |
1205 // otherwise, make sure to be at the start of the first selected node, | 1216 // 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 | 1217 // instead of possibly at the end of the last node before the selection |
1207 return visiblePosition.deepEquivalent().downstream(); | 1218 return visiblePosition.deepEquivalent().downstream(); |
1208 } | 1219 } |
1209 | 1220 |
1210 } // namespace WebCore | 1221 } // namespace WebCore |
OLD | NEW |