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

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

Issue 1173223003: Refactoring: Remove addDisplayInline parameter of StyledMarkupAccumulator::appendElement (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: tkent's review 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') | 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 e7cf7f5e3a294be81f1d9867e2abd9f07f6ef99b..ff080af32167b02c2e49a9ee55e99b5e819978c5 100644
--- a/Source/core/editing/StyledMarkupAccumulator.cpp
+++ b/Source/core/editing/StyledMarkupAccumulator.cpp
@@ -135,9 +135,13 @@ void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text)
out.append("</span>");
}
-void StyledMarkupAccumulator::appendElement(Element& element, PassRefPtrWillBeRawPtr<EditingStyle> style)
+void StyledMarkupAccumulator::appendElement(const Element& element, PassRefPtrWillBeRawPtr<EditingStyle> style)
{
- appendElement(m_result, element, false, style);
+ if ((element.isHTMLElement() && shouldAnnotate()) || shouldApplyWrappingStyle(element)) {
+ appendElementWithInlineStyle(m_result, element, style);
+ return;
+ }
+ appendElement(m_result, element);
}
RefPtrWillBeRawPtr<EditingStyle> StyledMarkupAccumulator::createInlineStyle(Element& element)
@@ -161,29 +165,31 @@ RefPtrWillBeRawPtr<EditingStyle> StyledMarkupAccumulator::createInlineStyle(Elem
return inlineStyle;
}
-void StyledMarkupAccumulator::appendElement(StringBuilder& out, Element& element, bool addDisplayInline, PassRefPtrWillBeRawPtr<EditingStyle> style)
+void StyledMarkupAccumulator::appendElementWithInlineStyle(StringBuilder& out, const Element& element, PassRefPtrWillBeRawPtr<EditingStyle> style)
{
const bool documentIsHTML = element.document().isHTMLDocument();
m_formatter.appendOpenTag(out, element, nullptr);
-
- const bool shouldOverrideStyleAttr = (element.isHTMLElement() && (shouldAnnotate() || addDisplayInline)) || shouldApplyWrappingStyle(element);
-
AttributeCollection attributes = element.attributes();
for (const auto& attribute : attributes) {
// We'll handle the style attribute separately, below.
- if (attribute.name() == styleAttr && shouldOverrideStyleAttr)
+ if (attribute.name() == styleAttr)
continue;
m_formatter.appendAttribute(out, element, attribute, nullptr);
}
-
- if (shouldOverrideStyleAttr) {
- if (style && !style->isEmpty()) {
- out.appendLiteral(" style=\"");
- MarkupFormatter::appendAttributeValue(out, style->style()->asText(), documentIsHTML);
- out.append('\"');
- }
+ if (style && !style->isEmpty()) {
+ out.appendLiteral(" style=\"");
+ MarkupFormatter::appendAttributeValue(out, style->style()->asText(), documentIsHTML);
+ out.append('\"');
}
+ m_formatter.appendCloseTag(out, element);
+}
+void StyledMarkupAccumulator::appendElement(StringBuilder& out, const Element& element)
+{
+ m_formatter.appendOpenTag(out, element, nullptr);
+ AttributeCollection attributes = element.attributes();
+ for (const auto& attribute : attributes)
+ m_formatter.appendAttribute(out, element, attribute, nullptr);
m_formatter.appendCloseTag(out, element);
}
« 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