Lines Matching full:node
104 Document* document = position.node() ? position.node()->document() : 0;
116 if (isTabSpanTextNode(position.node()) || isTabSpanNode((position.node())))
266 bool isStyleSpan(const Node *node)
268 if (!node || !node->isHTMLElement())
271 const HTMLElement* elem = static_cast<const HTMLElement*>(node);
275 static bool isUnstyledStyleSpan(const Node* node)
277 if (!node || !node->isHTMLElement() || !node->hasTagName(spanTag))
280 const HTMLElement* elem = static_cast<const HTMLElement*>(node);
285 static bool isSpanWithoutAttributesOrUnstyleStyleSpan(const Node* node)
287 if (!node || !node->isHTMLElement() || !node->hasTagName(spanTag))
290 const HTMLElement* elem = static_cast<const HTMLElement*>(node);
295 return isUnstyledStyleSpan(node);
298 static bool isEmptyFontTag(const Node *node)
300 if (!node || !node->hasTagName(fontTag))
303 const Element *elem = static_cast<const Element *>(node);
428 if (style && pos.node() && pos.node()->computedStyle()) {
429 RenderStyle* renderStyle = pos.node()->computedStyle();
430 // If a node's text fill color is invalid, then its children use
444 CSSMutableStyleDeclaration* typingStyle = pos.node()->document()->frame()->typingStyle();
471 void removeStylesAddedByNode(CSSMutableStyleDeclaration* editingStyle, Node* node)
473 ASSERT(node);
474 ASSERT(node->parentNode());
475 RefPtr<CSSMutableStyleDeclaration> parentStyle = editingStyleAtPosition(Position(node->parentNode(), 0));
476 RefPtr<CSSMutableStyleDeclaration> style = editingStyleAtPosition(Position(node, 0));
599 Node* scope = highestAncestor(visibleStart.deepEquivalent().node());
612 RefPtr<Node> block = enclosingBlock(paragraphStart.deepEquivalent().node());
613 RefPtr<Node> newBlock = moveParagraphContentsToNewBlockIfNecessary(paragraphStart.deepEquivalent());
671 if (start.node()->isTextNode()) {
672 joinChildTextNodes(start.node()->parentNode(), start, end);
676 if (end.node()->isTextNode() && start.node()->parentNode() != end.node()->parentNode()) {
677 joinChildTextNodes(end.node()->parentNode(), start, end);
695 // If the end node is before the start node (can only happen if the end node is
696 // an ancestor of the start node), we gather nodes up to the next sibling of the end node
697 Node *beyondEnd;
698 if (start.node()->isDescendantOf(end.node()))
699 beyondEnd = end.node()->traverseNextSibling();
701 beyondEnd = end.node()->traverseNextNode();
704 Node *startNode = start.node();
705 if (startNode->isTextNode() && start.deprecatedEditingOffset() >= caretMaxOffset(startNode)) // Move out of text node if range does not include its characters.
709 // This ensures that changes to one node won't effect another.
710 HashMap<Node*, float> startingFontSizes;
711 for (Node *node = startNode; node != beyondEnd; node = node->traverseNextNode())
712 startingFontSizes.set(node, computedFontSize(node));
717 Node* lastStyledNode = 0;
718 for (Node* node = startNode; node != beyondEnd; node = node->traverseNextNode()) {
720 if (node->isHTMLElement()) {
722 if (!nodeFullySelected(node, start, end))
724 element = static_cast<HTMLElement*>(node);
725 } else if (node->isTextNode() && node->renderer() && node->parentNode() != lastStyledNode) {
726 // Last styled node was not parent node of this text node, but we wish to style this
727 // text node. To make this possible, add a style span to surround this text node.
729 surroundNodeRangeWithElement(node, node, span.get());
735 lastStyledNode = node;
738 float currentFontSize = computedFontSize(node);
739 float desiredFontSize = max(MinimumFontSize, startingFontSizes.get(node) + adjustment);
743 currentFontSize = computedFontSize(node);
765 static Node* dummySpanAncestorForNode(const Node* node)
767 while (node && !isStyleSpan(node))
768 node = node->parent();
770 return node ? node->parent() : 0;
773 void ApplyStyleCommand::cleanupUnstyledAppleStyleSpans(Node* dummySpanAncestor)
778 // Dummy spans are created when text node is split, so that style information
780 // cloned/split, the new node is always a sibling of it. Therefore, we scan
782 Node* next;
783 for (Node* node = dummySpanAncestor->firstChild(); node; node = next) {
784 next = node->nextSibling();
785 if (isUnstyledStyleSpan(node))
786 removeNodePreservingChildren(node);
787 node = next;
791 HTMLElement* ApplyStyleCommand::splitAncestorsWithUnicodeBidi(Node* node, bool before, RefPtr<CSSPrimitiveValue> allowedDirection)
795 Node* block = enclosingBlock(node);
799 Node* highestAncestorWithUnicodeBidi = 0;
800 Node* nextHighestAncestorWithUnicodeBidi = 0;
802 for (Node* n = node->parent(); n != block; n = n->parent()) {
832 Node* n = node;
844 void ApplyStyleCommand::removeEmbeddingUpToEnclosingBlock(Node* node, Node* unsplitAncestor)
846 Node* block = enclosingBlock(node);
850 Node* n = node->parent();
852 Node* parent = n->parent();
888 Node* startDummySpanAncestor = 0;
889 Node* endDummySpanAncestor = 0;
905 // split the start node and containing element if the selection starts inside of it
910 startDummySpanAncestor = dummySpanAncestorForNode(start.node());
913 // split the end node and containing element if the selection ends inside of it
918 endDummySpanAncestor = dummySpanAncestorForNode(end.node());
934 startUnsplitAncestor = splitAncestorsWithUnicodeBidi(start.node(), true, allowedDirection);
935 endUnsplitAncestor = splitAncestorsWithUnicodeBidi(end.node(), false, allowedDirection);
936 removeEmbeddingUpToEnclosingBlock(start.node(), startUnsplitAncestor);
937 removeEmbeddingUpToEnclosingBlock(end.node(), endUnsplitAncestor);
996 Node* startEnclosingBlock = enclosingBlock(start.node());
997 for (Node* n = start.node(); n != startEnclosingBlock; n = n->parent()) {
1010 Node* endEnclosingBlock = enclosingBlock(end.node());
1011 for (Node* n = end.node(); n != endEnclosingBlock; n = n->parent()) {
1048 Node* node = start.node();
1053 if (start.deprecatedEditingOffset() >= caretMaxOffset(start.node())) {
1054 node = node->traverseNextNode();
1055 Position newStart = Position(node, 0);
1056 if (!node || comparePositions(end, newStart) < 0)
1061 // pastEndNode is the node after the last fully selected node.
1062 Node* pastEndNode = end.node();
1063 if (end.deprecatedEditingOffset() >= caretMaxOffset(end.node()))
1064 pastEndNode = end.node()->traverseNextSibling();
1067 if (start == end && start.node()->hasTagName(brTag))
1068 pastEndNode = start.node()->traverseNextNode();
1070 for (Node* next; node && node != pastEndNode; node = next) {
1072 next = node->traverseNextNode();
1074 if (!node->renderer() || !node->isContentEditable())
1077 if (!node->isContentRichlyEditable() && node->isHTMLElement()) {
1079 // pastEndNode is the node after the last fully selected node, so if it's inside node then
1080 // node isn't fully selected.
1081 if (pastEndNode && pastEndNode->isDescendantOf(node))
1084 HTMLElement* element = static_cast<HTMLElement*>(node);
1088 next = node->traverseNextSibling();
1092 if (isBlock(node))
1095 if (node->childNodeCount()) {
1096 if (editingIgnoresContent(node)) {
1097 next = node->traverseNextSibling();
1103 Node* runStart = node;
1105 Node* sibling = node->nextSibling();
1107 node = sibling;
1108 sibling = node->nextSibling();
1110 // Recompute next, since node has changed.
1111 next = node->traverseNextNode();
1113 addInlineStyleIfNeeded(style, runStart, node);
1129 // Remove node if it implicitly adds style not present in styleToApply
1269 static bool hasTextDecorationProperty(Node *node)
1271 if (!node->isElementNode())
1274 RefPtr<CSSValue> value = computedStyle(node)->getPropertyCSSValue(CSSPropertyTextDecoration, DoNotUpdateLayout);
1278 static Node* highestAncestorWithTextDecoration(Node *node)
1280 ASSERT(node);
1281 Node* result = 0;
1282 Node* unsplittableElement = unsplittableElementForPosition(Position(node, 0));
1284 for (Node *n = node; n; n = n->parentNode()) {
1296 PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractTextDecorationStyle(Node* node)
1298 ASSERT(node);
1299 ASSERT(node->isElementNode());
1302 if (!node->isHTMLElement())
1305 HTMLElement *element = static_cast<HTMLElement *>(node);
1320 PassRefPtr<CSSMutableStyleDeclaration> ApplyStyleCommand::extractAndNegateTextDecorationStyle(Node* node)
1322 ASSERT(node);
1323 ASSERT(node->isElementNode());
1326 if (!node->isHTMLElement())
1329 RefPtr<CSSComputedStyleDeclaration> nodeStyle = computedStyle(node);
1339 applyTextDecorationStyle(node, newStyle.get());
1345 void ApplyStyleCommand::applyTextDecorationStyle(Node *node, CSSMutableStyleDeclaration *style)
1347 ASSERT(node);
1352 StyleChange styleChange(style, Position(node, 0));
1354 if (node->isTextNode()) {
1356 surroundNodeRangeWithElement(node, node, styleSpan.get());
1357 node = styleSpan.get();
1360 if (!node->isElementNode())
1363 HTMLElement *element = static_cast<HTMLElement *>(node);
1372 surroundNodeRangeWithElement(node, node, createHTMLElement(document(), uTag));
1375 surroundNodeRangeWithElement(node, node, createHTMLElement(document(), sTag));
1378 void ApplyStyleCommand::pushDownTextDecorationStyleAroundNode(Node* targetNode, bool forceNegate)
1381 Node* highestAncestor = highestAncestorWithTextDecoration(targetNode);
1386 Node* current = highestAncestor;
1393 Node* child = current->firstChild();
1395 Node* nextChild = child->nextSibling();
1401 // We found the next node for the outer loop (contains targetNode)
1418 pushDownTextDecorationStyleAroundNode(start.node(), false);
1420 pushDownTextDecorationStyleAroundNode(start.node(), true);
1422 pushDownTextDecorationStyleAroundNode(end.node(), false);
1424 pushDownTextDecorationStyleAroundNode(end.node(), true);
1428 static int maxRangeOffset(Node *n)
1443 ASSERT(start.node()->inDocument());
1444 ASSERT(end.node()->inDocument());
1456 // takes place. This will help callers to recognize when either the start node or the end node
1461 Node* node = start.node();
1462 while (node) {
1463 Node* next = node->traverseNextNode();
1464 if (node->isHTMLElement() && nodeFullySelected(node, start, end)) {
1465 HTMLElement* elem = static_cast<HTMLElement*>(node);
1466 Node* prev = elem->traversePreviousNodePostOrder();
1467 Node* next = elem->traverseNextNode();
1474 // If the node was converted to a span, the span may still contain relevant
1482 if (s.node() == elem) {
1485 ASSERT(s.deprecatedEditingOffset() <= caretMinOffset(s.node()));
1488 if (e.node() == elem) {
1492 ASSERT(e.deprecatedEditingOffset() >= maxRangeOffset(e.node()));
1497 if (node == end.node())
1499 node = next;
1502 ASSERT(s.node()->inDocument());
1503 ASSERT(e.node()->inDocument());
1507 bool ApplyStyleCommand::nodeFullySelected(Node *node, const Position &start, const Position &end) const
1509 ASSERT(node);
1510 ASSERT(node->isElementNode());
1512 Position pos = Position(node, node->childNodeCount()).upstream();
1513 return comparePositions(Position(node, 0), start) >= 0 && comparePositions(pos, end) <= 0;
1516 bool ApplyStyleCommand::nodeFullyUnselected(Node *node, const Position &start, const Position &end) const
1518 ASSERT(node);
1519 ASSERT(node->isElementNode());
1521 Position pos = Position(node, node->childNodeCount()).upstream();
1523 bool isFullyAfterEnd = comparePositions(Position(node, 0), end) > 0;
1531 if (start.node()->isTextNode() && start.deprecatedEditingOffset() > caretMinOffset(start.node()) && start.deprecatedEditingOffset() < caretMaxOffset(start.node())) {
1532 int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
1533 Text *text = static_cast<Text *>(start.node());
1535 updateStartEnd(Position(start.node(), 0), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
1543 if (end.node()->isTextNode() && end.deprecatedEditingOffset() > caretMinOffset(end.node()) && end.deprecatedEditingOffset() < caretMaxOffset(end.node())) {
1544 Text *text = static_cast<Text *>(end.node());
1547 Node *prevNode = text->previousSibling();
1549 Node *startNode = start.node() == end.node() ? prevNode : start.node();
1559 if (start.node()->isTextNode() && start.deprecatedEditingOffset() > caretMinOffset(start.node()) && start.deprecatedEditingOffset() < caretMaxOffset(start.node())) {
1560 int endOffsetAdjustment = start.node() == end.node() ? start.deprecatedEditingOffset() : 0;
1561 Text *text = static_cast<Text *>(start.node());
1564 updateStartEnd(Position(start.node()->parentNode(), start.node()->nodeIndex()), Position(end.node(), end.deprecatedEditingOffset() - endOffsetAdjustment));
1572 if (end.node()->isTextNode() && end.deprecatedEditingOffset() > caretMinOffset(end.node()) && end.deprecatedEditingOffset() < caretMaxOffset(end.node())) {
1573 Text *text = static_cast<Text *>(end.node());
1576 Node *prevNode = text->parent()->previousSibling()->lastChild();
1578 Node *startNode = start.node() == end.node() ? prevNode : start.node();
1586 static bool areIdenticalElements(Node *first, Node *second)
1623 Node *startNode = start.node();
1626 if (isAtomicNode(start.node())) {
1632 if (start.node()->previousSibling())
1635 startNode = start.node()->parent();
1645 Node *previousSibling = startNode->previousSibling();
1650 Node *startChild = element->firstChild();
1655 int endOffsetAdjustment = startNode == end.node() ? startOffsetAdjustment : 0;
1656 updateStartEnd(Position(startNode, startOffsetAdjustment), Position(end.node(), end.deprecatedEditingOffset() + endOffsetAdjustment));
1665 Node *endNode = end.node();
1672 unsigned parentLastOffset = end.node()->parent()->childNodes()->length() - 1;
1673 if (end.node()->nextSibling())
1676 endNode = end.node()->parent();
1683 Node *nextSibling = endNode->nextSibling();
1688 Node *nextChild = nextElement->firstChild();
1692 Node *startNode = start.node() == endNode ? nextElement : start.node();
1703 void ApplyStyleCommand::surroundNodeRangeWithElement(Node* startNode, Node* endNode, PassRefPtr<Element> elementToInsert)
1712 Node* node = startNode;
1714 Node* next = node->traverseNextNode();
1715 if (node->childNodeCount() == 0 && node->renderer() && node->renderer()->isInline()) {
1716 removeNode(node);
1717 appendNode(node, element);
1719 if (node == endNode)
1721 node = next;
1724 Node* nextSibling = element->nextSibling();
1725 Node* previousSibling = element->previousSibling();
1731 Node* mergedElement = previousSibling->nextSibling();
1737 // FIXME: We should probably call updateStartEnd if the start or end was in the node
1783 void ApplyStyleCommand::addInlineStyleIfNeeded(CSSMutableStyleDeclaration *style, Node *startNode, Node *endNode)
1798 // text somehow. Otherwise it will be a garbage node that will create problems for us
1840 float ApplyStyleCommand::computedFontSize(const Node *node)
1842 if (!node)
1845 Position pos(const_cast<Node *>(node), 0);
1857 void ApplyStyleCommand::joinChildTextNodes(Node *node, const Position &start, const Position &end)
1859 if (!node)
1865 Node *child = node->firstChild();
1867 Node *next = child->nextSibling();
1871 if (next == start.node())
1873 if (next == end.node())
1878 // don't move child node pointer. it may want to merge with more text nodes.