| 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 "core/editing/serializers/StyledMarkupSerializer.h" | 5 #include "core/editing/serializers/StyledMarkupSerializer.h" |
| 6 | 6 |
| 7 #include "core/dom/Text.h" | 7 #include "core/dom/Text.h" |
| 8 #include "core/editing/EditingTestBase.h" | 8 #include "core/editing/EditingTestBase.h" |
| 9 | 9 |
| 10 namespace blink { | 10 namespace blink { |
| (...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 45 { | 45 { |
| 46 return createMarkup(start, end, shouldAnnotate).utf8().data(); | 46 return createMarkup(start, end, shouldAnnotate).utf8().data(); |
| 47 } | 47 } |
| 48 | 48 |
| 49 TEST_F(StyledMarkupSerializerTest, TextOnly) | 49 TEST_F(StyledMarkupSerializerTest, TextOnly) |
| 50 { | 50 { |
| 51 const char* bodyContent = "Hello world!"; | 51 const char* bodyContent = "Hello world!"; |
| 52 setBodyContent(bodyContent); | 52 setBodyContent(bodyContent); |
| 53 const char* expectedResult = "<span style=\"display: inline !important; floa
t: none;\">Hello world!</span>"; | 53 const char* expectedResult = "<span style=\"display: inline !important; floa
t: none;\">Hello world!</span>"; |
| 54 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); | 54 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); |
| 55 EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>()); | 55 EXPECT_EQ(expectedResult, serialize<EditingInFlatTreeStrategy>()); |
| 56 } | 56 } |
| 57 | 57 |
| 58 TEST_F(StyledMarkupSerializerTest, BlockFormatting) | 58 TEST_F(StyledMarkupSerializerTest, BlockFormatting) |
| 59 { | 59 { |
| 60 const char* bodyContent = "<div>Hello world!</div>"; | 60 const char* bodyContent = "<div>Hello world!</div>"; |
| 61 setBodyContent(bodyContent); | 61 setBodyContent(bodyContent); |
| 62 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); | 62 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); |
| 63 EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>()); | 63 EXPECT_EQ(bodyContent, serialize<EditingInFlatTreeStrategy>()); |
| 64 } | 64 } |
| 65 | 65 |
| 66 TEST_F(StyledMarkupSerializerTest, FormControlInput) | 66 TEST_F(StyledMarkupSerializerTest, FormControlInput) |
| 67 { | 67 { |
| 68 const char* bodyContent = "<input value='foo'>"; | 68 const char* bodyContent = "<input value='foo'>"; |
| 69 setBodyContent(bodyContent); | 69 setBodyContent(bodyContent); |
| 70 const char* expectedResult = "<input value=\"foo\">"; | 70 const char* expectedResult = "<input value=\"foo\">"; |
| 71 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); | 71 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); |
| 72 EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>()); | 72 EXPECT_EQ(expectedResult, serialize<EditingInFlatTreeStrategy>()); |
| 73 } | 73 } |
| 74 | 74 |
| 75 TEST_F(StyledMarkupSerializerTest, FormControlInputRange) | 75 TEST_F(StyledMarkupSerializerTest, FormControlInputRange) |
| 76 { | 76 { |
| 77 const char* bodyContent = "<input type=range>"; | 77 const char* bodyContent = "<input type=range>"; |
| 78 setBodyContent(bodyContent); | 78 setBodyContent(bodyContent); |
| 79 const char* expectedResult = "<input type=\"range\">"; | 79 const char* expectedResult = "<input type=\"range\">"; |
| 80 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); | 80 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); |
| 81 EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>()); | 81 EXPECT_EQ(expectedResult, serialize<EditingInFlatTreeStrategy>()); |
| 82 } | 82 } |
| 83 | 83 |
| 84 TEST_F(StyledMarkupSerializerTest, FormControlSelect) | 84 TEST_F(StyledMarkupSerializerTest, FormControlSelect) |
| 85 { | 85 { |
| 86 const char* bodyContent = "<select><option value=\"1\">one</option><option v
alue=\"2\">two</option></select>"; | 86 const char* bodyContent = "<select><option value=\"1\">one</option><option v
alue=\"2\">two</option></select>"; |
| 87 setBodyContent(bodyContent); | 87 setBodyContent(bodyContent); |
| 88 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); | 88 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); |
| 89 EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>()); | 89 EXPECT_EQ(bodyContent, serialize<EditingInFlatTreeStrategy>()); |
| 90 } | 90 } |
| 91 | 91 |
| 92 TEST_F(StyledMarkupSerializerTest, FormControlTextArea) | 92 TEST_F(StyledMarkupSerializerTest, FormControlTextArea) |
| 93 { | 93 { |
| 94 const char* bodyContent = "<textarea>foo bar</textarea>"; | 94 const char* bodyContent = "<textarea>foo bar</textarea>"; |
| 95 setBodyContent(bodyContent); | 95 setBodyContent(bodyContent); |
| 96 const char* expectedResult = "<textarea></textarea>"; | 96 const char* expectedResult = "<textarea></textarea>"; |
| 97 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()) | 97 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()) |
| 98 << "contents of TEXTAREA element should not be appeared."; | 98 << "contents of TEXTAREA element should not be appeared."; |
| 99 EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>()); | 99 EXPECT_EQ(expectedResult, serialize<EditingInFlatTreeStrategy>()); |
| 100 } | 100 } |
| 101 | 101 |
| 102 TEST_F(StyledMarkupSerializerTest, HeadingFormatting) | 102 TEST_F(StyledMarkupSerializerTest, HeadingFormatting) |
| 103 { | 103 { |
| 104 const char* bodyContent = "<h4>Hello world!</h4>"; | 104 const char* bodyContent = "<h4>Hello world!</h4>"; |
| 105 setBodyContent(bodyContent); | 105 setBodyContent(bodyContent); |
| 106 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); | 106 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); |
| 107 EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>()); | 107 EXPECT_EQ(bodyContent, serialize<EditingInFlatTreeStrategy>()); |
| 108 } | 108 } |
| 109 | 109 |
| 110 TEST_F(StyledMarkupSerializerTest, InlineFormatting) | 110 TEST_F(StyledMarkupSerializerTest, InlineFormatting) |
| 111 { | 111 { |
| 112 const char* bodyContent = "<b>Hello world!</b>"; | 112 const char* bodyContent = "<b>Hello world!</b>"; |
| 113 setBodyContent(bodyContent); | 113 setBodyContent(bodyContent); |
| 114 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); | 114 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); |
| 115 EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>()); | 115 EXPECT_EQ(bodyContent, serialize<EditingInFlatTreeStrategy>()); |
| 116 } | 116 } |
| 117 | 117 |
| 118 TEST_F(StyledMarkupSerializerTest, Mixed) | 118 TEST_F(StyledMarkupSerializerTest, Mixed) |
| 119 { | 119 { |
| 120 const char* bodyContent = "<i>foo<b>bar</b>baz</i>"; | 120 const char* bodyContent = "<i>foo<b>bar</b>baz</i>"; |
| 121 setBodyContent(bodyContent); | 121 setBodyContent(bodyContent); |
| 122 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); | 122 EXPECT_EQ(bodyContent, serialize<EditingStrategy>()); |
| 123 EXPECT_EQ(bodyContent, serialize<EditingInComposedTreeStrategy>()); | 123 EXPECT_EQ(bodyContent, serialize<EditingInFlatTreeStrategy>()); |
| 124 } | 124 } |
| 125 | 125 |
| 126 TEST_F(StyledMarkupSerializerTest, ShadowTreeDistributeOrder) | 126 TEST_F(StyledMarkupSerializerTest, ShadowTreeDistributeOrder) |
| 127 { | 127 { |
| 128 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; | 128 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; |
| 129 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; | 129 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; |
| 130 setBodyContent(bodyContent); | 130 setBodyContent(bodyContent); |
| 131 setShadowContent(shadowContent, "host"); | 131 setShadowContent(shadowContent, "host"); |
| 132 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) | 132 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) |
| 133 << "00 and 33 aren't appeared since they aren't distributed."; | 133 << "00 and 33 aren't appeared since they aren't distributed."; |
| 134 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"one\">11</b></a></p
>", serialize<EditingInComposedTreeStrategy>()) | 134 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"one\">11</b></a></p
>", serialize<EditingInFlatTreeStrategy>()) |
| 135 << "00 and 33 aren't appeared since they aren't distributed."; | 135 << "00 and 33 aren't appeared since they aren't distributed."; |
| 136 } | 136 } |
| 137 | 137 |
| 138 TEST_F(StyledMarkupSerializerTest, ShadowTreeInput) | 138 TEST_F(StyledMarkupSerializerTest, ShadowTreeInput) |
| 139 { | 139 { |
| 140 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
"><input value=\"22\"></b>33</p>"; | 140 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
"><input value=\"22\"></b>33</p>"; |
| 141 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; | 141 const char* shadowContent = "<a><content select=#two></content><content sele
ct=#one></content></a>"; |
| 142 setBodyContent(bodyContent); | 142 setBodyContent(bodyContent); |
| 143 setShadowContent(shadowContent, "host"); | 143 setShadowContent(shadowContent, "host"); |
| 144 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\"><input value=\"2
2\"></b></p>", serialize<EditingStrategy>()) | 144 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\"><input value=\"2
2\"></b></p>", serialize<EditingStrategy>()) |
| 145 << "00 and 33 aren't appeared since they aren't distributed."; | 145 << "00 and 33 aren't appeared since they aren't distributed."; |
| 146 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\"><input value=\"22\"></b><b id=\"o
ne\">11</b></a></p>", serialize<EditingInComposedTreeStrategy>()) | 146 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\"><input value=\"22\"></b><b id=\"o
ne\">11</b></a></p>", serialize<EditingInFlatTreeStrategy>()) |
| 147 << "00 and 33 aren't appeared since they aren't distributed."; | 147 << "00 and 33 aren't appeared since they aren't distributed."; |
| 148 } | 148 } |
| 149 | 149 |
| 150 TEST_F(StyledMarkupSerializerTest, ShadowTreeNested) | 150 TEST_F(StyledMarkupSerializerTest, ShadowTreeNested) |
| 151 { | 151 { |
| 152 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; | 152 const char* bodyContent = "<p id=\"host\">00<b id=\"one\">11</b><b id=\"two\
">22</b>33</p>"; |
| 153 const char* shadowContent1 = "<a><content select=#two></content><b id=host2>
</b><content select=#one></content></a>"; | 153 const char* shadowContent1 = "<a><content select=#two></content><b id=host2>
</b><content select=#one></content></a>"; |
| 154 const char* shadowContent2 = "NESTED"; | 154 const char* shadowContent2 = "NESTED"; |
| 155 setBodyContent(bodyContent); | 155 setBodyContent(bodyContent); |
| 156 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = setShadowContent(shadowContent1
, "host"); | 156 RefPtrWillBeRawPtr<ShadowRoot> shadowRoot1 = setShadowContent(shadowContent1
, "host"); |
| 157 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host2", shado
wContent2); | 157 createShadowRootForElementWithIDAndSetInnerHTML(*shadowRoot1, "host2", shado
wContent2); |
| 158 | 158 |
| 159 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) | 159 EXPECT_EQ("<p id=\"host\"><b id=\"one\">11</b><b id=\"two\">22</b></p>", ser
ialize<EditingStrategy>()) |
| 160 << "00 and 33 aren't appeared since they aren't distributed."; | 160 << "00 and 33 aren't appeared since they aren't distributed."; |
| 161 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>()) | 161 EXPECT_EQ("<p id=\"host\"><a><b id=\"two\">22</b><b id=\"host2\">NESTED</b><
b id=\"one\">11</b></a></p>", serialize<EditingInFlatTreeStrategy>()) |
| 162 << "00 and 33 aren't appeared since they aren't distributed."; | 162 << "00 and 33 aren't appeared since they aren't distributed."; |
| 163 } | 163 } |
| 164 | 164 |
| 165 TEST_F(StyledMarkupSerializerTest, ShadowTreeInterchangedNewline) | 165 TEST_F(StyledMarkupSerializerTest, ShadowTreeInterchangedNewline) |
| 166 { | 166 { |
| 167 const char* bodyContent = "<a id=host><b id=one>1</b></a>"; | 167 const char* bodyContent = "<a id=host><b id=one>1</b></a>"; |
| 168 const char* shadowContent = "<content select=#one></content><div><br></div>"
; | 168 const char* shadowContent = "<content select=#one></content><div><br></div>"
; |
| 169 setBodyContent(bodyContent); | 169 setBodyContent(bodyContent); |
| 170 setShadowContent(shadowContent, "host"); | 170 setShadowContent(shadowContent, "host"); |
| 171 | 171 |
| 172 std::string resultFromDOMTree = serialize<EditingStrategy>(AnnotateForInterc
hange); | 172 std::string resultFromDOMTree = serialize<EditingStrategy>(AnnotateForInterc
hange); |
| 173 std::string resultFromComposedTree = serialize<EditingInComposedTreeStrategy
>(AnnotateForInterchange); | 173 std::string resultFromFlatTree = serialize<EditingInFlatTreeStrategy>(Annota
teForInterchange); |
| 174 size_t mismatchedIndex = mismatch(resultFromDOMTree, resultFromComposedTree)
; | 174 size_t mismatchedIndex = mismatch(resultFromDOMTree, resultFromFlatTree); |
| 175 | 175 |
| 176 // Note: We check difference between DOM tree result and composed tree | 176 // Note: We check difference between DOM tree result and flat tree |
| 177 // result, because results contain "style" attribute and this test | 177 // result, because results contain "style" attribute and this test |
| 178 // doesn't care about actual value of "style" attribute. | 178 // doesn't care about actual value of "style" attribute. |
| 179 EXPECT_EQ("/a>", resultFromDOMTree.substr(mismatchedIndex)); | 179 EXPECT_EQ("/a>", resultFromDOMTree.substr(mismatchedIndex)); |
| 180 EXPECT_EQ("div><br></div></a><br class=\"Apple-interchange-newline\">", resu
ltFromComposedTree.substr(mismatchedIndex)); | 180 EXPECT_EQ("div><br></div></a><br class=\"Apple-interchange-newline\">", resu
ltFromFlatTree.substr(mismatchedIndex)); |
| 181 } | 181 } |
| 182 | 182 |
| 183 TEST_F(StyledMarkupSerializerTest, StyleDisplayNone) | 183 TEST_F(StyledMarkupSerializerTest, StyleDisplayNone) |
| 184 { | 184 { |
| 185 const char* bodyContent = "<b>00<i style='display:none'>11</i>22</b>"; | 185 const char* bodyContent = "<b>00<i style='display:none'>11</i>22</b>"; |
| 186 setBodyContent(bodyContent); | 186 setBodyContent(bodyContent); |
| 187 const char* expectedResult = "<b>0022</b>"; | 187 const char* expectedResult = "<b>0022</b>"; |
| 188 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); | 188 EXPECT_EQ(expectedResult, serialize<EditingStrategy>()); |
| 189 EXPECT_EQ(expectedResult, serialize<EditingInComposedTreeStrategy>()); | 189 EXPECT_EQ(expectedResult, serialize<EditingInFlatTreeStrategy>()); |
| 190 } | 190 } |
| 191 | 191 |
| 192 TEST_F(StyledMarkupSerializerTest, StyleDisplayNoneAndNewLines) | 192 TEST_F(StyledMarkupSerializerTest, StyleDisplayNoneAndNewLines) |
| 193 { | 193 { |
| 194 const char* bodyContent = "<div style='display:none'>11</div>\n\n"; | 194 const char* bodyContent = "<div style='display:none'>11</div>\n\n"; |
| 195 setBodyContent(bodyContent); | 195 setBodyContent(bodyContent); |
| 196 EXPECT_EQ("", serialize<EditingStrategy>()); | 196 EXPECT_EQ("", serialize<EditingStrategy>()); |
| 197 EXPECT_EQ("", serialize<EditingInComposedTreeStrategy>()); | 197 EXPECT_EQ("", serialize<EditingInFlatTreeStrategy>()); |
| 198 } | 198 } |
| 199 | 199 |
| 200 TEST_F(StyledMarkupSerializerTest, ShadowTreeStyle) | 200 TEST_F(StyledMarkupSerializerTest, ShadowTreeStyle) |
| 201 { | 201 { |
| 202 const char* bodyContent = "<p id='host' style='color: red'><span style='font
-weight: bold;'><span id='one'>11</span></span></p>\n"; | 202 const char* bodyContent = "<p id='host' style='color: red'><span style='font
-weight: bold;'><span id='one'>11</span></span></p>\n"; |
| 203 setBodyContent(bodyContent); | 203 setBodyContent(bodyContent); |
| 204 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 204 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
| 205 RefPtrWillBeRawPtr<Text> text = toText(one->firstChild()); | 205 RefPtrWillBeRawPtr<Text> text = toText(one->firstChild()); |
| 206 Position startDOM(text, 0); | 206 Position startDOM(text, 0); |
| 207 Position endDOM(text, 2); | 207 Position endDOM(text, 2); |
| 208 const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM,
endDOM, AnnotateForInterchange); | 208 const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM,
endDOM, AnnotateForInterchange); |
| 209 | 209 |
| 210 bodyContent = "<p id='host' style='color: red'>00<span id='one'>11</span>22<
/p>\n"; | 210 bodyContent = "<p id='host' style='color: red'>00<span id='one'>11</span>22<
/p>\n"; |
| 211 const char* shadowContent = "<span style='font-weight: bold'><content select
=#one></content></span>"; | 211 const char* shadowContent = "<span style='font-weight: bold'><content select
=#one></content></span>"; |
| 212 setBodyContent(bodyContent); | 212 setBodyContent(bodyContent); |
| 213 setShadowContent(shadowContent, "host"); | 213 setShadowContent(shadowContent, "host"); |
| 214 one = document().getElementById("one"); | 214 one = document().getElementById("one"); |
| 215 text = toText(one->firstChild()); | 215 text = toText(one->firstChild()); |
| 216 PositionInComposedTree startICT(text, 0); | 216 PositionInFlatTree startICT(text, 0); |
| 217 PositionInComposedTree endICT(text, 2); | 217 PositionInFlatTree endICT(text, 2); |
| 218 const std::string& serializedICT = serializePart<EditingInComposedTreeStrate
gy>(startICT, endICT, AnnotateForInterchange); | 218 const std::string& serializedICT = serializePart<EditingInFlatTreeStrategy>(
startICT, endICT, AnnotateForInterchange); |
| 219 | 219 |
| 220 EXPECT_EQ(serializedDOM, serializedICT); | 220 EXPECT_EQ(serializedDOM, serializedICT); |
| 221 } | 221 } |
| 222 | 222 |
| 223 TEST_F(StyledMarkupSerializerTest, AcrossShadow) | 223 TEST_F(StyledMarkupSerializerTest, AcrossShadow) |
| 224 { | 224 { |
| 225 const char* bodyContent = "<p id='host1'>[<span id='one'>11</span>]</p><p id
='host2'>[<span id='two'>22</span>]</p>"; | 225 const char* bodyContent = "<p id='host1'>[<span id='one'>11</span>]</p><p id
='host2'>[<span id='two'>22</span>]</p>"; |
| 226 setBodyContent(bodyContent); | 226 setBodyContent(bodyContent); |
| 227 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); | 227 RefPtrWillBeRawPtr<Element> one = document().getElementById("one"); |
| 228 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); | 228 RefPtrWillBeRawPtr<Element> two = document().getElementById("two"); |
| 229 Position startDOM(toText(one->firstChild()), 0); | 229 Position startDOM(toText(one->firstChild()), 0); |
| 230 Position endDOM(toText(two->firstChild()), 2); | 230 Position endDOM(toText(two->firstChild()), 2); |
| 231 const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM,
endDOM, AnnotateForInterchange); | 231 const std::string& serializedDOM = serializePart<EditingStrategy>(startDOM,
endDOM, AnnotateForInterchange); |
| 232 | 232 |
| 233 bodyContent = "<p id='host1'><span id='one'>11</span></p><p id='host2'><span
id='two'>22</span></p>"; | 233 bodyContent = "<p id='host1'><span id='one'>11</span></p><p id='host2'><span
id='two'>22</span></p>"; |
| 234 const char* shadowContent1 = "[<content select=#one></content>]"; | 234 const char* shadowContent1 = "[<content select=#one></content>]"; |
| 235 const char* shadowContent2 = "[<content select=#two></content>]"; | 235 const char* shadowContent2 = "[<content select=#two></content>]"; |
| 236 setBodyContent(bodyContent); | 236 setBodyContent(bodyContent); |
| 237 setShadowContent(shadowContent1, "host1"); | 237 setShadowContent(shadowContent1, "host1"); |
| 238 setShadowContent(shadowContent2, "host2"); | 238 setShadowContent(shadowContent2, "host2"); |
| 239 one = document().getElementById("one"); | 239 one = document().getElementById("one"); |
| 240 two = document().getElementById("two"); | 240 two = document().getElementById("two"); |
| 241 PositionInComposedTree startICT(toText(one->firstChild()), 0); | 241 PositionInFlatTree startICT(toText(one->firstChild()), 0); |
| 242 PositionInComposedTree endICT(toText(two->firstChild()), 2); | 242 PositionInFlatTree endICT(toText(two->firstChild()), 2); |
| 243 const std::string& serializedICT = serializePart<EditingInComposedTreeStrate
gy>(startICT, endICT, AnnotateForInterchange); | 243 const std::string& serializedICT = serializePart<EditingInFlatTreeStrategy>(
startICT, endICT, AnnotateForInterchange); |
| 244 | 244 |
| 245 EXPECT_EQ(serializedDOM, serializedICT); | 245 EXPECT_EQ(serializedDOM, serializedICT); |
| 246 } | 246 } |
| 247 | 247 |
| 248 TEST_F(StyledMarkupSerializerTest, AcrossInvisibleElements) | 248 TEST_F(StyledMarkupSerializerTest, AcrossInvisibleElements) |
| 249 { | 249 { |
| 250 const char* bodyContent = "<span id='span1' style='display: none'>11</span><
span id='span2' style='display: none'>22</span>"; | 250 const char* bodyContent = "<span id='span1' style='display: none'>11</span><
span id='span2' style='display: none'>22</span>"; |
| 251 setBodyContent(bodyContent); | 251 setBodyContent(bodyContent); |
| 252 RefPtrWillBeRawPtr<Element> span1 = document().getElementById("span1"); | 252 RefPtrWillBeRawPtr<Element> span1 = document().getElementById("span1"); |
| 253 RefPtrWillBeRawPtr<Element> span2 = document().getElementById("span2"); | 253 RefPtrWillBeRawPtr<Element> span2 = document().getElementById("span2"); |
| 254 Position startDOM = Position::firstPositionInNode(span1.get()); | 254 Position startDOM = Position::firstPositionInNode(span1.get()); |
| 255 Position endDOM = Position::lastPositionInNode(span2.get()); | 255 Position endDOM = Position::lastPositionInNode(span2.get()); |
| 256 EXPECT_EQ("", serializePart<EditingStrategy>(startDOM, endDOM)); | 256 EXPECT_EQ("", serializePart<EditingStrategy>(startDOM, endDOM)); |
| 257 PositionInComposedTree startICT = PositionInComposedTree::firstPositionInNod
e(span1.get()); | 257 PositionInFlatTree startICT = PositionInFlatTree::firstPositionInNode(span1.
get()); |
| 258 PositionInComposedTree endICT = PositionInComposedTree::lastPositionInNode(s
pan2.get()); | 258 PositionInFlatTree endICT = PositionInFlatTree::lastPositionInNode(span2.get
()); |
| 259 EXPECT_EQ("", serializePart<EditingInComposedTreeStrategy>(startICT, endICT)
); | 259 EXPECT_EQ("", serializePart<EditingInFlatTreeStrategy>(startICT, endICT)); |
| 260 } | 260 } |
| 261 | 261 |
| 262 } // namespace blink | 262 } // namespace blink |
| OLD | NEW |