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

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

Issue 2912213002: Support serializing shadow DOM to MHTML (Closed)
Patch Set: Add .gitattributes Created 3 years, 7 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..d922cd9465c801a70270c1326de75375c00c07a7 100644
--- a/third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp
+++ b/third_party/WebKit/Source/core/editing/serializers/MarkupAccumulator.cpp
@@ -151,6 +151,12 @@ bool MarkupAccumulator::SerializeAsHTMLDocument(const Node& node) const {
return formatter_.SerializeAsHTMLDocument(node);
}
+Node* MarkupAccumulator::GetAuxiliaryDOMTree(
+ const Element& element,
+ Element** enclosing_element) const {
+ return nullptr;
+}
+
template <typename Strategy>
static void SerializeNodesWithNamespaces(MarkupAccumulator& accumulator,
Node& target_node,
@@ -177,6 +183,24 @@ 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()) {
+ Element* enclosing_element = nullptr;
+ Node* auxiliary_tree = accumulator.GetAuxiliaryDOMTree(
+ ToElement(target_node), &enclosing_element);
+ if (auxiliary_tree) {
+ if (enclosing_element)
+ 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