Chromium Code Reviews| Index: Source/core/editing/StyledMarkupAccumulator.cpp |
| diff --git a/Source/core/editing/StyledMarkupAccumulator.cpp b/Source/core/editing/StyledMarkupAccumulator.cpp |
| index e7cf7f5e3a294be81f1d9867e2abd9f07f6ef99b..97b439b576639d4ea910d751e283c5171ee2055e 100644 |
| --- a/Source/core/editing/StyledMarkupAccumulator.cpp |
| +++ b/Source/core/editing/StyledMarkupAccumulator.cpp |
| @@ -137,7 +137,11 @@ void StyledMarkupAccumulator::appendText(StringBuilder& out, Text& text) |
| void StyledMarkupAccumulator::appendElement(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, 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, Element& element) |
|
tkent
2015/06/11 08:46:08
optional: Can we make |element| argument |const El
hajimehoshi
2015/06/11 08:56:14
Done.
|
| +{ |
| + 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); |
| } |