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

Unified Diff: Source/core/editing/StyledMarkupSerializer.cpp

Issue 1177623005: Refactoring: Remove StyledMarkupAccumulator::m_convertBlocksToInlines (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: yosin's review (early return) Created 5 years, 6 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 | « Source/core/editing/StyledMarkupSerializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/StyledMarkupSerializer.cpp
diff --git a/Source/core/editing/StyledMarkupSerializer.cpp b/Source/core/editing/StyledMarkupSerializer.cpp
index ce77ecda8eb6538f9496158c167a5d5146390277..633b65d297d2513c70da807ada173f244ddb4b18 100644
--- a/Source/core/editing/StyledMarkupSerializer.cpp
+++ b/Source/core/editing/StyledMarkupSerializer.cpp
@@ -119,7 +119,7 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
{
DEFINE_STATIC_LOCAL(const String, interchangeNewlineString, ("<br class=\"" AppleInterchangeNewline "\">"));
- StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset(m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent()), m_start.document(), m_shouldAnnotate, m_highestNodeToBeSerialized.get(), m_convertBlocksToInlines);
+ StyledMarkupAccumulator markupAccumulator(m_shouldResolveURLs, toTextOffset(m_start.parentAnchoredEquivalent()), toTextOffset(m_end.parentAnchoredEquivalent()), m_start.document(), m_shouldAnnotate, m_highestNodeToBeSerialized.get());
Node* pastEnd = m_end.nodeAsRangePastLastNode();
@@ -154,7 +154,7 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
// Also include all of the ancestors of lastClosed up to this special ancestor.
// FIXME: What is ancestor?
for (ContainerNode* ancestor = Strategy::parent(*lastClosed); ancestor; ancestor = Strategy::parent(*ancestor)) {
- if (ancestor == fullySelectedRoot && !markupAccumulator.convertBlocksToInlines()) {
+ if (ancestor == fullySelectedRoot && !convertBlocksToInlines()) {
RefPtrWillBeRawPtr<EditingStyle> fullySelectedRootStyle = styleFromMatchedRulesAndInlineDecl(fullySelectedRoot);
// Bring the background attribute over, but not as an attribute because a background attribute on a div
@@ -176,7 +176,7 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
} else {
// Since this node and all the other ancestors are not in the selection we want to set RangeFullySelectsNode to DoesNotFullySelectNode
// so that styles that affect the exterior of the node are not included.
- markupAccumulator.wrapWithNode(*ancestor, StyledMarkupAccumulator::DoesNotFullySelectNode);
+ wrapWithNode(markupAccumulator, *ancestor, StyledMarkupAccumulator::DoesNotFullySelectNode);
}
if (ancestor == m_highestNodeToBeSerialized)
@@ -283,7 +283,7 @@ Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
ASSERT(startNode);
ASSERT(Strategy::isDescendantOf(*startNode, *parent));
if (markupAccumulator)
- markupAccumulator->wrapWithNode(*parent);
+ wrapWithNode(*markupAccumulator, *parent, StyledMarkupAccumulator::DoesFullySelectNode);
lastClosed = parent;
}
}
@@ -291,6 +291,20 @@ Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
return lastClosed;
}
+template<typename Strategy>
+void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& accumulator, ContainerNode& node, StyledMarkupAccumulator::RangeFullySelectsNode rangeFullySelectsNode)
+{
+ StringBuilder markup;
+ if (node.isElementNode())
+ accumulator.appendElement(markup, toElement(node), convertBlocksToInlines() && isBlock(&node), rangeFullySelectsNode);
+ else
+ accumulator.appendStartMarkup(markup, node);
+ accumulator.pushMarkup(markup.toString());
+ if (!node.isElementNode())
+ return;
+ accumulator.appendEndTag(toElement(node));
+}
+
template class StyledMarkupSerializer<EditingStrategy>;
} // namespace blink
« no previous file with comments | « Source/core/editing/StyledMarkupSerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698