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

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

Issue 1165833002: Refactoring: Move StyledMarkupSerializer::m_reversedPrecedingMarkup to StyledMarkupAccumulator (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: rebase Created 5 years, 7 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/StyledMarkupAccumulator.h ('k') | Source/core/editing/StyledMarkupSerializer.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/StyledMarkupAccumulator.cpp
diff --git a/Source/core/editing/StyledMarkupAccumulator.cpp b/Source/core/editing/StyledMarkupAccumulator.cpp
index b709958151ff239959451b41a02fee2e90a6e585..5b0be7a492096642b9b66b67b88ca8a809c3be5f 100644
--- a/Source/core/editing/StyledMarkupAccumulator.cpp
+++ b/Source/core/editing/StyledMarkupAccumulator.cpp
@@ -50,12 +50,13 @@ const String& styleNodeCloseTag(bool isBlock)
using namespace HTMLNames;
-StyledMarkupAccumulator::StyledMarkupAccumulator(EAbsoluteURLs shouldResolveURLs, const TextOffset& start, const TextOffset& end, const PassRefPtrWillBeRawPtr<Document> document, EAnnotateForInterchange shouldAnnotate, Node* highestNodeToBeSerialized)
+StyledMarkupAccumulator::StyledMarkupAccumulator(EAbsoluteURLs shouldResolveURLs, const TextOffset& start, const TextOffset& end, const PassRefPtrWillBeRawPtr<Document> document, EAnnotateForInterchange shouldAnnotate, Node* highestNodeToBeSerialized, ConvertBlocksToInlines convertBlocksToInlines)
: m_accumulator(shouldResolveURLs)
, m_start(start)
, m_end(end)
, m_document(document)
, m_shouldAnnotate(shouldAnnotate)
+ , m_convertBlocksToInlines(convertBlocksToInlines)
, m_highestNodeToBeSerialized(highestNodeToBeSerialized)
{
}
@@ -212,9 +213,38 @@ void StyledMarkupAccumulator::appendStyleNodeOpenTag(StringBuilder& out, StylePr
out.appendLiteral("\">");
}
-void StyledMarkupAccumulator::concatenateMarkup(StringBuilder& result) const
+void StyledMarkupAccumulator::wrapWithNode(ContainerNode& node, RangeFullySelectsNode rangeFullySelectsNode)
{
+ StringBuilder markup;
+ if (node.isElementNode())
+ appendElement(markup, toElement(node), convertBlocksToInlines() && isBlock(&node), rangeFullySelectsNode);
+ else
+ appendStartMarkup(markup, node);
+ m_reversedPrecedingMarkup.append(markup.toString());
+ if (node.isElementNode())
+ appendEndTag(toElement(node));
+}
+
+void StyledMarkupAccumulator::wrapWithStyleNode(StylePropertySet* style, bool isBlock)
+{
+ StringBuilder openTag;
+ appendStyleNodeOpenTag(openTag, style, isBlock);
+ m_reversedPrecedingMarkup.append(openTag.toString());
+ appendString(styleNodeCloseTag(isBlock));
+}
+
+String StyledMarkupAccumulator::takeResults()
+{
+ StringBuilder result;
+ result.reserveCapacity(MarkupAccumulator::totalLength(m_reversedPrecedingMarkup) + m_accumulator.length());
+
+ for (size_t i = m_reversedPrecedingMarkup.size(); i > 0; --i)
+ result.append(m_reversedPrecedingMarkup[i - 1]);
+
m_accumulator.concatenateMarkup(result);
+
+ // We remove '\0' characters because they are not visibly rendered to the user.
+ return result.toString().replace(0, "");
}
String StyledMarkupAccumulator::renderedText(Text& textNode)
« no previous file with comments | « Source/core/editing/StyledMarkupAccumulator.h ('k') | Source/core/editing/StyledMarkupSerializer.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698