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

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

Issue 1163673005: Refactoring: Remove StyledMarkupAccumulator::RangeFullySelectsNodes (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: yosin'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
Index: Source/core/editing/StyledMarkupSerializer.cpp
diff --git a/Source/core/editing/StyledMarkupSerializer.cpp b/Source/core/editing/StyledMarkupSerializer.cpp
index 0a4d7e1620987fac506794771280d8534e1e222d..73ff93215e842ecdb112f54bc4efcb75a43fb29e 100644
--- a/Source/core/editing/StyledMarkupSerializer.cpp
+++ b/Source/core/editing/StyledMarkupSerializer.cpp
@@ -172,9 +172,16 @@ String StyledMarkupSerializer<Strategy>::createMarkup()
markupAccumulator.wrapWithStyleNode(fullySelectedRootStyle->style());
}
} else {
- // Since this node and all the other ancestors are not in the selection we want to set RangeFullySelectsNode to DoesNotFullySelectNode
- // so that styles that affect the exterior of the node are not included.
- wrapWithNode(markupAccumulator, *ancestor, StyledMarkupAccumulator::DoesNotFullySelectNode);
+ RefPtrWillBeRawPtr<EditingStyle> style = nullptr;
+ if (ancestor->isElementNode())
+ style = markupAccumulator.createInlineStyle(toElement(*ancestor), convertBlocksToInlines() && isBlock(ancestor));
+ // Since this node and all the other ancestors are not in the selection we want
+ // styles that affect the exterior of the node not to be not included.
+ // If the node is not fully selected by the range, then we don't want to keep styles that affect its relationship to the nodes around it
+ // only the ones that affect it and the nodes within it.
+ if (style && style->style())
+ style->style()->removeProperty(CSSPropertyFloat);
+ wrapWithNode(markupAccumulator, *ancestor, style);
}
if (ancestor == m_highestNodeToBeSerialized)
@@ -280,8 +287,12 @@ Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
// or b) ancestors that we never encountered during a pre-order traversal starting at startNode:
ASSERT(startNode);
ASSERT(Strategy::isDescendantOf(*startNode, *parent));
- if (markupAccumulator)
- wrapWithNode(*markupAccumulator, *parent, StyledMarkupAccumulator::DoesFullySelectNode);
+ if (markupAccumulator) {
+ RefPtrWillBeRawPtr<EditingStyle> style = nullptr;
+ if (parent->isElementNode())
+ style = markupAccumulator->createInlineStyle(toElement(*parent), convertBlocksToInlines() && isBlock(parent));
+ wrapWithNode(*markupAccumulator, *parent, style);
+ }
lastClosed = parent;
}
}
@@ -290,11 +301,11 @@ Node* StyledMarkupSerializer<Strategy>::traverseNodesForSerialization(Node* star
}
template<typename Strategy>
-void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& accumulator, ContainerNode& node, StyledMarkupAccumulator::RangeFullySelectsNode rangeFullySelectsNode)
+void StyledMarkupSerializer<Strategy>::wrapWithNode(StyledMarkupAccumulator& accumulator, ContainerNode& node, PassRefPtrWillBeRawPtr<EditingStyle> style)
{
StringBuilder markup;
if (node.isElementNode())
- accumulator.appendElement(markup, toElement(node), convertBlocksToInlines() && isBlock(&node), rangeFullySelectsNode);
+ accumulator.appendElement(markup, toElement(node), convertBlocksToInlines() && isBlock(&node), style);
else
accumulator.appendStartMarkup(markup, node);
accumulator.pushMarkup(markup.toString());
« Source/core/editing/StyledMarkupSerializer.h ('K') | « Source/core/editing/StyledMarkupSerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698