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 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
700 | 700 |
701 Node* sibling = node->traverseNextSibling(); | 701 Node* sibling = node->traverseNextSibling(); |
702 for (Node* descendent = node->firstChild(); descendent && descendent != sibl
ing; descendent = descendent->traverseNextNode()) { | 702 for (Node* descendent = node->firstChild(); descendent && descendent != sibl
ing; descendent = descendent->traverseNextNode()) { |
703 if (!descendent->rendererIsEditable()) | 703 if (!descendent->rendererIsEditable()) |
704 return true; | 704 return true; |
705 } | 705 } |
706 | 706 |
707 return false; | 707 return false; |
708 } | 708 } |
709 | 709 |
710 void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle* style, Node* n
ode, Node* pastEndNode) | 710 void ApplyStyleCommand::applyInlineStyleToNodeRange(EditingStyle* style, PassRef
Ptr<Node> startNode, PassRefPtr<Node> pastEndNode) |
711 { | 711 { |
712 if (m_removeOnly) | 712 if (m_removeOnly) |
713 return; | 713 return; |
714 | 714 |
715 for (RefPtr<Node> next; node && node != pastEndNode; node = next.get()) { | 715 RefPtr<Node> node = startNode; |
| 716 for (RefPtr<Node> next; node && node != pastEndNode; node = next) { |
716 next = node->traverseNextNode(); | 717 next = node->traverseNextNode(); |
717 | 718 |
718 if (!node->renderer() || !node->rendererIsEditable()) | 719 if (!node->renderer() || !node->rendererIsEditable()) |
719 continue; | 720 continue; |
720 | 721 |
721 if (!node->rendererIsRichlyEditable() && node->isHTMLElement()) { | 722 if (!node->rendererIsRichlyEditable() && node->isHTMLElement()) { |
722 // This is a plaintext-only region. Only proceed if it's fully selec
ted. | 723 // This is a plaintext-only region. Only proceed if it's fully selec
ted. |
723 // pastEndNode is the node after the last fully selected node, so if
it's inside node then | 724 // pastEndNode is the node after the last fully selected node, so if
it's inside node then |
724 // node isn't fully selected. | 725 // node isn't fully selected. |
725 if (pastEndNode && pastEndNode->isDescendantOf(node)) | 726 if (pastEndNode && pastEndNode->isDescendantOf(node.get())) |
726 break; | 727 break; |
727 // Add to this element's inline style and skip over its contents. | 728 // Add to this element's inline style and skip over its contents. |
728 HTMLElement* element = toHTMLElement(node); | 729 HTMLElement* element = toHTMLElement(node.get()); |
729 RefPtr<CSSMutableStyleDeclaration> inlineStyle = element->ensureInli
neStyleDecl()->copy(); | 730 RefPtr<CSSMutableStyleDeclaration> inlineStyle = element->ensureInli
neStyleDecl()->copy(); |
730 inlineStyle->merge(style->style()); | 731 inlineStyle->merge(style->style()); |
731 setNodeAttribute(element, styleAttr, inlineStyle->asText()); | 732 setNodeAttribute(element, styleAttr, inlineStyle->asText()); |
732 next = node->traverseNextSibling(); | 733 next = node->traverseNextSibling(); |
733 continue; | 734 continue; |
734 } | 735 } |
735 | 736 |
736 if (isBlock(node)) | 737 if (isBlock(node.get())) |
737 continue; | 738 continue; |
738 | 739 |
739 if (node->childNodeCount()) { | 740 if (node->childNodeCount()) { |
740 if (node->contains(pastEndNode) || containsNonEditableRegion(node) |
| !node->parentNode()->rendererIsEditable()) | 741 if (node->contains(pastEndNode.get()) || containsNonEditableRegion(n
ode.get()) || !node->parentNode()->rendererIsEditable()) |
741 continue; | 742 continue; |
742 if (editingIgnoresContent(node)) { | 743 if (editingIgnoresContent(node.get())) { |
743 next = node->traverseNextSibling(); | 744 next = node->traverseNextSibling(); |
744 continue; | 745 continue; |
745 } | 746 } |
746 } | 747 } |
747 | 748 |
748 RefPtr<Node> runStart = node; | 749 RefPtr<Node> runStart = node; |
749 RefPtr<Node> runEnd = node; | 750 RefPtr<Node> runEnd = node; |
750 Node* sibling = node->nextSibling(); | 751 Node* sibling = node->nextSibling(); |
751 while (sibling && sibling != pastEndNode && !sibling->contains(pastEndNo
de) | 752 while (sibling && sibling != pastEndNode && !sibling->contains(pastEndNo
de.get()) |
752 && (!isBlock(sibling) || sibling->hasTagName(brTag)) | 753 && (!isBlock(sibling) || sibling->hasTagName(brTag)) |
753 && !containsNonEditableRegion(sibling)) { | 754 && !containsNonEditableRegion(sibling)) { |
754 runEnd = sibling; | 755 runEnd = sibling; |
755 sibling = runEnd->nextSibling(); | 756 sibling = runEnd->nextSibling(); |
756 } | 757 } |
757 next = runEnd->traverseNextSibling(); | 758 next = runEnd->traverseNextSibling(); |
758 | 759 |
759 if (!removeStyleFromRunBeforeApplyingStyle(style, runStart, runEnd)) | 760 if (!removeStyleFromRunBeforeApplyingStyle(style, runStart, runEnd)) |
760 continue; | 761 continue; |
761 addInlineStyleIfNeeded(style, runStart.get(), runEnd.get(), AddStyledEle
ment); | 762 addInlineStyleIfNeeded(style, runStart.get(), runEnd.get(), AddStyledEle
ment); |
(...skipping 687 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1449 } | 1450 } |
1450 else { | 1451 else { |
1451 child = child->nextSibling(); | 1452 child = child->nextSibling(); |
1452 } | 1453 } |
1453 } | 1454 } |
1454 | 1455 |
1455 updateStartEnd(newStart, newEnd); | 1456 updateStartEnd(newStart, newEnd); |
1456 } | 1457 } |
1457 | 1458 |
1458 } | 1459 } |
OLD | NEW |