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

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

Issue 1177323005: Move StyledMarkupAccumulator::shouldApplyWrappingStyle to its serializer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: 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
Index: Source/core/editing/StyledMarkupAccumulator.cpp
diff --git a/Source/core/editing/StyledMarkupAccumulator.cpp b/Source/core/editing/StyledMarkupAccumulator.cpp
index 66a58e71a528c78a881424db553b44f07b2f7889..5e19e1cb680600d47bf63347300b5718ef0456b5 100644
--- a/Source/core/editing/StyledMarkupAccumulator.cpp
+++ b/Source/core/editing/StyledMarkupAccumulator.cpp
@@ -61,11 +61,6 @@ StyledMarkupAccumulator::StyledMarkupAccumulator(EAbsoluteURLs shouldResolveURLs
{
}
-void StyledMarkupAccumulator::appendStartTag(Node& node)
-{
- appendStartMarkup(node);
-}
-
void StyledMarkupAccumulator::appendEndTag(const Element& element)
{
appendEndMarkup(m_result, element);
@@ -74,9 +69,6 @@ void StyledMarkupAccumulator::appendEndTag(const Element& element)
void StyledMarkupAccumulator::appendStartMarkup(Node& node)
{
switch (node.nodeType()) {
- case Node::TEXT_NODE:
- appendText(toText(node));
- break;
case Node::ELEMENT_NODE: {
Element& element = toElement(node);
RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyle(element);
@@ -96,13 +88,25 @@ void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme
void StyledMarkupAccumulator::appendText(Text& text)
{
- appendText(m_result, text);
+ const String& str = text.data();
+ unsigned length = str.length();
+ unsigned start = 0;
+ if (m_end.isNotNull()) {
+ if (text == m_end.text())
+ length = m_end.offset();
+ }
+ if (m_start.isNotNull()) {
+ if (text == m_start.text()) {
+ start = m_start.offset();
+ length -= start;
+ }
+ }
+ MarkupFormatter::appendCharactersReplacingEntities(m_result, str, start, length, m_formatter.entityMaskForText(text));
}
-void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text)
+void StyledMarkupAccumulator::appendTextWithWrappingStyle(Text& text)
{
- const bool parentIsTextarea = text.parentElement() && text.parentElement()->tagQName() == textareaTag;
- const bool wrappingSpan = shouldApplyWrappingStyle(text) && !parentIsTextarea;
+ const bool wrappingSpan = shouldApplyWrappingStyle(text);
if (wrappingSpan) {
RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = m_wrappingStyle->copy();
// FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance
@@ -115,36 +119,23 @@ void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text)
ASSERT(propertyMissingOrEqualToNone(wrappingStyle->style(), CSSPropertyWebkitTextDecorationsInEffect));
ASSERT(m_document);
- out.appendLiteral("<span style=\"");
- MarkupFormatter::appendAttributeValue(out, wrappingStyle->style()->asText(), m_document->isHTMLDocument());
- out.appendLiteral("\">");
+ m_result.appendLiteral("<span style=\"");
+ MarkupFormatter::appendAttributeValue(m_result, wrappingStyle->style()->asText(), m_document->isHTMLDocument());
+ m_result.appendLiteral("\">");
}
- if (!shouldAnnotate() || parentIsTextarea) {
- const String& str = text.data();
- unsigned length = str.length();
- unsigned start = 0;
- if (m_end.isNotNull()) {
- if (text == m_end.text())
- length = m_end.offset();
- }
- if (m_start.isNotNull()) {
- if (text == m_start.text()) {
- start = m_start.offset();
- length -= start;
- }
- }
- MarkupFormatter::appendCharactersReplacingEntities(out, str, start, length, m_formatter.entityMaskForText(text));
+ if (!shouldAnnotate()) {
+ appendText(text);
} else {
const bool useRenderedText = !enclosingElementWithTag(firstPositionInNode(&text), selectTag);
String content = useRenderedText ? renderedText(text) : stringValueForRange(text);
StringBuilder buffer;
MarkupFormatter::appendCharactersReplacingEntities(buffer, content, 0, content.length(), EntityMaskInPCDATA);
- out.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text));
+ m_result.append(convertHTMLTextToInterchangeFormat(buffer.toString(), text));
}
if (wrappingSpan)
- out.append("</span>");
+ m_result.append("</span>");
}
void StyledMarkupAccumulator::appendElement(const Element& element, PassRefPtrWillBeRawPtr<EditingStyle> style)

Powered by Google App Engine
This is Rietveld 408576698