| 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 377 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 388 | 388 |
| 389 Node* lastStyledNode = nullptr; | 389 Node* lastStyledNode = nullptr; |
| 390 for (Node* node = startNode; node != beyondEnd; node = NodeTraversal::next(*
node)) { | 390 for (Node* node = startNode; node != beyondEnd; node = NodeTraversal::next(*
node)) { |
| 391 ASSERT(node); | 391 ASSERT(node); |
| 392 RefPtrWillBeRawPtr<HTMLElement> element = nullptr; | 392 RefPtrWillBeRawPtr<HTMLElement> element = nullptr; |
| 393 if (node->isHTMLElement()) { | 393 if (node->isHTMLElement()) { |
| 394 // Only work on fully selected nodes. | 394 // Only work on fully selected nodes. |
| 395 if (!elementFullySelected(toHTMLElement(*node), start, end)) | 395 if (!elementFullySelected(toHTMLElement(*node), start, end)) |
| 396 continue; | 396 continue; |
| 397 element = toHTMLElement(node); | 397 element = toHTMLElement(node); |
| 398 } else if (node->isTextNode() && node->renderer() && node->parentNode()
!= lastStyledNode) { | 398 } else if (node->isTextNode() && node->layoutObject() && node->parentNod
e() != lastStyledNode) { |
| 399 // Last styled node was not parent node of this text node, but we wi
sh to style this | 399 // Last styled node was not parent node of this text node, but we wi
sh to style this |
| 400 // text node. To make this possible, add a style span to surround th
is text node. | 400 // text node. To make this possible, add a style span to surround th
is text node. |
| 401 RefPtrWillBeRawPtr<HTMLSpanElement> span = createStyleSpanElement(do
cument()); | 401 RefPtrWillBeRawPtr<HTMLSpanElement> span = createStyleSpanElement(do
cument()); |
| 402 surroundNodeRangeWithElement(node, node, span.get()); | 402 surroundNodeRangeWithElement(node, node, span.get()); |
| 403 element = span.release(); | 403 element = span.release(); |
| 404 } else { | 404 } else { |
| 405 // Only handle HTML elements and text nodes. | 405 // Only handle HTML elements and text nodes. |
| 406 continue; | 406 continue; |
| 407 } | 407 } |
| 408 lastStyledNode = node; | 408 lastStyledNode = node; |
| (...skipping 369 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 778 if (m_removeOnly) | 778 if (m_removeOnly) |
| 779 return; | 779 return; |
| 780 | 780 |
| 781 document().updateLayoutIgnorePendingStylesheets(); | 781 document().updateLayoutIgnorePendingStylesheets(); |
| 782 | 782 |
| 783 WillBeHeapVector<InlineRunToApplyStyle> runs; | 783 WillBeHeapVector<InlineRunToApplyStyle> runs; |
| 784 RefPtrWillBeRawPtr<Node> node = startNode; | 784 RefPtrWillBeRawPtr<Node> node = startNode; |
| 785 for (RefPtrWillBeRawPtr<Node> next; node && node != pastEndNode; node = next
) { | 785 for (RefPtrWillBeRawPtr<Node> next; node && node != pastEndNode; node = next
) { |
| 786 next = NodeTraversal::next(*node); | 786 next = NodeTraversal::next(*node); |
| 787 | 787 |
| 788 if (!node->renderer() || !node->hasEditableStyle()) | 788 if (!node->layoutObject() || !node->hasEditableStyle()) |
| 789 continue; | 789 continue; |
| 790 | 790 |
| 791 if (!node->rendererIsRichlyEditable() && node->isHTMLElement()) { | 791 if (!node->rendererIsRichlyEditable() && node->isHTMLElement()) { |
| 792 HTMLElement* element = toHTMLElement(node); | 792 HTMLElement* element = toHTMLElement(node); |
| 793 // This is a plaintext-only region. Only proceed if it's fully selec
ted. | 793 // This is a plaintext-only region. Only proceed if it's fully selec
ted. |
| 794 // pastEndNode is the node after the last fully selected node, so if
it's inside node then | 794 // pastEndNode is the node after the last fully selected node, so if
it's inside node then |
| 795 // node isn't fully selected. | 795 // node isn't fully selected. |
| 796 if (pastEndNode && pastEndNode->isDescendantOf(element)) | 796 if (pastEndNode && pastEndNode->isDescendantOf(element)) |
| 797 break; | 797 break; |
| 798 // Add to this element's inline style and skip over its contents. | 798 // Add to this element's inline style and skip over its contents. |
| (...skipping 218 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1017 | 1017 |
| 1018 return result; | 1018 return result; |
| 1019 } | 1019 } |
| 1020 | 1020 |
| 1021 void ApplyStyleCommand::applyInlineStyleToPushDown(Node* node, EditingStyle* sty
le) | 1021 void ApplyStyleCommand::applyInlineStyleToPushDown(Node* node, EditingStyle* sty
le) |
| 1022 { | 1022 { |
| 1023 ASSERT(node); | 1023 ASSERT(node); |
| 1024 | 1024 |
| 1025 node->document().updateRenderTreeIfNeeded(); | 1025 node->document().updateRenderTreeIfNeeded(); |
| 1026 | 1026 |
| 1027 if (!style || style->isEmpty() || !node->renderer() || isHTMLIFrameElement(*
node)) | 1027 if (!style || style->isEmpty() || !node->layoutObject() || isHTMLIFrameEleme
nt(*node)) |
| 1028 return; | 1028 return; |
| 1029 | 1029 |
| 1030 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = style; | 1030 RefPtrWillBeRawPtr<EditingStyle> newInlineStyle = style; |
| 1031 if (node->isHTMLElement() && toHTMLElement(node)->inlineStyle()) { | 1031 if (node->isHTMLElement() && toHTMLElement(node)->inlineStyle()) { |
| 1032 newInlineStyle = style->copy(); | 1032 newInlineStyle = style->copy(); |
| 1033 newInlineStyle->mergeInlineStyleOfElement(toHTMLElement(node), EditingSt
yle::OverrideValues); | 1033 newInlineStyle->mergeInlineStyleOfElement(toHTMLElement(node), EditingSt
yle::OverrideValues); |
| 1034 } | 1034 } |
| 1035 | 1035 |
| 1036 // Since addInlineStyleIfNeeded can't add styles to block-flow render object
s, add style attribute instead. | 1036 // Since addInlineStyleIfNeeded can't add styles to block-flow render object
s, add style attribute instead. |
| 1037 // FIXME: applyInlineStyleToRange should be used here instead. | 1037 // FIXME: applyInlineStyleToRange should be used here instead. |
| 1038 if ((node->renderer()->isLayoutBlockFlow() || node->hasChildren()) && node->
isHTMLElement()) { | 1038 if ((node->layoutObject()->isLayoutBlockFlow() || node->hasChildren()) && no
de->isHTMLElement()) { |
| 1039 setNodeAttribute(toHTMLElement(node), styleAttr, AtomicString(newInlineS
tyle->style()->asText())); | 1039 setNodeAttribute(toHTMLElement(node), styleAttr, AtomicString(newInlineS
tyle->style()->asText())); |
| 1040 return; | 1040 return; |
| 1041 } | 1041 } |
| 1042 | 1042 |
| 1043 if (node->renderer()->isText() && toLayoutText(node->renderer())->isAllColla
psibleWhitespace()) | 1043 if (node->layoutObject()->isText() && toLayoutText(node->layoutObject())->is
AllCollapsibleWhitespace()) |
| 1044 return; | 1044 return; |
| 1045 | 1045 |
| 1046 // We can't wrap node with the styled element here because new styled elemen
t will never be removed if we did. | 1046 // We can't wrap node with the styled element here because new styled elemen
t will never be removed if we did. |
| 1047 // If we modified the child pointer in pushDownInlineStyleAroundNode to poin
t to new style element | 1047 // If we modified the child pointer in pushDownInlineStyleAroundNode to poin
t to new style element |
| 1048 // then we fall into an infinite loop where we keep removing and adding styl
ed element wrapping node. | 1048 // then we fall into an infinite loop where we keep removing and adding styl
ed element wrapping node. |
| 1049 addInlineStyleIfNeeded(newInlineStyle.get(), node, node, DoNotAddStyledEleme
nt); | 1049 addInlineStyleIfNeeded(newInlineStyle.get(), node, node, DoNotAddStyledEleme
nt); |
| 1050 } | 1050 } |
| 1051 | 1051 |
| 1052 void ApplyStyleCommand::pushDownInlineStyleAroundNode(EditingStyle* style, Node*
targetNode) | 1052 void ApplyStyleCommand::pushDownInlineStyleAroundNode(EditingStyle* style, Node*
targetNode) |
| 1053 { | 1053 { |
| (...skipping 532 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1586 DEFINE_TRACE(ApplyStyleCommand) | 1586 DEFINE_TRACE(ApplyStyleCommand) |
| 1587 { | 1587 { |
| 1588 visitor->trace(m_style); | 1588 visitor->trace(m_style); |
| 1589 visitor->trace(m_start); | 1589 visitor->trace(m_start); |
| 1590 visitor->trace(m_end); | 1590 visitor->trace(m_end); |
| 1591 visitor->trace(m_styledInlineElement); | 1591 visitor->trace(m_styledInlineElement); |
| 1592 CompositeEditCommand::trace(visitor); | 1592 CompositeEditCommand::trace(visitor); |
| 1593 } | 1593 } |
| 1594 | 1594 |
| 1595 } | 1595 } |
| OLD | NEW |