OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2004, 2006, 2008 Apple Inc. All rights reserved. | 2 * Copyright (C) 2004, 2006, 2008 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 20 matching lines...) Expand all Loading... |
31 #include "platform/text/TextDirection.h" | 31 #include "platform/text/TextDirection.h" |
32 #include "wtf/Forward.h" | 32 #include "wtf/Forward.h" |
33 #include "wtf/unicode/CharacterNames.h" | 33 #include "wtf/unicode/CharacterNames.h" |
34 | 34 |
35 namespace blink { | 35 namespace blink { |
36 | 36 |
37 class Document; | 37 class Document; |
38 class Element; | 38 class Element; |
39 class ExceptionState; | 39 class ExceptionState; |
40 class HTMLElement; | 40 class HTMLElement; |
| 41 class HTMLSpanElement; |
41 class Node; | 42 class Node; |
42 class Position; | 43 class Position; |
43 class PositionWithAffinity; | 44 class PositionWithAffinity; |
44 class Range; | 45 class Range; |
45 class VisiblePosition; | 46 class VisiblePosition; |
46 class VisibleSelection; | 47 class VisibleSelection; |
47 | 48 |
48 | 49 |
49 // This file contains a set of helper functions used by the editing commands | 50 // This file contains a set of helper functions used by the editing commands |
50 | 51 |
51 // ------------------------------------------------------------------------- | 52 // ------------------------------------------------------------------------- |
52 // Node | 53 // Node |
53 // ------------------------------------------------------------------------- | 54 // ------------------------------------------------------------------------- |
54 | 55 |
55 // Functions returning Node | 56 // Functions returning Node |
56 | 57 |
57 Node* highestEditableRoot(const Position&, EditableType = ContentIsEditable); | 58 ContainerNode* highestEditableRoot(const Position&, EditableType = ContentIsEdit
able); |
58 | 59 |
59 Node* highestEnclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Nod
e*), | 60 Node* highestEnclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Nod
e*), |
60 EditingBoundaryCrossingRule = CannotCrossEditingBoundary, Node* stayWithin =
0); | 61 EditingBoundaryCrossingRule = CannotCrossEditingBoundary, Node* stayWithin =
0); |
61 Node* highestNodeToRemoveInPruning(Node*, Node* excludeNode = 0); | 62 Node* highestNodeToRemoveInPruning(Node*, Node* excludeNode = 0); |
62 Node* lowestEditableAncestor(Node*); | 63 Element* lowestEditableAncestor(Node*); |
63 | 64 |
64 Element* enclosingBlock(Node*, EditingBoundaryCrossingRule = CannotCrossEditingB
oundary); | 65 Element* enclosingBlock(Node*, EditingBoundaryCrossingRule = CannotCrossEditingB
oundary); |
65 Node* enclosingTableCell(const Position&); | 66 Element* enclosingTableCell(const Position&); |
66 Node* enclosingEmptyListItem(const VisiblePosition&); | 67 Node* enclosingEmptyListItem(const VisiblePosition&); |
67 Element* enclosingAnchorElement(const Position&); | 68 Element* enclosingAnchorElement(const Position&); |
68 Node* enclosingNodeWithTag(const Position&, const QualifiedName&); | 69 Element* enclosingElementWithTag(const Position&, const QualifiedName&); |
69 Node* enclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*), Ed
itingBoundaryCrossingRule = CannotCrossEditingBoundary); | 70 Node* enclosingNodeOfType(const Position&, bool (*nodeIsOfType)(const Node*), Ed
itingBoundaryCrossingRule = CannotCrossEditingBoundary); |
70 | 71 |
71 Node* tabSpanNode(const Node*); | 72 HTMLSpanElement* tabSpanElement(const Node*); |
72 Node* isLastPositionBeforeTable(const VisiblePosition&); | 73 Node* isLastPositionBeforeTable(const VisiblePosition&); |
73 Node* isFirstPositionAfterTable(const VisiblePosition&); | 74 Node* isFirstPositionAfterTable(const VisiblePosition&); |
74 | 75 |
75 // offset functions on Node | 76 // offset functions on Node |
76 | 77 |
77 int lastOffsetForEditing(const Node*); | 78 int lastOffsetForEditing(const Node*); |
78 int caretMinOffset(const Node*); | 79 int caretMinOffset(const Node*); |
79 int caretMaxOffset(const Node*); | 80 int caretMaxOffset(const Node*); |
80 | 81 |
81 // boolean functions on Node | 82 // boolean functions on Node |
82 | 83 |
83 // FIXME: editingIgnoresContent, canHaveChildrenForEditing, and isAtomicNode | 84 // FIXME: editingIgnoresContent, canHaveChildrenForEditing, and isAtomicNode |
84 // should be renamed to reflect its usage. | 85 // should be renamed to reflect its usage. |
85 | 86 |
86 // Returns true for nodes that either have no content, or have content that is i
gnored (skipped over) while editing. | 87 // Returns true for nodes that either have no content, or have content that is i
gnored (skipped over) while editing. |
87 // There are no VisiblePositions inside these nodes. | 88 // There are no VisiblePositions inside these nodes. |
88 inline bool editingIgnoresContent(const Node* node) | 89 inline bool editingIgnoresContent(const Node* node) |
89 { | 90 { |
90 return !node->canContainRangeEndPoint(); | 91 return !node->canContainRangeEndPoint(); |
91 } | 92 } |
92 | 93 |
93 inline bool canHaveChildrenForEditing(const Node* node) | 94 inline bool canHaveChildrenForEditing(const Node* node) |
94 { | 95 { |
95 return !node->isTextNode() && node->canContainRangeEndPoint(); | 96 return !node->isTextNode() && node->canContainRangeEndPoint(); |
96 } | 97 } |
97 | 98 |
98 bool isAtomicNode(const Node*); | 99 bool isAtomicNode(const Node*); |
99 bool isBlock(const Node*); | 100 bool isBlock(const Node*); |
100 bool isInline(const Node*); | 101 bool isInline(const Node*); |
101 bool isSpecialElement(const Node*); | 102 bool isSpecialHTMLElement(const Node*); |
102 bool isTabSpanNode(const Node*); | 103 bool isTabSpanElement(const Node*); |
103 bool isTabSpanTextNode(const Node*); | 104 bool isTabSpanTextNode(const Node*); |
104 bool isMailBlockquote(const Node*); | 105 bool isMailBlockquote(const Node*); |
105 bool isRenderedTable(const Node*); | 106 bool isRenderedTable(const Node*); |
106 bool isRenderedTableElement(const Node*); | 107 bool isRenderedTableElement(const Node*); |
107 bool isTableCell(const Node*); | 108 bool isTableCell(const Node*); |
108 bool isEmptyTableCell(const Node*); | 109 bool isEmptyTableCell(const Node*); |
109 bool isTableStructureNode(const Node*); | 110 bool isTableStructureNode(const Node*); |
110 bool isListElement(Node*); | 111 bool isListElement(Node*); |
111 bool isListItem(const Node*); | 112 bool isListItem(const Node*); |
112 bool isNodeRendered(const Node*); | 113 bool isNodeRendered(const Node*); |
113 bool isNodeVisiblyContainedWithin(Node&, const Range&); | 114 bool isNodeVisiblyContainedWithin(Node&, const Range&); |
114 bool isRenderedAsNonInlineTableImageOrHR(const Node*); | 115 bool isRenderedAsNonInlineTableImageOrHR(const Node*); |
115 bool areIdenticalElements(const Node*, const Node*); | 116 bool areIdenticalElements(const Node*, const Node*); |
116 bool isNonTableCellHTMLBlockElement(const Node*); | 117 bool isNonTableCellHTMLBlockElement(const Node*); |
117 TextDirection directionOfEnclosingBlock(const Position&); | 118 TextDirection directionOfEnclosingBlock(const Position&); |
118 | 119 |
119 // ------------------------------------------------------------------------- | 120 // ------------------------------------------------------------------------- |
120 // Position | 121 // Position |
121 // ------------------------------------------------------------------------- | 122 // ------------------------------------------------------------------------- |
122 | 123 |
123 // Functions returning Position | 124 // Functions returning Position |
124 | 125 |
125 Position nextCandidate(const Position&); | 126 Position nextCandidate(const Position&); |
126 Position previousCandidate(const Position&); | 127 Position previousCandidate(const Position&); |
127 | 128 |
128 Position nextVisuallyDistinctCandidate(const Position&); | 129 Position nextVisuallyDistinctCandidate(const Position&); |
129 Position previousVisuallyDistinctCandidate(const Position&); | 130 Position previousVisuallyDistinctCandidate(const Position&); |
130 | 131 |
131 Position positionBeforeContainingSpecialElement(const Position&, Node** containi
ngSpecialElement = 0); | 132 Position positionBeforeContainingSpecialElement(const Position&, HTMLElement** c
ontainingSpecialElement = 0); |
132 Position positionAfterContainingSpecialElement(const Position&, Node** containin
gSpecialElement = 0); | 133 Position positionAfterContainingSpecialElement(const Position&, HTMLElement** co
ntainingSpecialElement = 0); |
133 | 134 |
134 inline Position firstPositionInOrBeforeNode(Node* node) | 135 inline Position firstPositionInOrBeforeNode(Node* node) |
135 { | 136 { |
136 if (!node) | 137 if (!node) |
137 return Position(); | 138 return Position(); |
138 return editingIgnoresContent(node) ? positionBeforeNode(node) : firstPositio
nInNode(node); | 139 return editingIgnoresContent(node) ? positionBeforeNode(node) : firstPositio
nInNode(node); |
139 } | 140 } |
140 | 141 |
141 inline Position lastPositionInOrAfterNode(Node* node) | 142 inline Position lastPositionInOrAfterNode(Node* node) |
142 { | 143 { |
(...skipping 29 matching lines...) Expand all Loading... |
172 Position trailingWhitespacePosition(const Position&, EAffinity, WhitespacePositi
onOption = NotConsiderNonCollapsibleWhitespace); | 173 Position trailingWhitespacePosition(const Position&, EAffinity, WhitespacePositi
onOption = NotConsiderNonCollapsibleWhitespace); |
173 unsigned numEnclosingMailBlockquotes(const Position&); | 174 unsigned numEnclosingMailBlockquotes(const Position&); |
174 void updatePositionForNodeRemoval(Position&, Node&); | 175 void updatePositionForNodeRemoval(Position&, Node&); |
175 | 176 |
176 // ------------------------------------------------------------------------- | 177 // ------------------------------------------------------------------------- |
177 // VisiblePosition | 178 // VisiblePosition |
178 // ------------------------------------------------------------------------- | 179 // ------------------------------------------------------------------------- |
179 | 180 |
180 // Functions returning VisiblePosition | 181 // Functions returning VisiblePosition |
181 | 182 |
182 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position&,
Node*); | 183 VisiblePosition firstEditableVisiblePositionAfterPositionInRoot(const Position&,
ContainerNode*); |
183 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&,
Node*); | 184 VisiblePosition lastEditableVisiblePositionBeforePositionInRoot(const Position&,
ContainerNode*); |
184 VisiblePosition visiblePositionBeforeNode(Node&); | 185 VisiblePosition visiblePositionBeforeNode(Node&); |
185 VisiblePosition visiblePositionAfterNode(Node&); | 186 VisiblePosition visiblePositionAfterNode(Node&); |
186 | 187 |
187 bool lineBreakExistsAtVisiblePosition(const VisiblePosition&); | 188 bool lineBreakExistsAtVisiblePosition(const VisiblePosition&); |
188 | 189 |
189 int comparePositions(const VisiblePosition&, const VisiblePosition&); | 190 int comparePositions(const VisiblePosition&, const VisiblePosition&); |
190 | 191 |
191 int indexForVisiblePosition(const VisiblePosition&, RefPtrWillBeRawPtr<Container
Node>& scope); | 192 int indexForVisiblePosition(const VisiblePosition&, RefPtrWillBeRawPtr<Container
Node>& scope); |
192 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope); | 193 VisiblePosition visiblePositionForIndex(int index, ContainerNode* scope); |
193 | 194 |
(...skipping 13 matching lines...) Expand all Loading... |
207 | 208 |
208 PassRefPtrWillBeRawPtr<HTMLElement> createDefaultParagraphElement(Document&); | 209 PassRefPtrWillBeRawPtr<HTMLElement> createDefaultParagraphElement(Document&); |
209 PassRefPtrWillBeRawPtr<HTMLElement> createBreakElement(Document&); | 210 PassRefPtrWillBeRawPtr<HTMLElement> createBreakElement(Document&); |
210 PassRefPtrWillBeRawPtr<HTMLElement> createOrderedListElement(Document&); | 211 PassRefPtrWillBeRawPtr<HTMLElement> createOrderedListElement(Document&); |
211 PassRefPtrWillBeRawPtr<HTMLElement> createUnorderedListElement(Document&); | 212 PassRefPtrWillBeRawPtr<HTMLElement> createUnorderedListElement(Document&); |
212 PassRefPtrWillBeRawPtr<HTMLElement> createListItemElement(Document&); | 213 PassRefPtrWillBeRawPtr<HTMLElement> createListItemElement(Document&); |
213 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document&, const Qualified
Name&); | 214 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document&, const Qualified
Name&); |
214 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document&, const AtomicStr
ing&); | 215 PassRefPtrWillBeRawPtr<HTMLElement> createHTMLElement(Document&, const AtomicStr
ing&); |
215 | 216 |
216 HTMLElement* enclosingList(Node*); | 217 HTMLElement* enclosingList(Node*); |
217 HTMLElement* outermostEnclosingList(Node*, Node* rootList = 0); | 218 HTMLElement* outermostEnclosingList(Node*, HTMLElement* rootList = 0); |
218 Node* enclosingListChild(Node*); | 219 Node* enclosingListChild(Node*); |
219 | 220 |
220 // ------------------------------------------------------------------------- | 221 // ------------------------------------------------------------------------- |
221 // Element | 222 // Element |
222 // ------------------------------------------------------------------------- | 223 // ------------------------------------------------------------------------- |
223 | 224 |
224 // Functions returning Element | 225 // Functions returning Element |
225 | 226 |
226 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document&); | 227 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document&); |
227 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document&, PassRefPtrWillBe
RawPtr<Node> tabTextNode); | 228 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document&, PassRefP
trWillBeRawPtr<Text> tabTextNode); |
228 PassRefPtrWillBeRawPtr<Element> createTabSpanElement(Document&, const String& ta
bText); | 229 PassRefPtrWillBeRawPtr<HTMLSpanElement> createTabSpanElement(Document&, const St
ring& tabText); |
229 PassRefPtrWillBeRawPtr<Element> createBlockPlaceholderElement(Document&); | 230 PassRefPtrWillBeRawPtr<Element> createBlockPlaceholderElement(Document&); |
230 | 231 |
231 Element* editableRootForPosition(const Position&, EditableType = ContentIsEditab
le); | 232 Element* editableRootForPosition(const Position&, EditableType = ContentIsEditab
le); |
232 Element* unsplittableElementForPosition(const Position&); | 233 Element* unsplittableElementForPosition(const Position&); |
233 | 234 |
234 // Boolean functions on Element | 235 // Boolean functions on Element |
235 | 236 |
236 bool canMergeLists(Element* firstList, Element* secondList); | 237 bool canMergeLists(Element* firstList, Element* secondList); |
237 | 238 |
238 // ------------------------------------------------------------------------- | 239 // ------------------------------------------------------------------------- |
(...skipping 25 matching lines...) Expand all Loading... |
264 // FIXME: this is required until 6853027 is fixed and text checking can do t
his for us. | 265 // FIXME: this is required until 6853027 is fixed and text checking can do t
his for us. |
265 return character == '\'' || character == rightSingleQuotationMark || charact
er == hebrewPunctuationGershayim; | 266 return character == '\'' || character == rightSingleQuotationMark || charact
er == hebrewPunctuationGershayim; |
266 } | 267 } |
267 | 268 |
268 String stringWithRebalancedWhitespace(const String&, bool startIsStartOfParagrap
h, bool endIsEndOfParagraph); | 269 String stringWithRebalancedWhitespace(const String&, bool startIsStartOfParagrap
h, bool endIsEndOfParagraph); |
269 const String& nonBreakingSpaceString(); | 270 const String& nonBreakingSpaceString(); |
270 | 271 |
271 } | 272 } |
272 | 273 |
273 #endif | 274 #endif |
OLD | NEW |