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

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

Issue 1181953004: Refactoring: Separate StyledMarkupAccumulator::appendText into this and appendTextWithInlineStyle (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Rename appendTextWithWrappingStyle -> appendTextWithInlineStyle 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/StyledMarkupAccumulator.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/StyledMarkupAccumulator.cpp
diff --git a/Source/core/editing/StyledMarkupAccumulator.cpp b/Source/core/editing/StyledMarkupAccumulator.cpp
index 66a58e71a528c78a881424db553b44f07b2f7889..7a5b8d19169de5764bfbb87a8943c7cbf066d4d3 100644
--- a/Source/core/editing/StyledMarkupAccumulator.cpp
+++ b/Source/core/editing/StyledMarkupAccumulator.cpp
@@ -96,13 +96,34 @@ void StyledMarkupAccumulator::appendEndMarkup(StringBuilder& result, const Eleme
void StyledMarkupAccumulator::appendText(Text& text)
{
- appendText(m_result, text);
+ if (text.parentElement() && text.parentElement()->tagQName() == textareaTag) {
+ appendText(m_result, text);
+ return;
+ }
+ appendTextWithInlineStyle(m_result, text);
}
void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text)
{
- const bool parentIsTextarea = text.parentElement() && text.parentElement()->tagQName() == textareaTag;
- const bool wrappingSpan = shouldApplyWrappingStyle(text) && !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));
+}
+
+void StyledMarkupAccumulator::appendTextWithInlineStyle(StringBuilder& out, Text& text)
+{
+ 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
@@ -120,21 +141,8 @@ void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text)
out.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(out, text);
} else {
const bool useRenderedText = !enclosingElementWithTag(firstPositionInNode(&text), selectTag);
String content = useRenderedText ? renderedText(text) : stringValueForRange(text);
« no previous file with comments | « Source/core/editing/StyledMarkupAccumulator.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698