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 947 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
958 if (!node) | 958 if (!node) |
959 return false; | 959 return false; |
960 | 960 |
961 RenderObject* renderer = node->renderer(); | 961 RenderObject* renderer = node->renderer(); |
962 if (!renderer) | 962 if (!renderer) |
963 return false; | 963 return false; |
964 | 964 |
965 return renderer->style()->visibility() == VISIBLE; | 965 return renderer->style()->visibility() == VISIBLE; |
966 } | 966 } |
967 | 967 |
968 unsigned numEnclosingMailBlockquotes(const Position& p) | |
969 { | |
970 unsigned num = 0; | |
971 for (Node* n = p.deprecatedNode(); n; n = n->parentNode()) | |
972 if (isMailBlockquote(n)) | |
973 num++; | |
974 | |
975 return num; | |
976 } | |
977 | |
978 void updatePositionForNodeRemoval(Position& position, Node* node) | 968 void updatePositionForNodeRemoval(Position& position, Node* node) |
979 { | 969 { |
980 if (position.isNull()) | 970 if (position.isNull()) |
981 return; | 971 return; |
982 switch (position.anchorType()) { | 972 switch (position.anchorType()) { |
983 case Position::PositionIsBeforeChildren: | 973 case Position::PositionIsBeforeChildren: |
984 if (position.containerNode() == node) | 974 if (position.containerNode() == node) |
985 position = positionInParentBeforeNode(node); | 975 position = positionInParentBeforeNode(node); |
986 break; | 976 break; |
987 case Position::PositionIsAfterChildren: | 977 case Position::PositionIsAfterChildren: |
(...skipping 10 matching lines...) Expand all Loading... |
998 if (node->containsIncludingShadowDOM(position.anchorNode())) | 988 if (node->containsIncludingShadowDOM(position.anchorNode())) |
999 position = positionInParentAfterNode(node); | 989 position = positionInParentAfterNode(node); |
1000 break; | 990 break; |
1001 case Position::PositionIsBeforeAnchor: | 991 case Position::PositionIsBeforeAnchor: |
1002 if (node->containsIncludingShadowDOM(position.anchorNode())) | 992 if (node->containsIncludingShadowDOM(position.anchorNode())) |
1003 position = positionInParentBeforeNode(node); | 993 position = positionInParentBeforeNode(node); |
1004 break; | 994 break; |
1005 } | 995 } |
1006 } | 996 } |
1007 | 997 |
1008 bool isMailBlockquote(const Node *node) | |
1009 { | |
1010 if (!node || !node->hasTagName(blockquoteTag)) | |
1011 return false; | |
1012 | |
1013 return static_cast<const Element *>(node)->getAttribute("type") == "cite"; | |
1014 } | |
1015 | |
1016 int caretMinOffset(const Node* n) | 998 int caretMinOffset(const Node* n) |
1017 { | 999 { |
1018 RenderObject* r = n->renderer(); | 1000 RenderObject* r = n->renderer(); |
1019 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a
runtime check that seemingly couldn't fail; changed it to an assertion for now. | 1001 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a
runtime check that seemingly couldn't fail; changed it to an assertion for now. |
1020 return r ? r->caretMinOffset() : 0; | 1002 return r ? r->caretMinOffset() : 0; |
1021 } | 1003 } |
1022 | 1004 |
1023 // If a node can contain candidates for VisiblePositions, return the offset of t
he last candidate, otherwise | 1005 // If a node can contain candidates for VisiblePositions, return the offset of t
he last candidate, otherwise |
1024 // return the number of children for container nodes and the length for unrender
ed text nodes. | 1006 // return the number of children for container nodes and the length for unrender
ed text nodes. |
1025 int caretMaxOffset(const Node* n) | 1007 int caretMaxOffset(const Node* n) |
(...skipping 175 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1201 // if the selection starts just before a paragraph break, skip over it | 1183 // if the selection starts just before a paragraph break, skip over it |
1202 if (isEndOfParagraph(visiblePosition)) | 1184 if (isEndOfParagraph(visiblePosition)) |
1203 return visiblePosition.next().deepEquivalent().downstream(); | 1185 return visiblePosition.next().deepEquivalent().downstream(); |
1204 | 1186 |
1205 // otherwise, make sure to be at the start of the first selected node, | 1187 // 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 | 1188 // instead of possibly at the end of the last node before the selection |
1207 return visiblePosition.deepEquivalent().downstream(); | 1189 return visiblePosition.deepEquivalent().downstream(); |
1208 } | 1190 } |
1209 | 1191 |
1210 } // namespace WebCore | 1192 } // namespace WebCore |
OLD | NEW |