| 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 864 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 875 if (!shouldApplyInlineStyleToRun(style, runStart, pastEndNode)) | 875 if (!shouldApplyInlineStyleToRun(style, runStart, pastEndNode)) |
| 876 continue; | 876 continue; |
| 877 | 877 |
| 878 runs.append(InlineRunToApplyStyle(runStart, runEnd, pastEndNode)); | 878 runs.append(InlineRunToApplyStyle(runStart, runEnd, pastEndNode)); |
| 879 } | 879 } |
| 880 | 880 |
| 881 for (auto& run : runs) { | 881 for (auto& run : runs) { |
| 882 removeConflictingInlineStyleFromRun(style, run.start, run.end, run.pastE
ndNode, editingState); | 882 removeConflictingInlineStyleFromRun(style, run.start, run.end, run.pastE
ndNode, editingState); |
| 883 if (editingState->isAborted()) | 883 if (editingState->isAborted()) |
| 884 return; | 884 return; |
| 885 if (run.startAndEndAreStillInDocument()) | 885 if (run.startAndEndAreStillInDocument()) { |
| 886 run.positionForStyleComputation = positionToComputeInlineStyleChange
(run.start, run.dummyElement); | 886 run.positionForStyleComputation = positionToComputeInlineStyleChange
(run.start, run.dummyElement, editingState); |
| 887 if (editingState->isAborted()) |
| 888 return; |
| 889 } |
| 887 } | 890 } |
| 888 | 891 |
| 889 document().updateLayoutIgnorePendingStylesheets(); | 892 document().updateLayoutIgnorePendingStylesheets(); |
| 890 | 893 |
| 891 for (auto& run : runs) { | 894 for (auto& run : runs) { |
| 892 if (run.positionForStyleComputation.isNotNull()) | 895 if (run.positionForStyleComputation.isNotNull()) |
| 893 run.change = StyleChange(style, run.positionForStyleComputation); | 896 run.change = StyleChange(style, run.positionForStyleComputation); |
| 894 } | 897 } |
| 895 | 898 |
| 896 for (auto& run : runs) { | 899 for (auto& run : runs) { |
| (...skipping 612 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1509 setNodeAttribute(block, styleAttr, cssText.toAtomicString()); | 1512 setNodeAttribute(block, styleAttr, cssText.toAtomicString()); |
| 1510 } | 1513 } |
| 1511 | 1514 |
| 1512 void ApplyStyleCommand::addInlineStyleIfNeeded(EditingStyle* style, PassRefPtrWi
llBeRawPtr<Node> passedStart, PassRefPtrWillBeRawPtr<Node> passedEnd, EditingSta
te* editingState) | 1515 void ApplyStyleCommand::addInlineStyleIfNeeded(EditingStyle* style, PassRefPtrWi
llBeRawPtr<Node> passedStart, PassRefPtrWillBeRawPtr<Node> passedEnd, EditingSta
te* editingState) |
| 1513 { | 1516 { |
| 1514 if (!passedStart || !passedEnd || !passedStart->inDocument() || !passedEnd->
inDocument()) | 1517 if (!passedStart || !passedEnd || !passedStart->inDocument() || !passedEnd->
inDocument()) |
| 1515 return; | 1518 return; |
| 1516 | 1519 |
| 1517 RefPtrWillBeRawPtr<Node> start = passedStart; | 1520 RefPtrWillBeRawPtr<Node> start = passedStart; |
| 1518 RefPtrWillBeMember<HTMLSpanElement> dummyElement = nullptr; | 1521 RefPtrWillBeMember<HTMLSpanElement> dummyElement = nullptr; |
| 1519 StyleChange styleChange(style, positionToComputeInlineStyleChange(start, dum
myElement)); | 1522 StyleChange styleChange(style, positionToComputeInlineStyleChange(start, dum
myElement, editingState)); |
| 1523 if (editingState->isAborted()) |
| 1524 return; |
| 1520 | 1525 |
| 1521 if (dummyElement) { | 1526 if (dummyElement) { |
| 1522 removeNode(dummyElement, editingState); | 1527 removeNode(dummyElement, editingState); |
| 1523 if (editingState->isAborted()) | 1528 if (editingState->isAborted()) |
| 1524 return; | 1529 return; |
| 1525 } | 1530 } |
| 1526 | 1531 |
| 1527 applyInlineStyleChange(start, passedEnd, styleChange, DoNotAddStyledElement,
editingState); | 1532 applyInlineStyleChange(start, passedEnd, styleChange, DoNotAddStyledElement,
editingState); |
| 1528 } | 1533 } |
| 1529 | 1534 |
| 1530 Position ApplyStyleCommand::positionToComputeInlineStyleChange(PassRefPtrWillBeR
awPtr<Node> startNode, RefPtrWillBeMember<HTMLSpanElement>& dummyElement) | 1535 Position ApplyStyleCommand::positionToComputeInlineStyleChange(PassRefPtrWillBeR
awPtr<Node> startNode, RefPtrWillBeMember<HTMLSpanElement>& dummyElement, Editin
gState* editingState) |
| 1531 { | 1536 { |
| 1532 // It's okay to obtain the style at the startNode because we've removed all
relevant styles from the current run. | 1537 // It's okay to obtain the style at the startNode because we've removed all
relevant styles from the current run. |
| 1533 if (!startNode->isElementNode()) { | 1538 if (!startNode->isElementNode()) { |
| 1534 dummyElement = HTMLSpanElement::create(document()); | 1539 dummyElement = HTMLSpanElement::create(document()); |
| 1535 insertNodeAt(dummyElement, positionBeforeNode(startNode.get())); | 1540 insertNodeAt(dummyElement, positionBeforeNode(startNode.get()), editingS
tate); |
| 1541 if (editingState->isAborted()) |
| 1542 return Position(); |
| 1536 return positionBeforeNode(dummyElement.get()); | 1543 return positionBeforeNode(dummyElement.get()); |
| 1537 } | 1544 } |
| 1538 | 1545 |
| 1539 return firstPositionInOrBeforeNode(startNode.get()); | 1546 return firstPositionInOrBeforeNode(startNode.get()); |
| 1540 } | 1547 } |
| 1541 | 1548 |
| 1542 void ApplyStyleCommand::applyInlineStyleChange(PassRefPtrWillBeRawPtr<Node> pass
edStart, PassRefPtrWillBeRawPtr<Node> passedEnd, StyleChange& styleChange, EAddS
tyledElement addStyledElement, EditingState* editingState) | 1549 void ApplyStyleCommand::applyInlineStyleChange(PassRefPtrWillBeRawPtr<Node> pass
edStart, PassRefPtrWillBeRawPtr<Node> passedEnd, StyleChange& styleChange, EAddS
tyledElement addStyledElement, EditingState* editingState) |
| 1543 { | 1550 { |
| 1544 RefPtrWillBeRawPtr<Node> startNode = passedStart; | 1551 RefPtrWillBeRawPtr<Node> startNode = passedStart; |
| 1545 RefPtrWillBeRawPtr<Node> endNode = passedEnd; | 1552 RefPtrWillBeRawPtr<Node> endNode = passedEnd; |
| (...skipping 158 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1704 DEFINE_TRACE(ApplyStyleCommand) | 1711 DEFINE_TRACE(ApplyStyleCommand) |
| 1705 { | 1712 { |
| 1706 visitor->trace(m_style); | 1713 visitor->trace(m_style); |
| 1707 visitor->trace(m_start); | 1714 visitor->trace(m_start); |
| 1708 visitor->trace(m_end); | 1715 visitor->trace(m_end); |
| 1709 visitor->trace(m_styledInlineElement); | 1716 visitor->trace(m_styledInlineElement); |
| 1710 CompositeEditCommand::trace(visitor); | 1717 CompositeEditCommand::trace(visitor); |
| 1711 } | 1718 } |
| 1712 | 1719 |
| 1713 } // namespace blink | 1720 } // namespace blink |
| OLD | NEW |