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 811 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
822 { | 822 { |
823 return (m_styledInlineElement && element->hasTagName(m_styledInlineElement->
tagQName())) | 823 return (m_styledInlineElement && element->hasTagName(m_styledInlineElement->
tagQName())) |
824 || (m_isInlineElementToRemoveFunction && m_isInlineElementToRemoveFuncti
on(element)); | 824 || (m_isInlineElementToRemoveFunction && m_isInlineElementToRemoveFuncti
on(element)); |
825 } | 825 } |
826 | 826 |
827 bool ApplyStyleCommand::shouldApplyInlineStyleToRun(EditingStyle* style, Node* r
unStart, Node* pastEndNode) | 827 bool ApplyStyleCommand::shouldApplyInlineStyleToRun(EditingStyle* style, Node* r
unStart, Node* pastEndNode) |
828 { | 828 { |
829 ASSERT(style && runStart); | 829 ASSERT(style && runStart); |
830 | 830 |
831 for (Node* node = runStart; node && node != pastEndNode; node = NodeTraversa
l::next(*node)) { | 831 for (Node* node = runStart; node && node != pastEndNode; node = NodeTraversa
l::next(*node)) { |
832 if (node->childNodeCount()) | 832 if (node->hasChildNodes()) |
833 continue; | 833 continue; |
834 // We don't consider m_isInlineElementToRemoveFunction here because we n
ever apply style when m_isInlineElementToRemoveFunction is specified | 834 // We don't consider m_isInlineElementToRemoveFunction here because we n
ever apply style when m_isInlineElementToRemoveFunction is specified |
835 if (!style->styleIsPresentInComputedStyleOfNode(node)) | 835 if (!style->styleIsPresentInComputedStyleOfNode(node)) |
836 return true; | 836 return true; |
837 if (m_styledInlineElement && !enclosingNodeWithTag(positionBeforeNode(no
de), m_styledInlineElement->tagQName())) | 837 if (m_styledInlineElement && !enclosingNodeWithTag(positionBeforeNode(no
de), m_styledInlineElement->tagQName())) |
838 return true; | 838 return true; |
839 } | 839 } |
840 return false; | 840 return false; |
841 } | 841 } |
842 | 842 |
(...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
988 return; | 988 return; |
989 | 989 |
990 RefPtr<EditingStyle> newInlineStyle = style; | 990 RefPtr<EditingStyle> newInlineStyle = style; |
991 if (node->isHTMLElement() && toHTMLElement(node)->inlineStyle()) { | 991 if (node->isHTMLElement() && toHTMLElement(node)->inlineStyle()) { |
992 newInlineStyle = style->copy(); | 992 newInlineStyle = style->copy(); |
993 newInlineStyle->mergeInlineStyleOfElement(toHTMLElement(node), EditingSt
yle::OverrideValues); | 993 newInlineStyle->mergeInlineStyleOfElement(toHTMLElement(node), EditingSt
yle::OverrideValues); |
994 } | 994 } |
995 | 995 |
996 // Since addInlineStyleIfNeeded can't add styles to block-flow render object
s, add style attribute instead. | 996 // Since addInlineStyleIfNeeded can't add styles to block-flow render object
s, add style attribute instead. |
997 // FIXME: applyInlineStyleToRange should be used here instead. | 997 // FIXME: applyInlineStyleToRange should be used here instead. |
998 if ((node->renderer()->isRenderBlockFlow() || node->childNodeCount()) && nod
e->isHTMLElement()) { | 998 if ((node->renderer()->isRenderBlockFlow() || node->hasChildNodes()) && node
->isHTMLElement()) { |
999 setNodeAttribute(toHTMLElement(node), styleAttr, AtomicString(newInlineS
tyle->style()->asText())); | 999 setNodeAttribute(toHTMLElement(node), styleAttr, AtomicString(newInlineS
tyle->style()->asText())); |
1000 return; | 1000 return; |
1001 } | 1001 } |
1002 | 1002 |
1003 if (node->renderer()->isText() && toRenderText(node->renderer())->isAllColla
psibleWhitespace()) | 1003 if (node->renderer()->isText() && toRenderText(node->renderer())->isAllColla
psibleWhitespace()) |
1004 return; | 1004 return; |
1005 | 1005 |
1006 // We can't wrap node with the styled element here because new styled elemen
t will never be removed if we did. | 1006 // We can't wrap node with the styled element here because new styled elemen
t will never be removed if we did. |
1007 // If we modified the child pointer in pushDownInlineStyleAroundNode to poin
t to new style element | 1007 // If we modified the child pointer in pushDownInlineStyleAroundNode to poin
t to new style element |
1008 // then we fall into an infinite loop where we keep removing and adding styl
ed element wrapping node. | 1008 // then we fall into an infinite loop where we keep removing and adding styl
ed element wrapping node. |
(...skipping 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1402 ASSERT(startNode->inDocument()); | 1402 ASSERT(startNode->inDocument()); |
1403 ASSERT(endNode->inDocument()); | 1403 ASSERT(endNode->inDocument()); |
1404 | 1404 |
1405 // Find appropriate font and span elements top-down. | 1405 // Find appropriate font and span elements top-down. |
1406 HTMLElement* fontContainer = 0; | 1406 HTMLElement* fontContainer = 0; |
1407 HTMLElement* styleContainer = 0; | 1407 HTMLElement* styleContainer = 0; |
1408 for (Node* container = startNode.get(); container && startNode == endNode; c
ontainer = container->firstChild()) { | 1408 for (Node* container = startNode.get(); container && startNode == endNode; c
ontainer = container->firstChild()) { |
1409 if (container->isHTMLElement() && container->hasTagName(fontTag)) | 1409 if (container->isHTMLElement() && container->hasTagName(fontTag)) |
1410 fontContainer = toHTMLElement(container); | 1410 fontContainer = toHTMLElement(container); |
1411 bool styleContainerIsNotSpan = !styleContainer || !styleContainer->hasTa
gName(spanTag); | 1411 bool styleContainerIsNotSpan = !styleContainer || !styleContainer->hasTa
gName(spanTag); |
1412 if (container->isHTMLElement() && (container->hasTagName(spanTag) || (st
yleContainerIsNotSpan && container->childNodeCount()))) | 1412 if (container->isHTMLElement()) { |
1413 styleContainer = toHTMLElement(container); | 1413 HTMLElement* containerElement = toHTMLElement(container); |
| 1414 if (containerElement->hasTagName(spanTag) || (styleContainerIsNotSpa
n && containerElement->hasChildNodes())) |
| 1415 styleContainer = toHTMLElement(container); |
| 1416 } |
1414 if (!container->firstChild()) | 1417 if (!container->firstChild()) |
1415 break; | 1418 break; |
1416 startNode = container->firstChild(); | 1419 startNode = container->firstChild(); |
1417 endNode = container->lastChild(); | 1420 endNode = container->lastChild(); |
1418 } | 1421 } |
1419 | 1422 |
1420 // Font tags need to go outside of CSS so that CSS font sizes override leagc
y font sizes. | 1423 // Font tags need to go outside of CSS so that CSS font sizes override leagc
y font sizes. |
1421 if (styleChange.applyFontColor() || styleChange.applyFontFace() || styleChan
ge.applyFontSize()) { | 1424 if (styleChange.applyFontColor() || styleChange.applyFontFace() || styleChan
ge.applyFontSize()) { |
1422 if (fontContainer) { | 1425 if (fontContainer) { |
1423 if (styleChange.applyFontColor()) | 1426 if (styleChange.applyFontColor()) |
(...skipping 102 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1526 String textToMove = nextText->data(); | 1529 String textToMove = nextText->data(); |
1527 insertTextIntoNode(childText, childText->length(), textToMove); | 1530 insertTextIntoNode(childText, childText->length(), textToMove); |
1528 removeNode(next); | 1531 removeNode(next); |
1529 // don't move child node pointer. it may want to merge with more text no
des. | 1532 // don't move child node pointer. it may want to merge with more text no
des. |
1530 } | 1533 } |
1531 | 1534 |
1532 updateStartEnd(newStart, newEnd); | 1535 updateStartEnd(newStart, newEnd); |
1533 } | 1536 } |
1534 | 1537 |
1535 } | 1538 } |
OLD | NEW |