OLD | NEW |
1 /** | 1 /** |
2 * Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) | 2 * Copyright (C) 2004 Allan Sandfeld Jensen (kde@carewolf.com) |
3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. | 3 * Copyright (C) 2006, 2007 Apple Inc. All rights reserved. |
4 * | 4 * |
5 * This library is free software; you can redistribute it and/or | 5 * This library is free software; you can redistribute it and/or |
6 * modify it under the terms of the GNU Library General Public | 6 * modify it under the terms of the GNU Library General Public |
7 * License as published by the Free Software Foundation; either | 7 * License as published by the Free Software Foundation; either |
8 * version 2 of the License, or (at your option) any later version. | 8 * version 2 of the License, or (at your option) any later version. |
9 * | 9 * |
10 * This library is distributed in the hope that it will be useful, | 10 * This library is distributed in the hope that it will be useful, |
(...skipping 48 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
59 for (Element* ancestor = FlatTreeTraversal::parentElement(element); ancestor; | 59 for (Element* ancestor = FlatTreeTraversal::parentElement(element); ancestor; |
60 ancestor = FlatTreeTraversal::parentElement(*ancestor)) { | 60 ancestor = FlatTreeTraversal::parentElement(*ancestor)) { |
61 if (ancestor->layoutObject() && | 61 if (ancestor->layoutObject() && |
62 ancestor->layoutObject()->style()->containsStyle()) | 62 ancestor->layoutObject()->style()->containsStyle()) |
63 return ancestor; | 63 return ancestor; |
64 } | 64 } |
65 return nullptr; | 65 return nullptr; |
66 } | 66 } |
67 | 67 |
68 // This function processes the layoutObject tree in the order of the DOM tree | 68 // This function processes the layoutObject tree in the order of the DOM tree |
69 // including pseudo elements as defined in CSS 2.1. This method will always retu
rn | 69 // including pseudo elements as defined in CSS 2.1. This method will always |
70 // either a previous object within the same contain: style scope or nullptr. | 70 // return either a previous object within the same contain: style scope or |
| 71 // nullptr. |
71 static LayoutObject* previousInPreOrderRespectingContainment( | 72 static LayoutObject* previousInPreOrderRespectingContainment( |
72 const LayoutObject& object) { | 73 const LayoutObject& object) { |
73 Element* self = toElement(object.node()); | 74 Element* self = toElement(object.node()); |
74 ASSERT(self); | 75 ASSERT(self); |
75 Element* previous = ElementTraversal::previousIncludingPseudo(*self); | 76 Element* previous = ElementTraversal::previousIncludingPseudo(*self); |
76 Element* styleContainAncestor = ancestorStyleContainmentObject(*self); | 77 Element* styleContainAncestor = ancestorStyleContainmentObject(*self); |
77 | 78 |
78 while (1) { | 79 while (1) { |
79 while (previous && !previous->layoutObject()) | 80 while (previous && !previous->layoutObject()) |
80 previous = ElementTraversal::previousIncludingPseudo(*previous); | 81 previous = ElementTraversal::previousIncludingPseudo(*previous); |
(...skipping 55 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
136 *next, stayWithin) | 137 *next, stayWithin) |
137 : ElementTraversal::nextIncludingPseudo(*next, stayWithin); | 138 : ElementTraversal::nextIncludingPseudo(*next, stayWithin); |
138 return next ? next->layoutObject() : nullptr; | 139 return next ? next->layoutObject() : nullptr; |
139 } | 140 } |
140 | 141 |
141 static bool planCounter(LayoutObject& object, | 142 static bool planCounter(LayoutObject& object, |
142 const AtomicString& identifier, | 143 const AtomicString& identifier, |
143 bool& isReset, | 144 bool& isReset, |
144 int& value) { | 145 int& value) { |
145 // Real text nodes don't have their own style so they can't have counters. | 146 // Real text nodes don't have their own style so they can't have counters. |
146 // We can't even look at their styles or we'll see extra resets and increments
! | 147 // We can't even look at their styles or we'll see extra resets and |
| 148 // increments! |
147 if (object.isText() && !object.isBR()) | 149 if (object.isText() && !object.isBR()) |
148 return false; | 150 return false; |
149 Node* generatingNode = object.generatingNode(); | 151 Node* generatingNode = object.generatingNode(); |
150 // We must have a generating node or else we cannot have a counter. | 152 // We must have a generating node or else we cannot have a counter. |
151 if (!generatingNode) | 153 if (!generatingNode) |
152 return false; | 154 return false; |
153 const ComputedStyle& style = object.styleRef(); | 155 const ComputedStyle& style = object.styleRef(); |
154 | 156 |
155 switch (style.styleType()) { | 157 switch (style.styleType()) { |
156 case PseudoIdNone: | 158 case PseudoIdNone: |
157 // Sometimes nodes have more than one layoutObject. Only the first one get
s the counter | 159 // Sometimes nodes have more than one layoutObject. Only the first one |
158 // LayoutTests/http/tests/css/counter-crash.html | 160 // gets the counter. See LayoutTests/http/tests/css/counter-crash.html |
159 if (generatingNode->layoutObject() != &object) | 161 if (generatingNode->layoutObject() != &object) |
160 return false; | 162 return false; |
161 break; | 163 break; |
162 case PseudoIdBefore: | 164 case PseudoIdBefore: |
163 case PseudoIdAfter: | 165 case PseudoIdAfter: |
164 break; | 166 break; |
165 default: | 167 default: |
166 return false; // Counters are forbidden from all other pseudo elements. | 168 return false; // Counters are forbidden from all other pseudo elements. |
167 } | 169 } |
168 | 170 |
(...skipping 26 matching lines...) Expand all Loading... |
195 value = 0; | 197 value = 0; |
196 isReset = true; | 198 isReset = true; |
197 return true; | 199 return true; |
198 } | 200 } |
199 } | 201 } |
200 } | 202 } |
201 | 203 |
202 return false; | 204 return false; |
203 } | 205 } |
204 | 206 |
205 // - Finds the insertion point for the counter described by counterOwner, isRese
t and | 207 // - Finds the insertion point for the counter described by counterOwner, |
206 // identifier in the CounterNode tree for identifier and sets parent and | 208 // isReset and identifier in the CounterNode tree for identifier and sets |
207 // previousSibling accordingly. | 209 // parent and previousSibling accordingly. |
208 // - The function returns true if the counter whose insertion point is searched
is NOT | 210 // - The function returns true if the counter whose insertion point is searched |
209 // the root of the tree. | 211 // is NOT the root of the tree. |
210 // - The root of the tree is a counter reference that is not in the scope of any
other | 212 // - The root of the tree is a counter reference that is not in the scope of any |
211 // counter with the same identifier. | 213 // other counter with the same identifier. |
212 // - All the counter references with the same identifier as this one that are in | 214 // - All the counter references with the same identifier as this one that are in |
213 // children or subsequent siblings of the layoutObject that owns the root of the
tree | 215 // children or subsequent siblings of the layoutObject that owns the root of |
214 // form the rest of of the nodes of the tree. | 216 // the tree form the rest of of the nodes of the tree. |
215 // - The root of the tree is always a reset type reference. | 217 // - The root of the tree is always a reset type reference. |
216 // - A subtree rooted at any reset node in the tree is equivalent to all counter | 218 // - A subtree rooted at any reset node in the tree is equivalent to all counter |
217 // references that are in the scope of the counter or nested counter defined by
that | 219 // references that are in the scope of the counter or nested counter defined |
218 // reset node. | 220 // by that reset node. |
219 // - Non-reset CounterNodes cannot have descendants. | 221 // - Non-reset CounterNodes cannot have descendants. |
220 | |
221 static bool findPlaceForCounter(LayoutObject& counterOwner, | 222 static bool findPlaceForCounter(LayoutObject& counterOwner, |
222 const AtomicString& identifier, | 223 const AtomicString& identifier, |
223 bool isReset, | 224 bool isReset, |
224 RefPtr<CounterNode>& parent, | 225 RefPtr<CounterNode>& parent, |
225 RefPtr<CounterNode>& previousSibling) { | 226 RefPtr<CounterNode>& previousSibling) { |
226 // We cannot stop searching for counters with the same identifier before we al
so | 227 // We cannot stop searching for counters with the same identifier before we |
227 // check this layoutObject, because it may affect the positioning in the tree
of our counter. | 228 // also check this layoutObject, because it may affect the positioning in the |
| 229 // tree of our counter. |
228 LayoutObject* searchEndLayoutObject = | 230 LayoutObject* searchEndLayoutObject = |
229 previousSiblingOrParentRespectingContainment(counterOwner); | 231 previousSiblingOrParentRespectingContainment(counterOwner); |
230 // We check layoutObjects in preOrder from the layoutObject that our counter i
s attached to | 232 // We check layoutObjects in preOrder from the layoutObject that our counter |
231 // towards the beginning of the document for counters with the same identifier
as the one | 233 // is attached to towards the beginning of the document for counters with the |
232 // we are trying to find a place for. This is the next layoutObject to be chec
ked. | 234 // same identifier as the one we are trying to find a place for. This is the |
| 235 // next layoutObject to be checked. |
233 LayoutObject* currentLayoutObject = | 236 LayoutObject* currentLayoutObject = |
234 previousInPreOrderRespectingContainment(counterOwner); | 237 previousInPreOrderRespectingContainment(counterOwner); |
235 previousSibling = nullptr; | 238 previousSibling = nullptr; |
236 RefPtr<CounterNode> previousSiblingProtector = nullptr; | 239 RefPtr<CounterNode> previousSiblingProtector = nullptr; |
237 | 240 |
238 while (currentLayoutObject) { | 241 while (currentLayoutObject) { |
239 CounterNode* currentCounter = | 242 CounterNode* currentCounter = |
240 makeCounterNodeIfNeeded(*currentLayoutObject, identifier, false); | 243 makeCounterNodeIfNeeded(*currentLayoutObject, identifier, false); |
241 if (searchEndLayoutObject == currentLayoutObject) { | 244 if (searchEndLayoutObject == currentLayoutObject) { |
242 // We may be at the end of our search. | 245 // We may be at the end of our search. |
243 if (currentCounter) { | 246 if (currentCounter) { |
244 // We have a suitable counter on the EndSearchLayoutObject. | 247 // We have a suitable counter on the EndSearchLayoutObject. |
245 if (previousSiblingProtector) { // But we already found another counter
that we come after. | 248 if (previousSiblingProtector) { |
| 249 // But we already found another counter that we come after. |
246 if (currentCounter->actsAsReset()) { | 250 if (currentCounter->actsAsReset()) { |
247 // We found a reset counter that is on a layoutObject that is a sibl
ing of ours or a parent. | 251 // We found a reset counter that is on a layoutObject that is a |
| 252 // sibling of ours or a parent. |
248 if (isReset && areLayoutObjectsElementsSiblings( | 253 if (isReset && areLayoutObjectsElementsSiblings( |
249 *currentLayoutObject, counterOwner)) { | 254 *currentLayoutObject, counterOwner)) { |
250 // We are also a reset counter and the previous reset was on a sib
ling layoutObject | 255 // We are also a reset counter and the previous reset was on a |
251 // hence we are the next sibling of that counter if that reset is
not a root or | 256 // sibling layoutObject hence we are the next sibling of that |
252 // we are a root node if that reset is a root. | 257 // counter if that reset is not a root or we are a root node if |
| 258 // that reset is a root. |
253 parent = currentCounter->parent(); | 259 parent = currentCounter->parent(); |
254 previousSibling = parent ? currentCounter : nullptr; | 260 previousSibling = parent ? currentCounter : nullptr; |
255 return parent.get(); | 261 return parent.get(); |
256 } | 262 } |
257 // We are not a reset node or the previous reset must be on an ances
tor of our owner layoutObject | 263 // We are not a reset node or the previous reset must be on an |
258 // hence we must be a child of that reset counter. | 264 // ancestor of our owner layoutObject hence we must be a child of |
| 265 // that reset counter. |
259 parent = currentCounter; | 266 parent = currentCounter; |
260 // In some cases layoutObjects can be reparented (ex. nodes inside a
table but not in a column or row). | 267 // In some cases layoutObjects can be reparented (ex. nodes inside a |
261 // In these cases the identified previousSibling will be invalid as
its parent is different from | 268 // table but not in a column or row). In these cases the identified |
| 269 // previousSibling will be invalid as its parent is different from |
262 // our identified parent. | 270 // our identified parent. |
263 if (previousSiblingProtector->parent() != currentCounter) | 271 if (previousSiblingProtector->parent() != currentCounter) |
264 previousSiblingProtector = nullptr; | 272 previousSiblingProtector = nullptr; |
265 | 273 |
266 previousSibling = previousSiblingProtector.get(); | 274 previousSibling = previousSiblingProtector.get(); |
267 return true; | 275 return true; |
268 } | 276 } |
269 // CurrentCounter, the counter at the EndSearchLayoutObject, is not re
set. | 277 // CurrentCounter, the counter at the EndSearchLayoutObject, is not |
| 278 // reset. |
270 if (!isReset || | 279 if (!isReset || |
271 !areLayoutObjectsElementsSiblings(*currentLayoutObject, | 280 !areLayoutObjectsElementsSiblings(*currentLayoutObject, |
272 counterOwner)) { | 281 counterOwner)) { |
273 // If the node we are placing is not reset or we have found a counte
r that is attached | 282 // If the node we are placing is not reset or we have found a |
274 // to an ancestor of the placed counter's owner layoutObject we know
we are a sibling of that node. | 283 // counter that is attached to an ancestor of the placed counter's |
| 284 // owner layoutObject we know we are a sibling of that node. |
275 if (currentCounter->parent() != previousSiblingProtector->parent()) | 285 if (currentCounter->parent() != previousSiblingProtector->parent()) |
276 return false; | 286 return false; |
277 | 287 |
278 parent = currentCounter->parent(); | 288 parent = currentCounter->parent(); |
279 previousSibling = previousSiblingProtector.get(); | 289 previousSibling = previousSiblingProtector.get(); |
280 return true; | 290 return true; |
281 } | 291 } |
282 } else { | 292 } else { |
283 // We are at the potential end of the search, but we had no previous s
ibling candidate | 293 // We are at the potential end of the search, but we had no previous |
284 // In this case we follow pretty much the same logic as above but no A
SSERTs about | 294 // sibling candidate. In this case we follow pretty much the same |
285 // previousSibling, and when we are a sibling of the end counter we mu
st set previousSibling | 295 // logic as above but no ASSERTs about previousSibling, and when we |
286 // to currentCounter. | 296 // are a sibling of the end counter we must set previousSibling to |
| 297 // currentCounter. |
287 if (currentCounter->actsAsReset()) { | 298 if (currentCounter->actsAsReset()) { |
288 if (isReset && areLayoutObjectsElementsSiblings( | 299 if (isReset && areLayoutObjectsElementsSiblings( |
289 *currentLayoutObject, counterOwner)) { | 300 *currentLayoutObject, counterOwner)) { |
290 parent = currentCounter->parent(); | 301 parent = currentCounter->parent(); |
291 previousSibling = currentCounter; | 302 previousSibling = currentCounter; |
292 return parent.get(); | 303 return parent.get(); |
293 } | 304 } |
294 parent = currentCounter; | 305 parent = currentCounter; |
295 previousSibling = previousSiblingProtector.get(); | 306 previousSibling = previousSiblingProtector.get(); |
296 return true; | 307 return true; |
297 } | 308 } |
298 if (!isReset || | 309 if (!isReset || |
299 !areLayoutObjectsElementsSiblings(*currentLayoutObject, | 310 !areLayoutObjectsElementsSiblings(*currentLayoutObject, |
300 counterOwner)) { | 311 counterOwner)) { |
301 parent = currentCounter->parent(); | 312 parent = currentCounter->parent(); |
302 previousSibling = currentCounter; | 313 previousSibling = currentCounter; |
303 return true; | 314 return true; |
304 } | 315 } |
305 previousSiblingProtector = currentCounter; | 316 previousSiblingProtector = currentCounter; |
306 } | 317 } |
307 } | 318 } |
308 // We come here if the previous sibling or parent of our owner layoutObjec
t had no | 319 // We come here if the previous sibling or parent of our owner |
309 // good counter, or we are a reset node and the counter on the previous si
bling | 320 // layoutObject had no good counter, or we are a reset node and the |
310 // of our owner layoutObject was not a reset counter. | 321 // counter on the previous sibling of our owner layoutObject was not a |
311 // Set a new goal for the end of the search. | 322 // reset counter. Set a new goal for the end of the search. |
312 searchEndLayoutObject = | 323 searchEndLayoutObject = |
313 previousSiblingOrParentRespectingContainment(*currentLayoutObject); | 324 previousSiblingOrParentRespectingContainment(*currentLayoutObject); |
314 } else { | 325 } else { |
315 // We are searching descendants of a previous sibling of the layoutObject
that the | 326 // We are searching descendants of a previous sibling of the layoutObject |
| 327 // that the |
316 // counter being placed is attached to. | 328 // counter being placed is attached to. |
317 if (currentCounter) { | 329 if (currentCounter) { |
318 // We found a suitable counter. | 330 // We found a suitable counter. |
319 if (previousSiblingProtector) { | 331 if (previousSiblingProtector) { |
320 // Since we had a suitable previous counter before, we should only con
sider this one as our | 332 // Since we had a suitable previous counter before, we should only |
321 // previousSibling if it is a reset counter and hence the current prev
iousSibling is its child. | 333 // consider this one as our previousSibling if it is a reset counter |
| 334 // and hence the current previousSibling is its child. |
322 if (currentCounter->actsAsReset()) { | 335 if (currentCounter->actsAsReset()) { |
323 previousSiblingProtector = currentCounter; | 336 previousSiblingProtector = currentCounter; |
324 // We are no longer interested in previous siblings of the currentLa
youtObject or their children | 337 // We are no longer interested in previous siblings of the |
325 // as counters they may have attached cannot be the previous sibling
of the counter we are placing. | 338 // currentLayoutObject or their children as counters they may have |
| 339 // attached cannot be the previous sibling of the counter we are |
| 340 // placing. |
326 Element* parent = parentElement(*currentLayoutObject); | 341 Element* parent = parentElement(*currentLayoutObject); |
327 currentLayoutObject = parent ? parent->layoutObject() : nullptr; | 342 currentLayoutObject = parent ? parent->layoutObject() : nullptr; |
328 continue; | 343 continue; |
329 } | 344 } |
330 } else { | 345 } else { |
331 previousSiblingProtector = currentCounter; | 346 previousSiblingProtector = currentCounter; |
332 } | 347 } |
333 currentLayoutObject = | 348 currentLayoutObject = |
334 previousSiblingOrParentRespectingContainment(*currentLayoutObject); | 349 previousSiblingOrParentRespectingContainment(*currentLayoutObject); |
335 continue; | 350 continue; |
336 } | 351 } |
337 } | 352 } |
338 // This function is designed so that the same test is not done twice in an i
teration, except for this one | 353 // This function is designed so that the same test is not done twice in an |
339 // which may be done twice in some cases. Rearranging the decision points th
ough, to accommodate this | 354 // iteration, except for this one which may be done twice in some cases. |
340 // performance improvement would create more code duplication than is worthw
hile in my opinion and may further | 355 // Rearranging the decision points though, to accommodate this performance |
341 // impede the readability of this already complex algorithm. | 356 // improvement would create more code duplication than is worthwhile in my |
| 357 // opinion and may further impede the readability of this already complex |
| 358 // algorithm. |
342 if (previousSiblingProtector) | 359 if (previousSiblingProtector) |
343 currentLayoutObject = | 360 currentLayoutObject = |
344 previousSiblingOrParentRespectingContainment(*currentLayoutObject); | 361 previousSiblingOrParentRespectingContainment(*currentLayoutObject); |
345 else | 362 else |
346 currentLayoutObject = | 363 currentLayoutObject = |
347 previousInPreOrderRespectingContainment(*currentLayoutObject); | 364 previousInPreOrderRespectingContainment(*currentLayoutObject); |
348 } | 365 } |
349 return false; | 366 return false; |
350 } | 367 } |
351 | 368 |
(...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
429 } | 446 } |
430 | 447 |
431 PassRefPtr<StringImpl> LayoutCounter::originalText() const { | 448 PassRefPtr<StringImpl> LayoutCounter::originalText() const { |
432 if (!m_counterNode) { | 449 if (!m_counterNode) { |
433 LayoutObject* beforeAfterContainer = parent(); | 450 LayoutObject* beforeAfterContainer = parent(); |
434 while (true) { | 451 while (true) { |
435 if (!beforeAfterContainer) | 452 if (!beforeAfterContainer) |
436 return nullptr; | 453 return nullptr; |
437 if (!beforeAfterContainer->isAnonymous() && | 454 if (!beforeAfterContainer->isAnonymous() && |
438 !beforeAfterContainer->isPseudoElement()) | 455 !beforeAfterContainer->isPseudoElement()) |
439 return nullptr; // LayoutCounters are restricted to before and after ps
eudo elements | 456 return nullptr; // LayoutCounters are restricted to before and after |
| 457 // pseudo elements |
440 PseudoId containerStyle = beforeAfterContainer->style()->styleType(); | 458 PseudoId containerStyle = beforeAfterContainer->style()->styleType(); |
441 if ((containerStyle == PseudoIdBefore) || | 459 if ((containerStyle == PseudoIdBefore) || |
442 (containerStyle == PseudoIdAfter)) | 460 (containerStyle == PseudoIdAfter)) |
443 break; | 461 break; |
444 beforeAfterContainer = beforeAfterContainer->parent(); | 462 beforeAfterContainer = beforeAfterContainer->parent(); |
445 } | 463 } |
446 makeCounterNodeIfNeeded(*beforeAfterContainer, m_counter.identifier(), true) | 464 makeCounterNodeIfNeeded(*beforeAfterContainer, m_counter.identifier(), true) |
447 ->addLayoutObject(const_cast<LayoutCounter*>(this)); | 465 ->addLayoutObject(const_cast<LayoutCounter*>(this)); |
448 ASSERT(m_counterNode); | 466 ASSERT(m_counterNode); |
449 } | 467 } |
(...skipping 151 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
601 for (LayoutObject* descendant = layoutObject; descendant; | 619 for (LayoutObject* descendant = layoutObject; descendant; |
602 descendant = descendant->nextInPreOrder(layoutObject)) | 620 descendant = descendant->nextInPreOrder(layoutObject)) |
603 updateCounters(*descendant); | 621 updateCounters(*descendant); |
604 } | 622 } |
605 | 623 |
606 void LayoutCounter::layoutObjectStyleChanged(LayoutObject& layoutObject, | 624 void LayoutCounter::layoutObjectStyleChanged(LayoutObject& layoutObject, |
607 const ComputedStyle* oldStyle, | 625 const ComputedStyle* oldStyle, |
608 const ComputedStyle& newStyle) { | 626 const ComputedStyle& newStyle) { |
609 Node* node = layoutObject.generatingNode(); | 627 Node* node = layoutObject.generatingNode(); |
610 if (!node || node->needsAttach()) | 628 if (!node || node->needsAttach()) |
611 return; // cannot have generated content or if it can have, it will be hand
led during attaching | 629 return; // cannot have generated content or if it can have, it will be |
| 630 // handled during attaching |
612 const CounterDirectiveMap* oldCounterDirectives = | 631 const CounterDirectiveMap* oldCounterDirectives = |
613 oldStyle ? oldStyle->counterDirectives() : 0; | 632 oldStyle ? oldStyle->counterDirectives() : 0; |
614 const CounterDirectiveMap* newCounterDirectives = | 633 const CounterDirectiveMap* newCounterDirectives = |
615 newStyle.counterDirectives(); | 634 newStyle.counterDirectives(); |
616 if (oldCounterDirectives) { | 635 if (oldCounterDirectives) { |
617 if (newCounterDirectives) { | 636 if (newCounterDirectives) { |
618 CounterDirectiveMap::const_iterator newMapEnd = | 637 CounterDirectiveMap::const_iterator newMapEnd = |
619 newCounterDirectives->end(); | 638 newCounterDirectives->end(); |
620 CounterDirectiveMap::const_iterator oldMapEnd = | 639 CounterDirectiveMap::const_iterator oldMapEnd = |
621 oldCounterDirectives->end(); | 640 oldCounterDirectives->end(); |
622 for (CounterDirectiveMap::const_iterator it = | 641 for (CounterDirectiveMap::const_iterator it = |
623 newCounterDirectives->begin(); | 642 newCounterDirectives->begin(); |
624 it != newMapEnd; ++it) { | 643 it != newMapEnd; ++it) { |
625 CounterDirectiveMap::const_iterator oldMapIt = | 644 CounterDirectiveMap::const_iterator oldMapIt = |
626 oldCounterDirectives->find(it->key); | 645 oldCounterDirectives->find(it->key); |
627 if (oldMapIt != oldMapEnd) { | 646 if (oldMapIt != oldMapEnd) { |
628 if (oldMapIt->value == it->value) | 647 if (oldMapIt->value == it->value) |
629 continue; | 648 continue; |
630 LayoutCounter::destroyCounterNode(layoutObject, it->key); | 649 LayoutCounter::destroyCounterNode(layoutObject, it->key); |
631 } | 650 } |
632 // We must create this node here, because the changed node may be a node
with no display such as | 651 // We must create this node here, because the changed node may be a node |
633 // as those created by the increment or reset directives and the re-layo
ut that will happen will | 652 // with no display such as as those created by the increment or reset |
634 // not catch the change if the node had no children. | 653 // directives and the re-layout that will happen will not catch the |
| 654 // change if the node had no children. |
635 makeCounterNodeIfNeeded(layoutObject, it->key, false); | 655 makeCounterNodeIfNeeded(layoutObject, it->key, false); |
636 } | 656 } |
637 // Destroying old counters that do not exist in the new counterDirective m
ap. | 657 // Destroying old counters that do not exist in the new counterDirective |
| 658 // map. |
638 for (CounterDirectiveMap::const_iterator it = | 659 for (CounterDirectiveMap::const_iterator it = |
639 oldCounterDirectives->begin(); | 660 oldCounterDirectives->begin(); |
640 it != oldMapEnd; ++it) { | 661 it != oldMapEnd; ++it) { |
641 if (!newCounterDirectives->contains(it->key)) | 662 if (!newCounterDirectives->contains(it->key)) |
642 LayoutCounter::destroyCounterNode(layoutObject, it->key); | 663 LayoutCounter::destroyCounterNode(layoutObject, it->key); |
643 } | 664 } |
644 } else { | 665 } else { |
645 if (layoutObject.hasCounterNodeMap()) | 666 if (layoutObject.hasCounterNodeMap()) |
646 LayoutCounter::destroyCounterNodes(layoutObject); | 667 LayoutCounter::destroyCounterNodes(layoutObject); |
647 } | 668 } |
648 } else if (newCounterDirectives) { | 669 } else if (newCounterDirectives) { |
649 if (layoutObject.hasCounterNodeMap()) | 670 if (layoutObject.hasCounterNodeMap()) |
650 LayoutCounter::destroyCounterNodes(layoutObject); | 671 LayoutCounter::destroyCounterNodes(layoutObject); |
651 CounterDirectiveMap::const_iterator newMapEnd = newCounterDirectives->end(); | 672 CounterDirectiveMap::const_iterator newMapEnd = newCounterDirectives->end(); |
652 for (CounterDirectiveMap::const_iterator it = newCounterDirectives->begin(); | 673 for (CounterDirectiveMap::const_iterator it = newCounterDirectives->begin(); |
653 it != newMapEnd; ++it) { | 674 it != newMapEnd; ++it) { |
654 // We must create this node here, because the added node may be a node wit
h no display such as | 675 // We must create this node here, because the added node may be a node |
655 // as those created by the increment or reset directives and the re-layout
that will happen will | 676 // with no display such as as those created by the increment or reset |
656 // not catch the change if the node had no children. | 677 // directives and the re-layout that will happen will not catch the change |
| 678 // if the node had no children. |
657 makeCounterNodeIfNeeded(layoutObject, it->key, false); | 679 makeCounterNodeIfNeeded(layoutObject, it->key, false); |
658 } | 680 } |
659 } | 681 } |
660 } | 682 } |
661 | 683 |
662 } // namespace blink | 684 } // namespace blink |
663 | 685 |
664 #ifndef NDEBUG | 686 #ifndef NDEBUG |
665 | 687 |
666 void showCounterLayoutObjectTree(const blink::LayoutObject* layoutObject, | 688 void showCounterLayoutObjectTree(const blink::LayoutObject* layoutObject, |
(...skipping 16 matching lines...) Expand all Loading... |
683 current->parent(), current->previousSibling(), current->nextSibling(), | 705 current->parent(), current->previousSibling(), current->nextSibling(), |
684 current->hasCounterNodeMap() | 706 current->hasCounterNodeMap() |
685 ? counterName ? blink::counterMaps().get(current)->get(identifier) | 707 ? counterName ? blink::counterMaps().get(current)->get(identifier) |
686 : (blink::CounterNode*)1 | 708 : (blink::CounterNode*)1 |
687 : (blink::CounterNode*)0); | 709 : (blink::CounterNode*)0); |
688 } | 710 } |
689 fflush(stderr); | 711 fflush(stderr); |
690 } | 712 } |
691 | 713 |
692 #endif // NDEBUG | 714 #endif // NDEBUG |
OLD | NEW |