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

Unified Diff: third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp

Issue 2912213002: Support serializing shadow DOM to MHTML (Closed)
Patch Set: Strip anoter shadow attribute Created 3 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: third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp
diff --git a/third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp b/third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp
index c8cbc31e60ee0f9f49c624b8beffe41dbaff43cf..d9427271ef010fe5b26d17bb05a64e0db037664c 100644
--- a/third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp
+++ b/third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp
@@ -151,6 +151,11 @@ bool MarkupAccumulator::SerializeAsHTMLDocument(const Node& node) const {
return formatter_.SerializeAsHTMLDocument(node);
}
+std::pair<Node*, Element*> MarkupAccumulator::GetAuxiliaryDOMTree(
+ const Element& element) const {
+ return std::pair<Node*, Element*>();
+}
+
template <typename Strategy>
static void SerializeNodesWithNamespaces(MarkupAccumulator& accumulator,
Node& target_node,
@@ -177,6 +182,25 @@ static void SerializeNodesWithNamespaces(MarkupAccumulator& accumulator,
for (; current; current = Strategy::NextSibling(*current))
SerializeNodesWithNamespaces<Strategy>(accumulator, *current,
kIncludeNode, &namespace_hash);
+
+ // Traverses other DOM tree, i.e., shadow tree.
+ if (target_node.IsElementNode()) {
+ std::pair<Node*, Element*> auxiliary_pair =
+ accumulator.GetAuxiliaryDOMTree(ToElement(target_node));
+ Node* auxiliary_tree = auxiliary_pair.first;
+ Element* enclosing_element = auxiliary_pair.second;
+ if (auxiliary_tree) {
+ if (auxiliary_pair.second)
+ accumulator.AppendStartTag(*enclosing_element);
+ current = Strategy::FirstChild(*auxiliary_tree);
+ for (; current; current = Strategy::NextSibling(*current)) {
+ SerializeNodesWithNamespaces<Strategy>(accumulator, *current,
+ kIncludeNode, &namespace_hash);
+ }
+ if (enclosing_element)
+ accumulator.AppendEndTag(*enclosing_element);
+ }
+ }
}
if ((!children_only && target_node.IsElementNode()) &&

Powered by Google App Engine
This is Rietveld 408576698