summaryrefslogtreecommitdiff
path: root/Source/WebCore/editing/DeleteSelectionCommand.cpp
diff options
context:
space:
mode:
authorSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
committerSimon Hausmann <simon.hausmann@nokia.com>2012-08-21 10:57:44 +0200
commit5ef7c8a6a70875d4430752d146bdcb069605d71d (patch)
treef6256640b6c46d7da221435803cae65326817ba2 /Source/WebCore/editing/DeleteSelectionCommand.cpp
parentdecad929f578d8db641febc8740649ca6c574638 (diff)
downloadqtwebkit-5ef7c8a6a70875d4430752d146bdcb069605d71d.tar.gz
Imported WebKit commit 356d83016b090995d08ad568f2d2c243aa55e831 (http://svn.webkit.org/repository/webkit/trunk@126147)
New snapshot including various build fixes for newer Qt 5
Diffstat (limited to 'Source/WebCore/editing/DeleteSelectionCommand.cpp')
-rw-r--r--Source/WebCore/editing/DeleteSelectionCommand.cpp18
1 files changed, 18 insertions, 0 deletions
diff --git a/Source/WebCore/editing/DeleteSelectionCommand.cpp b/Source/WebCore/editing/DeleteSelectionCommand.cpp
index 2e059c840..66deae7be 100644
--- a/Source/WebCore/editing/DeleteSelectionCommand.cpp
+++ b/Source/WebCore/editing/DeleteSelectionCommand.cpp
@@ -416,6 +416,22 @@ void DeleteSelectionCommand::deleteTextFromNode(PassRefPtr<Text> node, unsigned
CompositeEditCommand::deleteTextFromNode(node, offset, count);
}
+void DeleteSelectionCommand::makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss()
+{
+ RefPtr<Range> range = m_selectionToDelete.toNormalizedRange();
+ RefPtr<Node> node = range->firstNode();
+ while (node && node != range->pastLastNode()) {
+ RefPtr<Node> nextNode = node->traverseNextNode();
+ if ((node->hasTagName(styleTag) && !(toElement(node.get())->hasAttribute(scopedAttr))) || node->hasTagName(linkTag)) {
+ nextNode = node->traverseNextSibling();
+ RefPtr<ContainerNode> rootEditableElement = node->rootEditableElement();
+ removeNode(node);
+ appendNode(node, rootEditableElement);
+ }
+ node = nextNode;
+ }
+}
+
void DeleteSelectionCommand::handleGeneralDelete()
{
if (m_upstreamStart.isNull())
@@ -423,6 +439,8 @@ void DeleteSelectionCommand::handleGeneralDelete()
int startOffset = m_upstreamStart.deprecatedEditingOffset();
Node* startNode = m_upstreamStart.deprecatedNode();
+
+ makeStylingElementsDirectChildrenOfEditableRootToPreventStyleLoss();
// Never remove the start block unless it's a table, in which case we won't merge content in.
if (startNode == m_startBlock && startOffset == 0 && canHaveChildrenForEditing(startNode) && !startNode->hasTagName(tableTag)) {