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 142 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
153 bool isEditablePosition(const Position& p, EditableType editableType, EUpdateSty
le updateStyle) | 153 bool isEditablePosition(const Position& p, EditableType editableType, EUpdateSty
le updateStyle) |
154 { | 154 { |
155 Node* node = p.deprecatedNode(); | 155 Node* node = p.deprecatedNode(); |
156 if (!node) | 156 if (!node) |
157 return false; | 157 return false; |
158 if (updateStyle == UpdateStyle) | 158 if (updateStyle == UpdateStyle) |
159 node->document().updateLayoutIgnorePendingStylesheets(); | 159 node->document().updateLayoutIgnorePendingStylesheets(); |
160 else | 160 else |
161 ASSERT(updateStyle == DoNotUpdateStyle); | 161 ASSERT(updateStyle == DoNotUpdateStyle); |
162 | 162 |
163 if (node->renderer() && node->renderer()->isTable()) | 163 if (isTableElement(node)) |
164 node = node->parentNode(); | 164 node = node->parentNode(); |
165 | 165 |
166 return node->rendererIsEditable(editableType); | 166 return node->rendererIsEditable(editableType); |
167 } | 167 } |
168 | 168 |
169 bool isAtUnsplittableElement(const Position& pos) | 169 bool isAtUnsplittableElement(const Position& pos) |
170 { | 170 { |
171 Node* node = pos.deprecatedNode(); | 171 Node* node = pos.deprecatedNode(); |
172 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType(
pos, &isTableCell)); | 172 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType(
pos, &isTableCell)); |
173 } | 173 } |
174 | 174 |
175 | 175 |
176 bool isRichlyEditablePosition(const Position& p, EditableType editableType) | 176 bool isRichlyEditablePosition(const Position& p, EditableType editableType) |
177 { | 177 { |
178 Node* node = p.deprecatedNode(); | 178 Node* node = p.deprecatedNode(); |
179 if (!node) | 179 if (!node) |
180 return false; | 180 return false; |
181 | 181 |
182 if (node->renderer() && node->renderer()->isTable()) | 182 if (isTableElement(node)) |
183 node = node->parentNode(); | 183 node = node->parentNode(); |
184 | 184 |
185 return node->rendererIsRichlyEditable(editableType); | 185 return node->rendererIsRichlyEditable(editableType); |
186 } | 186 } |
187 | 187 |
188 Element* editableRootForPosition(const Position& p, EditableType editableType) | 188 Element* editableRootForPosition(const Position& p, EditableType editableType) |
189 { | 189 { |
190 Node* node = p.containerNode(); | 190 Node* node = p.containerNode(); |
191 if (!node) | 191 if (!node) |
192 return 0; | 192 return 0; |
193 | 193 |
194 if (node->renderer() && node->renderer()->isTable()) | 194 if (isTableElement(node)) |
195 node = node->parentNode(); | 195 node = node->parentNode(); |
196 | 196 |
197 return node->rootEditableElement(editableType); | 197 return node->rootEditableElement(editableType); |
198 } | 198 } |
199 | 199 |
200 // Finds the enclosing element until which the tree can be split. | 200 // Finds the enclosing element until which the tree can be split. |
201 // When a user hits ENTER, he/she won't expect this element to be split into two
. | 201 // When a user hits ENTER, he/she won't expect this element to be split into two
. |
202 // You may pass it as the second argument of splitTreeToNode. | 202 // You may pass it as the second argument of splitTreeToNode. |
203 Element* unsplittableElementForPosition(const Position& p) | 203 Element* unsplittableElementForPosition(const Position& p) |
204 { | 204 { |
(...skipping 540 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
745 if (!firstList || !secondList || !firstList->isHTMLElement() || !secondList-
>isHTMLElement()) | 745 if (!firstList || !secondList || !firstList->isHTMLElement() || !secondList-
>isHTMLElement()) |
746 return false; | 746 return false; |
747 | 747 |
748 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) | 748 return firstList->hasTagName(secondList->tagQName()) // make sure the list t
ypes match (ol vs. ul) |
749 && firstList->rendererIsEditable() && secondList->rendererIsEditable() // bo
th lists are editable | 749 && firstList->rendererIsEditable() && secondList->rendererIsEditable() // bo
th lists are editable |
750 && firstList->rootEditableElement() == secondList->rootEditableElement() //
don't cross editing boundaries | 750 && firstList->rootEditableElement() == secondList->rootEditableElement() //
don't cross editing boundaries |
751 && isVisiblyAdjacent(positionInParentAfterNode(firstList), positionInParentB
eforeNode(secondList)); | 751 && isVisiblyAdjacent(positionInParentAfterNode(firstList), positionInParentB
eforeNode(secondList)); |
752 // Make sure there is no visible content between this li and the previous li
st | 752 // Make sure there is no visible content between this li and the previous li
st |
753 } | 753 } |
754 | 754 |
755 bool isRenderedTable(const Node* n) | 755 bool isTableElement(const Node* node) |
756 { | 756 { |
757 if (!n || !n->isElementNode()) | 757 if (!node || !node->isElementNode()) |
758 return false; | 758 return false; |
759 | 759 |
760 RenderObject* renderer = n->renderer(); | 760 return node->hasTagName(tableTag); |
| 761 } |
| 762 |
| 763 bool isRenderedTable(const Node* node) |
| 764 { |
| 765 if (!node || !node->isElementNode()) |
| 766 return false; |
| 767 |
| 768 RenderObject* renderer = node->renderer(); |
761 return (renderer && renderer->isTable()); | 769 return (renderer && renderer->isTable()); |
762 } | 770 } |
763 | 771 |
764 bool isTableCell(const Node* node) | 772 bool isTableCell(const Node* node) |
765 { | 773 { |
766 RenderObject* r = node->renderer(); | 774 RenderObject* r = node->renderer(); |
767 if (!r) | 775 if (!r) |
768 return node->hasTagName(tdTag) || node->hasTagName(thTag); | 776 return node->hasTagName(tdTag) || node->hasTagName(thTag); |
769 | 777 |
770 return r->isTableCell(); | 778 return r->isTableCell(); |
(...skipping 382 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1153 // if the selection starts just before a paragraph break, skip over it | 1161 // if the selection starts just before a paragraph break, skip over it |
1154 if (isEndOfParagraph(visiblePosition)) | 1162 if (isEndOfParagraph(visiblePosition)) |
1155 return visiblePosition.next().deepEquivalent().downstream(); | 1163 return visiblePosition.next().deepEquivalent().downstream(); |
1156 | 1164 |
1157 // otherwise, make sure to be at the start of the first selected node, | 1165 // otherwise, make sure to be at the start of the first selected node, |
1158 // instead of possibly at the end of the last node before the selection | 1166 // instead of possibly at the end of the last node before the selection |
1159 return visiblePosition.deepEquivalent().downstream(); | 1167 return visiblePosition.deepEquivalent().downstream(); |
1160 } | 1168 } |
1161 | 1169 |
1162 } // namespace WebCore | 1170 } // namespace WebCore |
OLD | NEW |