| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005, 2006, 2008, 2009 Apple Inc. All rights reserved. | 2 * Copyright (C) 2005, 2006, 2008, 2009 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 924 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 935 { | 935 { |
| 936 DCHECK(style); | 936 DCHECK(style); |
| 937 DCHECK(runStart); | 937 DCHECK(runStart); |
| 938 | 938 |
| 939 for (Node* node = runStart; node && node != pastEndNode; node = NodeTraversa
l::next(*node)) { | 939 for (Node* node = runStart; node && node != pastEndNode; node = NodeTraversa
l::next(*node)) { |
| 940 if (node->hasChildren()) | 940 if (node->hasChildren()) |
| 941 continue; | 941 continue; |
| 942 // We don't consider m_isInlineElementToRemoveFunction here because we n
ever apply style when m_isInlineElementToRemoveFunction is specified | 942 // We don't consider m_isInlineElementToRemoveFunction here because we n
ever apply style when m_isInlineElementToRemoveFunction is specified |
| 943 if (!style->styleIsPresentInComputedStyleOfNode(node)) | 943 if (!style->styleIsPresentInComputedStyleOfNode(node)) |
| 944 return true; | 944 return true; |
| 945 if (m_styledInlineElement && !enclosingElementWithTag(positionBeforeNode
(node), m_styledInlineElement->tagQName())) | 945 if (m_styledInlineElement && !enclosingElementWithTag(Position::beforeNo
de(node), m_styledInlineElement->tagQName())) |
| 946 return true; | 946 return true; |
| 947 } | 947 } |
| 948 return false; | 948 return false; |
| 949 } | 949 } |
| 950 | 950 |
| 951 void ApplyStyleCommand::removeConflictingInlineStyleFromRun(EditingStyle* style,
Member<Node>& runStart, Member<Node>& runEnd, Node* pastEndNode, EditingState*
editingState) | 951 void ApplyStyleCommand::removeConflictingInlineStyleFromRun(EditingStyle* style,
Member<Node>& runStart, Member<Node>& runEnd, Node* pastEndNode, EditingState*
editingState) |
| 952 { | 952 { |
| 953 DCHECK(runStart); | 953 DCHECK(runStart); |
| 954 DCHECK(runEnd); | 954 DCHECK(runEnd); |
| 955 Node* next = runStart; | 955 Node* next = runStart; |
| (...skipping 381 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1337 { | 1337 { |
| 1338 DCHECK(start.computeContainerNode()->isTextNode()) << start; | 1338 DCHECK(start.computeContainerNode()->isTextNode()) << start; |
| 1339 | 1339 |
| 1340 Position newEnd; | 1340 Position newEnd; |
| 1341 if (start.computeContainerNode() == end.computeContainerNode()) | 1341 if (start.computeContainerNode() == end.computeContainerNode()) |
| 1342 newEnd = Position(end.computeContainerNode(), end.offsetInContainerNode(
) - start.offsetInContainerNode()); | 1342 newEnd = Position(end.computeContainerNode(), end.offsetInContainerNode(
) - start.offsetInContainerNode()); |
| 1343 else | 1343 else |
| 1344 newEnd = end; | 1344 newEnd = end; |
| 1345 | 1345 |
| 1346 splitTextNodeContainingElement(toText(start.computeContainerNode()), start.o
ffsetInContainerNode()); | 1346 splitTextNodeContainingElement(toText(start.computeContainerNode()), start.o
ffsetInContainerNode()); |
| 1347 updateStartEnd(positionBeforeNode(start.computeContainerNode()), newEnd); | 1347 updateStartEnd(Position::beforeNode(start.computeContainerNode()), newEnd); |
| 1348 } | 1348 } |
| 1349 | 1349 |
| 1350 void ApplyStyleCommand::splitTextElementAtEnd(const Position& start, const Posit
ion& end) | 1350 void ApplyStyleCommand::splitTextElementAtEnd(const Position& start, const Posit
ion& end) |
| 1351 { | 1351 { |
| 1352 DCHECK(end.computeContainerNode()->isTextNode()) << end; | 1352 DCHECK(end.computeContainerNode()->isTextNode()) << end; |
| 1353 | 1353 |
| 1354 bool shouldUpdateStart = start.computeContainerNode() == end.computeContaine
rNode(); | 1354 bool shouldUpdateStart = start.computeContainerNode() == end.computeContaine
rNode(); |
| 1355 splitTextNodeContainingElement(toText(end.computeContainerNode()), end.offse
tInContainerNode()); | 1355 splitTextNodeContainingElement(toText(end.computeContainerNode()), end.offse
tInContainerNode()); |
| 1356 | 1356 |
| 1357 Node* parentElement = end.computeContainerNode()->parentNode(); | 1357 Node* parentElement = end.computeContainerNode()->parentNode(); |
| (...skipping 191 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1549 } | 1549 } |
| 1550 | 1550 |
| 1551 applyInlineStyleChange(start, passedEnd, styleChange, DoNotAddStyledElement,
editingState); | 1551 applyInlineStyleChange(start, passedEnd, styleChange, DoNotAddStyledElement,
editingState); |
| 1552 } | 1552 } |
| 1553 | 1553 |
| 1554 Position ApplyStyleCommand::positionToComputeInlineStyleChange(Node* startNode,
Member<HTMLSpanElement>& dummyElement, EditingState* editingState) | 1554 Position ApplyStyleCommand::positionToComputeInlineStyleChange(Node* startNode,
Member<HTMLSpanElement>& dummyElement, EditingState* editingState) |
| 1555 { | 1555 { |
| 1556 // It's okay to obtain the style at the startNode because we've removed all
relevant styles from the current run. | 1556 // It's okay to obtain the style at the startNode because we've removed all
relevant styles from the current run. |
| 1557 if (!startNode->isElementNode()) { | 1557 if (!startNode->isElementNode()) { |
| 1558 dummyElement = HTMLSpanElement::create(document()); | 1558 dummyElement = HTMLSpanElement::create(document()); |
| 1559 insertNodeAt(dummyElement, positionBeforeNode(startNode), editingState); | 1559 insertNodeAt(dummyElement, Position::beforeNode(startNode), editingState
); |
| 1560 if (editingState->isAborted()) | 1560 if (editingState->isAborted()) |
| 1561 return Position(); | 1561 return Position(); |
| 1562 return positionBeforeNode(dummyElement); | 1562 return Position::beforeNode(dummyElement); |
| 1563 } | 1563 } |
| 1564 | 1564 |
| 1565 return firstPositionInOrBeforeNode(startNode); | 1565 return firstPositionInOrBeforeNode(startNode); |
| 1566 } | 1566 } |
| 1567 | 1567 |
| 1568 void ApplyStyleCommand::applyInlineStyleChange(Node* passedStart, Node* passedEn
d, StyleChange& styleChange, EAddStyledElement addStyledElement, EditingState* e
ditingState) | 1568 void ApplyStyleCommand::applyInlineStyleChange(Node* passedStart, Node* passedEn
d, StyleChange& styleChange, EAddStyledElement addStyledElement, EditingState* e
ditingState) |
| 1569 { | 1569 { |
| 1570 Node* startNode = passedStart; | 1570 Node* startNode = passedStart; |
| 1571 Node* endNode = passedEnd; | 1571 Node* endNode = passedEnd; |
| 1572 DCHECK(startNode->inShadowIncludingDocument()) << startNode; | 1572 DCHECK(startNode->inShadowIncludingDocument()) << startNode; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1731 DEFINE_TRACE(ApplyStyleCommand) | 1731 DEFINE_TRACE(ApplyStyleCommand) |
| 1732 { | 1732 { |
| 1733 visitor->trace(m_style); | 1733 visitor->trace(m_style); |
| 1734 visitor->trace(m_start); | 1734 visitor->trace(m_start); |
| 1735 visitor->trace(m_end); | 1735 visitor->trace(m_end); |
| 1736 visitor->trace(m_styledInlineElement); | 1736 visitor->trace(m_styledInlineElement); |
| 1737 CompositeEditCommand::trace(visitor); | 1737 CompositeEditCommand::trace(visitor); |
| 1738 } | 1738 } |
| 1739 | 1739 |
| 1740 } // namespace blink | 1740 } // namespace blink |
| OLD | NEW |