| 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 41 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 52 return staticCounterMaps; | 52 return staticCounterMaps; |
| 53 } | 53 } |
| 54 | 54 |
| 55 // This function processes the renderer tree in the order of the DOM tree | 55 // This function processes the renderer tree in the order of the DOM tree |
| 56 // including pseudo elements as defined in CSS 2.1. | 56 // including pseudo elements as defined in CSS 2.1. |
| 57 static LayoutObject* previousInPreOrder(const LayoutObject& object) | 57 static LayoutObject* previousInPreOrder(const LayoutObject& object) |
| 58 { | 58 { |
| 59 Element* self = toElement(object.node()); | 59 Element* self = toElement(object.node()); |
| 60 ASSERT(self); | 60 ASSERT(self); |
| 61 Element* previous = ElementTraversal::previousIncludingPseudo(*self); | 61 Element* previous = ElementTraversal::previousIncludingPseudo(*self); |
| 62 while (previous && !previous->renderer()) | 62 while (previous && !previous->layoutObject()) |
| 63 previous = ElementTraversal::previousIncludingPseudo(*previous); | 63 previous = ElementTraversal::previousIncludingPseudo(*previous); |
| 64 return previous ? previous->renderer() : 0; | 64 return previous ? previous->layoutObject() : 0; |
| 65 } | 65 } |
| 66 | 66 |
| 67 // This function processes the renderer tree in the order of the DOM tree | 67 // This function processes the renderer tree in the order of the DOM tree |
| 68 // including pseudo elements as defined in CSS 2.1. | 68 // including pseudo elements as defined in CSS 2.1. |
| 69 static LayoutObject* previousSiblingOrParent(const LayoutObject& object) | 69 static LayoutObject* previousSiblingOrParent(const LayoutObject& object) |
| 70 { | 70 { |
| 71 Element* self = toElement(object.node()); | 71 Element* self = toElement(object.node()); |
| 72 ASSERT(self); | 72 ASSERT(self); |
| 73 Element* previous = ElementTraversal::pseudoAwarePreviousSibling(*self); | 73 Element* previous = ElementTraversal::pseudoAwarePreviousSibling(*self); |
| 74 while (previous && !previous->renderer()) | 74 while (previous && !previous->layoutObject()) |
| 75 previous = ElementTraversal::pseudoAwarePreviousSibling(*previous); | 75 previous = ElementTraversal::pseudoAwarePreviousSibling(*previous); |
| 76 if (previous) | 76 if (previous) |
| 77 return previous->renderer(); | 77 return previous->layoutObject(); |
| 78 previous = self->parentElement(); | 78 previous = self->parentElement(); |
| 79 return previous ? previous->renderer() : 0; | 79 return previous ? previous->layoutObject() : 0; |
| 80 } | 80 } |
| 81 | 81 |
| 82 static inline Element* parentElement(LayoutObject& object) | 82 static inline Element* parentElement(LayoutObject& object) |
| 83 { | 83 { |
| 84 return toElement(object.node())->parentElement(); | 84 return toElement(object.node())->parentElement(); |
| 85 } | 85 } |
| 86 | 86 |
| 87 static inline bool areRenderersElementsSiblings(LayoutObject& first, LayoutObjec
t& second) | 87 static inline bool areRenderersElementsSiblings(LayoutObject& first, LayoutObjec
t& second) |
| 88 { | 88 { |
| 89 return parentElement(first) == parentElement(second); | 89 return parentElement(first) == parentElement(second); |
| 90 } | 90 } |
| 91 | 91 |
| 92 // This function processes the renderer tree in the order of the DOM tree | 92 // This function processes the renderer tree in the order of the DOM tree |
| 93 // including pseudo elements as defined in CSS 2.1. | 93 // including pseudo elements as defined in CSS 2.1. |
| 94 static LayoutObject* nextInPreOrder(const LayoutObject& object, const Element* s
tayWithin, bool skipDescendants = false) | 94 static LayoutObject* nextInPreOrder(const LayoutObject& object, const Element* s
tayWithin, bool skipDescendants = false) |
| 95 { | 95 { |
| 96 Element* self = toElement(object.node()); | 96 Element* self = toElement(object.node()); |
| 97 ASSERT(self); | 97 ASSERT(self); |
| 98 Element* next = skipDescendants ? ElementTraversal::nextIncludingPseudoSkipp
ingChildren(*self, stayWithin) : ElementTraversal::nextIncludingPseudo(*self, st
ayWithin); | 98 Element* next = skipDescendants ? ElementTraversal::nextIncludingPseudoSkipp
ingChildren(*self, stayWithin) : ElementTraversal::nextIncludingPseudo(*self, st
ayWithin); |
| 99 while (next && !next->renderer()) | 99 while (next && !next->layoutObject()) |
| 100 next = skipDescendants ? ElementTraversal::nextIncludingPseudoSkippingCh
ildren(*next, stayWithin) : ElementTraversal::nextIncludingPseudo(*next, stayWit
hin); | 100 next = skipDescendants ? ElementTraversal::nextIncludingPseudoSkippingCh
ildren(*next, stayWithin) : ElementTraversal::nextIncludingPseudo(*next, stayWit
hin); |
| 101 return next ? next->renderer() : 0; | 101 return next ? next->layoutObject() : 0; |
| 102 } | 102 } |
| 103 | 103 |
| 104 static bool planCounter(LayoutObject& object, const AtomicString& identifier, bo
ol& isReset, int& value) | 104 static bool planCounter(LayoutObject& object, const AtomicString& identifier, bo
ol& isReset, int& value) |
| 105 { | 105 { |
| 106 // Real text nodes don't have their own style so they can't have counters. | 106 // Real text nodes don't have their own style so they can't have counters. |
| 107 // We can't even look at their styles or we'll see extra resets and incremen
ts! | 107 // We can't even look at their styles or we'll see extra resets and incremen
ts! |
| 108 if (object.isText() && !object.isBR()) | 108 if (object.isText() && !object.isBR()) |
| 109 return false; | 109 return false; |
| 110 Node* generatingNode = object.generatingNode(); | 110 Node* generatingNode = object.generatingNode(); |
| 111 // We must have a generating node or else we cannot have a counter. | 111 // We must have a generating node or else we cannot have a counter. |
| 112 if (!generatingNode) | 112 if (!generatingNode) |
| 113 return false; | 113 return false; |
| 114 const LayoutStyle& style = object.styleRef(); | 114 const LayoutStyle& style = object.styleRef(); |
| 115 | 115 |
| 116 switch (style.styleType()) { | 116 switch (style.styleType()) { |
| 117 case NOPSEUDO: | 117 case NOPSEUDO: |
| 118 // Sometimes nodes have more then one renderer. Only the first one gets
the counter | 118 // Sometimes nodes have more then one renderer. Only the first one gets
the counter |
| 119 // LayoutTests/http/tests/css/counter-crash.html | 119 // LayoutTests/http/tests/css/counter-crash.html |
| 120 if (generatingNode->renderer() != &object) | 120 if (generatingNode->layoutObject() != &object) |
| 121 return false; | 121 return false; |
| 122 break; | 122 break; |
| 123 case BEFORE: | 123 case BEFORE: |
| 124 case AFTER: | 124 case AFTER: |
| 125 break; | 125 break; |
| 126 default: | 126 default: |
| 127 return false; // Counters are forbidden from all other pseudo elements. | 127 return false; // Counters are forbidden from all other pseudo elements. |
| 128 } | 128 } |
| 129 | 129 |
| 130 const CounterDirectives directives = style.getCounterDirectives(identifier); | 130 const CounterDirectives directives = style.getCounterDirectives(identifier); |
| (...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 263 // counter being placed is attached to. | 263 // counter being placed is attached to. |
| 264 if (currentCounter) { | 264 if (currentCounter) { |
| 265 // We found a suitable counter. | 265 // We found a suitable counter. |
| 266 if (previousSiblingProtector) { | 266 if (previousSiblingProtector) { |
| 267 // Since we had a suitable previous counter before, we shoul
d only consider this one as our | 267 // Since we had a suitable previous counter before, we shoul
d only consider this one as our |
| 268 // previousSibling if it is a reset counter and hence the cu
rrent previousSibling is its child. | 268 // previousSibling if it is a reset counter and hence the cu
rrent previousSibling is its child. |
| 269 if (currentCounter->actsAsReset()) { | 269 if (currentCounter->actsAsReset()) { |
| 270 previousSiblingProtector = currentCounter; | 270 previousSiblingProtector = currentCounter; |
| 271 // We are no longer interested in previous siblings of t
he currentRenderer or their children | 271 // We are no longer interested in previous siblings of t
he currentRenderer or their children |
| 272 // as counters they may have attached cannot be the prev
ious sibling of the counter we are placing. | 272 // as counters they may have attached cannot be the prev
ious sibling of the counter we are placing. |
| 273 currentRenderer = parentElement(*currentRenderer)->rende
rer(); | 273 currentRenderer = parentElement(*currentRenderer)->layou
tObject(); |
| 274 continue; | 274 continue; |
| 275 } | 275 } |
| 276 } else { | 276 } else { |
| 277 previousSiblingProtector = currentCounter; | 277 previousSiblingProtector = currentCounter; |
| 278 } | 278 } |
| 279 currentRenderer = previousSiblingOrParent(*currentRenderer); | 279 currentRenderer = previousSiblingOrParent(*currentRenderer); |
| 280 continue; | 280 continue; |
| 281 } | 281 } |
| 282 } | 282 } |
| 283 // This function is designed so that the same test is not done twice in
an iteration, except for this one | 283 // This function is designed so that the same test is not done twice in
an iteration, except for this one |
| (...skipping 319 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 |