| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "config.h" | 5 #include "config.h" |
| 6 #include "core/editing/serializers/StyledMarkupSerializer.h" | 6 #include "core/editing/serializers/StyledMarkupSerializer.h" |
| 7 | 7 |
| 8 #include "core/dom/Text.h" | 8 #include "core/dom/Text.h" |
| 9 #include "core/editing/EditingTestBase.h" | 9 #include "core/editing/EditingTestBase.h" |
| 10 | 10 |
| (...skipping 99 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 110 setBodyContent(bodyContent); | 110 setBodyContent(bodyContent); |
| 111 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); | 111 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); |
| 112 EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>()); | 112 EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>()); |
| 113 } | 113 } |
| 114 | 114 |
| 115 TEST_F(StyledMarkupSerializerTest, ShadowTreeDistributeOrder) | 115 TEST_F(StyledMarkupSerializerTest, ShadowTreeDistributeOrder) |
| 116 { | 116 { |
| 117 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; | 117 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; |
| 118 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; | 118 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; |
| 119 setBodyContent(bodyContent); | 119 setBodyContent(bodyContent); |
| 120 setShadowContent(shadowContent); | 120 setShadowContent(shadowContent, "host"); |
| 121 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) | 121 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) |
| 122 << "00 and 33 aren't appeared since they aren't distributed."; | 122 << "00 and 33 aren't appeared since they aren't distributed."; |
| 123 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"one\">11</b></a></p
>", serialize<EditingInComposedTreeStrategy>()) | 123 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"one\">11</b></a></p
>", serialize<EditingInComposedTreeStrategy>()) |
| 124 << "00 and 33 aren't appeared since they aren't distributed."; | 124 << "00 and 33 aren't appeared since they aren't distributed."; |
| 125 } | 125 } |
| 126 | 126 |
| 127 TEST_F(StyledMarkupSerializerTest, ShadowTreeInput) | 127 TEST_F(StyledMarkupSerializerTest, ShadowTreeInput) |
| 128 { | 128 { |
| 129 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
"><input value=\"22\"></b>33</p>"; | 129 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
"><input value=\"22\"></b>33</p>"; |
| 130 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; | 130 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; |
| 131 setBodyContent(bodyContent); | 131 setBodyContent(bodyContent); |
| 132 setShadowContent(shadowContent); | 132 setShadowContent(shadowContent, "host"); |
| 133 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\"><input value=\"2
2\"></b></p>", serialize<EditingStrategy>()) | 133 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\"><input value=\"2
2\"></b></p>", serialize<EditingStrategy>()) |
| 134 << "00 and 33 aren't appeared since they aren't distributed."; | 134 << "00 and 33 aren't appeared since they aren't distributed."; |
| 135 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\"><input value=\"22\"></b><b id=\"o
ne\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>()) | 135 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\"><input value=\"22\"></b><b id=\"o
ne\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>()) |
| 136 << "00 and 33 aren't appeared since they aren't distributed."; | 136 << "00 and 33 aren't appeared since they aren't distributed."; |
| 137 } | 137 } |
| 138 | 138 |
| 139 TEST_F(StyledMarkupSerializerTest, ShadowTreeNested) | 139 TEST_F(StyledMarkupSerializerTest, ShadowTreeNested) |
| 140 { | 140 { |
| 141 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; | 141 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; |
| 142 const char* shadowContent1 = "<a><content select=#two></content><b id=host2>
</b><content select=#one></content></a>"; | 142 const char* shadowContent1 = "<a><content select=#two></content><b id=host2>
</b><content select=#one></content></a>"; |
| 143 const char* shadowContent2 = "NESTED"; | 143 const char* shadowContent2 = "NESTED"; |
| 144 setBodyContent(bodyContent); | 144 setBodyContent(bodyContent); |
| 145 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = setShadowContent(shadowContent1
); | 145 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = setShadowContent(shadowContent1
, "host"); |
| 146 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host2", shado
wContent2); | 146 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host2", shado
wContent2); |
| 147 | 147 |
| 148 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) | 148 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) |
| 149 << "00 and 33 aren't appeared since they aren't distributed."; | 149 << "00 and 33 aren't appeared since they aren't distributed."; |
| 150 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"host2\">NESTED</b><
b id=\"one\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>()) | 150 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"host2\">NESTED</b><
b id=\"one\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>()) |
| 151 << "00 and 33 aren't appeared since they aren't distributed."; | 151 << "00 and 33 aren't appeared since they aren't distributed."; |
| 152 } | 152 } |
| 153 | 153 |
| 154 TEST_F(StyledMarkupSerializerTest, StyleDisplayNone) | 154 TEST_F(StyledMarkupSerializerTest, StyleDisplayNone) |
| 155 { | 155 { |
| (...skipping 18 matching lines...) Expand all Loading... |
| 174 setBodyContent(bodyContent); | 174 setBodyContent(bodyContent); |
| 175 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 175 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
| 176 RefPtrWillBeRawPtr<Text> text = toText(one->firstChild()); | 176 RefPtrWillBeRawPtr<Text> text = toText(one->firstChild()); |
| 177 Position startDOM(text, 0); | 177 Position startDOM(text, 0); |
| 178 Position endDOM(text, 2); | 178 Position endDOM(text, 2); |
| 179 const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM,
endDOM, AnnotateForInterchange); | 179 const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM,
endDOM, AnnotateForInterchange); |
| 180 | 180 |
| 181 bodyContent = "<p id='host' style='color: red'>00<span id='one'>11</span>22<
/p>\n"; | 181 bodyContent = "<p id='host' style='color: red'>00<span id='one'>11</span>22<
/p>\n"; |
| 182 const char* shadowContent = "<span style='font-weight: bold'><content select
=#one></content></span>"; | 182 const char* shadowContent = "<span style='font-weight: bold'><content select
=#one></content></span>"; |
| 183 setBodyContent(bodyContent); | 183 setBodyContent(bodyContent); |
| 184 setShadowContent(shadowContent); | 184 setShadowContent(shadowContent, "host"); |
| 185 one = document().getElementById("one"); | 185 one = document().getElementById("one"); |
| 186 text = toText(one->firstChild()); | 186 text = toText(one->firstChild()); |
| 187 PositionInComposedTree startICT(text, 0); | 187 PositionInComposedTree startICT(text, 0); |
| 188 PositionInComposedTree endICT(text, 2); | 188 PositionInComposedTree endICT(text, 2); |
| 189 const std::string& serializedICT = serializePart<EditingInComposedTreeStrate
gy>(startICT, endICT, AnnotateForInterchange); | 189 const std::string& serializedICT = serializePart<EditingInComposedTreeStrate
gy>(startICT, endICT, AnnotateForInterchange); |
| 190 | 190 |
| 191 EXPECT_EQ(serializedDOM, serializedICT); | 191 EXPECT_EQ(serializedDOM, serializedICT); |
| 192 } | 192 } |
| 193 | 193 |
| 194 TEST_F(StyledMarkupSerializerTest, AcrossShadow) | 194 TEST_F(StyledMarkupSerializerTest, AcrossShadow) |
| (...skipping 29 matching lines...) Expand all Loading... |
| 224 RefPtrWillBeRawPtr<Element> span2 = document().getElementById("span2"); | 224 RefPtrWillBeRawPtr<Element> span2 = document().getElementById("span2"); |
| 225 Position startDOM = Position::firstPositionInNode(span1.get()); | 225 Position startDOM = Position::firstPositionInNode(span1.get()); |
| 226 Position endDOM = Position::lastPositionInNode(span2.get()); | 226 Position endDOM = Position::lastPositionInNode(span2.get()); |
| 227 EXPECT_EQ("", serializePart<EditingStrategy>(startDOM, endDOM)); | 227 EXPECT_EQ("", serializePart<EditingStrategy>(startDOM, endDOM)); |
| 228 PositionInComposedTree startICT = PositionInComposedTree::firstPositionInNod
e(span1.get()); | 228 PositionInComposedTree startICT = PositionInComposedTree::firstPositionInNod
e(span1.get()); |
| 229 PositionInComposedTree endICT = PositionInComposedTree::lastPositionInNode(s
pan2.get()); | 229 PositionInComposedTree endICT = PositionInComposedTree::lastPositionInNode(s
pan2.get()); |
| 230 EXPECT_EQ("", serializePart<EditingInComposedTreeStrategy>(startICT, endICT)
); | 230 EXPECT_EQ("", serializePart<EditingInComposedTreeStrategy>(startICT, endICT)
); |
| 231 } | 231 } |
| 232 | 232 |
| 233 } // namespace blink | 233 } // namespace blink |
| OLD | NEW |