Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1403)

Unified Diff: third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp

Issue 2229703004: Keep formatting tags included when it is cut or copied. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: remove editor variable in test case Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/Source/core/editing/serializers/Serialization.cpp ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp
diff --git a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp
index 0929a85a166b881d96aa42f11b82d04a41f24b42..b4e07485225184e4937780f1a1dc60bc89c25fcc 100644
--- a/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp
+++ b/third_party/WebKit/Source/core/editing/serializers/StyledMarkupSerializer.cpp
@@ -189,8 +189,18 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
}
}
- if (!m_lastClosed)
+ // If there is no the highest node in the selected nodes, |m_lastClosed| can be #text
+ // when its parent is a formatting tag. In this case, #text is wrapped by <span> tag,
+ // but this text should be wrapped by the formatting tag. See http://crbug.com/634482
+ bool shouldAppendParentTag = false;
+ if (!m_lastClosed) {
m_lastClosed = StyledMarkupTraverser<Strategy>().traverse(firstNode, pastEnd);
+ if (m_lastClosed && m_lastClosed->isTextNode() && isPresentationalHTMLElement(m_lastClosed->parentNode())) {
+ m_lastClosed = m_lastClosed->parentElement();
+ shouldAppendParentTag = true;
+ }
+ }
+
StyledMarkupTraverser<Strategy> traverser(&markupAccumulator, m_lastClosed);
Node* lastClosed = traverser.traverse(firstNode, pastEnd);
@@ -240,6 +250,9 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
if (ancestor == m_highestNodeToBeSerialized)
break;
}
+ } else if (shouldAppendParentTag) {
+ EditingStyle* style = traverser.createInlineStyleIfNeeded(*m_lastClosed);
+ traverser.wrapWithNode(*toContainerNode(m_lastClosed), style);
}
// FIXME: The interchange newline should be placed in the block that it's in, not after all of the content, unconditionally.
« no previous file with comments | « third_party/WebKit/Source/core/editing/serializers/Serialization.cpp ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698