| 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 1050 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1061 | 1061 |
| 1062 for (Node* node = run_start; node && node != past_end_node; | 1062 for (Node* node = run_start; node && node != past_end_node; |
| 1063 node = NodeTraversal::Next(*node)) { | 1063 node = NodeTraversal::Next(*node)) { |
| 1064 if (node->hasChildren()) | 1064 if (node->hasChildren()) |
| 1065 continue; | 1065 continue; |
| 1066 // We don't consider m_isInlineElementToRemoveFunction here because we never | 1066 // We don't consider m_isInlineElementToRemoveFunction here because we never |
| 1067 // apply style when m_isInlineElementToRemoveFunction is specified | 1067 // apply style when m_isInlineElementToRemoveFunction is specified |
| 1068 if (!style->StyleIsPresentInComputedStyleOfNode(node)) | 1068 if (!style->StyleIsPresentInComputedStyleOfNode(node)) |
| 1069 return true; | 1069 return true; |
| 1070 if (styled_inline_element_ && | 1070 if (styled_inline_element_ && |
| 1071 !EnclosingElementWithTag(Position::BeforeNode(node), | 1071 !EnclosingElementWithTag(Position::BeforeNode(*node), |
| 1072 styled_inline_element_->TagQName())) | 1072 styled_inline_element_->TagQName())) |
| 1073 return true; | 1073 return true; |
| 1074 } | 1074 } |
| 1075 return false; | 1075 return false; |
| 1076 } | 1076 } |
| 1077 | 1077 |
| 1078 void ApplyStyleCommand::RemoveConflictingInlineStyleFromRun( | 1078 void ApplyStyleCommand::RemoveConflictingInlineStyleFromRun( |
| 1079 EditingStyle* style, | 1079 EditingStyle* style, |
| 1080 Member<Node>& run_start, | 1080 Member<Node>& run_start, |
| 1081 Member<Node>& run_end, | 1081 Member<Node>& run_end, |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1583 Position new_end; | 1583 Position new_end; |
| 1584 if (start.ComputeContainerNode() == end.ComputeContainerNode()) | 1584 if (start.ComputeContainerNode() == end.ComputeContainerNode()) |
| 1585 new_end = | 1585 new_end = |
| 1586 Position(end.ComputeContainerNode(), | 1586 Position(end.ComputeContainerNode(), |
| 1587 end.OffsetInContainerNode() - start.OffsetInContainerNode()); | 1587 end.OffsetInContainerNode() - start.OffsetInContainerNode()); |
| 1588 else | 1588 else |
| 1589 new_end = end; | 1589 new_end = end; |
| 1590 | 1590 |
| 1591 SplitTextNodeContainingElement(ToText(start.ComputeContainerNode()), | 1591 SplitTextNodeContainingElement(ToText(start.ComputeContainerNode()), |
| 1592 start.OffsetInContainerNode()); | 1592 start.OffsetInContainerNode()); |
| 1593 UpdateStartEnd(Position::BeforeNode(start.ComputeContainerNode()), new_end); | 1593 UpdateStartEnd(Position::BeforeNode(*start.ComputeContainerNode()), new_end); |
| 1594 } | 1594 } |
| 1595 | 1595 |
| 1596 void ApplyStyleCommand::SplitTextElementAtEnd(const Position& start, | 1596 void ApplyStyleCommand::SplitTextElementAtEnd(const Position& start, |
| 1597 const Position& end) { | 1597 const Position& end) { |
| 1598 DCHECK(end.ComputeContainerNode()->IsTextNode()) << end; | 1598 DCHECK(end.ComputeContainerNode()->IsTextNode()) << end; |
| 1599 | 1599 |
| 1600 bool should_update_start = | 1600 bool should_update_start = |
| 1601 start.ComputeContainerNode() == end.ComputeContainerNode(); | 1601 start.ComputeContainerNode() == end.ComputeContainerNode(); |
| 1602 SplitTextNodeContainingElement(ToText(end.ComputeContainerNode()), | 1602 SplitTextNodeContainingElement(ToText(end.ComputeContainerNode()), |
| 1603 end.OffsetInContainerNode()); | 1603 end.OffsetInContainerNode()); |
| (...skipping 223 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1827 } | 1827 } |
| 1828 | 1828 |
| 1829 Position ApplyStyleCommand::PositionToComputeInlineStyleChange( | 1829 Position ApplyStyleCommand::PositionToComputeInlineStyleChange( |
| 1830 Node* start_node, | 1830 Node* start_node, |
| 1831 Member<HTMLSpanElement>& dummy_element, | 1831 Member<HTMLSpanElement>& dummy_element, |
| 1832 EditingState* editing_state) { | 1832 EditingState* editing_state) { |
| 1833 // It's okay to obtain the style at the startNode because we've removed all | 1833 // It's okay to obtain the style at the startNode because we've removed all |
| 1834 // relevant styles from the current run. | 1834 // relevant styles from the current run. |
| 1835 if (!start_node->IsElementNode()) { | 1835 if (!start_node->IsElementNode()) { |
| 1836 dummy_element = HTMLSpanElement::Create(GetDocument()); | 1836 dummy_element = HTMLSpanElement::Create(GetDocument()); |
| 1837 InsertNodeAt(dummy_element, Position::BeforeNode(start_node), | 1837 InsertNodeAt(dummy_element, Position::BeforeNode(*start_node), |
| 1838 editing_state); | 1838 editing_state); |
| 1839 if (editing_state->IsAborted()) | 1839 if (editing_state->IsAborted()) |
| 1840 return Position(); | 1840 return Position(); |
| 1841 return Position::BeforeNode(dummy_element); | 1841 return Position::BeforeNode(*dummy_element); |
| 1842 } | 1842 } |
| 1843 | 1843 |
| 1844 return FirstPositionInOrBeforeNode(start_node); | 1844 return FirstPositionInOrBeforeNode(start_node); |
| 1845 } | 1845 } |
| 1846 | 1846 |
| 1847 void ApplyStyleCommand::ApplyInlineStyleChange( | 1847 void ApplyStyleCommand::ApplyInlineStyleChange( |
| 1848 Node* passed_start, | 1848 Node* passed_start, |
| 1849 Node* passed_end, | 1849 Node* passed_end, |
| 1850 StyleChange& style_change, | 1850 StyleChange& style_change, |
| 1851 EAddStyledElement add_styled_element, | 1851 EAddStyledElement add_styled_element, |
| (...skipping 194 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2046 | 2046 |
| 2047 DEFINE_TRACE(ApplyStyleCommand) { | 2047 DEFINE_TRACE(ApplyStyleCommand) { |
| 2048 visitor->Trace(style_); | 2048 visitor->Trace(style_); |
| 2049 visitor->Trace(start_); | 2049 visitor->Trace(start_); |
| 2050 visitor->Trace(end_); | 2050 visitor->Trace(end_); |
| 2051 visitor->Trace(styled_inline_element_); | 2051 visitor->Trace(styled_inline_element_); |
| 2052 CompositeEditCommand::Trace(visitor); | 2052 CompositeEditCommand::Trace(visitor); |
| 2053 } | 2053 } |
| 2054 | 2054 |
| 2055 } // namespace blink | 2055 } // namespace blink |
| OLD | NEW |