| 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 167 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 178 // references that are in the scope of the counter or nested counter defined by
that | 178 // references that are in the scope of the counter or nested counter defined by
that |
| 179 // reset node. | 179 // reset node. |
| 180 // - Non-reset CounterNodes cannot have descendants. | 180 // - Non-reset CounterNodes cannot have descendants. |
| 181 | 181 |
| 182 static bool findPlaceForCounter(LayoutObject& counterOwner, const AtomicString&
identifier, bool isReset, RefPtr<CounterNode>& parent, RefPtr<CounterNode>& prev
iousSibling) | 182 static bool findPlaceForCounter(LayoutObject& counterOwner, const AtomicString&
identifier, bool isReset, RefPtr<CounterNode>& parent, RefPtr<CounterNode>& prev
iousSibling) |
| 183 { | 183 { |
| 184 // We cannot stop searching for counters with the same identifier before we
also | 184 // We cannot stop searching for counters with the same identifier before we
also |
| 185 // check this layoutObject, because it may affect the positioning in the tre
e of our counter. | 185 // check this layoutObject, because it may affect the positioning in the tre
e of our counter. |
| 186 LayoutObject* searchEndLayoutObject = previousSiblingOrParent(counterOwner); | 186 LayoutObject* searchEndLayoutObject = previousSiblingOrParent(counterOwner); |
| 187 // We check layoutObjects in preOrder from the layoutObject that our counter
is attached to | 187 // We check layoutObjects in preOrder from the layoutObject that our counter
is attached to |
| 188 // towards the begining of the document for counters with the same identifie
r as the one | 188 // towards the beginning of the document for counters with the same identifi
er as the one |
| 189 // we are trying to find a place for. This is the next layoutObject to be ch
ecked. | 189 // we are trying to find a place for. This is the next layoutObject to be ch
ecked. |
| 190 LayoutObject* currentLayoutObject = previousInPreOrder(counterOwner); | 190 LayoutObject* currentLayoutObject = previousInPreOrder(counterOwner); |
| 191 previousSibling = nullptr; | 191 previousSibling = nullptr; |
| 192 RefPtr<CounterNode> previousSiblingProtector = nullptr; | 192 RefPtr<CounterNode> previousSiblingProtector = nullptr; |
| 193 | 193 |
| 194 while (currentLayoutObject) { | 194 while (currentLayoutObject) { |
| 195 CounterNode* currentCounter = makeCounterNode(*currentLayoutObject, iden
tifier, false); | 195 CounterNode* currentCounter = makeCounterNode(*currentLayoutObject, iden
tifier, false); |
| 196 if (searchEndLayoutObject == currentLayoutObject) { | 196 if (searchEndLayoutObject == currentLayoutObject) { |
| 197 // We may be at the end of our search. | 197 // We may be at the end of our search. |
| 198 if (currentCounter) { | 198 if (currentCounter) { |
| (...skipping 77 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 276 } | 276 } |
| 277 } else { | 277 } else { |
| 278 previousSiblingProtector = currentCounter; | 278 previousSiblingProtector = currentCounter; |
| 279 } | 279 } |
| 280 currentLayoutObject = previousSiblingOrParent(*currentLayoutObje
ct); | 280 currentLayoutObject = previousSiblingOrParent(*currentLayoutObje
ct); |
| 281 continue; | 281 continue; |
| 282 } | 282 } |
| 283 } | 283 } |
| 284 // This function is designed so that the same test is not done twice in
an iteration, except for this one | 284 // This function is designed so that the same test is not done twice in
an iteration, except for this one |
| 285 // which may be done twice in some cases. Rearranging the decision point
s though, to accommodate this | 285 // which may be done twice in some cases. Rearranging the decision point
s though, to accommodate this |
| 286 // performance improvement would create more code duplication than is wo
rthwhile in my oppinion and may further | 286 // performance improvement would create more code duplication than is wo
rthwhile in my opinion and may further |
| 287 // impede the readability of this already complex algorithm. | 287 // impede the readability of this already complex algorithm. |
| 288 if (previousSiblingProtector) | 288 if (previousSiblingProtector) |
| 289 currentLayoutObject = previousSiblingOrParent(*currentLayoutObject); | 289 currentLayoutObject = previousSiblingOrParent(*currentLayoutObject); |
| 290 else | 290 else |
| 291 currentLayoutObject = previousInPreOrder(*currentLayoutObject); | 291 currentLayoutObject = previousInPreOrder(*currentLayoutObject); |
| 292 } | 292 } |
| 293 return false; | 293 return false; |
| 294 } | 294 } |
| 295 | 295 |
| 296 static CounterNode* makeCounterNode(LayoutObject& object, const AtomicString& id
entifier, bool alwaysCreateCounter) | 296 static CounterNode* makeCounterNode(LayoutObject& object, const AtomicString& id
entifier, bool alwaysCreateCounter) |
| (...skipping 306 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 603 fprintf(stderr, " "); | 603 fprintf(stderr, " "); |
| 604 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n", | 604 fprintf(stderr, "%p N:%p P:%p PS:%p NS:%p C:%p\n", |
| 605 current, current->node(), current->parent(), current->previousSiblin
g(), | 605 current, current->node(), current->parent(), current->previousSiblin
g(), |
| 606 current->nextSibling(), current->hasCounterNodeMap() ? | 606 current->nextSibling(), current->hasCounterNodeMap() ? |
| 607 counterName ? blink::counterMaps().get(current)->get(identifier) : (
blink::CounterNode*)1 : (blink::CounterNode*)0); | 607 counterName ? blink::counterMaps().get(current)->get(identifier) : (
blink::CounterNode*)1 : (blink::CounterNode*)0); |
| 608 } | 608 } |
| 609 fflush(stderr); | 609 fflush(stderr); |
| 610 } | 610 } |
| 611 | 611 |
| 612 #endif // NDEBUG | 612 #endif // NDEBUG |
| OLD | NEW |