| Index: Source/core/editing/StyledMarkupSerializer.cpp
|
| diff --git a/Source/core/editing/StyledMarkupSerializer.cpp b/Source/core/editing/StyledMarkupSerializer.cpp
|
| index 4b10abcb39f8d0ee3cb0fed86f596222c00ed9ad..b0e52aa350dbb6dc66f93fc413a35d0da5df4ea0 100644
|
| --- a/Source/core/editing/StyledMarkupSerializer.cpp
|
| +++ b/Source/core/editing/StyledMarkupSerializer.cpp
|
| @@ -124,7 +124,7 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
|
| Node* firstNode = m_start.nodeAsRangeFirstNode();
|
| VisiblePosition visibleStart(toPositionInDOMTree(m_start), VP_DEFAULT_AFFINITY);
|
| VisiblePosition visibleEnd(toPositionInDOMTree(m_end), VP_DEFAULT_AFFINITY);
|
| - if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAfter(visibleStart)) {
|
| + if (shouldAnnotate() && needInterchangeNewlineAfter(visibleStart)) {
|
| markupAccumulator.appendInterchangeNewline();
|
| if (visibleStart == visibleEnd.previous())
|
| return markupAccumulator.takeResults();
|
| @@ -188,7 +188,7 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
|
| }
|
|
|
| // FIXME: The interchange newline should be placed in the block that it's in, not after all of the content, unconditionally.
|
| - if (m_shouldAnnotate == AnnotateForInterchange && needInterchangeNewlineAt(visibleEnd))
|
| + if (shouldAnnotate() && needInterchangeNewlineAt(visibleEnd))
|
| markupAccumulator.appendInterchangeNewline();
|
|
|
| return markupAccumulator.takeResults();
|
| @@ -204,8 +204,7 @@ Node* StyledMarkupSerializer<Strategy>::serializeNodes(Node* startNode, Node* pa
|
|
|
| Node* highestNodeToBeSerialized = markupAccumulator->highestNodeToBeSerialized();
|
| if (highestNodeToBeSerialized && Strategy::parent(*highestNodeToBeSerialized)) {
|
| - bool shouldAnnotate = m_shouldAnnotate == AnnotateForInterchange;
|
| - RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::wrappingStyleForSerialization(Strategy::parent(*highestNodeToBeSerialized), shouldAnnotate);
|
| + RefPtrWillBeRawPtr<EditingStyle> wrappingStyle = EditingStyle::wrappingStyleForSerialization(Strategy::parent(*highestNodeToBeSerialized), shouldAnnotate());
|
| markupAccumulator->setWrappingStyle(wrappingStyle.release());
|
| }
|
| return traverseNodesForSerialization(startNode, pastEnd, markupAccumulator);
|
| @@ -241,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)) {
|
| @@ -301,7 +300,7 @@ bool StyledMarkupSerializer<Strategy>::needsInlineStyle(const Element& element)
|
| {
|
| if (!element.isHTMLElement())
|
| return false;
|
| - if (m_shouldAnnotate == AnnotateForInterchange)
|
| + if (shouldAnnotate())
|
| return true;
|
| return convertBlocksToInlines() && isBlock(&element);
|
| }
|
| @@ -318,7 +317,7 @@ void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& acc
|
| if (!node.isElementNode())
|
| return;
|
| Element& element = toElement(node);
|
| - if (accumulator.shouldApplyWrappingStyle(element) || needsInlineStyle(element))
|
| + if (shouldApplyWrappingStyle(accumulator, element) || needsInlineStyle(element))
|
| accumulator.appendElementWithInlineStyle(markup, element, style);
|
| else
|
| accumulator.appendElement(markup, element);
|
| @@ -337,6 +336,50 @@ RefPtrWillBeRawPtr<EditingStyle> StyledMarkupSerializer<Strategy>::createInlineS
|
| return inlineStyle;
|
| }
|
|
|
| +template<typename Strategy>
|
| +void StyledMarkupSerializer<Strategy>::appendStartMarkup(StyledMarkupAccumulator& accumulator, Node& node)
|
| +{
|
| + switch (node.nodeType()) {
|
| + case Node::TEXT_NODE: {
|
| + Text& text = toText(node);
|
| + if (text.parentElement() && text.parentElement()->tagQName() == textareaTag) {
|
| + accumulator.appendText(text);
|
| + return;
|
| + }
|
| + RefPtrWillBeRawPtr<EditingStyle> inlineStyle = nullptr;
|
| + if (shouldApplyWrappingStyle(accumulator, text)) {
|
| + inlineStyle = accumulator.wrappingStyle()->copy();
|
| + // FIXME: <rdar://problem/5371536> Style rules that match pasted content can change it's appearance
|
| + // Make sure spans are inline style in paste side e.g. span { display: block }.
|
| + inlineStyle->forceInline();
|
| + // FIXME: Should this be included in forceInline?
|
| + inlineStyle->style()->setProperty(CSSPropertyFloat, CSSValueNone);
|
| + }
|
| + accumulator.appendTextWithInlineStyle(text, inlineStyle);
|
| + break;
|
| + } case Node::ELEMENT_NODE: {
|
| + Element& element = toElement(node);
|
| + if ((element.isHTMLElement() && shouldAnnotate()) || shouldApplyWrappingStyle(accumulator, element)) {
|
| + RefPtrWillBeRawPtr<EditingStyle> inlineStyle = accumulator.createInlineStyle(element);
|
| + accumulator.appendElementWithInlineStyle(element, inlineStyle);
|
| + return;
|
| + }
|
| + accumulator.appendElement(element);
|
| + break;
|
| + }
|
| + default:
|
| + accumulator.appendStartMarkup(node);
|
| + break;
|
| + }
|
| +}
|
| +
|
| +template<typename Strategy>
|
| +bool StyledMarkupSerializer<Strategy>::shouldApplyWrappingStyle(const StyledMarkupAccumulator& accumulator, const Node& node) const
|
| +{
|
| + return accumulator.highestNodeToBeSerialized() && Strategy::parent(*accumulator.highestNodeToBeSerialized()) == Strategy::parent(node)
|
| + && accumulator.wrappingStyle() && accumulator.wrappingStyle()->style();
|
| +}
|
| +
|
| template class StyledMarkupSerializer<EditingStrategy>;
|
|
|
| } // namespace blink
|
|
|