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

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

Issue 1181703003: Refactoring: Move StyledMarkupAccumulator::createInlineStyle to the serializer (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: bug fix: rebasing failed 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/StyledMarkupSerializer.h ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/core/editing/StyledMarkupSerializer.cpp
diff --git a/Source/core/editing/StyledMarkupSerializer.cpp b/Source/core/editing/StyledMarkupSerializer.cpp
index 71363895718ed27610c085bbaecf662566bc5941..698676e1c3d1dd07a469b73fd2c250af677074a5 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,59 @@ 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: {
+ Text& text = toText(node);
+ if (text.parentElement() && text.parentElement()->tagQName() == textareaTag) {
+ accumulator.appendText(text);
+ break;
+ }
+ accumulator.appendTextWithInlineStyle(text);
+ break;
+ }
+ case Node::ELEMENT_NODE: {
+ Element& element = toElement(node);
+ RefPtrWillBeRawPtr<EditingStyle> inlineStyle = createInlineStyle(accumulator, element);
+ accumulator.appendElement(element, inlineStyle);
+ 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
« no previous file with comments | « Source/core/editing/StyledMarkupSerializer.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698