| OLD | NEW |
| 1 /* | 1 /* |
| 2 * Copyright (C) 2005 Apple Computer, Inc. All rights reserved. | 2 * Copyright (C) 2005 Apple Computer, 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 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 262 // We must pass call parentAnchoredEquivalent on the positions since some ed
iting positions | 262 // We must pass call parentAnchoredEquivalent on the positions since some ed
iting positions |
| 263 // that appear inside their nodes aren't really inside them. [hr, 0] is one
example. | 263 // that appear inside their nodes aren't really inside them. [hr, 0] is one
example. |
| 264 // FIXME: parentAnchoredEquivalent should eventually be moved into enclosing
element getters | 264 // FIXME: parentAnchoredEquivalent should eventually be moved into enclosing
element getters |
| 265 // like the one below, since editing functions should obviously accept editi
ng positions. | 265 // like the one below, since editing functions should obviously accept editi
ng positions. |
| 266 // FIXME: Passing false to enclosingNodeOfType tells it that it's OK to retu
rn a non-editable | 266 // FIXME: Passing false to enclosingNodeOfType tells it that it's OK to retu
rn a non-editable |
| 267 // node. This was done to match existing behavior, but it seems wrong. | 267 // node. This was done to match existing behavior, but it seems wrong. |
| 268 m_startBlock = enclosingNodeOfType(m_downstreamStart.parentAnchoredEquivalen
t(), &isBlock, CanCrossEditingBoundary); | 268 m_startBlock = enclosingNodeOfType(m_downstreamStart.parentAnchoredEquivalen
t(), &isBlock, CanCrossEditingBoundary); |
| 269 m_endBlock = enclosingNodeOfType(m_upstreamEnd.parentAnchoredEquivalent(), &
isBlock, CanCrossEditingBoundary); | 269 m_endBlock = enclosingNodeOfType(m_upstreamEnd.parentAnchoredEquivalent(), &
isBlock, CanCrossEditingBoundary); |
| 270 } | 270 } |
| 271 | 271 |
| 272 // We don't want to inherit style from an element which can't have contents. |
| 273 static bool shouldNotInheritStyleFrom(const Node& node) |
| 274 { |
| 275 return !node.canContainRangeEndPoint(); |
| 276 } |
| 277 |
| 272 void DeleteSelectionCommand::saveTypingStyleState() | 278 void DeleteSelectionCommand::saveTypingStyleState() |
| 273 { | 279 { |
| 274 // A common case is deleting characters that are all from the same text node
. In | 280 // A common case is deleting characters that are all from the same text node
. In |
| 275 // that case, the style at the start of the selection before deletion will b
e the | 281 // that case, the style at the start of the selection before deletion will b
e the |
| 276 // same as the style at the start of the selection after deletion (since tho
se | 282 // same as the style at the start of the selection after deletion (since tho
se |
| 277 // two positions will be identical). Therefore there is no need to save the | 283 // two positions will be identical). Therefore there is no need to save the |
| 278 // typing style at the start of the selection, nor is there a reason to | 284 // typing style at the start of the selection, nor is there a reason to |
| 279 // compute the style at the start of the selection after deletion (see the | 285 // compute the style at the start of the selection after deletion (see the |
| 280 // early return in calculateTypingStyleAfterDelete). | 286 // early return in calculateTypingStyleAfterDelete). |
| 281 if (m_upstreamStart.deprecatedNode() == m_downstreamEnd.deprecatedNode() &&
m_upstreamStart.deprecatedNode()->isTextNode()) | 287 if (m_upstreamStart.deprecatedNode() == m_downstreamEnd.deprecatedNode() &&
m_upstreamStart.deprecatedNode()->isTextNode()) |
| 282 return; | 288 return; |
| 283 | 289 |
| 290 if (shouldNotInheritStyleFrom(*m_selectionToDelete.start().anchorNode())) |
| 291 return; |
| 292 |
| 284 // Figure out the typing style in effect before the delete is done. | 293 // Figure out the typing style in effect before the delete is done. |
| 285 m_typingStyle = EditingStyle::create(m_selectionToDelete.start()); | 294 m_typingStyle = EditingStyle::create(m_selectionToDelete.start()); |
| 286 m_typingStyle->removeStyleAddedByNode(enclosingAnchorElement(m_selectionToDe
lete.start())); | 295 m_typingStyle->removeStyleAddedByNode(enclosingAnchorElement(m_selectionToDe
lete.start())); |
| 287 | 296 |
| 288 // If we're deleting into a Mail blockquote, save the style at end() instead
of start() | 297 // If we're deleting into a Mail blockquote, save the style at end() instead
of start() |
| 289 // We'll use this later in computeTypingStyleAfterDelete if we end up outsid
e of a Mail blockquote | 298 // We'll use this later in computeTypingStyleAfterDelete if we end up outsid
e of a Mail blockquote |
| 290 if (enclosingNodeOfType(m_selectionToDelete.start(), isMailBlockquote)) | 299 if (enclosingNodeOfType(m_selectionToDelete.start(), isMailBlockquote)) |
| 291 m_deleteIntoBlockquoteStyle = EditingStyle::create(m_selectionToDelete.e
nd()); | 300 m_deleteIntoBlockquoteStyle = EditingStyle::create(m_selectionToDelete.e
nd()); |
| 292 else | 301 else |
| 293 m_deleteIntoBlockquoteStyle = 0; | 302 m_deleteIntoBlockquoteStyle = 0; |
| (...skipping 533 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 827 | 836 |
| 828 // Normally deletion doesn't preserve the typing style that was present before i
t. For example, | 837 // Normally deletion doesn't preserve the typing style that was present before i
t. For example, |
| 829 // type a character, Bold, then delete the character and start typing. The Bold
typing style shouldn't | 838 // type a character, Bold, then delete the character and start typing. The Bold
typing style shouldn't |
| 830 // stick around. Deletion should preserve a typing style that *it* sets, howeve
r. | 839 // stick around. Deletion should preserve a typing style that *it* sets, howeve
r. |
| 831 bool DeleteSelectionCommand::preservesTypingStyle() const | 840 bool DeleteSelectionCommand::preservesTypingStyle() const |
| 832 { | 841 { |
| 833 return m_typingStyle; | 842 return m_typingStyle; |
| 834 } | 843 } |
| 835 | 844 |
| 836 } // namespace WebCore | 845 } // namespace WebCore |
| OLD | NEW |