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

Side by Side Diff: third_party/WebKit/Source/core/css/ActiveStyleSheetsTest.cpp

Issue 2566403003: Migrate WTF::Vector::append() to ::push_back() [part 3 of N] (Closed)
Patch Set: Created 4 years 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 unified diff | Download patch
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 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/css/ActiveStyleSheets.h" 5 #include "core/css/ActiveStyleSheets.h"
6 6
7 #include "core/css/CSSStyleSheet.h" 7 #include "core/css/CSSStyleSheet.h"
8 #include "core/css/MediaQueryEvaluator.h" 8 #include "core/css/MediaQueryEvaluator.h"
9 #include "core/css/StyleSheetContents.h" 9 #include "core/css/StyleSheetContents.h"
10 #include "core/css/StyleSheetList.h" 10 #include "core/css/StyleSheetList.h"
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after
59 ActiveStyleSheetVector newSheets; 59 ActiveStyleSheetVector newSheets;
60 HeapHashSet<Member<RuleSet>> changedRuleSets; 60 HeapHashSet<Member<RuleSet>> changedRuleSets;
61 61
62 EXPECT_EQ(NoActiveSheetsChanged, 62 EXPECT_EQ(NoActiveSheetsChanged,
63 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 63 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
64 EXPECT_EQ(0u, changedRuleSets.size()); 64 EXPECT_EQ(0u, changedRuleSets.size());
65 65
66 CSSStyleSheet* sheet1 = createSheet(); 66 CSSStyleSheet* sheet1 = createSheet();
67 CSSStyleSheet* sheet2 = createSheet(); 67 CSSStyleSheet* sheet2 = createSheet();
68 68
69 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 69 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
70 oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 70 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
71 71
72 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 72 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
73 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 73 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
74 74
75 EXPECT_EQ(NoActiveSheetsChanged, 75 EXPECT_EQ(NoActiveSheetsChanged,
76 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 76 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
77 EXPECT_EQ(0u, changedRuleSets.size()); 77 EXPECT_EQ(0u, changedRuleSets.size());
78 } 78 }
79 79
80 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AppendedToEmpty) { 80 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AppendedToEmpty) {
81 ActiveStyleSheetVector oldSheets; 81 ActiveStyleSheetVector oldSheets;
82 ActiveStyleSheetVector newSheets; 82 ActiveStyleSheetVector newSheets;
83 HeapHashSet<Member<RuleSet>> changedRuleSets; 83 HeapHashSet<Member<RuleSet>> changedRuleSets;
84 84
85 CSSStyleSheet* sheet1 = createSheet(); 85 CSSStyleSheet* sheet1 = createSheet();
86 CSSStyleSheet* sheet2 = createSheet(); 86 CSSStyleSheet* sheet2 = createSheet();
87 87
88 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 88 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
89 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 89 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
90 90
91 EXPECT_EQ(ActiveSheetsAppended, 91 EXPECT_EQ(ActiveSheetsAppended,
92 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 92 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
93 EXPECT_EQ(2u, changedRuleSets.size()); 93 EXPECT_EQ(2u, changedRuleSets.size());
94 } 94 }
95 95
96 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AppendedToNonEmpty) { 96 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AppendedToNonEmpty) {
97 ActiveStyleSheetVector oldSheets; 97 ActiveStyleSheetVector oldSheets;
98 ActiveStyleSheetVector newSheets; 98 ActiveStyleSheetVector newSheets;
99 HeapHashSet<Member<RuleSet>> changedRuleSets; 99 HeapHashSet<Member<RuleSet>> changedRuleSets;
100 100
101 CSSStyleSheet* sheet1 = createSheet(); 101 CSSStyleSheet* sheet1 = createSheet();
102 CSSStyleSheet* sheet2 = createSheet(); 102 CSSStyleSheet* sheet2 = createSheet();
103 103
104 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 104 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
105 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 105 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
106 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 106 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
107 107
108 EXPECT_EQ(ActiveSheetsAppended, 108 EXPECT_EQ(ActiveSheetsAppended,
109 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 109 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
110 EXPECT_EQ(1u, changedRuleSets.size()); 110 EXPECT_EQ(1u, changedRuleSets.size());
111 } 111 }
112 112
113 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Mutated) { 113 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Mutated) {
114 ActiveStyleSheetVector oldSheets; 114 ActiveStyleSheetVector oldSheets;
115 ActiveStyleSheetVector newSheets; 115 ActiveStyleSheetVector newSheets;
116 HeapHashSet<Member<RuleSet>> changedRuleSets; 116 HeapHashSet<Member<RuleSet>> changedRuleSets;
117 117
118 CSSStyleSheet* sheet1 = createSheet(); 118 CSSStyleSheet* sheet1 = createSheet();
119 CSSStyleSheet* sheet2 = createSheet(); 119 CSSStyleSheet* sheet2 = createSheet();
120 CSSStyleSheet* sheet3 = createSheet(); 120 CSSStyleSheet* sheet3 = createSheet();
121 121
122 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 122 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
123 oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 123 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
124 oldSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 124 oldSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
125 125
126 sheet2->contents()->clearRuleSet(); 126 sheet2->contents()->clearRuleSet();
127 sheet2->contents()->ensureRuleSet(MediaQueryEvaluator(), 127 sheet2->contents()->ensureRuleSet(MediaQueryEvaluator(),
128 RuleHasDocumentSecurityOrigin); 128 RuleHasDocumentSecurityOrigin);
129 129
130 EXPECT_NE(oldSheets[1].second, &sheet2->contents()->ruleSet()); 130 EXPECT_NE(oldSheets[1].second, &sheet2->contents()->ruleSet());
131 131
132 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 132 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
133 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 133 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
134 newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 134 newSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
135 135
136 EXPECT_EQ(ActiveSheetsChanged, 136 EXPECT_EQ(ActiveSheetsChanged,
137 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 137 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
138 EXPECT_EQ(2u, changedRuleSets.size()); 138 EXPECT_EQ(2u, changedRuleSets.size());
139 EXPECT_TRUE(changedRuleSets.contains(&sheet2->contents()->ruleSet())); 139 EXPECT_TRUE(changedRuleSets.contains(&sheet2->contents()->ruleSet()));
140 EXPECT_TRUE(changedRuleSets.contains(oldSheets[1].second)); 140 EXPECT_TRUE(changedRuleSets.contains(oldSheets[1].second));
141 } 141 }
142 142
143 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Inserted) { 143 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Inserted) {
144 ActiveStyleSheetVector oldSheets; 144 ActiveStyleSheetVector oldSheets;
145 ActiveStyleSheetVector newSheets; 145 ActiveStyleSheetVector newSheets;
146 HeapHashSet<Member<RuleSet>> changedRuleSets; 146 HeapHashSet<Member<RuleSet>> changedRuleSets;
147 147
148 CSSStyleSheet* sheet1 = createSheet(); 148 CSSStyleSheet* sheet1 = createSheet();
149 CSSStyleSheet* sheet2 = createSheet(); 149 CSSStyleSheet* sheet2 = createSheet();
150 CSSStyleSheet* sheet3 = createSheet(); 150 CSSStyleSheet* sheet3 = createSheet();
151 151
152 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 152 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
153 oldSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 153 oldSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
154 154
155 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 155 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
156 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 156 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
157 newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 157 newSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
158 158
159 EXPECT_EQ(ActiveSheetsChanged, 159 EXPECT_EQ(ActiveSheetsChanged,
160 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 160 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
161 EXPECT_EQ(1u, changedRuleSets.size()); 161 EXPECT_EQ(1u, changedRuleSets.size());
162 EXPECT_TRUE(changedRuleSets.contains(&sheet2->contents()->ruleSet())); 162 EXPECT_TRUE(changedRuleSets.contains(&sheet2->contents()->ruleSet()));
163 } 163 }
164 164
165 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Removed) { 165 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_Removed) {
166 ActiveStyleSheetVector oldSheets; 166 ActiveStyleSheetVector oldSheets;
167 ActiveStyleSheetVector newSheets; 167 ActiveStyleSheetVector newSheets;
168 HeapHashSet<Member<RuleSet>> changedRuleSets; 168 HeapHashSet<Member<RuleSet>> changedRuleSets;
169 169
170 CSSStyleSheet* sheet1 = createSheet(); 170 CSSStyleSheet* sheet1 = createSheet();
171 CSSStyleSheet* sheet2 = createSheet(); 171 CSSStyleSheet* sheet2 = createSheet();
172 CSSStyleSheet* sheet3 = createSheet(); 172 CSSStyleSheet* sheet3 = createSheet();
173 173
174 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 174 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
175 oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 175 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
176 oldSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 176 oldSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
177 177
178 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 178 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
179 newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 179 newSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
180 180
181 EXPECT_EQ(ActiveSheetsChanged, 181 EXPECT_EQ(ActiveSheetsChanged,
182 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 182 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
183 EXPECT_EQ(1u, changedRuleSets.size()); 183 EXPECT_EQ(1u, changedRuleSets.size());
184 EXPECT_TRUE(changedRuleSets.contains(&sheet2->contents()->ruleSet())); 184 EXPECT_TRUE(changedRuleSets.contains(&sheet2->contents()->ruleSet()));
185 } 185 }
186 186
187 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_RemovedAll) { 187 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_RemovedAll) {
188 ActiveStyleSheetVector oldSheets; 188 ActiveStyleSheetVector oldSheets;
189 ActiveStyleSheetVector newSheets; 189 ActiveStyleSheetVector newSheets;
190 HeapHashSet<Member<RuleSet>> changedRuleSets; 190 HeapHashSet<Member<RuleSet>> changedRuleSets;
191 191
192 CSSStyleSheet* sheet1 = createSheet(); 192 CSSStyleSheet* sheet1 = createSheet();
193 CSSStyleSheet* sheet2 = createSheet(); 193 CSSStyleSheet* sheet2 = createSheet();
194 CSSStyleSheet* sheet3 = createSheet(); 194 CSSStyleSheet* sheet3 = createSheet();
195 195
196 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 196 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
197 oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 197 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
198 oldSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 198 oldSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
199 199
200 EXPECT_EQ(ActiveSheetsChanged, 200 EXPECT_EQ(ActiveSheetsChanged,
201 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 201 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
202 EXPECT_EQ(3u, changedRuleSets.size()); 202 EXPECT_EQ(3u, changedRuleSets.size());
203 } 203 }
204 204
205 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_InsertedAndRemoved) { 205 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_InsertedAndRemoved) {
206 ActiveStyleSheetVector oldSheets; 206 ActiveStyleSheetVector oldSheets;
207 ActiveStyleSheetVector newSheets; 207 ActiveStyleSheetVector newSheets;
208 HeapHashSet<Member<RuleSet>> changedRuleSets; 208 HeapHashSet<Member<RuleSet>> changedRuleSets;
209 209
210 CSSStyleSheet* sheet1 = createSheet(); 210 CSSStyleSheet* sheet1 = createSheet();
211 CSSStyleSheet* sheet2 = createSheet(); 211 CSSStyleSheet* sheet2 = createSheet();
212 CSSStyleSheet* sheet3 = createSheet(); 212 CSSStyleSheet* sheet3 = createSheet();
213 213
214 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 214 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
215 oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 215 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
216 216
217 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 217 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
218 newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 218 newSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
219 219
220 EXPECT_EQ(ActiveSheetsChanged, 220 EXPECT_EQ(ActiveSheetsChanged,
221 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 221 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
222 EXPECT_EQ(2u, changedRuleSets.size()); 222 EXPECT_EQ(2u, changedRuleSets.size());
223 EXPECT_TRUE(changedRuleSets.contains(&sheet1->contents()->ruleSet())); 223 EXPECT_TRUE(changedRuleSets.contains(&sheet1->contents()->ruleSet()));
224 EXPECT_TRUE(changedRuleSets.contains(&sheet3->contents()->ruleSet())); 224 EXPECT_TRUE(changedRuleSets.contains(&sheet3->contents()->ruleSet()));
225 } 225 }
226 226
227 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddNullRuleSet) { 227 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddNullRuleSet) {
228 ActiveStyleSheetVector oldSheets; 228 ActiveStyleSheetVector oldSheets;
229 ActiveStyleSheetVector newSheets; 229 ActiveStyleSheetVector newSheets;
230 HeapHashSet<Member<RuleSet>> changedRuleSets; 230 HeapHashSet<Member<RuleSet>> changedRuleSets;
231 231
232 CSSStyleSheet* sheet1 = createSheet(); 232 CSSStyleSheet* sheet1 = createSheet();
233 CSSStyleSheet* sheet2 = createSheet(); 233 CSSStyleSheet* sheet2 = createSheet();
234 234
235 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 235 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
236 236
237 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 237 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
238 newSheets.append(std::make_pair(sheet2, nullptr)); 238 newSheets.push_back(std::make_pair(sheet2, nullptr));
239 239
240 EXPECT_EQ(NoActiveSheetsChanged, 240 EXPECT_EQ(NoActiveSheetsChanged,
241 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 241 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
242 EXPECT_EQ(0u, changedRuleSets.size()); 242 EXPECT_EQ(0u, changedRuleSets.size());
243 } 243 }
244 244
245 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_RemoveNullRuleSet) { 245 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_RemoveNullRuleSet) {
246 ActiveStyleSheetVector oldSheets; 246 ActiveStyleSheetVector oldSheets;
247 ActiveStyleSheetVector newSheets; 247 ActiveStyleSheetVector newSheets;
248 HeapHashSet<Member<RuleSet>> changedRuleSets; 248 HeapHashSet<Member<RuleSet>> changedRuleSets;
249 249
250 CSSStyleSheet* sheet1 = createSheet(); 250 CSSStyleSheet* sheet1 = createSheet();
251 CSSStyleSheet* sheet2 = createSheet(); 251 CSSStyleSheet* sheet2 = createSheet();
252 252
253 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 253 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
254 oldSheets.append(std::make_pair(sheet2, nullptr)); 254 oldSheets.push_back(std::make_pair(sheet2, nullptr));
255 255
256 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 256 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
257 257
258 EXPECT_EQ(NoActiveSheetsChanged, 258 EXPECT_EQ(NoActiveSheetsChanged,
259 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 259 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
260 EXPECT_EQ(0u, changedRuleSets.size()); 260 EXPECT_EQ(0u, changedRuleSets.size());
261 } 261 }
262 262
263 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddRemoveNullRuleSet) { 263 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_AddRemoveNullRuleSet) {
264 ActiveStyleSheetVector oldSheets; 264 ActiveStyleSheetVector oldSheets;
265 ActiveStyleSheetVector newSheets; 265 ActiveStyleSheetVector newSheets;
266 HeapHashSet<Member<RuleSet>> changedRuleSets; 266 HeapHashSet<Member<RuleSet>> changedRuleSets;
267 267
268 CSSStyleSheet* sheet1 = createSheet(); 268 CSSStyleSheet* sheet1 = createSheet();
269 CSSStyleSheet* sheet2 = createSheet(); 269 CSSStyleSheet* sheet2 = createSheet();
270 CSSStyleSheet* sheet3 = createSheet(); 270 CSSStyleSheet* sheet3 = createSheet();
271 271
272 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 272 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
273 oldSheets.append(std::make_pair(sheet2, nullptr)); 273 oldSheets.push_back(std::make_pair(sheet2, nullptr));
274 274
275 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 275 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
276 newSheets.append(std::make_pair(sheet3, nullptr)); 276 newSheets.push_back(std::make_pair(sheet3, nullptr));
277 277
278 EXPECT_EQ(NoActiveSheetsChanged, 278 EXPECT_EQ(NoActiveSheetsChanged,
279 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 279 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
280 EXPECT_EQ(0u, changedRuleSets.size()); 280 EXPECT_EQ(0u, changedRuleSets.size());
281 } 281 }
282 282
283 TEST_F(ActiveStyleSheetsTest, 283 TEST_F(ActiveStyleSheetsTest,
284 CompareActiveStyleSheets_RemoveNullRuleSetAndAppend) { 284 CompareActiveStyleSheets_RemoveNullRuleSetAndAppend) {
285 ActiveStyleSheetVector oldSheets; 285 ActiveStyleSheetVector oldSheets;
286 ActiveStyleSheetVector newSheets; 286 ActiveStyleSheetVector newSheets;
287 HeapHashSet<Member<RuleSet>> changedRuleSets; 287 HeapHashSet<Member<RuleSet>> changedRuleSets;
288 288
289 CSSStyleSheet* sheet1 = createSheet(); 289 CSSStyleSheet* sheet1 = createSheet();
290 CSSStyleSheet* sheet2 = createSheet(); 290 CSSStyleSheet* sheet2 = createSheet();
291 CSSStyleSheet* sheet3 = createSheet(); 291 CSSStyleSheet* sheet3 = createSheet();
292 292
293 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 293 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
294 oldSheets.append(std::make_pair(sheet2, nullptr)); 294 oldSheets.push_back(std::make_pair(sheet2, nullptr));
295 295
296 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 296 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
297 newSheets.append(std::make_pair(sheet3, &sheet3->contents()->ruleSet())); 297 newSheets.push_back(std::make_pair(sheet3, &sheet3->contents()->ruleSet()));
298 298
299 EXPECT_EQ(ActiveSheetsChanged, 299 EXPECT_EQ(ActiveSheetsChanged,
300 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 300 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
301 EXPECT_EQ(1u, changedRuleSets.size()); 301 EXPECT_EQ(1u, changedRuleSets.size());
302 EXPECT_TRUE(changedRuleSets.contains(&sheet3->contents()->ruleSet())); 302 EXPECT_TRUE(changedRuleSets.contains(&sheet3->contents()->ruleSet()));
303 } 303 }
304 304
305 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_ReorderedImportSheets) { 305 TEST_F(ActiveStyleSheetsTest, CompareActiveStyleSheets_ReorderedImportSheets) {
306 ActiveStyleSheetVector oldSheets; 306 ActiveStyleSheetVector oldSheets;
307 ActiveStyleSheetVector newSheets; 307 ActiveStyleSheetVector newSheets;
308 HeapHashSet<Member<RuleSet>> changedRuleSets; 308 HeapHashSet<Member<RuleSet>> changedRuleSets;
309 309
310 CSSStyleSheet* sheet1 = createSheet(); 310 CSSStyleSheet* sheet1 = createSheet();
311 CSSStyleSheet* sheet2 = createSheet(); 311 CSSStyleSheet* sheet2 = createSheet();
312 312
313 // It is possible to have CSSStyleSheet pointers re-orderered for html imports 313 // It is possible to have CSSStyleSheet pointers re-orderered for html imports
314 // because their documents, and hence their stylesheets are persisted on 314 // because their documents, and hence their stylesheets are persisted on
315 // remove / insert. This test is here to show that the active sheet comparison 315 // remove / insert. This test is here to show that the active sheet comparison
316 // is not able to see that anything changed. 316 // is not able to see that anything changed.
317 // 317 //
318 // Imports are handled by forcing re-append and recalc of the document scope 318 // Imports are handled by forcing re-append and recalc of the document scope
319 // when html imports are removed. 319 // when html imports are removed.
320 oldSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 320 oldSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
321 oldSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 321 oldSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
322 322
323 newSheets.append(std::make_pair(sheet2, &sheet2->contents()->ruleSet())); 323 newSheets.push_back(std::make_pair(sheet2, &sheet2->contents()->ruleSet()));
324 newSheets.append(std::make_pair(sheet1, &sheet1->contents()->ruleSet())); 324 newSheets.push_back(std::make_pair(sheet1, &sheet1->contents()->ruleSet()));
325 325
326 EXPECT_EQ(NoActiveSheetsChanged, 326 EXPECT_EQ(NoActiveSheetsChanged,
327 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets)); 327 compareActiveStyleSheets(oldSheets, newSheets, changedRuleSets));
328 EXPECT_EQ(0u, changedRuleSets.size()); 328 EXPECT_EQ(0u, changedRuleSets.size());
329 } 329 }
330 330
331 TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) { 331 TEST_F(ApplyRulesetsTest, AddUniversalRuleToDocument) {
332 document().view()->updateAllLifecyclePhases(); 332 document().view()->updateAllLifecyclePhases();
333 333
334 CSSStyleSheet* sheet = createSheet("body * { color:red }"); 334 CSSStyleSheet* sheet = createSheet("body * { color:red }");
335 335
336 ActiveStyleSheetVector newStyleSheets; 336 ActiveStyleSheetVector newStyleSheets;
337 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); 337 newStyleSheets.push_back(
338 std::make_pair(sheet, &sheet->contents()->ruleSet()));
338 339
339 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(), 340 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(),
340 newStyleSheets); 341 newStyleSheets);
341 342
342 EXPECT_EQ(SubtreeStyleChange, document().getStyleChangeType()); 343 EXPECT_EQ(SubtreeStyleChange, document().getStyleChangeType());
343 } 344 }
344 345
345 TEST_F(ApplyRulesetsTest, AddUniversalRuleToShadowTree) { 346 TEST_F(ApplyRulesetsTest, AddUniversalRuleToShadowTree) {
346 document().body()->setInnerHTML("<div id=host></div>"); 347 document().body()->setInnerHTML("<div id=host></div>");
347 Element* host = document().getElementById("host"); 348 Element* host = document().getElementById("host");
348 ASSERT_TRUE(host); 349 ASSERT_TRUE(host);
349 350
350 ShadowRoot& shadowRoot = attachShadow(*host); 351 ShadowRoot& shadowRoot = attachShadow(*host);
351 document().view()->updateAllLifecyclePhases(); 352 document().view()->updateAllLifecyclePhases();
352 353
353 CSSStyleSheet* sheet = createSheet("body * { color:red }"); 354 CSSStyleSheet* sheet = createSheet("body * { color:red }");
354 355
355 ActiveStyleSheetVector newStyleSheets; 356 ActiveStyleSheetVector newStyleSheets;
356 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); 357 newStyleSheets.push_back(
358 std::make_pair(sheet, &sheet->contents()->ruleSet()));
357 359
358 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(), 360 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(),
359 newStyleSheets); 361 newStyleSheets);
360 362
361 EXPECT_FALSE(document().needsStyleRecalc()); 363 EXPECT_FALSE(document().needsStyleRecalc());
362 EXPECT_EQ(SubtreeStyleChange, host->getStyleChangeType()); 364 EXPECT_EQ(SubtreeStyleChange, host->getStyleChangeType());
363 } 365 }
364 366
365 TEST_F(ApplyRulesetsTest, AddShadowV0BoundaryCrossingRuleToDocument) { 367 TEST_F(ApplyRulesetsTest, AddShadowV0BoundaryCrossingRuleToDocument) {
366 document().view()->updateAllLifecyclePhases(); 368 document().view()->updateAllLifecyclePhases();
367 369
368 CSSStyleSheet* sheet = createSheet(".a /deep/ .b { color:red }"); 370 CSSStyleSheet* sheet = createSheet(".a /deep/ .b { color:red }");
369 371
370 ActiveStyleSheetVector newStyleSheets; 372 ActiveStyleSheetVector newStyleSheets;
371 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); 373 newStyleSheets.push_back(
374 std::make_pair(sheet, &sheet->contents()->ruleSet()));
372 375
373 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(), 376 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(),
374 newStyleSheets); 377 newStyleSheets);
375 378
376 EXPECT_EQ(SubtreeStyleChange, document().getStyleChangeType()); 379 EXPECT_EQ(SubtreeStyleChange, document().getStyleChangeType());
377 } 380 }
378 381
379 TEST_F(ApplyRulesetsTest, AddShadowV0BoundaryCrossingRuleToShadowTree) { 382 TEST_F(ApplyRulesetsTest, AddShadowV0BoundaryCrossingRuleToShadowTree) {
380 document().body()->setInnerHTML("<div id=host></div>"); 383 document().body()->setInnerHTML("<div id=host></div>");
381 Element* host = document().getElementById("host"); 384 Element* host = document().getElementById("host");
382 ASSERT_TRUE(host); 385 ASSERT_TRUE(host);
383 386
384 ShadowRoot& shadowRoot = attachShadow(*host); 387 ShadowRoot& shadowRoot = attachShadow(*host);
385 document().view()->updateAllLifecyclePhases(); 388 document().view()->updateAllLifecyclePhases();
386 389
387 CSSStyleSheet* sheet = createSheet(".a /deep/ .b { color:red }"); 390 CSSStyleSheet* sheet = createSheet(".a /deep/ .b { color:red }");
388 391
389 ActiveStyleSheetVector newStyleSheets; 392 ActiveStyleSheetVector newStyleSheets;
390 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); 393 newStyleSheets.push_back(
394 std::make_pair(sheet, &sheet->contents()->ruleSet()));
391 395
392 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(), 396 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(),
393 newStyleSheets); 397 newStyleSheets);
394 398
395 EXPECT_FALSE(document().needsStyleRecalc()); 399 EXPECT_FALSE(document().needsStyleRecalc());
396 EXPECT_EQ(SubtreeStyleChange, host->getStyleChangeType()); 400 EXPECT_EQ(SubtreeStyleChange, host->getStyleChangeType());
397 } 401 }
398 402
399 TEST_F(ApplyRulesetsTest, AddFontFaceRuleToDocument) { 403 TEST_F(ApplyRulesetsTest, AddFontFaceRuleToDocument) {
400 document().view()->updateAllLifecyclePhases(); 404 document().view()->updateAllLifecyclePhases();
401 405
402 CSSStyleSheet* sheet = 406 CSSStyleSheet* sheet =
403 createSheet("@font-face { font-family: ahum; src: url(ahum.ttf) }"); 407 createSheet("@font-face { font-family: ahum; src: url(ahum.ttf) }");
404 408
405 ActiveStyleSheetVector newStyleSheets; 409 ActiveStyleSheetVector newStyleSheets;
406 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); 410 newStyleSheets.push_back(
411 std::make_pair(sheet, &sheet->contents()->ruleSet()));
407 412
408 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(), 413 styleEngine().applyRuleSetChanges(document(), ActiveStyleSheetVector(),
409 newStyleSheets); 414 newStyleSheets);
410 415
411 EXPECT_EQ(SubtreeStyleChange, document().getStyleChangeType()); 416 EXPECT_EQ(SubtreeStyleChange, document().getStyleChangeType());
412 } 417 }
413 418
414 TEST_F(ApplyRulesetsTest, AddFontFaceRuleToShadowTree) { 419 TEST_F(ApplyRulesetsTest, AddFontFaceRuleToShadowTree) {
415 document().body()->setInnerHTML("<div id=host></div>"); 420 document().body()->setInnerHTML("<div id=host></div>");
416 Element* host = document().getElementById("host"); 421 Element* host = document().getElementById("host");
417 ASSERT_TRUE(host); 422 ASSERT_TRUE(host);
418 423
419 ShadowRoot& shadowRoot = attachShadow(*host); 424 ShadowRoot& shadowRoot = attachShadow(*host);
420 document().view()->updateAllLifecyclePhases(); 425 document().view()->updateAllLifecyclePhases();
421 426
422 CSSStyleSheet* sheet = 427 CSSStyleSheet* sheet =
423 createSheet("@font-face { font-family: ahum; src: url(ahum.ttf) }"); 428 createSheet("@font-face { font-family: ahum; src: url(ahum.ttf) }");
424 429
425 ActiveStyleSheetVector newStyleSheets; 430 ActiveStyleSheetVector newStyleSheets;
426 newStyleSheets.append(std::make_pair(sheet, &sheet->contents()->ruleSet())); 431 newStyleSheets.push_back(
432 std::make_pair(sheet, &sheet->contents()->ruleSet()));
427 433
428 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(), 434 styleEngine().applyRuleSetChanges(shadowRoot, ActiveStyleSheetVector(),
429 newStyleSheets); 435 newStyleSheets);
430 436
431 EXPECT_FALSE(document().needsStyleRecalc()); 437 EXPECT_FALSE(document().needsStyleRecalc());
432 EXPECT_FALSE(document().childNeedsStyleRecalc()); 438 EXPECT_FALSE(document().childNeedsStyleRecalc());
433 EXPECT_FALSE(document().needsStyleInvalidation()); 439 EXPECT_FALSE(document().needsStyleInvalidation());
434 EXPECT_FALSE(document().childNeedsStyleInvalidation()); 440 EXPECT_FALSE(document().childNeedsStyleInvalidation());
435 } 441 }
436 442
437 TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) { 443 TEST_F(ApplyRulesetsTest, RemoveSheetFromShadowTree) {
438 document().body()->setInnerHTML("<div id=host></div>"); 444 document().body()->setInnerHTML("<div id=host></div>");
439 Element* host = document().getElementById("host"); 445 Element* host = document().getElementById("host");
440 ASSERT_TRUE(host); 446 ASSERT_TRUE(host);
441 447
442 ShadowRoot& shadowRoot = attachShadow(*host); 448 ShadowRoot& shadowRoot = attachShadow(*host);
443 shadowRoot.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>"); 449 shadowRoot.setInnerHTML("<style>::slotted(#dummy){color:pink}</style>");
444 document().view()->updateAllLifecyclePhases(); 450 document().view()->updateAllLifecyclePhases();
445 451
446 EXPECT_EQ(1u, styleEngine().treeBoundaryCrossingScopes().size()); 452 EXPECT_EQ(1u, styleEngine().treeBoundaryCrossingScopes().size());
447 ASSERT_EQ(1u, shadowRoot.styleSheets().length()); 453 ASSERT_EQ(1u, shadowRoot.styleSheets().length());
448 454
449 StyleSheet* sheet = shadowRoot.styleSheets().item(0); 455 StyleSheet* sheet = shadowRoot.styleSheets().item(0);
450 ASSERT_TRUE(sheet); 456 ASSERT_TRUE(sheet);
451 ASSERT_TRUE(sheet->isCSSStyleSheet()); 457 ASSERT_TRUE(sheet->isCSSStyleSheet());
452 458
453 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet); 459 CSSStyleSheet* cssSheet = toCSSStyleSheet(sheet);
454 ActiveStyleSheetVector oldStyleSheets; 460 ActiveStyleSheetVector oldStyleSheets;
455 oldStyleSheets.append( 461 oldStyleSheets.push_back(
456 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet())); 462 std::make_pair(cssSheet, &cssSheet->contents()->ruleSet()));
457 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets, 463 styleEngine().applyRuleSetChanges(shadowRoot, oldStyleSheets,
458 ActiveStyleSheetVector()); 464 ActiveStyleSheetVector());
459 465
460 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty()); 466 EXPECT_TRUE(styleEngine().treeBoundaryCrossingScopes().isEmpty());
461 } 467 }
462 468
463 } // namespace blink 469 } // namespace blink
OLDNEW
« no previous file with comments | « third_party/WebKit/Source/core/clipboard/DataObject.cpp ('k') | third_party/WebKit/Source/core/css/CSSBasicShapeValues.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698