Lines Matching full:node
60 // Atomic means that the node has no children, or has children which are ignored for the
62 bool isAtomicNode(const Node *node)
64 return node && (!node->hasChildNodes() || editingIgnoresContent(node));
69 bool editingIgnoresContent(const Node* node)
71 return !canHaveChildrenForEditing(node) && !node->isTextNode();
74 bool canHaveChildrenForEditing(const Node* node)
76 return !node->hasTagName(hrTag) &&
77 !node->hasTagName(brTag) &&
78 !node->hasTagName(imgTag) &&
79 !node->hasTagName(buttonTag) &&
80 !node->hasTagName(inputTag) &&
81 !node->hasTagName(textareaTag) &&
82 !node->hasTagName(objectTag) &&
83 !node->hasTagName(iframeTag) &&
84 !node->hasTagName(embedTag) &&
85 !node->hasTagName(appletTag) &&
86 !node->hasTagName(selectTag) &&
87 !node->hasTagName(datagridTag) &&
89 !node->hasTagName(WMLNames::doTag) &&
91 !node->isTextNode();
98 Node* nodeA = a.node();
100 Node* nodeB = b.node();
105 Node* shadowAncestorA = nodeA->shadowAncestorNode();
108 Node* shadowAncestorB = nodeB->shadowAncestorNode();
135 Node* highestEditableRoot(const Position& position)
137 Node* node = position.node();
138 if (!node)
141 Node* highestRoot = editableRootForPosition(position);
145 node = highestRoot;
146 while (node) {
147 if (node->isContentEditable())
148 highestRoot = node;
149 if (node->hasTagName(bodyTag))
151 node = node->parentNode();
157 Node* lowestEditableAncestor(Node* node)
159 if (!node)
162 Node *lowestRoot = 0;
163 while (node) {
164 if (node->isContentEditable())
165 return node->rootEditableElement();
166 if (node->hasTagName(bodyTag))
168 node = node->parentNode();
176 Node* node = p.node();
177 if (!node)
180 if (node->renderer() && node->renderer()->isTable())
181 node = node->parentNode();
183 return node->isContentEditable();
188 Node* node = pos.node();
189 return (node == editableRootForPosition(pos) || node == enclosingNodeOfType(pos, &isTableCell));
195 Node* node = p.node();
196 if (!node)
199 if (node->renderer() && node->renderer()->isTable())
200 node = node->parentNode();
202 return node->isContentRichlyEditable();
207 Node* node = p.node();
208 if (!node)
211 if (node->renderer() && node->renderer()->isTable())
212 node = node->parentNode();
214 return node->rootEditableElement();
222 // Since enclosingNodeOfType won't search beyond the highest root editable node,
223 // this code works even if the closest table cell was outside of the root editable node.
277 VisiblePosition firstEditablePositionAfterPositionInRoot(const Position& position, Node* highestRoot)
285 if (Node* shadowAncestor = p.node()->shadowAncestorNode())
286 if (shadowAncestor != p.node())
289 while (p.node() && !isEditablePosition(p) && p.node()->isDescendantOf(highestRoot))
290 p = isAtomicNode(p.node()) ? positionInParentAfterNode(p.node()) : nextVisuallyDistinctCandidate(p);
292 if (p.node() && p.node() != highestRoot && !p.node()->isDescendantOf(highestRoot))
298 VisiblePosition lastEditablePositionBeforePositionInRoot(const Position& position, Node* highestRoot)
306 if (Node* shadowAncestor = p.node()->shadowAncestorNode())
307 if (shadowAncestor != p.node())
310 while (p.node() && !isEditablePosition(p) && p.node()->isDescendantOf(highestRoot))
311 p = isAtomicNode(p.node()) ? positionInParentBeforeNode(p.node()) : previousVisuallyDistinctCandidate(p);
313 if (p.node() && p.node() != highestRoot && !p.node()->isDescendantOf(highestRoot))
320 // Whether or not content before and after this node will collapse onto the same line as it.
321 bool isBlock(const Node* node)
323 return node && node->renderer() && !node->renderer()->isInline();
330 Node* enclosingBlock(Node* node)
332 return static_cast<Element*>(enclosingNodeOfType(Position(node, 0), isBlock));
345 Node* node = pos.node();
348 if (node->parentNode() && (editingIgnoresContent(node) || isTableElement(node)))
349 return positionInParentBeforeNode(node);
350 return Position(node, 0);
353 if (node->offsetInCharacters())
354 return Position(node, min(node->maxCharacterOffset(), pos.deprecatedEditingOffset()));
356 int maxCompliantOffset = node->childNodeCount();
358 if (node->parentNode())
359 return positionInParentAfterNode(node);
362 // use the highest allowed position in the node
363 return Position(node, maxCompliantOffset);
367 if ((pos.deprecatedEditingOffset() < maxCompliantOffset) && editingIgnoresContent(node)) {
369 return node->parentNode() ? positionInParentBeforeNode(node) : Position(node, 0);
372 if (pos.deprecatedEditingOffset() == maxCompliantOffset && (editingIgnoresContent(node) || isTableElement(node)))
373 return positionInParentAfterNode(node);
384 // in a node. It returns 1 for some elements even though they do not have children, which
387 int lastOffsetForEditing(const Node* node)
389 ASSERT(node);
390 if (!node)
392 if (node->offsetInCharacters())
393 return node->maxCharacterOffset();
395 if (node->hasChildNodes())
396 return node->childNodeCount();
399 if (editingIgnoresContent(node))
428 bool isTableStructureNode(const Node *node)
430 RenderObject *r = node->renderer();
441 bool isSpecialElement(const Node *n)
500 static Node* firstInSpecialElement(const Position& pos)
502 // FIXME: This begins at pos.node(), which doesn't necessarily contain pos (suppose pos was [img, 0]). See <rdar://problem/5027702>.
503 Node* rootEditableElement = pos.node
504 for (Node* n = pos.node(); n && n->rootEditableElement() == rootEditableElement; n = n->parentNode())
516 static Node* lastInSpecialElement(const Position& pos)
518 // FIXME: This begins at pos.node(), which doesn't necessarily contain pos (suppose pos was [img, 0]). See <rdar://problem/5027702>.
519 Node* rootEditableElement = pos.node()->rootEditableElement();
520 for (Node* n = pos.node(); n && n->rootEditableElement() == rootEditableElement; n = n->parentNode())
537 Position positionBeforeContainingSpecialElement(const Position& pos, Node** containingSpecialElement)
539 Node* n = firstInSpecialElement(pos);
543 if (result.isNull() || result.node()->rootEditableElement() != pos.node()->rootEditableElement())
555 Position positionAfterContainingSpecialElement(const Position& pos, Node **containingSpecialElement)
557 Node* n = lastInSpecialElement(pos);
561 if (result.isNull() || result.node()->rootEditableElement() != pos.node()->rootEditableElement())
568 Position positionOutsideContainingSpecialElement(const Position &pos, Node **containingSpecialElement)
577 Node* isFirstPositionAfterTable(const VisiblePosition& visiblePosition)
580 if (upstream.node() && upstream.node()->renderer() && upstream.node()->renderer()->isTable() && upstream.atLastEditingPositionForNode())
581 return upstream.node();
586 Node* isLastPositionBeforeTable(const VisiblePosition& visiblePosition)
589 if (downstream.node() && downstream.node()->renderer() && downstream.node()->renderer()->isTable() && downstream.atFirstEditingPositionForNode())
590 return downstream.node();
595 // Returns the visible position at the beginning of a node
596 VisiblePosition visiblePositionBeforeNode(Node* node)
598 ASSERT(node);
599 if (node->childNodeCount())
600 return VisiblePosition(node, 0, DOWNSTREAM);
601 ASSERT(node->parentNode());
602 return positionInParentBeforeNode(node);
605 // Returns the visible position at the ending of a node
606 VisiblePosition visiblePositionAfterNode(Node* node)
608 ASSERT(node);
609 if (node->childNodeCount())
610 return VisiblePosition(node, node->childNodeCount(), DOWNSTREAM);
611 ASSERT(node->parentNode());
612 return positionInParentAfterNode(node);
631 // This function stops extending the range immediately below rootNode; i.e. the extended range can contain a child node of rootNode
633 PassRefPtr<Range> extendRangeToWrappingNodes(PassRefPtr<Range> range, const Range* maximumRange, const Node* rootNode)
639 Node* ancestor = range->commonAncestorContainer(ec);// find the cloeset common ancestor
640 Node* highestNode = 0;
650 // Create new range with the highest editable node contained within the range
656 bool isListElement(Node *n)
661 bool isListItem(Node *n)
666 Node* enclosingNodeWithTag(const Position& p, const QualifiedName& tagName)
671 Node* root = highestEditableRoot(p);
672 for (Node* n = p.node(); n; n = n->parentNode()) {
684 Node* enclosingNodeOfType(const Position& p, bool (*nodeIsOfType)(const Node*), bool onlyReturnEditableNodes)
689 Node* root = highestEditableRoot(p);
690 for (Node* n = p.node(); n; n = n->parentNode()) {
691 // Don't return a non-editable node if the input position was editable, since
692 // the callers from editing will no doubt want to perform editing inside the returned node.
704 Node* highestEnclosingNodeOfType(const Position& p, bool (*nodeIsOfType)(const Node*))
706 Node* highest = 0;
707 Node* root = highestEditableRoot(p);
708 for (Node* n = p.node(); n; n = n->parentNode()) {
718 Node* enclosingTableCell(const Position& p)
723 Node* enclosingAnchorElement(const Position& p)
728 Node* node = p.node();
729 while (node && !(node->isElementNode() && node->isLink()))
730 node = node->parentNode();
731 return node;
734 HTMLElement* enclosingList(Node* node)
736 if (!node)
739 Node* root = highestEditableRoot(Position(node, 0));
741 for (Node* n = node->parentNode(); n; n = n->parentNode()) {
751 HTMLElement* enclosingListChild(Node *node)
753 if (!node)
755 // Check for a list item element, or for a node whose parent is a list element. Such a node
757 Node* root = highestEditableRoot(Position(node, 0));
759 // FIXME: This function is inappropriately named if it starts with node instead of node->parentNode()
760 for (Node* n = node; n && n->parentNode(); n = n->parentNode()) {
770 static HTMLElement* embeddedSublist(Node* listItem)
773 for (Node* n = listItem->firstChild(); n; n = n->nextSibling()) {
781 static Node* appendedSublist(Node* listItem)
784 for (Node* n = listItem->nextSibling(); n; n = n->nextSibling()) {
795 Node* enclosingEmptyListItem(const VisiblePosition& visiblePos)
798 Node* listChildNode = enclosingListChild(visiblePos.deepEquivalent().node());
814 HTMLElement* outermostEnclosingList(Node* node)
816 HTMLElement* list = enclosingList(node);
836 Node* highestAncestor(Node* node)
838 ASSERT(node);
839 Node* parent = node;
840 while ((node = node->parentNode()))
841 parent = node;
846 bool isTableElement(Node* n)
855 bool isTableCell(const Node* node)
857 RenderObject* r = node->renderer();
859 return node->hasTagName(tdTag) || node->hasTagName(thTag);
864 bool isEmptyTableCell(const Node* node)
866 return node && node->renderer() && (node->renderer()->isTableCell() || (node->renderer()->isBR() && node->parentNode()->renderer() && node->parentNode()->renderer()->isTableCell()));
904 bool isTabSpanNode(const Node *node)
906 return node && node->hasTagName(spanTag) && node->isElementNode() && static_cast<const Element *>(node)->getAttribute(classAttr) == AppleTabSpanClass;
909 bool isTabSpanTextNode(const Node *node)
911 return node && node->isTextNode() && node->parentNode() && isTabSpanNode(node->parentNode());
914 Node *tabSpanNode(const Node *node)
916 return isTabSpanTextNode(node) ? node->parentNode() : 0;
919 bool isNodeInTextFormControl(Node* node)
921 if (!node)
923 Node* ancestor = node->shadowAncestorNode();
924 if (ancestor == node)
931 Node *node = pos.node();
932 if (isTabSpanTextNode(node))
933 node = tabSpanNode(node);
934 else if (!isTabSpanNode(node))
937 return positionInParentBeforeNode(node);
940 PassRefPtr<Element> createTabSpanElement(Document* document, PassRefPtr<Node> tabTextNode)
965 return createTabSpanElement(document, PassRefPtr<Node>());
968 bool isNodeRendered(const Node *node)
970 if (!node)
973 RenderObject *renderer = node->renderer();
980 Node *nearestMailBlockquote(const Node *node)
982 for (Node *n = const_cast<Node *>(node); n; n = n->parentNode()) {
992 for (Node* n = p.node(); n; n = n->parentNode())
999 bool isMailBlockquote(const Node *node)
1001 if (!node || !node->hasTagName(blockquoteTag))
1004 return static_cast<const Element *>(node)->getAttribute("type") == "cite";
1007 int caretMinOffset(const Node* n)
1014 // If a node can contain candidates for VisiblePositions, return the offset of the last candidate, otherwise
1016 int caretMaxOffset(const Node* n)
1059 if (Node* table = isFirstPositionAfterTable(endOfSelection))
1060 if (startOfSelection.deepEquivalent().node()->isDescendantOf(table))
1067 if (Node* table = isLastPositionBeforeTable(startOfSelection))
1068 if (endOfSelection.deepEquivalent().node()->isDescendantOf(table))
1080 RefPtr<Range> range = Range::create(p.node()->document(), Position(p.node()->document(), 0), rangeCompliantEquivalent(p));
1091 // Determines whether a node is inside a range or visibly starts and ends at the boundaries of the range.
1092 // Call this function to determine whether a node is visibly fit inside selectedRange
1093 bool isNodeVisiblyContainedWithin(Node* node, const Range* selectedRange)
1095 ASSERT(node);
1097 // If the node is inside the range, then it surely is contained within
1099 if (selectedRange->compareNode(node, ec) == Range::NODE_INSIDE)
1102 // If the node starts and ends at where selectedRange starts and ends, the node is contained within
1103 return visiblePositionBeforeNode(node) == selectedRange->startPosition()
1104 && visiblePositionAfterNode(node) == selectedRange->endPosition();
1107 bool isRenderedAsNonInlineTableImageOrHR(const Node* node)
1109 if (!node)
1111 RenderObject* renderer = node->renderer();
1115 PassRefPtr<Range> avoidIntersectionWithNode(const Range* range, Node* node)
1122 Node* startContainer = range->startContainer();
1124 Node* endContainer = range->endContainer();
1132 if (startContainer == node || startContainer->isDescendantOf(node)) {
1133 ASSERT(node->parentNode());
1134 startContainer = node->parentNode();
1135 startOffset = node->nodeIndex();
1137 if (endContainer == node || endContainer->isDescendantOf(node)) {
1138 ASSERT(node->parentNode());
1139 endContainer = node->parentNode();
1140 endOffset = node->nodeIndex();
1146 VisibleSelection avoidIntersectionWithNode(const VisibleSelection& selection, Node* node)
1152 Node* base = selection.base().node();
1153 Node* extent = selection.extent().node();
1157 if (base == node || base->isDescendantOf(node)) {
1158 ASSERT(node->parentNode());
1159 updatedSelection.setBase(Position(node->parentNode(), node->nodeIndex()));
1162 if (extent == node || extent->isDescendantOf(node)) {
1163 ASSERT(node->parentNode());
1164 updatedSelection.setExtent(Position(node->parentNode(), node->nodeIndex()));