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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 #include "core/editing/VisibleUnits.h" | 44 #include "core/editing/VisibleUnits.h" |
45 #include "core/html/HTMLBRElement.h" | 45 #include "core/html/HTMLBRElement.h" |
46 #include "core/html/HTMLDivElement.h" | 46 #include "core/html/HTMLDivElement.h" |
47 #include "core/html/HTMLLIElement.h" | 47 #include "core/html/HTMLLIElement.h" |
48 #include "core/html/HTMLOListElement.h" | 48 #include "core/html/HTMLOListElement.h" |
49 #include "core/html/HTMLParagraphElement.h" | 49 #include "core/html/HTMLParagraphElement.h" |
50 #include "core/html/HTMLTableElement.h" | 50 #include "core/html/HTMLTableElement.h" |
51 #include "core/html/HTMLUListElement.h" | 51 #include "core/html/HTMLUListElement.h" |
52 #include "core/page/Frame.h" | 52 #include "core/page/Frame.h" |
53 #include "core/rendering/RenderObject.h" | 53 #include "core/rendering/RenderObject.h" |
| 54 #include "core/rendering/RenderText.h" |
54 #include "wtf/Assertions.h" | 55 #include "wtf/Assertions.h" |
55 #include "wtf/StdLibExtras.h" | 56 #include "wtf/StdLibExtras.h" |
56 #include "wtf/text/StringBuilder.h" | 57 #include "wtf/text/StringBuilder.h" |
57 #include "wtf/unicode/CharacterNames.h" | 58 #include "wtf/unicode/CharacterNames.h" |
58 | 59 |
59 using namespace std; | 60 using namespace std; |
60 | 61 |
61 namespace WebCore { | 62 namespace WebCore { |
62 | 63 |
63 using namespace HTMLNames; | 64 using namespace HTMLNames; |
(...skipping 900 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
964 if (!node || !node->hasTagName(blockquoteTag)) | 965 if (!node || !node->hasTagName(blockquoteTag)) |
965 return false; | 966 return false; |
966 | 967 |
967 return toElement(node)->getAttribute("type") == "cite"; | 968 return toElement(node)->getAttribute("type") == "cite"; |
968 } | 969 } |
969 | 970 |
970 int caretMinOffset(const Node* n) | 971 int caretMinOffset(const Node* n) |
971 { | 972 { |
972 RenderObject* r = n->renderer(); | 973 RenderObject* r = n->renderer(); |
973 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a
runtime check that seemingly couldn't fail; changed it to an assertion for now. | 974 ASSERT(!n->isCharacterDataNode() || !r || r->isText()); // FIXME: This was a
runtime check that seemingly couldn't fail; changed it to an assertion for now. |
974 return r ? r->caretMinOffset() : 0; | 975 if (!r) |
| 976 return 0; |
| 977 if (r->isText()) |
| 978 return r->caretMinOffset() + toRenderText(r)->textStartOffset(); |
| 979 return r->caretMinOffset(); |
975 } | 980 } |
976 | 981 |
977 // If a node can contain candidates for VisiblePositions, return the offset of t
he last candidate, otherwise | 982 // If a node can contain candidates for VisiblePositions, return the offset of t
he last candidate, otherwise |
978 // return the number of children for container nodes and the length for unrender
ed text nodes. | 983 // return the number of children for container nodes and the length for unrender
ed text nodes. |
979 int caretMaxOffset(const Node* n) | 984 int caretMaxOffset(const Node* n) |
980 { | 985 { |
981 // For rendered text nodes, return the last position that a caret could occu
py. | 986 // For rendered text nodes, return the last position that a caret could occu
py. |
982 if (n->isTextNode() && n->renderer()) | 987 RenderObject* renderer = n->renderer(); |
983 return n->renderer()->caretMaxOffset(); | 988 if (renderer && renderer->isText()) |
| 989 return renderer->caretMaxOffset() + toRenderText(renderer)->textStartOff
set(); |
984 // For containers return the number of children. For others do the same as a
bove. | 990 // For containers return the number of children. For others do the same as a
bove. |
985 return lastOffsetForEditing(n); | 991 return lastOffsetForEditing(n); |
986 } | 992 } |
987 | 993 |
988 bool lineBreakExistsAtVisiblePosition(const VisiblePosition& visiblePosition) | 994 bool lineBreakExistsAtVisiblePosition(const VisiblePosition& visiblePosition) |
989 { | 995 { |
990 return lineBreakExistsAtPosition(visiblePosition.deepEquivalent().downstream
()); | 996 return lineBreakExistsAtPosition(visiblePosition.deepEquivalent().downstream
()); |
991 } | 997 } |
992 | 998 |
993 bool lineBreakExistsAtPosition(const Position& position) | 999 bool lineBreakExistsAtPosition(const Position& position) |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1155 // 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 |
1156 if (isEndOfParagraph(visiblePosition)) | 1162 if (isEndOfParagraph(visiblePosition)) |
1157 return visiblePosition.next().deepEquivalent().downstream(); | 1163 return visiblePosition.next().deepEquivalent().downstream(); |
1158 | 1164 |
1159 // 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, |
1160 // 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 |
1161 return visiblePosition.deepEquivalent().downstream(); | 1167 return visiblePosition.deepEquivalent().downstream(); |
1162 } | 1168 } |
1163 | 1169 |
1164 } // namespace WebCore | 1170 } // namespace WebCore |
OLD | NEW |