Chromium Code Reviews| Index: Source/core/editing/StyledMarkupSerializer.cpp |
| diff --git a/Source/core/editing/StyledMarkupSerializer.cpp b/Source/core/editing/StyledMarkupSerializer.cpp |
| index 71363895718ed27610c085bbaecf662566bc5941..3c000f3488abfee1b3ac2e62f52620763f5ed524 100644 |
| --- a/Source/core/editing/StyledMarkupSerializer.cpp |
| +++ b/Source/core/editing/StyledMarkupSerializer.cpp |
| @@ -240,7 +240,7 @@ Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star |
| } else { |
| // Add the node to the markup if we're not skipping the descendants |
| if (markupAccumulator) |
| - markupAccumulator->appendStartTag(*n); |
| + appendStartMarkup(*markupAccumulator, *n); |
| // If node has no children, close the tag now. |
| if (Strategy::hasChildren(*n)) { |
| @@ -330,12 +330,53 @@ RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineS |
| { |
| if (!node.isElementNode()) |
| return nullptr; |
| - RefPtrWillBeRawPtr<EditingStyle> inlineStyle = accumulator.createInlineStyle(toElement(node)); |
| + RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(accumulator, toElement(node)); |
| if (convertBlocksToInlines() && isBlock(&node)) |
| inlineStyle->forceInline(); |
| return inlineStyle; |
| } |
| +template<typename Strategy> |
| +void StyledMarkupSerializer<Strategy>::appendStartMarkup(StyledMarkupAccumulator& accumulator, Node& node) |
| +{ |
| + switch (node.nodeType()) { |
| + case Node::TEXT_NODE: |
| + accumulator.appendText(toText(node)); |
| + break; |
| + case Node::ELEMENT_NODE: { |
| + Element& element = toElement(node); |
| + RefPtrWillBeRawPtr<EditingStyle> style = createInlineStyle(accumulator, element); |
|
yosin_UTC9
2015/06/17 01:07:31
nit: better to use |inlineStyle| rather than |styl
hajimehoshi
2015/06/17 04:33:51
Done.
|
| + accumulator.appendElement(element, style); |
| + break; |
| + } |
| + default: |
| + accumulator.appendStartMarkup(node); |
| + break; |
| + } |
| +} |
| + |
| +template<typename Strategy> |
| +RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineStyle(StyledMarkupAccumulator& accumulator, Element& element) |
| +{ |
| + RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr; |
| + |
| + if (accumulator.shouldApplyWrappingStyle(element)) { |
| + inlineStyle = accumulator.wrappingStyle()->copy(); |
| + inlineStyle->removePropertiesInElementDefaultStyle(&element); |
| + inlineStyle->removeStyleConflictingWithStyleOfElement(&element); |
| + } else { |
| + inlineStyle = EditingStyle::create(); |
| + } |
| + |
| + if (element.isStyledElement() && element.inlineStyle()) |
| + inlineStyle->overrideWithStyle(element.inlineStyle()); |
| + |
| + if (element.isHTMLElement() && shouldAnnotate()) |
| + inlineStyle->mergeStyleFromRulesForSerialization(&toHTMLElement(element)); |
| + |
| + return inlineStyle; |
| +} |
| + |
| template class StyledMarkupSerializer<EditingStrategy>; |
| } // namespace blink |