summaryrefslogtreecommitdiffstats
path: root/WebCore/editing/DeleteSelectionCommand.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'WebCore/editing/DeleteSelectionCommand.cpp')
-rw-r--r--WebCore/editing/DeleteSelectionCommand.cpp33
1 files changed, 14 insertions, 19 deletions
diff --git a/WebCore/editing/DeleteSelectionCommand.cpp b/WebCore/editing/DeleteSelectionCommand.cpp
index 5a0d8fc..d57c241 100644
--- a/WebCore/editing/DeleteSelectionCommand.cpp
+++ b/WebCore/editing/DeleteSelectionCommand.cpp
@@ -44,6 +44,7 @@
#include "Text.h"
#include "TextIterator.h"
#include "visible_units.h"
+#include "ApplyStyleCommand.h"
namespace WebCore {
@@ -259,11 +260,8 @@ static void removeEnclosingAnchorStyle(CSSMutableStyleDeclaration* style, const
Node* enclosingAnchor = enclosingAnchorElement(position);
if (!enclosingAnchor || !enclosingAnchor->parentNode())
return;
-
- RefPtr<CSSMutableStyleDeclaration> parentStyle = Position(enclosingAnchor->parentNode(), 0).computedStyle()->copyInheritableProperties();
- RefPtr<CSSMutableStyleDeclaration> anchorStyle = Position(enclosingAnchor, 0).computedStyle()->copyInheritableProperties();
- parentStyle->diff(anchorStyle.get());
- anchorStyle->diff(style);
+
+ removeStylesAddedByNode(style, enclosingAnchor);
}
void DeleteSelectionCommand::saveTypingStyleState()
@@ -277,19 +275,17 @@ void DeleteSelectionCommand::saveTypingStyleState()
// early return in calculateTypingStyleAfterDelete).
if (m_upstreamStart.node() == m_downstreamEnd.node() && m_upstreamStart.node()->isTextNode())
return;
-
+
// Figure out the typing style in effect before the delete is done.
- RefPtr<CSSComputedStyleDeclaration> computedStyle = positionBeforeTabSpan(m_selectionToDelete.start()).computedStyle();
- m_typingStyle = computedStyle->copyInheritableProperties();
-
+ m_typingStyle = editingStyleAtPosition(positionBeforeTabSpan(m_selectionToDelete.start()));
+
removeEnclosingAnchorStyle(m_typingStyle.get(), m_selectionToDelete.start());
-
+
// If we're deleting into a Mail blockquote, save the style at end() instead of start()
// We'll use this later in computeTypingStyleAfterDelete if we end up outside of a Mail blockquote
- if (nearestMailBlockquote(m_selectionToDelete.start().node())) {
- computedStyle = m_selectionToDelete.end().computedStyle();
- m_deleteIntoBlockquoteStyle = computedStyle->copyInheritableProperties();
- } else
+ if (nearestMailBlockquote(m_selectionToDelete.start().node()))
+ m_deleteIntoBlockquoteStyle = editingStyleAtPosition(m_selectionToDelete.end());
+ else
m_deleteIntoBlockquoteStyle = 0;
}
@@ -364,8 +360,8 @@ void DeleteSelectionCommand::removeNode(PassRefPtr<Node> node)
// make sure empty cell has some height
updateLayout();
RenderObject *r = node->renderer();
- if (r && r->isTableCell() && static_cast<RenderTableCell*>(r)->contentHeight() <= 0)
- insertBlockPlaceholder(Position(node,0));
+ if (r && r->isTableCell() && toRenderTableCell(r)->contentHeight() <= 0)
+ insertBlockPlaceholder(Position(node, 0));
return;
}
@@ -668,9 +664,8 @@ void DeleteSelectionCommand::calculateTypingStyleAfterDelete()
if (m_deleteIntoBlockquoteStyle && !nearestMailBlockquote(m_endingPosition.node()))
m_typingStyle = m_deleteIntoBlockquoteStyle;
m_deleteIntoBlockquoteStyle = 0;
-
- RefPtr<CSSComputedStyleDeclaration> endingStyle = computedStyle(m_endingPosition.node());
- endingStyle->diff(m_typingStyle.get());
+
+ prepareEditingStyleToApplyAt(m_typingStyle.get(), m_endingPosition);
if (!m_typingStyle->length())
m_typingStyle = 0;
VisiblePosition visibleEnd(m_endingPosition);